Many bugfixes. Improved internal structures, added more localized names

that were missing. Healthbars for mobs modified to display all their
health and how many healthbars remain. Fix shop drop items that were
identifical to each other. Rare drops now have name tags when dropped on
the ground, increasing visibility. Added "Buy" shops. Increased Loot and
EXP rate of Zombie Leaders. Some mobs have shields now.
dev
sigonasr2 9 years ago
parent 0cc1a8949f
commit ee6784447a
  1. BIN
      TwosideKeeper.jar
  2. 7
      src/plugin.yml
  3. 9
      src/sig/plugin/TwosideKeeper/Artifact.java
  4. 58
      src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java
  5. 7
      src/sig/plugin/TwosideKeeper/HelperStructures/SessionState.java
  6. 15
      src/sig/plugin/TwosideKeeper/HelperStructures/ShopPurchase.java
  7. 136
      src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java
  8. 6
      src/sig/plugin/TwosideKeeper/MonsterController.java
  9. 10
      src/sig/plugin/TwosideKeeper/Party.java
  10. 2
      src/sig/plugin/TwosideKeeper/PlayerStructure.java
  11. 808
      src/sig/plugin/TwosideKeeper/TwosideKeeper.java
  12. 31
      src/sig/plugin/TwosideKeeper/WorldShopManager.java

Binary file not shown.

@ -1,6 +1,6 @@
name: TwosideKeeper name: TwosideKeeper
main: sig.plugin.TwosideKeeper.TwosideKeeper main: sig.plugin.TwosideKeeper.TwosideKeeper
version: 3.3.4 version: 3.3.5
commands: commands:
money: money:
description: Tells the player the amount of money they are holding. description: Tells the player the amount of money they are holding.
@ -32,6 +32,11 @@ commands:
usage: /recyclingcenter usage: /recyclingcenter
permission: TwosideKeeper.recyclingcenter permission: TwosideKeeper.recyclingcenter
permission-message: No permissions! permission-message: No permissions!
glowingitem:
description: Creates a new glowing item.
usage: /glowingitem
permission: TwosideKeeper.glowingitem
permission-message: No permissions!
sound: sound:
description: Toggle sound message notifications. description: Toggle sound message notifications.
usage: /sound usage: /sound

@ -173,4 +173,13 @@ public class Artifact {
return false; return false;
} }
} }
public static boolean isMysteriousEssence(ItemStack item) {
//Check for type of item, and if it's an artifact.
if (isArtifact(item) &&
item.getType()==Material.PUMPKIN_SEEDS) {
return true;
} else {
return false;
}
}
} }

