diff --git a/changelog.txt b/changelog.txt index 9276906..9afc359 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +1.0.48 + Added fix for 1.13 Auction houses NPCs. + Added ability to customize buttons. + 1.0.47 Fixed issue where offline-amount is not displaying the correct amount Fixed issue where offline-amount would stack amount. diff --git a/plugin.yml b/plugin.yml index 5c4d76a..94c13cc 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,5 +1,5 @@ main: me.zombie_striker.npcauctions.Main -version: 1.0.47 +version: 1.0.48 name: NPCAuctions api-version: 1.13 commands: diff --git a/src/me/zombie_striker/npcauctions/Main.java b/src/me/zombie_striker/npcauctions/Main.java index 0fdafc2..85e1edb 100644 --- a/src/me/zombie_striker/npcauctions/Main.java +++ b/src/me/zombie_striker/npcauctions/Main.java @@ -50,7 +50,7 @@ public class Main extends JavaPlugin implements Listener { public static String s_rejoin_amount = " Since the last time you were on, you have recieved $%amount%!"; public static String s_rejoin_items = " The following auctions had no bidders: "; public static String s_someoneBid = "%player% has bid $%bid% ($%amount%) for your %item% auction"; - public static String s_someoneBought = "%player% has bought you %item% auction for $%amount%."; + public static String s_someoneBought = "%player% has bought your %item% auction for $%amount%."; public static String s_youBid = "You have has bid %amount% for the %item% auction"; public static String s_auctionCancelRefund = "The owner of the %item% auction canceled the auction. You have been refunded $%amount%."; @@ -169,14 +169,19 @@ public void run() { USE_VILLAGERS = true; } else { USE_VILLAGERS = false; - try { - Bukkit.getPluginManager().registerEvents(new TraitEventHandler(), this); - } catch (Exception | Error e) { - } } getConfig().set("UseVillager", USE_VILLAGERS); saveConfig(); } + if(!USE_VILLAGERS) { + try { + Bukkit.getPluginManager().registerEvents(new TraitEventHandler(), this); + } catch (Exception | Error e) { + getLogger().log(Level.SEVERE, "Citizens 2.0 not found or not enabled"); + e.printStackTrace(); + USE_VILLAGERS = true; + } + } ConfigHandler c = null; try { c = ConfigHandler.init(this); @@ -261,26 +266,26 @@ public void run() { e.printStackTrace(); } - bufferstack = QuickMaterialConversionClass.getGrayStained(); + bufferstack = this.getConfigItemStack("NoItemSlot", QuickMaterialConversionClass.getGrayStained()); ItemMeta im = bufferstack.getItemMeta(); im.setDisplayName(" "); bufferstack.setItemMeta(im); - nextpage = QuickMaterialConversionClass.getGreenWool(); + nextpage = this.getConfigItemStack("NextPageIcon",QuickMaterialConversionClass.getGreenWool()); ItemMeta im2 = nextpage.getItemMeta(); im2.setDisplayName(s_ItemNex); nextpage.setItemMeta(im2); - prevpage = QuickMaterialConversionClass.getRedWool(); + prevpage = this.getConfigItemStack("PrevPageIcon",QuickMaterialConversionClass.getRedWool()); ItemMeta im3 = prevpage.getItemMeta(); im3.setDisplayName(s_ItemPrev); prevpage.setItemMeta(im3); - addAuc = QuickMaterialConversionClass.getBlueWool(); + addAuc = this.getConfigItemStack("AddAuctionIcon",QuickMaterialConversionClass.getGreenWool()); ItemMeta im4 = addAuc.getItemMeta(); im4.setDisplayName(s_ItemAdd); addAuc.setItemMeta(im4); - cancelAuc = QuickMaterialConversionClass.getRedWool(); + cancelAuc = this.getConfigItemStack("CancelAuctionIcon",QuickMaterialConversionClass.getRedWool()); ItemMeta im5 = cancelAuc.getItemMeta(); im5.setDisplayName(s_ItemRemove); cancelAuc.setItemMeta(im5); @@ -514,7 +519,7 @@ public void run() { getConfig().set(e.getPlayer().getUniqueId().toString() + ".recievedItems", null); save = true; } - if(save) + if (save) saveConfig(); } }.runTaskLater(this, 2); @@ -817,7 +822,8 @@ public void onClick(InventoryClickEvent e) { if (ofowner != null) { ofowner.sendMessage(prefix + s_someoneBid .replace("%player%", e.getWhoClicked().getName()) - .replace("%amount%", "" + aa.currentPrice).replace("%bid%", ""+aa.biddingPrice).replace("%item%", + .replace("%amount%", "" + aa.currentPrice) + .replace("%bid%", "" + aa.biddingPrice).replace("%item%", (aa.is.getItemMeta().hasDisplayName() ? aa.is.getItemMeta().getDisplayName() : aa.is.getType().name()) + ".x." + aa.is.getAmount())); @@ -989,4 +995,18 @@ public ItemStack c(Auction a) { } return temp; } + + @SuppressWarnings("deprecation") + public ItemStack getConfigItemStack(String pathname, ItemStack base) { + if(getConfig().contains("Items."+pathname+".Material")) { + Material m = Material.matchMaterial(getConfig().getString("Items."+pathname+".Material")); + short durib = (short) getConfig().getInt("Items."+pathname+".data"); + ItemStack is = new ItemStack(m,1,durib); + return is; + } + getConfig().set("Items."+pathname+".Material", base.getType().name()); + getConfig().set("Items."+pathname+".data", base.getDurability()); + saveConfig(); + return base; + } }