World Shops completed. Deal of the day feature now exists!
This commit is contained in:
parent
213dcfc7dc
commit
06bd56e661
Binary file not shown.
@ -1280,6 +1280,16 @@ public class GenericFunctions {
|
|||||||
return "Lingering Potion";
|
return "Lingering Potion";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case SPONGE:{
|
||||||
|
switch (type.getDurability()) {
|
||||||
|
case 0:{
|
||||||
|
return "Sponge";
|
||||||
|
}
|
||||||
|
case 1:{
|
||||||
|
return "Wet Sponge";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
case WOOD_STEP:{
|
case WOOD_STEP:{
|
||||||
switch (type.getDurability()) {
|
switch (type.getDurability()) {
|
||||||
case 0:{
|
case 0:{
|
||||||
@ -2057,7 +2067,9 @@ public class GenericFunctions {
|
|||||||
item.getType().toString().contains("LEGGINGS") ||
|
item.getType().toString().contains("LEGGINGS") ||
|
||||||
item.getType().toString().contains("HELMET") ||
|
item.getType().toString().contains("HELMET") ||
|
||||||
item.getType().toString().contains("FISHING_ROD") ||
|
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;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -133,7 +133,9 @@ public class Habitation {
|
|||||||
bw.write((String)locationhashes.keySet().toArray()[i]+","+locationhashes.get((String)locationhashes.keySet().toArray()[i]));
|
bw.write((String)locationhashes.keySet().toArray()[i]+","+locationhashes.get((String)locationhashes.keySet().toArray()[i]));
|
||||||
bw.newLine();
|
bw.newLine();
|
||||||
}
|
}
|
||||||
|
if (locationhashes.keySet().toArray().length>0) {
|
||||||
TwosideKeeper.log("[Habitat]Saved "+(locationhashes.keySet().toArray().length)+" habitats successfully.",2);
|
TwosideKeeper.log("[Habitat]Saved "+(locationhashes.keySet().toArray().length)+" habitats successfully.",2);
|
||||||
|
}
|
||||||
bw.close();
|
bw.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -77,4 +77,16 @@ public class ItemUtils {
|
|||||||
return "";
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -8,11 +8,14 @@ import java.io.FileWriter;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -61,16 +64,19 @@ public class WorldShop {
|
|||||||
int amt;
|
int amt;
|
||||||
int storedamt = 0;
|
int storedamt = 0;
|
||||||
int id;
|
int id;
|
||||||
public static HashMap<Material,Double> pricelist = new HashMap<Material,Double>();
|
Location loc;
|
||||||
|
public static final double DEFAULTPRICE = 99.99;
|
||||||
|
public static HashMap<String,Double> pricelist = new HashMap<String,Double>();
|
||||||
public static String price_file = TwosideKeeper.plugin.getDataFolder()+"/ShopPrices.data";
|
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.item=i;
|
||||||
this.price=p;
|
this.price=p;
|
||||||
this.owner=player;
|
this.owner=player;
|
||||||
this.amt = amt;
|
this.amt = amt;
|
||||||
this.storedamt = storedamt;
|
this.storedamt = storedamt;
|
||||||
this.id = shopID;
|
this.id = shopID;
|
||||||
|
this.loc = shopLoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String GetItemName() {
|
public String GetItemName() {
|
||||||
@ -96,6 +102,16 @@ public class WorldShop {
|
|||||||
public void UpdateItem(ItemStack item) {
|
public void UpdateItem(ItemStack item) {
|
||||||
this.item=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() {
|
public ItemStack GetItem() {
|
||||||
return item;
|
return item;
|
||||||
@ -107,16 +123,74 @@ public class WorldShop {
|
|||||||
return price;
|
return price;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static double GetWorldShopPrice(ItemStack item) {
|
private double GetWorldShopPrice(ItemStack item) {
|
||||||
if (!pricelist.containsKey(item.getType())) {
|
String searchstring = item.getType().name();
|
||||||
//Create a new key for this item.
|
if (item.getDurability()!=0) {
|
||||||
TwosideKeeper.log("Material "+ChatColor.YELLOW+item.getType()+ChatColor.RESET+" does not have a price set yet! Adding to price list!", 1);
|
searchstring = item.getType().name()+","+item.getDurability();
|
||||||
AddEntryToFile(item.getType());
|
|
||||||
}
|
}
|
||||||
return pricelist.get(item.getType());
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddEntryToFile(Material type) {
|
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("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());
|
||||||
|
}
|
||||||
|
return Math.round(price*100)/100d;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
File file = new File(price_file);
|
||||||
|
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
@ -126,10 +200,17 @@ public class WorldShop {
|
|||||||
FileWriter fw = new FileWriter(price_file, true);
|
FileWriter fw = new FileWriter(price_file, true);
|
||||||
BufferedWriter bw = new BufferedWriter(fw);)
|
BufferedWriter bw = new BufferedWriter(fw);)
|
||||||
{
|
{
|
||||||
bw.write(type.name()+","+"0.50");
|
if (item.getDurability()!=0) {
|
||||||
|
bw.write(item.getType().name()+","+item.getDurability()+","+DEFAULTPRICE);
|
||||||
bw.newLine();
|
bw.newLine();
|
||||||
pricelist.put(type, 0.50);
|
pricelist.put(item.getType().name()+","+item.getDurability(), DEFAULTPRICE);
|
||||||
bw.close();
|
bw.close();
|
||||||
|
} else {
|
||||||
|
bw.write(item.getType().name()+","+DEFAULTPRICE);
|
||||||
|
bw.newLine();
|
||||||
|
pricelist.put(item.getType().name(), DEFAULTPRICE);
|
||||||
|
bw.close();
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -975,7 +1056,7 @@ public class WorldShop {
|
|||||||
|
|
||||||
public static void createWorldShopRecipes() {
|
public static void createWorldShopRecipes() {
|
||||||
for (Material mat : Material.values()) {
|
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.DARK_PURPLE+"World Shop Chest");
|
||||||
ItemUtils.addLore(result,ChatColor.BLACK+""+ChatColor.MAGIC+mat.name());
|
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+"Place in the world to setup a");
|
||||||
@ -988,6 +1069,20 @@ public class WorldShop {
|
|||||||
rec.addIngredient(Material.CHEST);
|
rec.addIngredient(Material.CHEST);
|
||||||
rec.addIngredient(Material.SIGN);
|
rec.addIngredient(Material.SIGN);
|
||||||
Bukkit.addRecipe(rec);
|
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) {
|
if (readline!=null) {
|
||||||
lines++;
|
lines++;
|
||||||
String[] split = readline.split(",");
|
String[] split = readline.split(",");
|
||||||
|
if (split.length==2) {
|
||||||
double price = Double.parseDouble(split[1]);
|
double price = Double.parseDouble(split[1]);
|
||||||
pricelist.put(Material.valueOf(split[0]), price);
|
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();
|
readline = bw.readLine();
|
||||||
}} while (readline!=null);
|
}} while (readline!=null);
|
||||||
TwosideKeeper.log("[WorldShop]Loaded "+lines+" shop entries successfully.",2);
|
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) {
|
private static void PopulateNewFile(File file) {
|
||||||
try(
|
try(
|
||||||
FileWriter fw = new FileWriter(price_file, false);
|
FileWriter fw = new FileWriter(price_file, false);
|
||||||
BufferedWriter bw = new BufferedWriter(fw);)
|
BufferedWriter bw = new BufferedWriter(fw);)
|
||||||
{
|
{
|
||||||
for (Material mat : Material.values()) {
|
for (Material mat : Material.values()) {
|
||||||
bw.write(mat.name()+","+"0.50");
|
bw.write(mat.name()+","+DEFAULTPRICE);
|
||||||
bw.newLine();
|
bw.newLine();
|
||||||
pricelist.put(mat, 0.50);
|
pricelist.put(mat.name(), DEFAULTPRICE);
|
||||||
}
|
}
|
||||||
bw.close();
|
bw.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -1068,24 +1179,60 @@ public class WorldShop {
|
|||||||
wallsign.setData(sign.getData());
|
wallsign.setData(sign.getData());
|
||||||
Sign s = (Sign)wallsign.getState();
|
Sign s = (Sign)wallsign.getState();
|
||||||
s.setLine(0,"shop");
|
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(0, ChatColor.BLUE+"-- SHOP --");
|
||||||
s.setLine(1, GenericFunctions.UserFriendlyMaterialName(item));
|
s.setLine(1, GenericFunctions.UserFriendlyMaterialName(item));
|
||||||
s.setLine(2, "$"+df.format(GetWorldShopPrice(item))+ChatColor.DARK_BLUE+" [x10000]");
|
s.setLine(2, "$"+df.format(GetWorldShopPrice(item))+ChatColor.DARK_BLUE+" [x10000]");
|
||||||
DecimalFormat df2 = new DecimalFormat("000000");
|
DecimalFormat df2 = new DecimalFormat("000000");
|
||||||
s.setLine(3, ChatColor.DARK_GRAY+df2.format(TwosideKeeper.WORLD_SHOP_ID));
|
s.setLine(3, ChatColor.DARK_GRAY+df2.format(TwosideKeeper.WORLD_SHOP_ID));
|
||||||
TwosideKeeper.WORLD_SHOP_ID++;*/
|
TwosideKeeper.WORLD_SHOP_ID++;*/
|
||||||
|
shop.UpdateUnitPrice(shop.GetUnitPrice());
|
||||||
WorldShop.spawnShopItem(s.getLocation(), shop);
|
WorldShop.spawnShopItem(s.getLocation(), shop);
|
||||||
TwosideKeeper.TwosideShops.SaveWorldShopData(shop);
|
TwosideKeeper.TwosideShops.SaveWorldShopData(shop);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack ExtractPlaceableShopMaterial(ItemStack item) {
|
public static ItemStack ExtractPlaceableShopMaterial(ItemStack item) {
|
||||||
if (isPlaceableWorldShop(item)) {
|
if (isPlaceableWorldShop(item)) {
|
||||||
Material mat = Material.valueOf(ItemUtils.GetLoreLine(item, 1).replace(ChatColor.BLACK+""+ChatColor.MAGIC, ""));
|
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);
|
return new ItemStack(mat);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
TwosideKeeper.log("THIS SHOULD NOT BE HAPPENING! Trying to extract from a non-world shop item!", 0);
|
TwosideKeeper.log("THIS SHOULD NOT BE HAPPENING! Trying to extract from a non-world shop item!", 0);
|
||||||
return new ItemStack(Material.AIR);
|
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<String> 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,9 @@ public class PlayerStructure {
|
|||||||
//This is a new player! Let the whole world know!
|
//This is a new player! Let the whole world know!
|
||||||
//Give the player free tools and items.
|
//Give the player free tools and items.
|
||||||
Bukkit.getServer().broadcastMessage(ChatColor.GOLD+"Welcome to new player "+ChatColor.WHITE+""+this.name+"!");
|
Bukkit.getServer().broadcastMessage(ChatColor.GOLD+"Welcome to new player "+ChatColor.WHITE+""+this.name+"!");
|
||||||
|
if (TwosideKeeper.SERVER_TYPE==ServerType.MAIN) {
|
||||||
aPlugin.API.discordSendRaw("Welcome to new player **"+this.name+"**!");
|
aPlugin.API.discordSendRaw("Welcome to new player **"+this.name+"**!");
|
||||||
|
}
|
||||||
p.sendMessage(ChatColor.GREEN+"Welcome to the server! Thanks for joining us.");
|
p.sendMessage(ChatColor.GREEN+"Welcome to the server! Thanks for joining us.");
|
||||||
p.sendMessage(ChatColor.GOLD+" Here's a manual to get you started!");
|
p.sendMessage(ChatColor.GOLD+" Here's a manual to get you started!");
|
||||||
|
|
||||||
|
@ -188,7 +188,11 @@ public class RecyclingCenter {
|
|||||||
}
|
}
|
||||||
c.getBlockInventory().setItem(itemslot, i);
|
c.getBlockInventory().setItem(itemslot, i);
|
||||||
populateItemList(i);
|
populateItemList(i);
|
||||||
|
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);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import java.io.IOException;
|
|||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
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.Common.RecipeLinker;
|
||||||
import sig.plugin.TwosideKeeper.HelperStructures.Effects.LavaPlume;
|
import sig.plugin.TwosideKeeper.HelperStructures.Effects.LavaPlume;
|
||||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.BlockUtils;
|
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.SoundUtils;
|
||||||
|
import sig.plugin.TwosideKeeper.HelperStructures.Utils.TimeUtils;
|
||||||
import sig.plugin.TwosideKeeper.Logging.BowModeLogger;
|
import sig.plugin.TwosideKeeper.Logging.BowModeLogger;
|
||||||
import sig.plugin.TwosideKeeper.Logging.LootLogger;
|
import sig.plugin.TwosideKeeper.Logging.LootLogger;
|
||||||
import sig.plugin.TwosideKeeper.Logging.MysteriousEssenceLogger;
|
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 ServerType SERVER_TYPE=ServerType.TEST; //The type of server this is running on.
|
||||||
public static int COMMONITEMPCT=3;
|
public static int COMMONITEMPCT=3;
|
||||||
public static long LAST_ELITE_SPAWN = 0;
|
public static long LAST_ELITE_SPAWN = 0;
|
||||||
|
public static int LAST_DEAL = 0;
|
||||||
public static Location ELITE_LOCATION = null;
|
public static Location ELITE_LOCATION = null;
|
||||||
public static boolean LOOT_TABLE_NEEDS_POPULATING=true;
|
public static boolean LOOT_TABLE_NEEDS_POPULATING=true;
|
||||||
public static List<ArtifactAbility> TEMPORARYABILITIES = new ArrayList<ArtifactAbility>();
|
public static List<ArtifactAbility> TEMPORARYABILITIES = new ArrayList<ArtifactAbility>();
|
||||||
@ -343,6 +347,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
public static CustomPotion STRENGTHENING_VIAL;
|
public static CustomPotion STRENGTHENING_VIAL;
|
||||||
public static CustomPotion LIFE_VIAL;
|
public static CustomPotion LIFE_VIAL;
|
||||||
public static CustomPotion HARDENING_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 POTION_DEBUG_LEVEL=5;
|
||||||
public static final int LAVA_PLUME_COOLDOWN=60;
|
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 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 CLEANUP_DEBUG = 2;
|
||||||
public static final int LOOT_DEBUG = 3;
|
public static final int LOOT_DEBUG = 3;
|
||||||
@ -676,7 +681,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
|
|
||||||
loadConfig();
|
loadConfig();
|
||||||
|
|
||||||
|
|
||||||
CustomItem.InitializeItemRecipes();
|
CustomItem.InitializeItemRecipes();
|
||||||
Recipes.Initialize_ItemCube_Recipes();
|
Recipes.Initialize_ItemCube_Recipes();
|
||||||
Recipes.Initialize_ArrowQuiver_Recipe();
|
Recipes.Initialize_ArrowQuiver_Recipe();
|
||||||
@ -781,6 +785,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
STRENGTHENING_VIAL = CustomRecipe.DefineStrengtheningVial();
|
STRENGTHENING_VIAL = CustomRecipe.DefineStrengtheningVial();
|
||||||
LIFE_VIAL = CustomRecipe.DefineLifeVial();
|
LIFE_VIAL = CustomRecipe.DefineLifeVial();
|
||||||
HARDENING_VIAL = CustomRecipe.DefineHardeningVial();
|
HARDENING_VIAL = CustomRecipe.DefineHardeningVial();
|
||||||
|
|
||||||
|
TWOSIDE_LOCATION = new Location(Bukkit.getServer().getWorld("world"),1630,65,-265);
|
||||||
//tpstracker = new Lag();
|
//tpstracker = new Lag();
|
||||||
|
|
||||||
//Let's not assume there are no players online. Load their data.
|
//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.createWorldShopRecipes();
|
||||||
WorldShop.loadShopPrices();
|
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) {
|
if (!LOOT_TABLE_NEEDS_POPULATING) {
|
||||||
Loot.DefineLootChests();
|
Loot.DefineLootChests();
|
||||||
@ -814,6 +822,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
|
|
||||||
//This is the constant timing method.
|
//This is the constant timing method.
|
||||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, new runServerHeartbeat(this), 20l, 20l);
|
getServer().getScheduler().scheduleSyncRepeatingTask(this, new runServerHeartbeat(this), 20l, 20l);
|
||||||
|
|
||||||
|
//log(Calendar.getInstance().get(Calendar.DAY_OF_WEEK)+"",0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1459,6 +1469,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
if (SERVER_TYPE==ServerType.MAIN && !restarting_server) {
|
if (SERVER_TYPE==ServerType.MAIN && !restarting_server) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(this, pluginupdater);
|
Bukkit.getScheduler().runTaskAsynchronously(this, pluginupdater);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AnnounceDealOfTheDay(ev.getPlayer());
|
||||||
playerdata.put(ev.getPlayer().getUniqueId(), new PlayerStructure(ev.getPlayer(),getServerTickTime()));
|
playerdata.put(ev.getPlayer().getUniqueId(), new PlayerStructure(ev.getPlayer(),getServerTickTime()));
|
||||||
log("[TASK] New Player Data has been added. Size of array: "+playerdata.size(),4);
|
log("[TASK] New Player Data has been added. Size of array: "+playerdata.size(),4);
|
||||||
|
|
||||||
@ -1479,6 +1491,15 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
ev.getPlayer().getAttribute(Attribute.GENERIC_ATTACK_SPEED).setBaseValue(4.0d);
|
ev.getPlayer().getAttribute(Attribute.GENERIC_ATTACK_SPEED).setBaseValue(4.0d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
||||||
public void onPlayerLeave(PlayerQuitEvent ev) {
|
public void onPlayerLeave(PlayerQuitEvent ev) {
|
||||||
TwosideSpleefGames.PassEvent(ev);
|
TwosideSpleefGames.PassEvent(ev);
|
||||||
@ -6053,6 +6074,35 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
|
|
||||||
//Check if we are using an item cube in a non-item cube recipe.
|
//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<ev.getInventory().getSize();i++) {
|
||||||
|
ItemStack item = ev.getInventory().getItem(i);
|
||||||
|
if (item!=null && item.getType()!=Material.SIGN &&
|
||||||
|
item.getType()!=Material.CHEST) {
|
||||||
|
//This is the item. Check for durability.
|
||||||
|
if (ItemUtils.isValidLoreItem(item) || (item.getDurability()!=0 && GenericFunctions.isEquip(item))) { //We cannot use this in this recipe.
|
||||||
|
ev.getInventory().setResult(new ItemStack(Material.AIR));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (item.getDurability()!=0 && !GenericFunctions.isEquip(item)) {
|
||||||
|
//Modify the final chest.
|
||||||
|
ItemUtils.clearLore(result);
|
||||||
|
ItemUtils.addLore(result,ChatColor.DARK_PURPLE+"World Shop Chest");
|
||||||
|
ItemUtils.addLore(result,ChatColor.BLACK+""+ChatColor.MAGIC+item.getType().name()+","+item.getDurability());
|
||||||
|
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(item));
|
||||||
|
ItemUtils.setDisplayName(result,ChatColor.YELLOW+GenericFunctions.UserFriendlyMaterialName(item)+" Shop Chest");
|
||||||
|
ItemUtils.hideEnchantments(result);
|
||||||
|
result.addUnsafeEnchantment(Enchantment.LUCK, 4);
|
||||||
|
ev.getInventory().setResult(result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//Item cube should be in slot 4.
|
//Item cube should be in slot 4.
|
||||||
if (ev.getInventory().getItem(5)!=null) {
|
if (ev.getInventory().getItem(5)!=null) {
|
||||||
ItemMeta inventory_itemMeta=ev.getInventory().getItem(5).getItemMeta();
|
ItemMeta inventory_itemMeta=ev.getInventory().getItem(5).getItemMeta();
|
||||||
@ -6499,6 +6549,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
//getConfig().set("ARTIFACT_RARITY", ARTIFACT_RARITY);
|
//getConfig().set("ARTIFACT_RARITY", ARTIFACT_RARITY);
|
||||||
getConfig().set("SERVER_TYPE", SERVER_TYPE.GetValue());
|
getConfig().set("SERVER_TYPE", SERVER_TYPE.GetValue());
|
||||||
getConfig().set("LAST_ELITE_SPAWN", LAST_ELITE_SPAWN);
|
getConfig().set("LAST_ELITE_SPAWN", LAST_ELITE_SPAWN);
|
||||||
|
getConfig().set("LAST_DEAL", LAST_DEAL);
|
||||||
if (ELITE_LOCATION!=null) {
|
if (ELITE_LOCATION!=null) {
|
||||||
getConfig().set("ELITE_LOCATION_X", ELITE_LOCATION.getBlockX());
|
getConfig().set("ELITE_LOCATION_X", ELITE_LOCATION.getBlockX());
|
||||||
getConfig().set("ELITE_LOCATION_Z", ELITE_LOCATION.getBlockZ());
|
getConfig().set("ELITE_LOCATION_Z", ELITE_LOCATION.getBlockZ());
|
||||||
@ -6561,6 +6612,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
getConfig().addDefault("LAST_ELITE_SPAWN", LAST_ELITE_SPAWN);
|
getConfig().addDefault("LAST_ELITE_SPAWN", LAST_ELITE_SPAWN);
|
||||||
getConfig().addDefault("WORLD_SHOP_DIST", worldShopDistanceSquared);
|
getConfig().addDefault("WORLD_SHOP_DIST", worldShopDistanceSquared);
|
||||||
getConfig().addDefault("WORLD_SHOP_MULT", worldShopPriceMult);
|
getConfig().addDefault("WORLD_SHOP_MULT", worldShopPriceMult);
|
||||||
|
getConfig().addDefault("LAST_DEAL", TimeUtils.GetCurrentDayOfWeek());
|
||||||
getConfig().options().copyDefaults(true);
|
getConfig().options().copyDefaults(true);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
SERVERTICK = getConfig().getLong("SERVERTICK");
|
SERVERTICK = getConfig().getLong("SERVERTICK");
|
||||||
@ -6596,6 +6648,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
LAST_ELITE_SPAWN = getConfig().getLong("LAST_ELITE_SPAWN");
|
LAST_ELITE_SPAWN = getConfig().getLong("LAST_ELITE_SPAWN");
|
||||||
worldShopDistanceSquared = getConfig().getDouble("WORLD_SHOP_DIST");
|
worldShopDistanceSquared = getConfig().getDouble("WORLD_SHOP_DIST");
|
||||||
worldShopPriceMult = getConfig().getDouble("WORLD_SHOP_MULT");
|
worldShopPriceMult = getConfig().getDouble("WORLD_SHOP_MULT");
|
||||||
|
LAST_DEAL = getConfig().getInt("LAST_DEAL");
|
||||||
if (getConfig().contains("ELITE_LOCATION_X")) {
|
if (getConfig().contains("ELITE_LOCATION_X")) {
|
||||||
int x = getConfig().getInt("ELITE_LOCATION_X");
|
int x = getConfig().getInt("ELITE_LOCATION_X");
|
||||||
int z = getConfig().getInt("ELITE_LOCATION_Z");
|
int z = getConfig().getInt("ELITE_LOCATION_Z");
|
||||||
|
@ -347,6 +347,9 @@ public final class TwosideKeeperAPI {
|
|||||||
public static boolean canPlaceShopSignOnBlock(Block block) {
|
public static boolean canPlaceShopSignOnBlock(Block block) {
|
||||||
return WorldShop.canPlaceShopSignOnBlock(block);
|
return WorldShop.canPlaceShopSignOnBlock(block);
|
||||||
}
|
}
|
||||||
|
public static double getWorldShopItemBasePrice(ItemStack item) {
|
||||||
|
return WorldShop.getBaseWorldShopPrice(item);
|
||||||
|
}
|
||||||
|
|
||||||
//Recycling Center COMMANDS.
|
//Recycling Center COMMANDS.
|
||||||
public static boolean isRecyclingCenter(Block b) {
|
public static boolean isRecyclingCenter(Block b) {
|
||||||
|
@ -8,6 +8,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Chest;
|
import org.bukkit.block.Chest;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
@ -44,7 +45,7 @@ public class WorldShopManager {
|
|||||||
public WorldShop CreateWorldShop(Sign s, ItemStack item, int amt, double price, String owner, boolean purchaseshop) {
|
public WorldShop CreateWorldShop(Sign s, ItemStack item, int amt, double price, String owner, boolean purchaseshop) {
|
||||||
//Convert the sign.
|
//Convert the sign.
|
||||||
String[] lines = s.getLines();
|
String[] lines = s.getLines();
|
||||||
WorldShop newshop = new WorldShop(item, amt, 0, price, owner, TwosideKeeper.WORLD_SHOP_ID);
|
WorldShop newshop = new WorldShop(item, amt, 0, price, owner, TwosideKeeper.WORLD_SHOP_ID, s.getLocation());
|
||||||
if (lines[0].equalsIgnoreCase("shop") || lines[0].equalsIgnoreCase("buyshop")) {
|
if (lines[0].equalsIgnoreCase("shop") || lines[0].equalsIgnoreCase("buyshop")) {
|
||||||
UpdateSign(newshop, TwosideKeeper.WORLD_SHOP_ID, s,purchaseshop);
|
UpdateSign(newshop, TwosideKeeper.WORLD_SHOP_ID, s,purchaseshop);
|
||||||
}
|
}
|
||||||
@ -130,7 +131,12 @@ public class WorldShopManager {
|
|||||||
config = new File(TwosideKeeper.filesave,"worldshop.data");
|
config = new File(TwosideKeeper.filesave,"worldshop.data");
|
||||||
FileConfiguration workable = YamlConfiguration.loadConfiguration(config);
|
FileConfiguration workable = YamlConfiguration.loadConfiguration(config);
|
||||||
|
|
||||||
return new WorldShop(workable.getItemStack("item"+id),workable.getInt("amt"+id),workable.getInt("storedamt"+id),workable.getDouble("item_price"+id),workable.getString("owner"+id),id);
|
if (workable.contains("locationdata"+id)) {
|
||||||
|
String[] splitloc = workable.getString("locationdata"+id).split(",");
|
||||||
|
return new WorldShop(workable.getItemStack("item"+id),workable.getInt("amt"+id),workable.getInt("storedamt"+id),workable.getDouble("item_price"+id),workable.getString("owner"+id),id,new Location(Bukkit.getWorld(splitloc[0]),Integer.parseInt(splitloc[1]),Integer.parseInt(splitloc[2]),Integer.parseInt(splitloc[3])));
|
||||||
|
} else {
|
||||||
|
return new WorldShop(workable.getItemStack("item"+id),workable.getInt("amt"+id),workable.getInt("storedamt"+id),workable.getDouble("item_price"+id),workable.getString("owner"+id),id,TwosideKeeper.TWOSIDE_LOCATION);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveWorldShopData(WorldShop shop) {
|
public void SaveWorldShopData(WorldShop shop) {
|
||||||
@ -145,6 +151,7 @@ public class WorldShopManager {
|
|||||||
workable.set("amt"+id,shop.GetAmount());
|
workable.set("amt"+id,shop.GetAmount());
|
||||||
workable.set("owner"+id,shop.GetOwner());
|
workable.set("owner"+id,shop.GetOwner());
|
||||||
workable.set("storedamt"+id,shop.GetStoredAmount());
|
workable.set("storedamt"+id,shop.GetStoredAmount());
|
||||||
|
workable.set("locationdata"+id,shop.GetLocString());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
workable.save(config);
|
workable.save(config);
|
||||||
@ -238,7 +245,7 @@ public class WorldShopManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public WorldShop SetupNextItemShop(WorldShop shop, Chest shopchest, final Sign s) {
|
public WorldShop SetupNextItemShop(WorldShop shop, Chest shopchest, final Sign s) {
|
||||||
final WorldShop oldshop = new WorldShop(shop.GetItem().clone(), shop.GetAmount(), shop.GetStoredAmount(), shop.GetUnitPrice(), shop.GetOwner(), shop.getID());
|
final WorldShop oldshop = new WorldShop(shop.GetItem().clone(), shop.GetAmount(), shop.GetStoredAmount(), shop.GetUnitPrice(), shop.GetOwner(), shop.getID(), shopchest.getLocation());
|
||||||
if (shop.GetAmount()==0) {
|
if (shop.GetAmount()==0) {
|
||||||
TwosideKeeper.log("Amount is 0. Proceed to look for next item.", 5);
|
TwosideKeeper.log("Amount is 0. Proceed to look for next item.", 5);
|
||||||
for (int i=0;i<shopchest.getInventory().getSize();i++) {
|
for (int i=0;i<shopchest.getInventory().getSize();i++) {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package sig.plugin.TwosideKeeper;
|
package sig.plugin.TwosideKeeper;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -29,8 +31,11 @@ import sig.plugin.TwosideKeeper.HelperStructures.BankSession;
|
|||||||
import sig.plugin.TwosideKeeper.HelperStructures.ItemSet;
|
import sig.plugin.TwosideKeeper.HelperStructures.ItemSet;
|
||||||
import sig.plugin.TwosideKeeper.HelperStructures.MonsterDifficulty;
|
import sig.plugin.TwosideKeeper.HelperStructures.MonsterDifficulty;
|
||||||
import sig.plugin.TwosideKeeper.HelperStructures.PlayerMode;
|
import sig.plugin.TwosideKeeper.HelperStructures.PlayerMode;
|
||||||
|
import sig.plugin.TwosideKeeper.HelperStructures.ServerType;
|
||||||
|
import sig.plugin.TwosideKeeper.HelperStructures.WorldShop;
|
||||||
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
|
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
|
||||||
import sig.plugin.TwosideKeeper.HelperStructures.Effects.LavaPlume;
|
import sig.plugin.TwosideKeeper.HelperStructures.Effects.LavaPlume;
|
||||||
|
import sig.plugin.TwosideKeeper.HelperStructures.Utils.MessageUtils;
|
||||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils;
|
import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils;
|
||||||
|
|
||||||
final class runServerHeartbeat implements Runnable {
|
final class runServerHeartbeat implements Runnable {
|
||||||
@ -58,6 +63,22 @@ final class runServerHeartbeat implements Runnable {
|
|||||||
//SAVE SERVER SETTINGS.
|
//SAVE SERVER SETTINGS.
|
||||||
final long serverTickTime = TwosideKeeper.getServerTickTime();
|
final long serverTickTime = TwosideKeeper.getServerTickTime();
|
||||||
if (serverTickTime-TwosideKeeper.LASTSERVERCHECK>=TwosideKeeper.SERVERCHECKERTICKS) { //15 MINUTES (DEFAULT)
|
if (serverTickTime-TwosideKeeper.LASTSERVERCHECK>=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();
|
ServerHeartbeat.saveOurData();
|
||||||
|
|
||||||
//Advertisement messages could go here.
|
//Advertisement messages could go here.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user