@ -6,6 +6,8 @@ import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -13,6 +15,7 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.inventory.meta.PotionMeta;
import sig.plugin.TwosideKeeper.TwosideKeeper; import sig.plugin.TwosideKeeper.TwosideKeeper;
import sig.plugin.TwosideKeeper.HelperStructures.WorldShop;
public class GenericFunctions { public class GenericFunctions {
@ -1037,8 +1040,11 @@ public class GenericFunctions {
public static boolean isHardenedItem(ItemStack item) { public static boolean isHardenedItem(ItemStack item) {
if (item.hasItemMeta() && if (item.hasItemMeta() &&
item.getItemMeta().hasLore()) { item.getItemMeta().hasLore()) {
//TwosideKeeper.log("This item has lore...", 2);
for (int i=0;i<item.getItemMeta().getLore().size();i++) { for (int i=0;i<item.getItemMeta().getLore().size();i++) {
TwosideKeeper.log("Lore line is: "+item.getItemMeta().getLore().get(i), 5);
if (item.getItemMeta().getLore().get(i).contains(ChatColor.GRAY+"Breaks Remaining:")) { if (item.getItemMeta().getLore().get(i).contains(ChatColor.GRAY+"Breaks Remaining:")) {
TwosideKeeper.log("Item "+item.toString()+" is hardened. Return it!", 5);
return true; return true;
} }
} }
@ -1077,5 +1083,57 @@ public class GenericFunctions {
return false; return false;
} }
} }
public static boolean isRareItem(ItemStack it) {
if (((it.getItemMeta().hasDisplayName() && (it.getItemMeta().getDisplayName().contains("Mega") ||
it.getItemMeta().getDisplayName().contains("Hardened") ||
ChatColor.getByChar(it.getItemMeta().getDisplayName().charAt(0))!=null)) ||
isHardenedItem(it)
)) {
TwosideKeeper.log("Returning it!", 5);
return true;
} else {
return false;
}
}
public static boolean isEdible(ItemStack it) {
if (it.getType()==Material.GOLDEN_CARROT ||
it.getType()==Material.GOLDEN_APPLE ||
it.getType()==Material.GRILLED_PORK ||
it.getType()==Material.COOKED_BEEF ||
it.getType()==Material.COOKED_MUTTON ||
it.getType()==Material.COOKED_FISH ||
it.getType()==Material.SPIDER_EYE ||
it.getType()==Material.CARROT_ITEM ||
it.getType()==Material.BAKED_POTATO ||
it.getType()==Material.COOKED_CHICKEN ||
it.getType()==Material.COOKED_RABBIT ||
it.getType()==Material.RABBIT_STEW ||
it.getType()==Material.MUSHROOM_SOUP ||
it.getType()==Material.BREAD ||
it.getType()==Material.RAW_FISH ||
it.getType()==Material.BEETROOT ||
it.getType()==Material.BEETROOT_SOUP ||
it.getType()==Material.PUMPKIN_PIE ||
it.getType()==Material.APPLE ||
it.getType()==Material.RAW_BEEF ||
it.getType()==Material.PORK ||
it.getType()==Material.MUTTON ||
it.getType()==Material.RAW_CHICKEN ||
it.getType()==Material.RABBIT ||
it.getType()==Material.POISONOUS_POTATO ||
it.getType()==Material.MELON ||
it.getType()==Material.POTATO ||
it.getType()==Material.CHORUS_FRUIT ||
it.getType()==Material.COOKIE ||
it.getType()==Material.ROTTEN_FLESH ||
it.getType()==Material.RAW_FISH
) {
return true;
} else {
return false;
}
}
} }

@ -5,5 +5,10 @@ public enum SessionState {
PRICE, //Creating a shop. Asks for price of each unit. PRICE, //Creating a shop. Asks for price of each unit.
EDIT, //Editing a shop. Asks for amount to put in or take out. EDIT, //Editing a shop. Asks for amount to put in or take out.
UPDATE, //Editing a shop. Asks for new price of each unit. UPDATE, //Editing a shop. Asks for new price of each unit.
PURCHASE PURCHASE,
BUY_CREATE, //Creating a buy shop. Asks for amount you want to purchase.
BUY_PRICE, //Creating a buy shop. Asks for buy price of each unit.
BUY_EDIT, //Editing a shop. Asks for amount to withdraw.
BUY_UPDATE, //Editing a shop. Asks for new price of each unit.
SELL
} }

@ -14,13 +14,22 @@ public class ShopPurchase {
String itemname; String itemname;
double money; double money;
int amt; int amt;
boolean sell;
public ShopPurchase(String p, Player customer, ItemStack item, double money, int amt) { public ShopPurchase(String p, Player customer, ItemStack item, double money, int amt) {
ShopPurchase(p,customer,item,money,amt,true); //Assume this is a selling purchase by default.
}
public ShopPurchase(String p, Player customer, ItemStack item, double money, int amt, boolean sell) {
ShopPurchase(p,customer,item,money,amt,sell); //Assume this is a selling purchase by default.
}
public void ShopPurchase(String p, Player customer, ItemStack item, double money, int amt, boolean sell) {
player = p; player = p;
this.customer=customer.getName(); this.customer=customer.getName();
itemname = GenericFunctions.GetItemName(item); itemname = GenericFunctions.GetItemName(item);
this.money = money; this.money = money;
this.amt=amt; this.amt=amt;
this.sell=sell;
} }
public String getPlayer() { public String getPlayer() {
@ -32,6 +41,10 @@ public class ShopPurchase {
public String announcementString() { public String announcementString() {
DecimalFormat df = new DecimalFormat("0.00"); DecimalFormat df = new DecimalFormat("0.00");
return "Player "+ChatColor.BLUE+customer+ChatColor.WHITE+" has purchased "+ChatColor.YELLOW+amt+ChatColor.WHITE+" of your "+ChatColor.YELLOW+itemname+". You have earned $"+df.format(money)+". "+ChatColor.GRAY+""+ChatColor.ITALIC+"(See /money)"; if (sell) {
return "Player "+ChatColor.BLUE+customer+ChatColor.WHITE+" has purchased "+ChatColor.YELLOW+amt+ChatColor.WHITE+" of your "+ChatColor.YELLOW+itemname+". You have earned $"+df.format(money)+". "+ChatColor.GRAY+""+ChatColor.ITALIC+"(See /money)";
} else {
return "Player "+ChatColor.BLUE+customer+ChatColor.WHITE+" has sold "+ChatColor.YELLOW+amt+ChatColor.WHITE+" "+ChatColor.YELLOW+itemname+" to you. $"+df.format(money)+" has been deducted from your bank account. "+ChatColor.GRAY+""+ChatColor.ITALIC+"(Check your shop to collect your items.)";
}
} }
} }

@ -1,18 +1,30 @@
package sig.plugin.TwosideKeeper.HelperStructures; package sig.plugin.TwosideKeeper.HelperStructures;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.List; import java.util.List;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import org.bukkit.material.MaterialData; import org.bukkit.material.MaterialData;
import org.bukkit.potion.PotionType; import org.bukkit.potion.PotionType;
import org.bukkit.util.Vector;
import com.google.common.collect.Iterables;
import sig.plugin.TwosideKeeper.Artifact;
import sig.plugin.TwosideKeeper.TwosideKeeper;
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
public class WorldShop { public class WorldShop {
@ -20,13 +32,15 @@ public class WorldShop {
String owner; String owner;
double price; double price;
int amt; int amt;
int storedamt = 0;
int id; int id;
public WorldShop (ItemStack i, int amt, double p, String player, int shopID) { public WorldShop (ItemStack i, int amt, int storedamt, double p, String player, int shopID) {
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.id = shopID; this.id = shopID;
} }
@ -38,9 +52,15 @@ public class WorldShop {
return GenericFunctions.UserFriendlyMaterialName(this.item); return GenericFunctions.UserFriendlyMaterialName(this.item);
} }
} }
public int GetStoredAmount() {
return this.storedamt;
}
public void UpdateAmount(int amt) { public void UpdateAmount(int amt) {
this.amt=amt; this.amt=amt;
} }
public void UpdateStoredAmount(int newamt) {
this.storedamt=newamt;
}
public void UpdateUnitPrice(double price) { public void UpdateUnitPrice(double price) {
this.price=price; this.price=price;
} }
@ -66,7 +86,7 @@ public class WorldShop {
} }
public String toString() { public String toString() {
return "WorldShop:{Item:"+item.toString()+",Price:"+price+",Amount:"+amt+",Owner:"+owner+"}"; return "WorldShop:{Item:"+item.toString()+",Price:"+price+",Amount:"+amt+",Stored Amount:"+storedamt+",Owner:"+owner+"}";
} }
public static String GetItemInfo(ItemStack item) { public static String GetItemInfo(ItemStack item) {
@ -94,6 +114,47 @@ public class WorldShop {
} }
} }
if (item.getType().toString().contains("RECORD")) {
switch (item.getType()) {
case GREEN_RECORD:{
message+=ChatColor.GRAY+"\nC418 - cat";
}break;
case GOLD_RECORD:{
message+=ChatColor.GRAY+"\nC418 - 13";
}break;
case RECORD_3:{
message+=ChatColor.GRAY+"\nC418 - blocks";
}break;
case RECORD_4:{
message+=ChatColor.GRAY+"\nC418 - chirp";
}break;
case RECORD_5:{
message+=ChatColor.GRAY+"\nC418 - far";
}break;
case RECORD_6:{
message+=ChatColor.GRAY+"\nC418 - mall";
}break;
case RECORD_7:{
message+=ChatColor.GRAY+"\nC418 - melohi";
}break;
case RECORD_8:{
message+=ChatColor.GRAY+"\nC418 - stal";
}break;
case RECORD_9:{
message+=ChatColor.GRAY+"\nC418 - strad";
}break;
case RECORD_10:{
message+=ChatColor.GRAY+"\nC418 - ward";
}break;
case RECORD_11:{
message+=ChatColor.GRAY+"\nC418 - 11";
}break;
case RECORD_12:{
message+=ChatColor.GRAY+"\nC418 - wait";
}break;
}
}
if (item.getType().toString().contains("HELMET") || if (item.getType().toString().contains("HELMET") ||
item.getType().toString().contains("CHESTPLATE") || item.getType().toString().contains("CHESTPLATE") ||
item.getType().toString().contains("LEGGINGS") || item.getType().toString().contains("LEGGINGS") ||
@ -347,11 +408,78 @@ public class WorldShop {
} }
} }
public static boolean IsWorldSign(Sign s) { public static boolean isWorldShopSign(Sign s) {
if (s.getLine(0).equalsIgnoreCase(ChatColor.BLUE+"-- SHOP --")) { if (s.getLine(0).equalsIgnoreCase(ChatColor.BLUE+"-- SHOP --") ||
s.getLine(0).equalsIgnoreCase(ChatColor.BLUE+"- BUYING SHOP -")) {
return true; return true;
} else { } else {
return false; return false;
} }
} }
public static boolean hasShopSignAttached(Block b) {
//Returns true if there is a shop sign attached to this block.
//Look on all four sides relative to this block.
TwosideKeeper.log("Reference block is "+b.getLocation().toString()+" of type "+b.getType(),5);
for (int x=-1;x<=1;x++) {
for (int z=-1;z<=1;z++) {
if ((x!=0 || z!=0) && Math.abs(x)!=Math.abs(z)) {
Block checkblock = b.getRelative(x, 0, z);
TwosideKeeper.log("This is a "+checkblock.getType(),5);
if (checkblock.getType()==Material.WALL_SIGN) {
org.bukkit.material.Sign s = (org.bukkit.material.Sign)(checkblock.getState().getData());
//See if this sign is "facing" this block.
TwosideKeeper.log("Checked block is a "+checkblock.getRelative(s.getAttachedFace()).getType()+" at Loc "+checkblock.getRelative(s.getAttachedFace()).getLocation().toString(), 4);
if (checkblock.getRelative(s.getAttachedFace()).equals(b)) {
TwosideKeeper.log("This is the block on the sign! Proceed.",5);
//See if this sign is a world shop.
if (WorldShop.isWorldShopSign((Sign)checkblock.getState())) {
return true;
}
}
}
}
}
}
return false;
}
public static void spawnShopItem(PlayerInteractEvent ev, Location loc, WorldShop shop) {
//See if a drop entity is already here.
boolean item_here=false;
Collection<Entity> entities = ev.getPlayer().getLocation().getWorld().getNearbyEntities(loc, 1, 1, 1);
for (int i=0;i<entities.size();i++) {
Entity e = Iterables.get(entities, i);
TwosideKeeper.log("Entity Location:"+e.getLocation().toString(),5);
TwosideKeeper.log("Comparing locations: "+e.getLocation().toString()+":::"+loc.toString(),5);
if (e.getType()==EntityType.DROPPED_ITEM) {
Item it = (Item)e;
if (
it.getItemStack().getType()==shop.GetItem().getType() &&
it.getItemStack().getDurability()==shop.GetItem().getDurability() &&
it.getCustomName()!=null &&
it.getCustomName().equalsIgnoreCase(""+shop.getID()) &&
Math.abs(e.getLocation().getX()-loc.getX()) <= 1 &&
Math.abs(e.getLocation().getZ()-loc.getZ()) <= 1 &&
Math.abs(e.getLocation().getY()-loc.getY())<=1
) {
item_here=true;
}
}
}
if (!item_here) {
TwosideKeeper.log("Spawning item!",5);
ItemStack i = shop.GetItem().clone();
ItemStack drop = Artifact.convert(i);
drop.removeEnchantment(Enchantment.LUCK);
Item it = ev.getPlayer().getWorld().dropItemNaturally(ev.getClickedBlock().getLocation().add(-ev.getBlockFace().getModX()+0.5, -ev.getBlockFace().getModY()+1.5, -ev.getBlockFace().getModZ()+0.5), drop);
it.setPickupDelay(999999999);
it.setVelocity(new Vector(0,0,0));
it.setCustomName(""+shop.getID());
it.setCustomNameVisible(false);
it.setInvulnerable(true);
//it.setGlowing(true);
it.teleport(ev.getClickedBlock().getLocation().add(-ev.getBlockFace().getModX()+0.5, -ev.getBlockFace().getModY()+1.5, -ev.getBlockFace().getModZ()+0.5));
}
}
} }

