v1.1 Update || New additions

Hello, here is a update that adds request features to the plugin.

Added:
  Bigger amounts of money can be used.
  Sound toggle option in the config.yml.
  Able to change the sound in the config.yml.
  New bypass permission for staff. (CrazyAuctions.Bypass)
  Add into the config a lore option to some of the items. You could add
a lore already but I didn't put the option there so people were not
aware of this.
This commit is contained in:
BadBones69 2016-11-08 13:39:34 -05:00
parent 9aca319650
commit 936b7cf34f
7 changed files with 114 additions and 43 deletions

View File

@ -16,6 +16,11 @@ Settings:
Max-Beginning-Bid-Price: 1000000 #Maximum starting bid.
Allow-Damaged-Items: False #Allow items that have been damaged.
Category-Page-Opens-First: False #If set to true the categories page will open when they do /CA.
Sounds:
Toggle: False #Disable the clicking sound.
Sound: 'CLICK' #Make sure if you use 1.8 or lower you use the 1.8 sound and 1.9 and up use 1.9 sounds. The default sound is 1.8.
#1.8 sounds are found here: http://docs.codelanx.com/Bukkit/1.8/org/bukkit/Sound.html
#1.9 sounds are found here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html
GUISettings: #Settings for things in the gui.
SellingItemLore: #The lore on items that are being sold.
- '&7-------------------------'
@ -122,14 +127,17 @@ Settings:
Item: '339'
Slot: 49
Name: '&6Previous Page'
Lore: {}
Refesh: #The button for Refresh Page.
Item: '175'
Slot: 50
Name: '&6Refresh Page'
Lore: {}
NextPage: #The button for Next Page.
Item: '339'
Slot: 51
Name: '&6Next Page'
Lore: {}
Category1: #The button for Next Page.
Item: '54'
Slot: 52

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.0.2
version: 1.1
depend: [Vault]
description: >
A plugin to auction off items globally.

View File

