mirror of
https://github.com/Crazy-Crew/CrazyAuctions.git
synced 2024-11-10 10:10:22 +01:00
v1.0.1 Update
Hello there, this is a small update that fixes a bug and adds two small feature. Bug: - If your selling limit or bidding limit was at max then it stops you from selling and bidding items. Added: - New setting in the config. "Category-Page-Opens-First: False" This allows you to make it so that the Categories tab is the 1st thing that opens when doing /CA. - In-Game Update notifier.
This commit is contained in:
parent
91a719af78
commit
1f823c409b
@ -15,6 +15,7 @@ Settings:
|
||||
Minimum-Bid-Price: 100 #Minimum starting bid.
|
||||
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.
|
||||
GUISettings: #Settings for things in the gui.
|
||||
SellingItemLore: #The lore on items that are being sold.
|
||||
- '&7-------------------------'
|
||||
|
@ -1,12 +1,12 @@
|
||||
name: CrazyAuctions
|
||||
author: BadBones69
|
||||
main: me.BadBones69.CrazyAuctions.Main
|
||||
main: me.badbones69.crazyauctions.Main
|
||||
website: https://www.spigotmc.org/resources/authors/kicjow.9719/
|
||||
version: 1.0
|
||||
version: 1.0.1
|
||||
depend: [Vault]
|
||||
description: >
|
||||
A plugin to auction off items globally.
|
||||
commands:
|
||||
CA:
|
||||
ca:
|
||||
description: Opens the Crazy Auctions GUI.
|
||||
aliases: [crazyauction, crazyauctions, ah]
|
@ -1,5 +1,9 @@
|
||||
package me.BadBones69.CrazyAuctions;
|
||||
package me.badbones69.crazyauctions;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
@ -17,10 +21,16 @@ import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import me.BadBones69.CrazyAuctions.Currency.CM;
|
||||
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;
|
||||
@ -215,6 +225,38 @@ public class Api {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public static void hasUpdate(){
|
||||
try {
|
||||
HttpURLConnection c = (HttpURLConnection)new URL("http://www.spigotmc.org/api/general.php").openConnection();
|
||||
c.setDoOutput(true);
|
||||
c.setRequestMethod("POST");
|
||||
c.getOutputStream().write(("key=98BE0FE67F88AB82B4C197FAF1DC3B69206EFDCC4D3B80FC83A00037510B99B4&resource=25219").getBytes("UTF-8"));
|
||||
String oldVersion = plugin.getDescription().getVersion();
|
||||
String newVersion = new BufferedReader(new InputStreamReader(c.getInputStream())).readLine().replaceAll("[a-zA-Z ]", "");
|
||||
if(!newVersion.equals(oldVersion)) {
|
||||
Bukkit.getConsoleSender().sendMessage(getPrefix()+color("&cYour server is running &7v"+oldVersion+"&c and the newest is &7v"+newVersion+"&c."));
|
||||
}
|
||||
}
|
||||
catch(Exception e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
public static void hasUpdate(Player player){
|
||||
try {
|
||||
HttpURLConnection c = (HttpURLConnection)new URL("http://www.spigotmc.org/api/general.php").openConnection();
|
||||
c.setDoOutput(true);
|
||||
c.setRequestMethod("POST");
|
||||
c.getOutputStream().write(("key=98BE0FE67F88AB82B4C197FAF1DC3B69206EFDCC4D3B80FC83A00037510B99B4&resource=25219").getBytes("UTF-8"));
|
||||
String oldVersion = plugin.getDescription().getVersion();
|
||||
String newVersion = new BufferedReader(new InputStreamReader(c.getInputStream())).readLine().replaceAll("[a-zA-Z ]", "");
|
||||
if(!newVersion.equals(oldVersion)) {
|
||||
player.sendMessage(getPrefix()+color("&cYour server is running &7v"+oldVersion+"&c and the newest is &7v"+newVersion+"&c."));
|
||||
}
|
||||
}
|
||||
catch(Exception e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
public static List<ItemStack> getPage(List<ItemStack> list, Integer page){
|
||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
if(page<=0)page=1;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package me.BadBones69.CrazyAuctions;
|
||||
package me.badbones69.crazyauctions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package me.BadBones69.CrazyAuctions;
|
||||
package me.badbones69.crazyauctions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
package me.BadBones69.CrazyAuctions.Currency;
|
||||
package me.badbones69.crazyauctions.currency;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.BadBones69.CrazyAuctions.Main;
|
||||
import me.badbones69.crazyauctions.Main;
|
||||
|
||||
public enum CM { // Currency Manager
|
||||
VAULT("Vault", "Money");
|
||||
|
@ -1,4 +1,4 @@
|
||||
package me.BadBones69.CrazyAuctions.Currency;
|
||||
package me.badbones69.crazyauctions.currency;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package me.BadBones69.CrazyAuctions;
|
||||
package me.badbones69.crazyauctions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -18,7 +18,7 @@ import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import me.BadBones69.CrazyAuctions.Currency.CM;
|
||||
import me.badbones69.crazyauctions.currency.CM;
|
||||
|
||||
public class GUI implements Listener{
|
||||
private static HashMap<Player, Integer> Bidding = new HashMap<Player, Integer>();
|
||||
@ -43,7 +43,11 @@ public class GUI implements Listener{
|
||||
data.set("Items.Clear", null);
|
||||
Main.settings.saveData();
|
||||
}
|
||||
Cat.put(player, cat);
|
||||
if(cat!=null){
|
||||
Cat.put(player, cat);
|
||||
}else{
|
||||
Cat.put(player, Category.NONE);
|
||||
}
|
||||
if(data.contains("Items")){
|
||||
for(String i : data.getConfigurationSection("Items").getKeys(false)){
|
||||
List<String> lore = new ArrayList<String>();
|
||||
@ -115,7 +119,7 @@ public class GUI implements Listener{
|
||||
List.put(player, Id);
|
||||
player.openInventory(inv);
|
||||
}
|
||||
public static void openCateories(Player player){
|
||||
public static void openCateories(Player player, Shop shop){
|
||||
Api.updateAuction();
|
||||
FileConfiguration config = Main.settings.getConfig();
|
||||
Inventory inv = Bukkit.createInventory(null, 54, Api.color(config.getString("Settings.Categories")));
|
||||
@ -135,6 +139,7 @@ public class GUI implements Listener{
|
||||
inv.setItem(slot-1, Api.makeItem(id, 1, name));
|
||||
}
|
||||
}
|
||||
Type.put(player, shop);
|
||||
player.openInventory(inv);
|
||||
}
|
||||
public static void openPlayersCurrentList(Player player, int page){
|
||||
@ -595,12 +600,12 @@ public class GUI implements Listener{
|
||||
return;
|
||||
}
|
||||
if(item.getItemMeta().getDisplayName().equals(Api.color(config.getString("Settings.GUISettings.OtherSettings.Category1.Name")))){
|
||||
openCateories(player);
|
||||
openCateories(player, Type.get(player));
|
||||
playClick(player);
|
||||
return;
|
||||
}
|
||||
if(item.getItemMeta().getDisplayName().equals(Api.color(config.getString("Settings.GUISettings.OtherSettings.Category2.Name")))){
|
||||
openCateories(player);
|
||||
openCateories(player, Type.get(player));
|
||||
playClick(player);
|
||||
return;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package me.BadBones69.CrazyAuctions;
|
||||
package me.badbones69.crazyauctions;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@ -16,7 +16,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import me.BadBones69.CrazyAuctions.Currency.Vault;
|
||||
import me.badbones69.crazyauctions.currency.Vault;
|
||||
|
||||
public class Main extends JavaPlugin implements Listener{
|
||||
public static SettingsManager settings = SettingsManager.getInstance();
|
||||
@ -31,6 +31,7 @@ public class Main extends JavaPlugin implements Listener{
|
||||
public void onEnable(){
|
||||
saveDefaultConfig();
|
||||
settings.setup(this);
|
||||
Api.hasUpdate();
|
||||
Bukkit.getServer().getPluginManager().registerEvents(this, this);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new GUI(this), this);
|
||||
Api.updateAuction();
|
||||
@ -39,7 +40,8 @@ public class Main extends JavaPlugin implements Listener{
|
||||
saveDefaultConfig();
|
||||
}
|
||||
if(Bukkit.getPluginManager().getPlugin("Vault")==null){
|
||||
Bukkit.getConsoleSender().sendMessage(Api.getPrefix()+Api.color("&cThis plugin is shutting down. This plugin requires a compatable currency plugin."
|
||||
Bukkit.getConsoleSender().sendMessage(Api.getPrefix()+
|
||||
Api.color("&cThis plugin is shutting down. This plugin requires a compatable currency plugin."
|
||||
+ " &cPlease add Vault to continue using this."));
|
||||
Bukkit.getServer().getPluginManager().disablePlugin(this);
|
||||
}
|
||||
@ -59,6 +61,12 @@ public class Main extends JavaPlugin implements Listener{
|
||||
return true;
|
||||
}
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
GUI.openShop(player, Shop.SELL, Category.NONE, 1);
|
||||
return true;
|
||||
}
|
||||
@ -192,13 +200,17 @@ public class Main extends JavaPlugin implements Listener{
|
||||
}
|
||||
}
|
||||
}
|
||||
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(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")){
|
||||
if(item.getType()==Api.makeItem(id, 1).getType()){
|
||||
@ -271,6 +283,9 @@ public class Main extends JavaPlugin implements Listener{
|
||||
player.sendMessage(Api.getPrefix()+Api.color("&7This server is running your Crazy Auctions Plugin. "
|
||||
+ "&7It is running version &av"+Bukkit.getServer().getPluginManager().getPlugin("CrazyAuctions").getDescription().getVersion()+"&7."));
|
||||
}
|
||||
if(player.isOp()){
|
||||
Api.hasUpdate(player);
|
||||
}
|
||||
}
|
||||
}, 40);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package me.BadBones69.CrazyAuctions;
|
||||
package me.badbones69.crazyauctions;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package me.BadBones69.CrazyAuctions;
|
||||
package me.badbones69.crazyauctions;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package me.BadBones69.CrazyAuctions;
|
||||
package me.badbones69.crazyauctions;
|
||||
|
||||
public enum Shop{
|
||||
SELL("Sell"), BID("Bid");
|
||||
|
Loading…
Reference in New Issue
Block a user