@ -284,6 +284,9 @@ public class MonsterController {
} }
m.getEquipment().setItemInMainHand(weapon); m.getEquipment().setItemInMainHand(weapon);
} }
if (Math.random()<0.2) {
m.getEquipment().setItemInOffHand(new ItemStack(Material.SHIELD));
}
} else { } else {
ItemStack weapon = new ItemStack(Material.BOW); ItemStack weapon = new ItemStack(Material.BOW);
m.getEquipment().setItemInMainHand(weapon); m.getEquipment().setItemInMainHand(weapon);
@ -380,6 +383,9 @@ public class MonsterController {
} }
m.getEquipment().setItemInMainHand(weapon); m.getEquipment().setItemInMainHand(weapon);
} }
if (Math.random()<0.5) {
m.getEquipment().setItemInOffHand(new ItemStack(Material.SHIELD));
}
} else { } else {
ItemStack weapon = new ItemStack(Material.BOW); ItemStack weapon = new ItemStack(Material.BOW);
m.getEquipment().setItemInMainHand(weapon); m.getEquipment().setItemInMainHand(weapon);

@ -12,11 +12,13 @@ import org.bukkit.scoreboard.DisplaySlot;
public class Party { public class Party {
public List<Player> partyplayers; public List<Player> partyplayers;
public List<Player> lastorder;
int color; int color;
Location region; Location region;
Party(int color, Location rawPos) { Party(int color, Location rawPos) {
partyplayers = new ArrayList<Player>(); partyplayers = new ArrayList<Player>();
lastorder = new ArrayList<Player>();
rawPos.setX((int)(rawPos.getX()/(16*TwosideKeeper.PARTY_CHUNK_SIZE))*(16*TwosideKeeper.PARTY_CHUNK_SIZE)); rawPos.setX((int)(rawPos.getX()/(16*TwosideKeeper.PARTY_CHUNK_SIZE))*(16*TwosideKeeper.PARTY_CHUNK_SIZE));
rawPos.setZ((int)(rawPos.getZ()/(16*TwosideKeeper.PARTY_CHUNK_SIZE))*(16*TwosideKeeper.PARTY_CHUNK_SIZE)); rawPos.setZ((int)(rawPos.getZ()/(16*TwosideKeeper.PARTY_CHUNK_SIZE))*(16*TwosideKeeper.PARTY_CHUNK_SIZE));
region=rawPos; region=rawPos;
@ -126,8 +128,12 @@ public class Party {
sortedorder.add(lasti,partyplayers.get(i)); sortedorder.add(lasti,partyplayers.get(i));
} }
} }
for (int i=0;i<sortedorder.size();i++) { if (!lastorder.equals(sortedorder)) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "scoreboard players set "+sortedorder.get(i).getName().toLowerCase()+" Party"+color+" "+(i+1)*-1); for (int i=0;i<sortedorder.size();i++) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "scoreboard players set "+sortedorder.get(i).getName().toLowerCase()+" Party"+color+" "+(i+1)*-1);
}
lastorder.clear();
lastorder.addAll(sortedorder);
} }
} }