@ -27,21 +27,21 @@ import me.badbones69.crazyauctions.currency.CM;
public class Api {
public static Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("CrazyAuctions");
@SuppressWarnings("static-access")
public Api(Plugin plugin){
this.plugin = plugin;
}
public static String color(String msg){
msg = ChatColor.translateAlternateColorCodes('&', msg);
return msg;
}
public static String removeColor(String msg){
msg = ChatColor.stripColor(msg);
return msg;
}
public static String getPrefix(){
return color(Main.settings.getConfig().getString("Settings.Prefix"));
}
public static ItemStack makeItem(String type, int amount){
int ty = 0;
if(type.contains(":")){
@ -58,6 +58,7 @@ public class Api {
}
return item;
}
public static ItemStack makeItem(String type, int amount, String name){
int ty = 0;
if(type.contains(":")){
@ -77,6 +78,7 @@ public class Api {
item.setItemMeta(me);
return item;
}
public static ItemStack makeItem(String type, int amount, String name, List<String> lore){
ArrayList<String> l = new ArrayList<String>();
int ty = 0;
@ -99,6 +101,7 @@ public class Api {
item.setItemMeta(me);
return item;
}
public static ItemStack makeItem(Material material, int amount, int type, String name){
ItemStack item = new ItemStack(material, amount, (short) type);
ItemMeta m = item.getItemMeta();
@ -106,6 +109,7 @@ public class Api {
item.setItemMeta(m);
return item;
}
public static ItemStack makeItem(Material material, int amount, int type, String name, List<String> lore){
ArrayList<String> l = new ArrayList<String>();
ItemStack item = new ItemStack(material, amount, (short) type);
@ -116,6 +120,7 @@ public class Api {
item.setItemMeta(m);
return item;
}
public static ItemStack makeItem(Material material, int amount, int type, String name, List<String> lore, Map<Enchantment, Integer> enchants){
ItemStack item = new ItemStack(material, amount, (short) type);
ItemMeta m = item.getItemMeta();
@ -125,6 +130,7 @@ public class Api {
item.addUnsafeEnchantments(enchants);
return item;
}
public static ItemStack addLore(ItemStack item, String i){
ArrayList<String> lore = new ArrayList<String>();
ItemMeta m = item.getItemMeta();
@ -136,6 +142,7 @@ public class Api {
item.setItemMeta(m);
return item;
}
public static ItemStack addLore(ItemStack item, List<String> list){
ArrayList<String> lore = new ArrayList<String>();
ItemMeta m = item.getItemMeta();
@ -145,12 +152,14 @@ public class Api {
item.setItemMeta(m);
return item;
}
public static Integer getVersion(){
String ver = Bukkit.getServer().getClass().getPackage().getName();
ver = ver.substring(ver.lastIndexOf('.')+1);
ver=ver.replaceAll("_", "").replaceAll("R", "").replaceAll("v", "");
return Integer.parseInt(ver);
}
@SuppressWarnings("deprecation")
public static ItemStack getItemInHand(Player player){
if(getVersion()>=191){
@ -159,6 +168,7 @@ public class Api {
return player.getItemInHand();
}
}
@SuppressWarnings("deprecation")
public static void setItemInHand(Player player, ItemStack item){
if(Api.getVersion()>=191){
@ -167,6 +177,7 @@ public class Api {
player.setItemInHand(item);
}
}
public static boolean isInt(String s) {
try {
Integer.parseInt(s);
@ -175,19 +186,24 @@ public class Api {
}
return true;
}
public static Player getPlayer(String name){
return Bukkit.getServer().getPlayer(name);
}
@SuppressWarnings("deprecation")
public static OfflinePlayer getOfflinePlayer(String name){
return Bukkit.getServer().getOfflinePlayer(name);
}
public static Location getLoc(Player player){
return player.getLocation();
}
public static void runCMD(Player player, String CMD){
player.performCommand(CMD);
}
public static boolean isOnline(String name){
for(Player player : Bukkit.getServer().getOnlinePlayers()){
if(player.getName().equalsIgnoreCase(name)){
@ -196,6 +212,7 @@ public class Api {
}
return false;
}
public static boolean isOnline(String name, CommandSender p){
for(Player player : Bukkit.getServer().getOnlinePlayers()){
if(player.getName().equalsIgnoreCase(name)){
@ -205,6 +222,7 @@ public class Api {
p.sendMessage(color(Main.settings.getMsg().getString("Messages.Not-Online")));
return false;
}
public static boolean hasPermission(Player player, String perm){
if(!player.hasPermission("CrazyAuctions." + perm)){
player.sendMessage(color(Main.settings.getMsg().getString("Messages.No-Permission")));
@ -212,6 +230,7 @@ public class Api {
}
return true;
}
public static boolean hasPermission(CommandSender sender, String perm){
if(sender instanceof Player){
Player player = (Player) sender;
@ -225,6 +244,7 @@ public class Api {
return true;
}
}
public static void hasUpdate(){
try {
HttpURLConnection c = (HttpURLConnection)new URL("http://www.spigotmc.org/api/general.php").openConnection();
@ -241,6 +261,7 @@ public class Api {
return;
}
}
public static void hasUpdate(Player player){
try {
HttpURLConnection c = (HttpURLConnection)new URL("http://www.spigotmc.org/api/general.php").openConnection();
@ -257,6 +278,7 @@ public class Api {
return;
}
}
public static List<ItemStack> getPage(List<ItemStack> list, Integer page){
List<ItemStack> items = new ArrayList<ItemStack>();
if(page<=0)page=1;
@ -276,6 +298,7 @@ public class Api {
}
return items;
}
public static List<Integer> getPageInts(List<Integer> list, Integer page){
List<Integer> items = new ArrayList<Integer>();
if(page<=0)page=1;
@ -295,12 +318,14 @@ public class Api {
}
return items;
}
public static int getMaxPage(List<ItemStack> list){
int maxPage = 1;
int amount = list.size();
for(;amount>45;amount-=45,maxPage++);
return maxPage;
}
public static String convertToTime(long time){
Calendar C = Calendar.getInstance();
Calendar cal = Calendar.getInstance();
@ -316,6 +341,7 @@ public class Api {
S+=total;
return D+"d "+H+"h "+M+"m "+S+"s ";
}
public static long convertToMill(String time){
Calendar cal = Calendar.getInstance();
for(String i : time.split(" ")){
@ -334,12 +360,14 @@ public class Api {
}
return cal.getTimeInMillis();
}
public static boolean isInvFull(Player player){
if(player.getInventory().firstEmpty()==-1){
return true;
}
return false;
}
public static void updateAuction(){
FileConfiguration data = Main.settings.getData();
FileConfiguration msg = Main.settings.getMsg();
@ -399,6 +427,7 @@ public class Api {
}
Main.settings.saveData();
}
public static String getPrice(String ID, Boolean Expired){
Long price = 0L;
if(Expired){
@ -412,4 +441,5 @@ public class Api {
}
return NumberFormat.getNumberInstance().format(price);
}
}

View File

@ -5,6 +5,7 @@ import java.util.ArrayList;
import org.bukkit.Material;
public enum Category{
NONE("None", new ArrayList<Material>()), OTHER("Other", getOthers()),
ARMOR("Armor", getArmor()), WEAPONS("Weapons", getWeapons()), TOOLS("Tools", getTools()),
FOOD("Food", getFood()), POTIONS("Potions", getPotions()), BLOCKS("Blocks", getBlocks());

View File

@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class CrazyAuctions {
static CrazyAuctions instance = new CrazyAuctions();
public static CrazyAuctions getInstance() {

View File

@ -3,6 +3,7 @@ package me.badbones69.crazyauctions;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@ -21,17 +22,16 @@ import org.bukkit.plugin.Plugin;
import me.badbones69.crazyauctions.currency.CM;
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, 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");
@SuppressWarnings("static-access")
public GUI(Plugin plugin){
this.plugin = plugin;
}
public static void openShop(Player player, Shop sell, Category cat, int page){
Api.updateAuction();
FileConfiguration config = Main.settings.getConfig();
@ -119,6 +119,7 @@ public class GUI implements Listener{
List.put(player, Id);
player.openInventory(inv);
}
public static void openCateories(Player player, Shop shop){
Api.updateAuction();
FileConfiguration config = Main.settings.getConfig();
@ -142,6 +143,7 @@ public class GUI implements Listener{
Type.put(player, shop);
player.openInventory(inv);
}
public static void openPlayersCurrentList(Player player, int page){
Api.updateAuction();
FileConfiguration config = Main.settings.getConfig();
@ -185,6 +187,7 @@ public class GUI implements Listener{
List.put(player, Id);
player.openInventory(inv);
}
public static void openPlayersExpiredList(Player player, int page){
Api.updateAuction();
FileConfiguration config = Main.settings.getConfig();
@ -232,6 +235,7 @@ public class GUI implements Listener{
List.put(player, Id);
player.openInventory(inv);
}
public static void openBuying(Player player, String ID){
Api.updateAuction();
FileConfiguration config = Main.settings.getConfig();
@ -277,6 +281,7 @@ public class GUI implements Listener{
IDs.put(player, ID);
player.openInventory(inv);
}
public static void openBidding(Player player, String ID){
Api.updateAuction();
FileConfiguration config = Main.settings.getConfig();
@ -304,6 +309,7 @@ public class GUI implements Listener{
inv.setItem(4, getBiddingItem(player, ID));
player.openInventory(inv);
}
public static void openViewer(Player player, String other, int page){
Api.updateAuction();
FileConfiguration config = Main.settings.getConfig();
@ -366,6 +372,7 @@ public class GUI implements Listener{
List.put(player, Id);
player.openInventory(inv);
}
public static ItemStack getBiddingGlass(Player player, String ID){
FileConfiguration config = Main.settings.getConfig();
String id = config.getString("Settings.GUISettings.OtherSettings.Bidding.Item");
@ -384,6 +391,7 @@ public class GUI implements Listener{
}
return item;
}
public static ItemStack getBiddingItem(Player player, String ID){
FileConfiguration config = Main.settings.getConfig();
FileConfiguration data = Main.settings.getData();
@ -399,6 +407,7 @@ public class GUI implements Listener{
}
return Api.addLore(item.clone(), lore);
}
@EventHandler
public void onInvClose(InventoryCloseEvent e){
FileConfiguration config = Main.settings.getConfig();
@ -412,6 +421,7 @@ public class GUI implements Listener{
}
}
}
@EventHandler
public void onInvClick(InventoryClickEvent e){
FileConfiguration config = Main.settings.getConfig();
@ -920,11 +930,30 @@ public class GUI implements Listener{
}
}
}
private static void playClick(Player player){
if(Api.getVersion()>=191){
player.playSound(player.getLocation(), Sound.valueOf("UI_BUTTON_CLICK"), 1, 1);
if(Main.settings.getConfig().contains("Settings.Sounds.Toggle")){
if(Main.settings.getConfig().getBoolean("Settings.Sounds.Toggle")){
String sound = Main.settings.getConfig().getString("Settings.Sounds.Sound");
try{
player.playSound(player.getLocation(), Sound.valueOf(sound), 1, 1);
}catch(Exception e){
if(Api.getVersion()>=191){
player.playSound(player.getLocation(), Sound.valueOf("UI_BUTTON_CLICK"), 1, 1);
}else{
player.playSound(player.getLocation(), Sound.valueOf("CLICK"), 1, 1);
}
Bukkit.getLogger().log(Level.WARNING, "[Crazy Auctions]>> You set the sound to "+sound+" and this is not a sound for your minecraft version. "
+ "Please go to the config and set a correct sound or turn the sound off in the toggle setting.");
}
}
}else{
player.playSound(player.getLocation(), Sound.valueOf("CLICK"), 1, 1);
if(Api.getVersion()>=191){
player.playSound(player.getLocation(), Sound.valueOf("UI_BUTTON_CLICK"), 1, 1);
}else{
player.playSound(player.getLocation(), Sound.valueOf("CLICK"), 1, 1);
}
}
}
}

View File

@ -33,7 +33,7 @@ public class Main extends JavaPlugin implements Listener{
settings.setup(this);
Api.hasUpdate();
Bukkit.getServer().getPluginManager().registerEvents(this, this);
Bukkit.getServer().getPluginManager().registerEvents(new GUI(this), this);
Bukkit.getServer().getPluginManager().registerEvents(new GUI(), this);
Api.updateAuction();
startCheck();
if (!Vault.setupEconomy()){
@ -161,55 +161,57 @@ public class Main extends JavaPlugin implements Listener{
}
int price = Integer.parseInt(args[1]);
if(args[0].equalsIgnoreCase("Bid")){
if(price<settings.getConfig().getInt("Settings.Minimum-Bid-Price")){
if(price<settings.getConfig().getLong("Settings.Minimum-Bid-Price")){
player.sendMessage(Api.getPrefix()+Api.color(settings.getMsg().getString("Messages.Bid-Price-To-Low")));
return true;
}
if(price>settings.getConfig().getInt("Settings.Max-Beginning-Bid-Price")){
if(price>settings.getConfig().getLong("Settings.Max-Beginning-Bid-Price")){
player.sendMessage(Api.getPrefix()+Api.color(settings.getMsg().getString("Messages.Bid-Price-To-High")));
return true;
}
}else{
if(price<settings.getConfig().getInt("Settings.Minimum-Sell-Price")){
if(price<settings.getConfig().getLong("Settings.Minimum-Sell-Price")){
player.sendMessage(Api.getPrefix()+Api.color(settings.getMsg().getString("Messages.Sell-Price-To-Low")));
return true;
}
if(price>settings.getConfig().getInt("Settings.Max-Beginning-Sell-Price")){
if(price>settings.getConfig().getLong("Settings.Max-Beginning-Sell-Price")){
player.sendMessage(Api.getPrefix()+Api.color(settings.getMsg().getString("Messages.Sell-Price-To-High")));
return true;
}
}
int SellLimit = 0;
int BidLimit = 0;
for(PermissionAttachmentInfo permission : player.getEffectivePermissions()){
String perm = permission.getPermission();
if(perm.startsWith("crazyauctions.sell.")){
perm=perm.replace("crazyauctions.sell.", "");
if(Api.isInt(perm)){
if(Integer.parseInt(perm)>SellLimit){
SellLimit = Integer.parseInt(perm);
if(!player.hasPermission("crazyauctions.bypass")){
int SellLimit = 0;
int BidLimit = 0;
for(PermissionAttachmentInfo permission : player.getEffectivePermissions()){
String perm = permission.getPermission();
if(perm.startsWith("crazyauctions.sell.")){
perm=perm.replace("crazyauctions.sell.", "");
if(Api.isInt(perm)){
if(Integer.parseInt(perm)>SellLimit){
SellLimit = Integer.parseInt(perm);
}
}
}
if(perm.startsWith("crazyauctions.bid.")){
perm=perm.replace("crazyauctions.bid.", "");
if(Api.isInt(perm)){
if(Integer.parseInt(perm)>BidLimit){
BidLimit = Integer.parseInt(perm);
}
}
}
}
if(perm.startsWith("crazyauctions.bid.")){
perm=perm.replace("crazyauctions.bid.", "");
if(Api.isInt(perm)){
if(Integer.parseInt(perm)>BidLimit){
BidLimit = Integer.parseInt(perm);
}
if(args[0].equalsIgnoreCase("Sell")){
if(auc.getItems(player, Shop.SELL).size()>=SellLimit){
player.sendMessage(Api.getPrefix()+Api.color(settings.getMsg().getString("Messages.Max-Items")));
return true;
}
}
}
if(args[0].equalsIgnoreCase("Sell")){
if(auc.getItems(player, Shop.SELL).size()>=SellLimit){
player.sendMessage(Api.getPrefix()+Api.color(settings.getMsg().getString("Messages.Max-Items")));
return true;
}
}
if(args[0].equalsIgnoreCase("Bid")){
if(auc.getItems(player, Shop.BID).size()>=BidLimit){
player.sendMessage(Api.getPrefix()+Api.color(settings.getMsg().getString("Messages.Max-Items")));
return true;
if(args[0].equalsIgnoreCase("Bid")){
if(auc.getItems(player, Shop.BID).size()>=BidLimit){
player.sendMessage(Api.getPrefix()+Api.color(settings.getMsg().getString("Messages.Max-Items")));
return true;
}
}
}
for(String id : settings.getConfig().getStringList("Settings.BlackList")){