Skip to content

Commit

Permalink
v1.0.54
Browse files Browse the repository at this point in the history
  • Loading branch information
ZombieStriker authored Nov 10, 2018
1 parent c645669 commit 4a49644
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 23 deletions.
19 changes: 19 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
1.0.54
Made "page: " suffix configurable
Made "Price" item lore tag configurable
Removed coolectAuctions button if there are no blacklisted worlds

1.0.53
Fixed naming of items for broadcasting

1.0.52D
Fixed perm for npc endall

1.0.52C
Added different messages for if a player claimed an item, instead of joining.
Rewrote joining messages

1.0.52B
Made config reload on disable. Should allow server owners to add blacklist even if server is online, as long as no auctions end at that moment
Fixed NPE on no one buying auction.

1.0.52
The Prefix is now configurable in the messages.yml.
Added ability to blacklist worlds.
Expand Down
3 changes: 2 additions & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
main: me.zombie_striker.npcauctions.Main
version: 1.0.52
version: 1.0.54
name: NPCAuctions
api-version: 1.13
commands:
Expand All @@ -14,6 +14,7 @@ permissions:
npcauctions.destroy: true
npcauctions.bypasslimit: true
npcauctions.default: true
npcauctions.endall: true
npcauctions.auctionlimit.1:
description: limits the auction to 1
npcauctions.default:
Expand Down
6 changes: 3 additions & 3 deletions src/me/zombie_striker/npcauctions/ConfigHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ public enum Keys {
"CancelExistingAuctionBecauseItsUnfinished"),
PREFIX("Prefix"),CancelOwn(
"CancelBidBecauseItsThePlayers"), AddAuc(
"SuccessfullyAddedAuction"), WonAuction("BidderWonAuction"), CollectAuction("BidderMustCollectAuction"), WonAucEarn(
"SuccessfullyAddedAuction"), PAGE_SUFFIX("MENU_Page_Suffix"),WonAuction("BidderWonAuction"), CollectAuction("BidderMustCollectAuction"), WonAucEarn(
"AuctionEndedSold"), NoBids("AuctionEndedNoBids"), BidIncrease(
"InitialIncreaseBidding"), BiddingStart("InitialStarttingBid"), BiddingDur(
"InitialBiddingDurration"), BiddingBuy("InitialBuyItNow"), VillagersName(
"NPCName"), ItemNext("Item_NextPage"), ITEMCollect("Item_CollectAuctions"),youbought("youBought"), youbid("youBid"),refundCanceled("refundCanceledAuction"), someonebid("someoneBid"),someonebought("someoneBought"),ItemPrev(
"Item_PrevPage"), ItemAdd("Item_AddItemToAuctionHouse"), ItemCancel(
"Item_CancelExisitngAuction"), IncreaseMin("Min-Increase"),IncreaseMax("Max-Increase"),LoreTime(
"ItemLore_Time_Remaining"), LoreBuyItNow("ItemLore_Buy_it_Now"), loreBuyItNowHow(
"ItemLore_Buy_Ity_Now_Message"), LoreOwner(
"ItemLore_Buy_Ity_Now_Message"), LorePrice("ItemLore_Price"),LoreOwner(
"ItemLore_Created_By"), CAnnotBidOwnAuction(
"CancelCannotBidOwnAuction"), BuyIUtNowNo(
"Buy_It_Now_Optional_Say_No"), BuyItNowSetTo(
"Buy_It_Now_Price_Set"),rejoin_items("PlayerRejoinRecievesItems"), rejoin_amount("PlayerRejoinRecievesMoney"),Blacklisted("BlacklistedMaterial"),MAX_HOURS(
"Buy_It_Now_Price_Set"),CLAIM_items("PlayerClaimItems"),rejoin_items("PlayerRejoinRecievesItems"), rejoin_amount("PlayerRejoinRecievesMoney"),Blacklisted("BlacklistedMaterial"),MAX_HOURS(
"MaximumHoursForBids"),CANNOTBIDALRADYBID("AlreadyPlacedBid"),HIGHESTBIDDER("HighestBidder"),OutBid(
"OutBid"),broadcastAuction("BroacastAuctionOnSubmit"),broadcastAuctionMesssage("BroacastAuctionOnSubmitMessage"),limitAuctions("EnableAuctionLimitPerPlayer"),overlimit("AuctionLimitReached");
public String s;
Expand Down
40 changes: 27 additions & 13 deletions src/me/zombie_striker/npcauctions/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ public class Main extends JavaPlugin implements Listener {
public static String s_highestBidder = " Highest Bidder: %player%";
public static String s_outBid = " You have been outbid for the %item% auction!";
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_rejoin_items = " The following auctions ended while you were offline: ";
public static String s_CLAIM_items = " Claiming auctions: ";
public static String s_someoneBid = "%player% has bid $%bid% ($%amount%) for your %item% auction";
public static String s_someoneBought = "%player% has bought your %item% auction for $%amount%.";
public static String s_youBid = "You have bid $%bid% ($%amount%) for the %item% auction";
public static String s_youBought = "You have bought the %item% auction for $%amount%.";
public static String s_auctionCancelRefund = "The owner of the %item% auction canceled the auction. You have been refunded $%amount%.";
public static String s_holdingWonAuction = "This auction will be held in the auction house till you collect it.";
public static String s_Menu_page = " Page: ";

public static String s_VillagerName = "&6[AuctionHouse]";

Expand All @@ -75,6 +77,8 @@ public class Main extends JavaPlugin implements Listener {
public static String s_buyitnowset = " Set the Buy-It_now to $%price%";
public static String s_blacklistedmaterial = "&c %material% is not allowed to be auctioned!";

public static String s_lorePrice = "Price : [$%price%+%bid%]";

public static boolean enableViewLastBid = false;
public static double increaseMin = 1.0;
public static double increaseMax = 1000.0;
Expand Down Expand Up @@ -145,6 +149,7 @@ public void saveAuctionNoSave(Auction a) {

@Override
public void onDisable() {
reloadConfig();
for (Auction a : auctions) {
saveAuctionNoSave(a);
}
Expand Down Expand Up @@ -214,6 +219,8 @@ public void run() {
s_cancelAlreadyBid = c.getMessage(Keys.CANNOTBIDALRADYBID, s_cancelAlreadyBid);
s_highestBidder = c.getMessage(Keys.HIGHESTBIDDER, s_highestBidder);

s_Menu_page = c.getMessage(Keys.PAGE_SUFFIX, s_Menu_page);

s_VillagerName = c.getMessage(Keys.VillagersName, s_VillagerName);
s_outBid = c.getMessage(Keys.OutBid, s_outBid);
s_someoneBid = c.getMessage(Keys.someonebid, s_someoneBid);
Expand All @@ -223,6 +230,7 @@ public void run() {
s_auctionCancelRefund = c.getMessage(Keys.refundCanceled, s_auctionCancelRefund);
s_rejoin_amount = c.getMessage(Keys.rejoin_amount, s_rejoin_amount);
s_rejoin_items = c.getMessage(Keys.rejoin_items, s_rejoin_items);
s_CLAIM_items = c.getMessage(Keys.CLAIM_items, s_CLAIM_items);

prefix = c.getMessage(Keys.PREFIX, prefix);

Expand All @@ -239,6 +247,7 @@ public void run() {
s_cannotbidown = c.getMessage(Keys.CAnnotBidOwnAuction, s_cannotbidown);
s_buyitnowoptional = c.getMessage(Keys.BuyIUtNowNo, s_buyitnowoptional);
s_buyitnowset = c.getMessage(Keys.BuyItNowSetTo, s_buyitnowset);
s_lorePrice = c.getMessage(Keys.LorePrice, s_lorePrice);

enableBroadcasting = Boolean.valueOf(c.getMessage(Keys.broadcastAuction, enableBroadcasting + ""));
s_broadcastMessage = c.getMessage(Keys.broadcastAuctionMesssage, s_broadcastMessage);
Expand Down Expand Up @@ -302,14 +311,13 @@ public void run() {
ItemMeta im5 = cancelAuc.getItemMeta();
im5.setDisplayName(s_ItemRemove);
cancelAuc.setItemMeta(im5);

collectAuc = this.getConfigItemStack("CollectAuctionIcon", QuickMaterialConversionClass.getGoldBlock());
ItemMeta im6 = collectAuc.getItemMeta();
im6.setDisplayName(s_ItemCollect);
collectAuc.setItemMeta(im6);

for (int i = 0; i < 20; i++) {
gui[i] = Bukkit.createInventory(null, 54, s_Title + " Page: " + (i + 1));
gui[i] = Bukkit.createInventory(null, 54, s_Title + s_Menu_page + (i + 1));
}
if (getConfig().contains("Auctions"))
for (String owners : getConfig().getConfigurationSection("Auctions").getKeys(false)) {
Expand Down Expand Up @@ -441,7 +449,7 @@ public void win(Auction a, boolean withBuyItNow) {
if (items == null)
items = new ArrayList<ItemStack>();
items.add(a.is);
getConfig().set(a.lastBid.toString() + ".recievedItems", items);
getConfig().set(a.owner.toString() + ".recievedItems", items);
saveConfig();
} else {
((Player) creator).sendMessage(prefix + s_AuctionEneededNoBids.replace("%item%",
Expand Down Expand Up @@ -520,8 +528,8 @@ public Inventory updatePage(Inventory in, int page, boolean nextPage, boolean pr
}
in.setItem(4, addAuc);
in.setItem(5, cancelAuc);

in.setItem(8, collectAuc);
if (!blacklistWorlds.isEmpty())
in.setItem(8, collectAuc);
if (prevPage)
in.setItem(52, prevpage);
if (nextPage)
Expand Down Expand Up @@ -696,7 +704,10 @@ public void price(AsyncPlayerChatEvent e) {
if (enableBroadcasting) {
Bukkit.broadcastMessage(prefix + s_broadcastMessage.replaceAll("%player%", e.getPlayer().getName())
.replaceAll("%amount%", "" + aa.is.getAmount())
.replaceAll("%material%", "" + aa.is.getType().name())
.replaceAll("%material%",
"" + ((aa.is.hasItemMeta() && aa.is.getItemMeta().hasDisplayName())
? aa.is.getItemMeta().getDisplayName()
: aa.is.getType().name()))
.replaceAll("%cost%", aa.currentPrice + ""));
}
}
Expand Down Expand Up @@ -820,7 +831,7 @@ public void onClick(InventoryClickEvent e) {
is.getType().name() + (is.getAmount() > 1 ? ":" + is.getAmount() : "") + ", ");
}
}
e.getWhoClicked().sendMessage(prefix + s_rejoin_items + sb.toString());
e.getWhoClicked().sendMessage(prefix + s_CLAIM_items + sb.toString());
getConfig().set(e.getWhoClicked().getUniqueId().toString() + ".recievedItems", null);
save = true;
}
Expand All @@ -829,13 +840,13 @@ public void onClick(InventoryClickEvent e) {
}

} else if (e.getSlot() == 52 && (slotcheck)) {
int k = (Integer.parseInt(e.getWhoClicked().getOpenInventory().getTitle().split("Page:")[1].trim()) - 1)
- 1;
int k = (Integer.parseInt(e.getWhoClicked().getOpenInventory().getTitle().split(s_Menu_page)[1].trim())
- 1) - 1;
if (k >= 0)
e.getWhoClicked().openInventory(gui[k]);
} else if (e.getSlot() == 53 && (slotcheck) && (!buffercheck)) {
int k = (Integer.parseInt(e.getWhoClicked().getOpenInventory().getTitle().split("Page:")[1].trim()) - 1)
+ 1;
int k = (Integer.parseInt(e.getWhoClicked().getOpenInventory().getTitle().split(s_Menu_page)[1].trim())
- 1) + 1;
if (k < gui.length)
e.getWhoClicked().openInventory(gui[k]);

Expand Down Expand Up @@ -1062,7 +1073,10 @@ public ItemStack c(Auction a) {

List<String> lore = new ArrayList<>();
lore.add(ChatColor.BLACK + "" + a.auctionID);
lore.add(ChatColor.GREEN + "Price : [$" + a.currentPrice + "+" + a.biddingPrice + "]");
lore.add(ChatColor.GREEN
+ s_lorePrice.replaceAll("%price%", a.currentPrice + "").replaceAll("%bid%", a.biddingPrice + ""));
// lore.add(ChatColor.GREEN + "Price : [$" + a.currentPrice + "+" +
// a.biddingPrice + "]");
if (a.hasBuyItNow()) {
lore.add(s_lorebuyitnow.replaceAll("%price%", a.buyitnow + ""));
lore.add(s_lorebuyitnowhow);
Expand Down
13 changes: 7 additions & 6 deletions src/me/zombie_striker/npcauctions/NPCAuctionCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,18 @@ public void run() {
sender.sendMessage(Main.prefix + ChatColor.RED + Main.s_NOPERM);
}
} else if (args[0].equalsIgnoreCase("open")) {
if(sender.hasPermission("npcauctions.openGUIFromCommand"))
if (sender instanceof Player)
((Player) sender).openInventory(Main.gui[0]);
if (sender.hasPermission("npcauctions.openGUIFromCommand"))
if (sender instanceof Player)
((Player) sender).openInventory(Main.gui[0]);

} else if (args[0].equalsIgnoreCase("endAllAuctions")) {

for(Auction a : Main.instance.auctions) {
if (!sender.hasPermission("npcauctions.endall"))
return false;
for (Auction a : Main.instance.auctions) {
a.setWait(0);
}
sender.sendMessage(Main.prefix + " Ending all auctions");

} else if (args[0].equalsIgnoreCase("respawn")) {
for (Entry<UUID, Location> k : Main.tpbackto.entrySet()) {
for (Entity e : k.getValue().getWorld().getEntities()) {
Expand Down

0 comments on commit 4a49644

Please sign in to comment.