@ -38,6 +38,7 @@ public class PlayerStructure {
public int saturation; //We will now track saturation manually to remove health healing from saturation. public int saturation; //We will now track saturation manually to remove health healing from saturation.
public long last_regen_time; //Last time a health regen took place. public long last_regen_time; //Last time a health regen took place.
public double damagereduction; public double damagereduction;
public double damagedealt;
public int insertItem=-1; //The position in the chat message to insert an item to. public int insertItem=-1; //The position in the chat message to insert an item to.
//public double basedmg; //public double basedmg;
public LivingEntity target; //The current entity this player is looking at. public LivingEntity target; //The current entity this player is looking at.
@ -63,6 +64,7 @@ public class PlayerStructure {
this.last_regen_time=TwosideKeeper.SERVERTICK; this.last_regen_time=TwosideKeeper.SERVERTICK;
this.target=null; this.target=null;
this.damagereduction=1.0; this.damagereduction=1.0;
this.damagedealt=1.0;
//this.basedmg=0.0; //this.basedmg=0.0;
this.partybonus=0; this.partybonus=0;
this.enderdragon_spawned=false; this.enderdragon_spawned=false;

File diff suppressed because it is too large Load Diff

@ -36,23 +36,36 @@ public class WorldShopManager {
* @param owner Owner of the shop. * @param owner Owner of the shop.
*/ */
public WorldShop CreateWorldShop(Sign s, ItemStack item, int amt, double price, String owner) { public WorldShop CreateWorldShop(Sign s, ItemStack item, int amt, double price, String owner) {
//Convert the sign.
return CreateWorldShop(s,item,amt,price,owner,false);
}
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();
List<String> sign_lines = new ArrayList<String>(); List<String> sign_lines = new ArrayList<String>();
WorldShop newshop = new WorldShop(item, amt, price, owner, TwosideKeeper.WORLD_SHOP_ID); WorldShop newshop = new WorldShop(item, amt, 0, price, owner, TwosideKeeper.WORLD_SHOP_ID);
if (lines[0].equalsIgnoreCase("shop")) { if (lines[0].equalsIgnoreCase("shop") || lines[0].equalsIgnoreCase("buyshop")) {
UpdateSign(newshop, TwosideKeeper.WORLD_SHOP_ID, s); UpdateSign(newshop, TwosideKeeper.WORLD_SHOP_ID, s,purchaseshop);
} }
TwosideKeeper.WORLD_SHOP_ID++; TwosideKeeper.WORLD_SHOP_ID++;
return newshop; return newshop;
} }
public void UpdateSign(WorldShop shop, int id, Sign s) { public void UpdateSign(WorldShop shop, int id, Sign s, boolean purchaseshop) {
//Convert the sign. //Convert the sign.
String[] lines = s.getLines(); String[] lines = s.getLines();
List<String> sign_lines = new ArrayList<String>(); List<String> sign_lines = new ArrayList<String>();
//Create a shop out of this. //Create a shop out of this.
sign_lines.add(ChatColor.BLUE+"-- SHOP --"); if (purchaseshop) {
if (shop.GetStoredAmount()>0) {
sign_lines.add(ChatColor.YELLOW+""+ChatColor.BOLD+"-BUYING SHOP-");
} else {
sign_lines.add(ChatColor.BLUE+"- BUYING SHOP -");
}
} else {
sign_lines.add(ChatColor.BLUE+"-- SHOP --");
}
if (shop.GetItem().hasItemMeta() && if (shop.GetItem().hasItemMeta() &&
shop.GetItem().getItemMeta().hasDisplayName()) { shop.GetItem().getItemMeta().hasDisplayName()) {
sign_lines.add(shop.GetItem().getItemMeta().getDisplayName()); sign_lines.add(shop.GetItem().getItemMeta().getDisplayName());
@ -78,7 +91,7 @@ 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.getDouble("item_price"+id),workable.getString("owner"+id),id); 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);
} }
public void SaveWorldShopData(WorldShop shop) { public void SaveWorldShopData(WorldShop shop) {
@ -92,6 +105,7 @@ public class WorldShopManager {
workable.set("item_price"+id,shop.GetUnitPrice()); workable.set("item_price"+id,shop.GetUnitPrice());
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());
try { try {
workable.save(config); workable.save(config);
@ -151,10 +165,13 @@ public class WorldShopManager {
public void RemoveSession(WorldShopSession ss) { public void RemoveSession(WorldShopSession ss) {
sessions.remove(ss); sessions.remove(ss);
} }
public void AddNewPurchase(String owner, Player purchaser, ItemStack item, double price, int amt) { public void AddNewPurchase(String owner, Player purchaser, ItemStack item, double price, int amt) {
purchases.add(new ShopPurchase(owner, purchaser, item, price, amt)); purchases.add(new ShopPurchase(owner, purchaser, item, price, amt));
} }
public void AddNewPurchase(String owner, Player purchaser, ItemStack item, double price, int amt, boolean sell) {
purchases.add(new ShopPurchase(owner, purchaser, item, price, amt, sell));
}
public boolean PlayerHasPurchases(Player p) { public boolean PlayerHasPurchases(Player p) {
for (int i=0;i<purchases.size();i++) { for (int i=0;i<purchases.size();i++) {
if (p.getName().equalsIgnoreCase(purchases.get(i).getPlayer())) { if (p.getName().equalsIgnoreCase(purchases.get(i).getPlayer())) {

Loading…
Cancel
Save