diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index 470bcad..e97cce8 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java index 0f0fe0f..f257fdd 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java @@ -1280,6 +1280,16 @@ public class GenericFunctions { return "Lingering Potion"; } } + case SPONGE:{ + switch (type.getDurability()) { + case 0:{ + return "Sponge"; + } + case 1:{ + return "Wet Sponge"; + } + } + } case WOOD_STEP:{ switch (type.getDurability()) { case 0:{ @@ -2057,7 +2067,9 @@ public class GenericFunctions { item.getType().toString().contains("LEGGINGS") || item.getType().toString().contains("HELMET") || item.getType().toString().contains("FISHING_ROD") || - item.getType().toString().contains("SHIELD"))) { + item.getType().toString().contains("SHIELD") || + item.getType().toString().contains("CARROT_STICK") || + item.getType().toString().contains("ELYTRA"))) { return true; } else { return false; diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/Habitation.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/Habitation.java index dcc7f72..c81e02b 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/Habitation.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/Habitation.java @@ -133,7 +133,9 @@ public class Habitation { bw.write((String)locationhashes.keySet().toArray()[i]+","+locationhashes.get((String)locationhashes.keySet().toArray()[i])); bw.newLine(); } - TwosideKeeper.log("[Habitat]Saved "+(locationhashes.keySet().toArray().length)+" habitats successfully.",2); + if (locationhashes.keySet().toArray().length>0) { + TwosideKeeper.log("[Habitat]Saved "+(locationhashes.keySet().toArray().length)+" habitats successfully.",2); + } bw.close(); } catch (IOException e) { e.printStackTrace(); diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemUtils.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemUtils.java index 3b99239..144b9ad 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemUtils.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemUtils.java @@ -77,4 +77,16 @@ public class ItemUtils { return ""; } + public static void clearLore(ItemStack item) { + if (isValidItem(item)) { + ItemMeta m = item.getItemMeta(); + m.setLore(null); + item.setItemMeta(m); + } + } + + private static boolean isValidItem(ItemStack item) { + return (item!=null && item.hasItemMeta()); + } + } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/MessageUtils.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/MessageUtils.java new file mode 100644 index 0000000..17c2628 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/MessageUtils.java @@ -0,0 +1,15 @@ +package sig.plugin.TwosideKeeper.HelperStructures.Utils; + +import org.bukkit.Bukkit; + +import sig.plugin.TwosideKeeper.TwosideKeeper; +import sig.plugin.TwosideKeeper.HelperStructures.ServerType; + +public class MessageUtils { + public static void announceMessage(String msg) { + if (TwosideKeeper.SERVER_TYPE!=ServerType.QUIET) { + aPlugin.API.discordSendRaw(msg); + } + Bukkit.broadcastMessage(msg); + } +} diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/TimeUtils.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/TimeUtils.java new file mode 100644 index 0000000..23cebbc --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/TimeUtils.java @@ -0,0 +1,9 @@ +package sig.plugin.TwosideKeeper.HelperStructures.Utils; + +import java.util.Calendar; + +public class TimeUtils { + public static int GetCurrentDayOfWeek() { + return Calendar.getInstance().get(Calendar.DAY_OF_WEEK); + } +} diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java b/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java index 1a98699..4693da5 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java @@ -8,11 +8,14 @@ import java.io.FileWriter; import java.io.IOException; import java.text.DecimalFormat; import java.util.ArrayList; +import java.util.Calendar; import java.util.Collection; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Random; +import java.util.Set; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -61,16 +64,19 @@ public class WorldShop { int amt; int storedamt = 0; int id; - public static HashMap pricelist = new HashMap(); + Location loc; + public static final double DEFAULTPRICE = 99.99; + public static HashMap pricelist = new HashMap(); public static String price_file = TwosideKeeper.plugin.getDataFolder()+"/ShopPrices.data"; - public WorldShop (ItemStack i, int amt, int storedamt, double p, String player, int shopID) { + public WorldShop (ItemStack i, int amt, int storedamt, double p, String player, int shopID, Location shopLoc) { this.item=i; this.price=p; this.owner=player; this.amt = amt; this.storedamt = storedamt; this.id = shopID; + this.loc = shopLoc; } public String GetItemName() { @@ -96,6 +102,16 @@ public class WorldShop { public void UpdateItem(ItemStack item) { this.item=item; } + public void UpdateLoc(Location loc) { + this.loc=loc; + } + + public Location getLoc() { + return loc; + } + public String GetLocString() { + return loc.getWorld().getName()+","+loc.getBlockX()+","+loc.getBlockY()+","+loc.getBlockZ(); + } public ItemStack GetItem() { return item; @@ -107,16 +123,74 @@ public class WorldShop { return price; } } - private static double GetWorldShopPrice(ItemStack item) { - if (!pricelist.containsKey(item.getType())) { + private double GetWorldShopPrice(ItemStack item) { + String searchstring = item.getType().name(); + if (item.getDurability()!=0) { + searchstring = item.getType().name()+","+item.getDurability(); + } + if (!pricelist.containsKey(searchstring)) { + //Create a new key for this item. + TwosideKeeper.log("Item "+ChatColor.YELLOW+item.toString()+ChatColor.RESET+" does not have a price set yet! Adding to price list!", 1); + AddEntryToFile(item); + } + double price = 0.0; + if (item.getDurability()!=0) { + price = pricelist.get(searchstring); + } else { + price = pricelist.get(item.getType().name()); + } + if (TwosideKeeper.DEAL_OF_THE_DAY_ITEM.isSimilar(item)) { + price*=0.8; + } + return ModifyPriceBasedOnLocation(price); + } + + public static double getBaseWorldShopPrice(ItemStack item) { + String searchstring = item.getType().name(); + if (item.getDurability()!=0) { + searchstring = item.getType().name()+","+item.getDurability(); + } + if (!pricelist.containsKey(searchstring)) { //Create a new key for this item. - TwosideKeeper.log("Material "+ChatColor.YELLOW+item.getType()+ChatColor.RESET+" does not have a price set yet! Adding to price list!", 1); - AddEntryToFile(item.getType()); + TwosideKeeper.log("Item "+ChatColor.YELLOW+item.toString()+ChatColor.RESET+" does not have a price set yet! Adding to price list!", 1); + AddEntryToFile(item); } - return pricelist.get(item.getType()); + double price = 0.0; + if (item.getDurability()!=0) { + price = pricelist.get(searchstring); + } else { + price = pricelist.get(item.getType().name()); + } + return Math.round(price*100)/100d; } - private static void AddEntryToFile(Material type) { + private double ModifyPriceBasedOnLocation(double price) { + if (!loc.getWorld().equals(TwosideKeeper.TWOSIDE_LOCATION.getWorld())) { + //This is in another world. Automatically increase price by x4. + price *= 4; + } else { + //Price based on distance from town. + double dist = (TwosideKeeper.TWOSIDE_LOCATION.distance(loc)); + if (dist>1000) { + double mult = dist/10000d; + price += price*mult; + } + } + if (loc.getWorld().getName().equalsIgnoreCase("world")) { + if (loc.getBlockY()<=48) { + price *= 1.5; + } + if (loc.getBlockY()<=32) { + price *= 1.5; + } + if (loc.getBlockY()<=16) { + price *= 1.5; + } + } + return Math.round(price*100)/100d; + } + + private static void AddEntryToFile(ItemStack item) { File file = new File(price_file); if (!file.exists()) { @@ -126,10 +200,17 @@ public class WorldShop { FileWriter fw = new FileWriter(price_file, true); BufferedWriter bw = new BufferedWriter(fw);) { - bw.write(type.name()+","+"0.50"); - bw.newLine(); - pricelist.put(type, 0.50); - bw.close(); + if (item.getDurability()!=0) { + bw.write(item.getType().name()+","+item.getDurability()+","+DEFAULTPRICE); + bw.newLine(); + pricelist.put(item.getType().name()+","+item.getDurability(), DEFAULTPRICE); + bw.close(); + } else { + bw.write(item.getType().name()+","+DEFAULTPRICE); + bw.newLine(); + pricelist.put(item.getType().name(), DEFAULTPRICE); + bw.close(); + } } catch (IOException e) { e.printStackTrace(); } @@ -975,7 +1056,7 @@ public class WorldShop { public static void createWorldShopRecipes() { for (Material mat : Material.values()) { - ItemStack result = new ItemStack(Material.TRAPPED_CHEST); + ItemStack result = new ItemStack(Material.CHEST); ItemUtils.addLore(result,ChatColor.DARK_PURPLE+"World Shop Chest"); ItemUtils.addLore(result,ChatColor.BLACK+""+ChatColor.MAGIC+mat.name()); ItemUtils.addLore(result,ChatColor.LIGHT_PURPLE+"Place in the world to setup a"); @@ -988,6 +1069,20 @@ public class WorldShop { rec.addIngredient(Material.CHEST); rec.addIngredient(Material.SIGN); Bukkit.addRecipe(rec); + result = new ItemStack(Material.TRAPPED_CHEST); + ItemUtils.addLore(result,ChatColor.DARK_PURPLE+"World Shop Chest"); + ItemUtils.addLore(result,ChatColor.BLACK+""+ChatColor.MAGIC+mat.name()); + ItemUtils.addLore(result,ChatColor.LIGHT_PURPLE+"Place in the world to setup a"); + ItemUtils.addLore(result,ChatColor.LIGHT_PURPLE+"world shop that sells "+ChatColor.YELLOW+GenericFunctions.UserFriendlyMaterialName(mat)); + ItemUtils.setDisplayName(result,ChatColor.YELLOW+GenericFunctions.UserFriendlyMaterialName(mat)+" Shop Chest"); + ItemUtils.hideEnchantments(result); + result.addUnsafeEnchantment(Enchantment.LUCK, 4); + rec = new ShapelessRecipe(result); + rec.addIngredient(mat, -1); + rec.addIngredient(Material.TRAPPED_CHEST); + rec.addIngredient(Material.SIGN); + Bukkit.addRecipe(rec); + Bukkit.addRecipe(rec); } } @@ -1020,8 +1115,20 @@ public class WorldShop { if (readline!=null) { lines++; String[] split = readline.split(","); - double price = Double.parseDouble(split[1]); - pricelist.put(Material.valueOf(split[0]), price); + if (split.length==2) { + double price = Double.parseDouble(split[1]); + if (pricelist.containsKey(split[0])) { + PossibleDuplicateWarning("Possible Duplicate World Shop Price Found for "+split[0]+"! At Line: "+lines,1); + } + pricelist.put(split[0], price); + } else { + //3 means there's a data value there too. + double price = Double.parseDouble(split[2]); + if (pricelist.containsKey(split[0]+","+split[1])) { + PossibleDuplicateWarning("Possible Duplicate World Shop Price Found for "+split[0]+","+split[1]+"! At Line: "+lines,1); + } + pricelist.put(split[0]+","+split[1], price); + } readline = bw.readLine(); }} while (readline!=null); TwosideKeeper.log("[WorldShop]Loaded "+lines+" shop entries successfully.",2); @@ -1030,15 +1137,19 @@ public class WorldShop { } } + private static void PossibleDuplicateWarning(String string, int loglv) { + TwosideKeeper.log(string, loglv); + } + private static void PopulateNewFile(File file) { try( FileWriter fw = new FileWriter(price_file, false); BufferedWriter bw = new BufferedWriter(fw);) { for (Material mat : Material.values()) { - bw.write(mat.name()+","+"0.50"); + bw.write(mat.name()+","+DEFAULTPRICE); bw.newLine(); - pricelist.put(mat, 0.50); + pricelist.put(mat.name(), DEFAULTPRICE); } bw.close(); } catch (IOException e) { @@ -1068,24 +1179,60 @@ public class WorldShop { wallsign.setData(sign.getData()); Sign s = (Sign)wallsign.getState(); s.setLine(0,"shop"); - WorldShop shop = TwosideKeeper.TwosideShops.CreateWorldShop(s, item, 10000, GetWorldShopPrice(item), "admin"); + WorldShop shop = TwosideKeeper.TwosideShops.CreateWorldShop(s, item, 10000, DEFAULTPRICE, "admin"); /*s.setLine(0, ChatColor.BLUE+"-- SHOP --"); s.setLine(1, GenericFunctions.UserFriendlyMaterialName(item)); s.setLine(2, "$"+df.format(GetWorldShopPrice(item))+ChatColor.DARK_BLUE+" [x10000]"); DecimalFormat df2 = new DecimalFormat("000000"); s.setLine(3, ChatColor.DARK_GRAY+df2.format(TwosideKeeper.WORLD_SHOP_ID)); TwosideKeeper.WORLD_SHOP_ID++;*/ + shop.UpdateUnitPrice(shop.GetUnitPrice()); WorldShop.spawnShopItem(s.getLocation(), shop); TwosideKeeper.TwosideShops.SaveWorldShopData(shop); } public static ItemStack ExtractPlaceableShopMaterial(ItemStack item) { if (isPlaceableWorldShop(item)) { - Material mat = Material.valueOf(ItemUtils.GetLoreLine(item, 1).replace(ChatColor.BLACK+""+ChatColor.MAGIC, "")); - return new ItemStack(mat); + String[] split = ItemUtils.GetLoreLine(item, 1).replace(ChatColor.BLACK+""+ChatColor.MAGIC, "").split(","); + if (split.length>1) { + return new ItemStack(Material.valueOf(split[0]),1,Short.parseShort(split[1])); + } else { + Material mat = Material.valueOf(split[0]); + return new ItemStack(mat); + } } else { TwosideKeeper.log("THIS SHOULD NOT BE HAPPENING! Trying to extract from a non-world shop item!", 0); return new ItemStack(Material.AIR); } } + + public static ItemStack generateItemDealOftheDay(int iter) { + Calendar cal = Calendar.getInstance(); + int seed = cal.get(Calendar.YEAR)*cal.get(Calendar.DAY_OF_YEAR)*iter; + Random r = new Random(); + r.setSeed(seed); + Set items = WorldShop.pricelist.keySet(); + int rand = r.nextInt(items.size()); + for (String s : items) { + if (rand>0) { + rand--; + } else { + double price = WorldShop.pricelist.get(s); + if (price==DEFAULTPRICE || price>1000000) { + //This is bad, this is not an item we can actually purchase. We will default to the first entry that we know works. + //TwosideKeeper.log("Price for "+s+" was "+price, 0); + return generateItemDealOftheDay(iter+1); + } else { + String[] split = s.split(","); + if (split.length==1) { + return new ItemStack(Material.valueOf(split[0])); + } else { + return new ItemStack(Material.valueOf(split[0]),1,Short.parseShort(split[1])); + } + } + } + } + TwosideKeeper.log("COULD NOT GET A DEAL OF THE DAY! RAN OUT OF ENTRIES!!! THIS SHOULD NOT BE HAPPENING.", 0); + return null; + } } diff --git a/src/sig/plugin/TwosideKeeper/PlayerStructure.java b/src/sig/plugin/TwosideKeeper/PlayerStructure.java index 3f72c2d..e07e78d 100644 --- a/src/sig/plugin/TwosideKeeper/PlayerStructure.java +++ b/src/sig/plugin/TwosideKeeper/PlayerStructure.java @@ -217,7 +217,9 @@ public class PlayerStructure { //This is a new player! Let the whole world know! //Give the player free tools and items. Bukkit.getServer().broadcastMessage(ChatColor.GOLD+"Welcome to new player "+ChatColor.WHITE+""+this.name+"!"); - aPlugin.API.discordSendRaw("Welcome to new player **"+this.name+"**!"); + if (TwosideKeeper.SERVER_TYPE==ServerType.MAIN) { + aPlugin.API.discordSendRaw("Welcome to new player **"+this.name+"**!"); + } p.sendMessage(ChatColor.GREEN+"Welcome to the server! Thanks for joining us."); p.sendMessage(ChatColor.GOLD+" Here's a manual to get you started!"); diff --git a/src/sig/plugin/TwosideKeeper/RecyclingCenter.java b/src/sig/plugin/TwosideKeeper/RecyclingCenter.java index 5f7d35b..72f170d 100644 --- a/src/sig/plugin/TwosideKeeper/RecyclingCenter.java +++ b/src/sig/plugin/TwosideKeeper/RecyclingCenter.java @@ -188,7 +188,11 @@ public class RecyclingCenter { } c.getBlockInventory().setItem(itemslot, i); populateItemList(i); - TwosideKeeper.log("Sent "+ChatColor.AQUA+GenericFunctions.UserFriendlyMaterialName(i)+((i.getAmount()>1)?ChatColor.YELLOW+" x"+i.getAmount():"")+ChatColor.RESET+" to Recycling Center Node "+rand_node.toString(),2); + if (TwosideKeeper.LOGGING_LEVEL>=3) { + TwosideKeeper.log("Sent "+ChatColor.AQUA+GenericFunctions.UserFriendlyMaterialName(i)+((i.getAmount()>1)?ChatColor.YELLOW+" x"+i.getAmount():"")+ChatColor.RESET+" to Recycling Center Node "+rand_node.toString(),2); + } else { + TwosideKeeper.log("Sent "+ChatColor.AQUA+GenericFunctions.UserFriendlyMaterialName(i)+((i.getAmount()>1)?ChatColor.YELLOW+" x"+i.getAmount():"")+ChatColor.RESET+" to Recycling Center.",2); + } } } } diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java index 3f02305..0e0cd47 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java @@ -5,6 +5,7 @@ import java.io.IOException; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; +import java.util.Calendar; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -187,7 +188,9 @@ import sig.plugin.TwosideKeeper.HelperStructures.Common.RecipeCategory; import sig.plugin.TwosideKeeper.HelperStructures.Common.RecipeLinker; import sig.plugin.TwosideKeeper.HelperStructures.Effects.LavaPlume; import sig.plugin.TwosideKeeper.HelperStructures.Utils.BlockUtils; +import sig.plugin.TwosideKeeper.HelperStructures.Utils.ItemUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils; +import sig.plugin.TwosideKeeper.HelperStructures.Utils.TimeUtils; import sig.plugin.TwosideKeeper.Logging.BowModeLogger; import sig.plugin.TwosideKeeper.Logging.LootLogger; import sig.plugin.TwosideKeeper.Logging.MysteriousEssenceLogger; @@ -234,6 +237,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public static ServerType SERVER_TYPE=ServerType.TEST; //The type of server this is running on. public static int COMMONITEMPCT=3; public static long LAST_ELITE_SPAWN = 0; + public static int LAST_DEAL = 0; public static Location ELITE_LOCATION = null; public static boolean LOOT_TABLE_NEEDS_POPULATING=true; public static List TEMPORARYABILITIES = new ArrayList(); @@ -343,6 +347,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public static CustomPotion STRENGTHENING_VIAL; public static CustomPotion LIFE_VIAL; public static CustomPotion HARDENING_VIAL; + public static ItemStack DEAL_OF_THE_DAY_ITEM; public static final int POTION_DEBUG_LEVEL=5; public static final int LAVA_PLUME_COOLDOWN=60; @@ -363,7 +368,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public static final Material[] ClearFallingBlockList = {Material.REDSTONE_BLOCK}; - public static final Location TWOSIDE_LOCATION = new Location(Bukkit.getServer().getWorld("world"),1630,65,-265); + public static Location TWOSIDE_LOCATION; public static final int CLEANUP_DEBUG = 2; public static final int LOOT_DEBUG = 3; @@ -675,7 +680,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener { plugin=this; loadConfig(); - CustomItem.InitializeItemRecipes(); Recipes.Initialize_ItemCube_Recipes(); @@ -781,6 +785,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { STRENGTHENING_VIAL = CustomRecipe.DefineStrengtheningVial(); LIFE_VIAL = CustomRecipe.DefineLifeVial(); HARDENING_VIAL = CustomRecipe.DefineHardeningVial(); + + TWOSIDE_LOCATION = new Location(Bukkit.getServer().getWorld("world"),1630,65,-265); //tpstracker = new Lag(); //Let's not assume there are no players online. Load their data. @@ -792,6 +798,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { WorldShop.createWorldShopRecipes(); WorldShop.loadShopPrices(); + TwosideKeeper.DEAL_OF_THE_DAY_ITEM = WorldShop.generateItemDealOftheDay(1); + log("Deal of the day loaded successfully: "+GenericFunctions.UserFriendlyMaterialName(TwosideKeeper.DEAL_OF_THE_DAY_ITEM),2); if (!LOOT_TABLE_NEEDS_POPULATING) { Loot.DefineLootChests(); @@ -814,6 +822,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { //This is the constant timing method. getServer().getScheduler().scheduleSyncRepeatingTask(this, new runServerHeartbeat(this), 20l, 20l); + + //log(Calendar.getInstance().get(Calendar.DAY_OF_WEEK)+"",0); } @Override @@ -1459,6 +1469,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (SERVER_TYPE==ServerType.MAIN && !restarting_server) { Bukkit.getScheduler().runTaskAsynchronously(this, pluginupdater); } + + AnnounceDealOfTheDay(ev.getPlayer()); playerdata.put(ev.getPlayer().getUniqueId(), new PlayerStructure(ev.getPlayer(),getServerTickTime())); log("[TASK] New Player Data has been added. Size of array: "+playerdata.size(),4); @@ -1479,7 +1491,16 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ev.getPlayer().getAttribute(Attribute.GENERIC_ATTACK_SPEED).setBaseValue(4.0d); } - @EventHandler(priority=EventPriority.LOW,ignoreCancelled = true) + public static void AnnounceDealOfTheDay(Player p) { + p.sendMessage("--------------------"); + p.sendMessage(ChatColor.DARK_AQUA+""+ChatColor.BOLD+"Deal of the Day:"); + DecimalFormat df = new DecimalFormat("0.00"); + p.sendMessage(" "+ChatColor.GREEN+""+ChatColor.BOLD+""+GenericFunctions.UserFriendlyMaterialName(TwosideKeeper.DEAL_OF_THE_DAY_ITEM)+" "+ChatColor.RESET+ChatColor.STRIKETHROUGH+"$"+df.format(TwosideKeeperAPI.getWorldShopItemBasePrice(TwosideKeeper.DEAL_OF_THE_DAY_ITEM))+ChatColor.RESET+ChatColor.GOLD+""+ChatColor.BOLD+" $"+df.format(TwosideKeeperAPI.getWorldShopItemBasePrice(TwosideKeeper.DEAL_OF_THE_DAY_ITEM)*0.8)+" "+ChatColor.DARK_GREEN+ChatColor.BOLD+"20% Off"); + p.sendMessage(" "+ChatColor.RED+ChatColor.BOLD+"TODAY ONLY!"+ChatColor.RESET+ChatColor.YELLOW+" Find the offer at your local world shops!"); + p.sendMessage("--------------------"); + } + + @EventHandler(priority=EventPriority.LOW,ignoreCancelled = true) public void onPlayerLeave(PlayerQuitEvent ev) { TwosideSpleefGames.PassEvent(ev); for (EliteMonster em : elitemonsters) { @@ -6052,6 +6073,35 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } //Check if we are using an item cube in a non-item cube recipe. + + if (WorldShop.isPlaceableWorldShop(result)) { + //Find the slot with the world shop item. + for (int i=1;i=TwosideKeeper.SERVERCHECKERTICKS) { //15 MINUTES (DEFAULT) + + if (TwosideKeeper.LAST_DEAL!=Calendar.getInstance().get(Calendar.DAY_OF_WEEK)) { + //This means the deal of the day has to be updated! + TwosideKeeper.LAST_DEAL = Calendar.getInstance().get(Calendar.DAY_OF_WEEK); + TwosideKeeper.DEAL_OF_THE_DAY_ITEM = WorldShop.generateItemDealOftheDay(1); + if (TwosideKeeper.SERVER_TYPE!=ServerType.QUIET) { + DecimalFormat df = new DecimalFormat("0.00"); + aPlugin.API.discordSendRaw("*The Deal of the Day has been updated!*\n **"+GenericFunctions.UserFriendlyMaterialName(TwosideKeeper.DEAL_OF_THE_DAY_ITEM)+"** ~~$"+df.format(WorldShop.getBaseWorldShopPrice(TwosideKeeper.DEAL_OF_THE_DAY_ITEM))+"~~ $"+df.format(WorldShop.getBaseWorldShopPrice(TwosideKeeper.DEAL_OF_THE_DAY_ITEM)*0.8)+" **20% Off!**"); + //MessageUtils.announceMessage("The Deal of the Day has been updated!"); + } + for (Player p : Bukkit.getOnlinePlayers()) { + p.sendMessage(ChatColor.AQUA+""+ChatColor.ITALIC+"The Deal of the Day has been updated!"); + TwosideKeeper.AnnounceDealOfTheDay(p); + } + } + ServerHeartbeat.saveOurData(); //Advertisement messages could go here.