->Recycling Centers now prevent common items from appearing inside
Recycling Centers. (If they are actually common.) ->Death Loot Manager now properly survives server restarts, so players who have died and ragequitted no longer will have permanently lost their loot. ->Added 'hasPermissionToBreakWorldShopSign(Sign,Player)' to API. ->Added ->Shops now update their stocked amount properly if they are relocated to another chest or if the server crashes. ->Item Localization Fixes
This commit is contained in:
parent
4f8563376d
commit
94d4a88948
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
name: TwosideKeeper
|
||||
main: sig.plugin.TwosideKeeper.TwosideKeeper
|
||||
version: 3.7.2
|
||||
version: 3.7.3-alpha1
|
||||
commands:
|
||||
money:
|
||||
description: Tells the player the amount of money they are holding.
|
||||
|
@ -29,9 +29,13 @@ public class DeathManager {
|
||||
|
||||
public static void addNewDeathStructure(List<ItemStack> deathinv, Location deathloc, Player p) {
|
||||
ds.add(new DeathStructure(deathinv,deathloc,p));
|
||||
TwosideKeeper.log("Added a new Death Structure: "+ds.get(ds.size()-1).toString(),5);
|
||||
}
|
||||
public static void removeDeathStructure(Player p) {
|
||||
ds.remove(getDeathStructure(p));
|
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
|
||||
pd.deathloot.clear();
|
||||
pd.hasDied=false;
|
||||
}
|
||||
public static boolean deathStructureExists(Player p) {
|
||||
if (getDeathStructure(p)!=null) {
|
||||
|
@ -445,7 +445,7 @@ public class GenericFunctions {
|
||||
return "Clay";
|
||||
}
|
||||
case COBBLE_WALL:{
|
||||
return "Cobblestone Wall";
|
||||
return "Mossy Cobblestone Wall";
|
||||
}
|
||||
case COMMAND:{
|
||||
return "Command Block";
|
||||
@ -605,9 +605,12 @@ public class GenericFunctions {
|
||||
case MILK_BUCKET:{
|
||||
return "Milk";
|
||||
}
|
||||
case NETHER_BRICK_ITEM:{
|
||||
case NETHER_BRICK:{
|
||||
return "Nether Bricks";
|
||||
}
|
||||
case NETHER_BRICK_ITEM:{
|
||||
return "Nether Brick";
|
||||
}
|
||||
case NETHER_WARTS:{
|
||||
return "Nether Wart";
|
||||
}
|
||||
@ -615,7 +618,7 @@ public class GenericFunctions {
|
||||
return "Nether Wart";
|
||||
}
|
||||
case GOLD_PLATE:{
|
||||
return "Gold Pressure Plate";
|
||||
return "Weighted Pressure Plate (Light)";
|
||||
}
|
||||
case PISTON_BASE:{
|
||||
return "Piston";
|
||||
@ -724,7 +727,20 @@ public class GenericFunctions {
|
||||
return "Skull";
|
||||
}
|
||||
case SMOOTH_BRICK:{
|
||||
return "Stone Brick";
|
||||
switch (type.getDurability()) {
|
||||
case 0:{
|
||||
return "Stone Brick";
|
||||
}
|
||||
case 1:{
|
||||
return "Mossy Stone Brick";
|
||||
}
|
||||
case 2:{
|
||||
return "Cracked Stone Brick";
|
||||
}
|
||||
case 3:{
|
||||
return "Chiseled Stone Brick";
|
||||
}
|
||||
}
|
||||
}
|
||||
case SMOOTH_STAIRS:{
|
||||
return "Stone Brick Stairs";
|
||||
@ -1553,6 +1569,50 @@ public class GenericFunctions {
|
||||
case WORKBENCH:{
|
||||
return "Crafting Table";
|
||||
}
|
||||
case CLAY:{
|
||||
return "Clay Block";
|
||||
}
|
||||
case WOOD_PLATE:{
|
||||
return "Wooden Pressure Plate";
|
||||
}
|
||||
case STONE_PLATE:{
|
||||
return "Stone Pressure Plate";
|
||||
}
|
||||
case IRON_PLATE:{
|
||||
return "Weighted Pressure Plate (Heavy)";
|
||||
}
|
||||
case MOSSY_COBBLESTONE:{
|
||||
return "Moss Stone";
|
||||
}
|
||||
case SANDSTONE:{
|
||||
switch (type.getDurability()) {
|
||||
case 0:{
|
||||
return "Sandstone";
|
||||
}
|
||||
case 1:{
|
||||
return "Chiseled Sandstone";
|
||||
}
|
||||
case 2:{
|
||||
return "Smooth Sandstone";
|
||||
}
|
||||
}
|
||||
}
|
||||
case RED_SANDSTONE:{
|
||||
switch (type.getDurability()) {
|
||||
case 0:{
|
||||
return "Red Sandstone";
|
||||
}
|
||||
case 1:{
|
||||
return "Chiseled Red Sandstone";
|
||||
}
|
||||
case 2:{
|
||||
return "Smooth Red Sandstone";
|
||||
}
|
||||
}
|
||||
}
|
||||
case TRAP_DOOR:{
|
||||
return "Wooden Trapdoor";
|
||||
}
|
||||
default:{
|
||||
return GenericFunctions.CapitalizeFirstLetters(type.getType().toString().replace("_", " "));
|
||||
}
|
||||
|
@ -17,4 +17,8 @@ public class DeathStructure {
|
||||
this.deathloc=dl;
|
||||
this.p=p.getName();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Death Inventory: "+deathinventory.size()+" items, belongs to Player "+p+". Death location is "+deathloc.toString();
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,10 @@ public class Loot {
|
||||
raresword.setItemMeta(sword_meta);
|
||||
raresword = addEnchantments(raresword,true);
|
||||
}
|
||||
/*
|
||||
if (GenericFunctions.isArmor(raresword)) {
|
||||
raresword = GenerateSetPiece();
|
||||
}*/
|
||||
return raresword;
|
||||
}
|
||||
|
||||
|
@ -717,6 +717,10 @@ public class WorldShop {
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeShopItem(Sign s) {
|
||||
removeShopItem(s, TwosideKeeper.TwosideShops.LoadWorldShopData(s));
|
||||
}
|
||||
|
||||
public static void removeShopItem(Sign s, WorldShop shop) {
|
||||
Collection<Entity> nearby = WorldShop.getBlockShopSignAttachedTo(s).getWorld().getNearbyEntities(WorldShop.getBlockShopSignAttachedTo(s).getLocation().add(0.5,0,0.5), 0.3, 1, 0.3);
|
||||
for (int i=0;i<nearby.size();i++) {
|
||||
@ -792,4 +796,14 @@ public class WorldShop {
|
||||
it.teleport(ev.getClickedBlock().getLocation().add(-ev.getBlockFace().getModX()+0.5, -ev.getBlockFace().getModY()+1.5, -ev.getBlockFace().getModZ()+0.5));
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasPermissionToBreakWorldShopSign(Sign s, Player p) {
|
||||
String[] lines = s.getLines();
|
||||
WorldShop shop = TwosideKeeper.TwosideShops.LoadWorldShopData(s);
|
||||
if (shop.GetOwner().equalsIgnoreCase(p.getName()) || p.isOp()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,8 @@ import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.inventivetalent.glow.GlowAPI;
|
||||
import org.inventivetalent.glow.GlowAPI.Color;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -19,6 +20,7 @@ import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import sig.plugin.TwosideKeeper.HelperStructures.DeathStructure;
|
||||
import sig.plugin.TwosideKeeper.Logging.DamageLogger;
|
||||
|
||||
/*PLAYER STRUCTURE
|
||||
@ -77,6 +79,12 @@ public class PlayerStructure {
|
||||
public long last_rejuvenate=TwosideKeeper.getServerTickTime();
|
||||
public DamageLogger damagedata;
|
||||
public boolean damagelogging=false;
|
||||
public boolean hasDied=false;
|
||||
public double deathloc_x = 0;
|
||||
public double deathloc_y = 0;
|
||||
public double deathloc_z = 0;
|
||||
public String deathloc_world = "";
|
||||
public List<ItemStack> deathloot = new ArrayList<ItemStack>();
|
||||
|
||||
public double prev_weapondmg=0.0;
|
||||
public double prev_buffdmg=0.0;
|
||||
@ -205,6 +213,24 @@ public class PlayerStructure {
|
||||
workable.set("spleef_pts", spleef_pts);
|
||||
workable.set("spleef_wins", spleef_wins);
|
||||
workable.set("sounds_enabled", sounds_enabled);
|
||||
workable.set("hasDied", hasDied);
|
||||
ConfigurationSection deathlootlist = workable.createSection("deathloot");
|
||||
if (DeathManager.deathStructureExists(Bukkit.getPlayer(name))) {
|
||||
DeathStructure ds = DeathManager.getDeathStructure(Bukkit.getPlayer(name));
|
||||
deathloc_x = ds.deathloc.getX();
|
||||
deathloc_y = ds.deathloc.getY();
|
||||
deathloc_z = ds.deathloc.getZ();
|
||||
deathloc_world = ds.deathloc.getWorld().getName();
|
||||
for (int i=0;i<ds.deathinventory.size();i++) {
|
||||
if (ds.deathinventory.get(i)!=null) {
|
||||
deathlootlist.set("item"+i, ds.deathinventory.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
workable.set("deathloc_x", deathloc_x);
|
||||
workable.set("deathloc_y", deathloc_y);
|
||||
workable.set("deathloc_z", deathloc_z);
|
||||
workable.set("deathloc_world", deathloc_world);
|
||||
|
||||
try {
|
||||
workable.save(config);
|
||||
@ -231,7 +257,7 @@ public class PlayerStructure {
|
||||
workable.addDefault("enderdragon_spawned", enderdragon_spawned);
|
||||
workable.addDefault("spleef_pts", spleef_pts);
|
||||
workable.addDefault("spleef_wins", spleef_wins);
|
||||
workable.addDefault("sounds_enabled", sounds_enabled);
|
||||
workable.addDefault("hasDied", hasDied);
|
||||
|
||||
workable.options().copyDefaults();
|
||||
|
||||
@ -249,6 +275,21 @@ public class PlayerStructure {
|
||||
this.spleef_pts = workable.getInt("spleef_pts");
|
||||
this.spleef_wins = workable.getInt("spleef_wins");
|
||||
this.sounds_enabled = workable.getBoolean("sounds_enabled");
|
||||
this.hasDied = workable.getBoolean("hasDied");
|
||||
this.deathloc_x = workable.getDouble("deathloc_x");
|
||||
this.deathloc_y = workable.getDouble("deathloc_y");
|
||||
this.deathloc_z = workable.getDouble("deathloc_z");
|
||||
this.deathloc_world = workable.getString("deathloc_world");
|
||||
|
||||
if (this.hasDied) {
|
||||
List<ItemStack> deathlootlist = new ArrayList<ItemStack>();
|
||||
ConfigurationSection deathlootsection = workable.getConfigurationSection("deathloot");
|
||||
for (int i=0;i<deathlootsection.getKeys(false).size();i++) {
|
||||
ItemStack item = deathlootsection.getItemStack((String)(deathlootsection.getKeys(false).toArray()[i]));
|
||||
deathlootlist.add(item);
|
||||
}
|
||||
DeathManager.addNewDeathStructure(deathlootlist, new Location(Bukkit.getWorld(this.deathloc_world),this.deathloc_x,this.deathloc_y,this.deathloc_z), Bukkit.getPlayer(name));
|
||||
}
|
||||
|
||||
try {
|
||||
workable.save(config);
|
||||
|
@ -2,16 +2,22 @@ package sig.plugin.TwosideKeeper;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
|
||||
@ -19,11 +25,14 @@ import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
|
||||
public class RecyclingCenter {
|
||||
//Each Recycling center has nodes which contain all the chests.
|
||||
List<Location> nodes;
|
||||
HashMap<Material,Integer> itemmap;
|
||||
int totalitems=0;
|
||||
|
||||
boolean choosing = false;
|
||||
|
||||
public RecyclingCenter() {
|
||||
nodes = new ArrayList<Location>();
|
||||
itemmap = new HashMap<Material,Integer>();
|
||||
}
|
||||
|
||||
public void AddNode(World world, int locx,int locy,int locz) {
|
||||
@ -100,7 +109,112 @@ public class RecyclingCenter {
|
||||
}
|
||||
}
|
||||
|
||||
public void populateItemListFromAllNodes() {
|
||||
for (int i=0;i<getNumberOfNodes();i++) {
|
||||
Location node = getNodeLocation(i);
|
||||
node.getWorld().loadChunk(node.getChunk());
|
||||
Block b = node.getBlock();
|
||||
if (b!=null && (b.getType()==Material.CHEST || b.getType()==Material.TRAPPED_CHEST)) {
|
||||
if (b.getState()!=null) {
|
||||
Chest c = (Chest)b.getState();
|
||||
for (int j=0;j<27;j++) {
|
||||
ItemStack item = c.getBlockInventory().getItem(j);
|
||||
if (item!=null) {
|
||||
populateItemList(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (totalitems<100) {
|
||||
totalitems=100;
|
||||
}
|
||||
TwosideKeeper.log("Populated Recycled Item List with "+totalitems+" items.", 2);
|
||||
}
|
||||
|
||||
|
||||
public void populateItemListFromNode(Location node) {
|
||||
node.getWorld().loadChunk(node.getChunk());
|
||||
Block b = node.getBlock();
|
||||
if (b!=null && (b.getType()==Material.CHEST || b.getType()==Material.TRAPPED_CHEST)) {
|
||||
if (b.getState()!=null) {
|
||||
Chest c = (Chest)b.getState();
|
||||
for (int j=0;j<27;j++) {
|
||||
ItemStack item = c.getBlockInventory().getItem(j);
|
||||
if (item!=null) {
|
||||
populateItemList(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
TwosideKeeper.log("Populated Recycled Item List with "+totalitems+" items.", 2);
|
||||
}
|
||||
|
||||
public void populateItemList(ItemStack item) {
|
||||
if (itemmap.containsKey(item.getType())) {
|
||||
int amt = itemmap.get(item.getType());
|
||||
itemmap.put(item.getType(), amt+item.getAmount());
|
||||
totalitems+=item.getAmount();
|
||||
} else {
|
||||
itemmap.put(item.getType(),1);
|
||||
totalitems++;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isRecyclingCenter(Block b) {
|
||||
return TwosideKeeper.TwosideRecyclingCenter.nodes.contains(new Location(b.getWorld(),b.getLocation().getBlockX(),b.getLocation().getBlockY(),b.getLocation().getBlockZ()));
|
||||
}
|
||||
|
||||
public void AddItemToRecyclingCenter(Item i) {
|
||||
//There is a % chance of it going to a recycling center.
|
||||
if (Math.random()*100<=TwosideKeeper.RECYCLECHANCE &&
|
||||
IsItemAllowed(i.getItemStack())) {
|
||||
//Recycle allowed. Now figure out which node to go to.
|
||||
if (getNumberOfNodes()>0) {
|
||||
Location rand_node=getRandomNode();
|
||||
rand_node.getWorld().loadChunk(rand_node.getChunk()); //Load that chunk to make sure we can throw items into it.
|
||||
Block b = rand_node.getWorld().getBlockAt(rand_node);
|
||||
if (b!=null && b.getType()==Material.CHEST ||
|
||||
b.getType()==Material.TRAPPED_CHEST) {
|
||||
if (b.getState()!=null) {
|
||||
Chest c = (Chest) b.getState();
|
||||
//Choose a random inventory slot and copy the vanished item into it.
|
||||
double chancer = 100.0;
|
||||
for (int j=0;j<27;j++) {
|
||||
if (c.getBlockInventory().getItem(j)!=null && c.getBlockInventory().getItem(j).getType()==i.getItemStack().getType()) {
|
||||
chancer-=TwosideKeeper.RECYCLEDECAYAMT;
|
||||
}
|
||||
}
|
||||
int itemslot = (int)Math.floor(Math.random()*27);
|
||||
ItemStack oldItem = c.getBlockInventory().getItem(itemslot);
|
||||
//There is also a chance to move this item to another random spot.
|
||||
if (!isCommon(i.getItemStack().getType())) {
|
||||
if (oldItem!=null && Math.random()*100<=TwosideKeeper.RECYCLECHANCE) {
|
||||
int itemslot2 = (int)Math.floor(Math.random()*27);
|
||||
c.getBlockInventory().setItem(itemslot2, oldItem);
|
||||
}
|
||||
c.getBlockInventory().setItem(itemslot, i.getItemStack());
|
||||
populateItemList(i.getItemStack());
|
||||
TwosideKeeper.log("Sent "+ChatColor.AQUA+GenericFunctions.UserFriendlyMaterialName(i.getItemStack())+((i.getItemStack().getAmount()>1)?ChatColor.YELLOW+" x"+i.getItemStack().getAmount():"")+ChatColor.RESET+" to Recycling Center Node "+rand_node.toString(),3);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
TwosideKeeper.log("No Recycling Center Nodes set! All dropped items will continue to be discarded. Use /recyclingcenter to define them.",1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isCommon(Material m) {
|
||||
if (itemmap.containsKey(m)) {
|
||||
int amt = itemmap.get(m);
|
||||
double chance = (amt/(double)totalitems*100d);
|
||||
if (totalitems>0 && chance>=TwosideKeeper.COMMONITEMPCT) {
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
TwosideKeeper.log(df.format(chance)+"% of items in nodes are "+GenericFunctions.UserFriendlyMaterialName(m)+". Common item detected...", 3);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -157,6 +157,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.potion.PotionType;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.inventivetalent.glow.GlowAPI;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Iterators;
|
||||
@ -238,6 +239,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
public static int LOGGING_LEVEL=0; //The logging level the server will output in for the console. 0 = No Debug Messages. Toggled with /log.
|
||||
public static double ARTIFACT_RARITY=1.5; //The multiplier of artifact drops.
|
||||
public static ServerType SERVER_TYPE=ServerType.TEST; //The type of server this is running on.
|
||||
public static int COMMONITEMPCT=3;
|
||||
|
||||
public static final int DODGE_COOLDOWN=100;
|
||||
public static final int DEATHMARK_COOLDOWN=240;
|
||||
@ -331,6 +333,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
|
||||
TwosideRecyclingCenter = new RecyclingCenter();
|
||||
TwosideRecyclingCenter.loadConfig();
|
||||
TwosideRecyclingCenter.populateItemListFromAllNodes();
|
||||
log("Recycling Centers Loaded: "+TwosideRecyclingCenter.getNumberOfNodes(),3);
|
||||
|
||||
pluginupdater = new AutoUpdatePlugin(this);
|
||||
@ -1827,6 +1830,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
TwosideRecyclingCenter.setChoosingRecyclingCenter(false);
|
||||
//Create a new Recycling Center.
|
||||
TwosideRecyclingCenter.AddNode(ev.getClickedBlock().getWorld(), ev.getClickedBlock().getLocation().getBlockX(), ev.getClickedBlock().getLocation().getBlockY(), ev.getClickedBlock().getLocation().getBlockZ());
|
||||
TwosideRecyclingCenter.populateItemListFromNode(ev.getClickedBlock().getLocation());
|
||||
ev.getPlayer().sendMessage(ChatColor.DARK_BLUE+"New Recycling Center successfully created at "+ev.getClickedBlock().getLocation().toString());
|
||||
}
|
||||
|
||||
@ -2241,7 +2245,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
log("This is a buy shop sign.",5);
|
||||
int shopID = TwosideShops.GetShopID(s);
|
||||
WorldShop shop = TwosideShops.LoadWorldShopData(shopID);
|
||||
|
||||
Chest c = (Chest)chest.getState();
|
||||
shop.UpdateAmount(GenericFunctions.CountItems(c.getInventory(), shop.GetItem()));
|
||||
TwosideShops.UpdateSign(shop, shop.getID(),s,false);
|
||||
TwosideShops.SaveWorldShopData(shop);
|
||||
Location newloc = ev.getClickedBlock().getLocation().add(-ev.getBlockFace().getModX()+0.5, -ev.getBlockFace().getModY()+1.5, -ev.getBlockFace().getModZ()+0.5);
|
||||
|
||||
WorldShop.spawnShopItem(ev,newloc,shop);
|
||||
@ -2262,7 +2269,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
TwosideShops.AddSession(SessionState.UPDATE, player, s);
|
||||
} else {
|
||||
if (shop.GetAmount()>0) {
|
||||
//player.sendMessage("How many "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+" would you like to buy? "+ChatColor.GREEN+"(MAX: "+((getPlayerMoney(player)<(shop.GetAmount()*shop.GetUnitPrice()))?(int)(getPlayerMoney(player)/shop.GetUnitPrice()):shop.GetAmount())+")");
|
||||
//player.sendMessage("How many "+Cha tColor.GREEN+shop.GetItemName()+ChatColor.WHITE+" would you like to buy? "+ChatColor.GREEN+"(MAX: "+((getPlayerMoney(player)<(shop.GetAmount()*shop.GetUnitPrice()))?(int)(getPlayerMoney(player)/shop.GetUnitPrice()):shop.GetAmount())+")");
|
||||
TextComponent message1 = new TextComponent("How many ");
|
||||
TextComponent message2 = new TextComponent(ChatColor.GREEN+"["+shop.GetItemName()+ChatColor.RESET+""+ChatColor.GREEN+"]");
|
||||
message2.setHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(shop.GetItemName()+WorldShop.GetItemInfo(shop.GetItem())).create()));
|
||||
@ -2325,6 +2332,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
//This is a buy shop.
|
||||
int shopID = TwosideShops.GetShopID(s);
|
||||
WorldShop shop = TwosideShops.LoadWorldShopData(shopID);
|
||||
Chest c = (Chest)chest.getState();
|
||||
shop.UpdateAmount(GenericFunctions.CountItems(c.getInventory(), shop.GetItem()));
|
||||
TwosideShops.UpdateSign(shop, shop.getID(),s,false);
|
||||
TwosideShops.SaveWorldShopData(shop);
|
||||
Location newloc = ev.getClickedBlock().getLocation().add(-ev.getBlockFace().getModX()+0.5, -ev.getBlockFace().getModY()+1.5, -ev.getBlockFace().getModZ()+0.5);
|
||||
WorldShop.spawnShopItem(ev,newloc,shop);
|
||||
|
||||
@ -2528,6 +2539,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
log("Y position is "+p.getLocation().getY(), 4);
|
||||
DeathManager.addNewDeathStructure(ev.getDrops(), (p.getLocation().getY()<0)?p.getLocation().add(0,-p.getLocation().getY()+256,0) //This means they fell into the void. Might as well put it way higher.
|
||||
:p.getLocation(), p);
|
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
|
||||
pd.hasDied=true;
|
||||
p.getInventory().clear();
|
||||
}
|
||||
}
|
||||
@ -3392,42 +3405,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
log("Respawn this shop item.",5);
|
||||
}
|
||||
}
|
||||
//There is a % chance of it going to a recycling center.
|
||||
if (Math.random()*100<=RECYCLECHANCE &&
|
||||
TwosideRecyclingCenter.IsItemAllowed(i.getItemStack())) {
|
||||
//Recycle allowed. Now figure out which node to go to.
|
||||
if (TwosideRecyclingCenter.getNumberOfNodes()>0) {
|
||||
Location rand_node=TwosideRecyclingCenter.getRandomNode();
|
||||
rand_node.getWorld().loadChunk(rand_node.getChunk()); //Load that chunk to make sure we can throw items into it.
|
||||
Block b = rand_node.getWorld().getBlockAt(rand_node);
|
||||
if (b!=null && b.getType()==Material.CHEST ||
|
||||
b.getType()==Material.TRAPPED_CHEST) {
|
||||
if (b.getState()!=null) {
|
||||
Chest c = (Chest) b.getState();
|
||||
//Choose a random inventory slot and copy the vanished item into it.
|
||||
double chancer = 100.0;
|
||||
for (int j=0;j<27;j++) {
|
||||
if (c.getBlockInventory().getItem(j)!=null && c.getBlockInventory().getItem(j).getType()==i.getItemStack().getType()) {
|
||||
chancer-=RECYCLEDECAYAMT;
|
||||
}
|
||||
}
|
||||
int itemslot = (int)Math.floor(Math.random()*27);
|
||||
ItemStack oldItem = c.getBlockInventory().getItem(itemslot);
|
||||
//There is also a chance to move this item to another random spot.
|
||||
if (chancer>0 && Math.random()*100<chancer) {
|
||||
if (oldItem!=null && Math.random()*100<=RECYCLECHANCE) {
|
||||
int itemslot2 = (int)Math.floor(Math.random()*27);
|
||||
c.getBlockInventory().setItem(itemslot2, oldItem);
|
||||
}
|
||||
c.getBlockInventory().setItem(itemslot, i.getItemStack());
|
||||
log("Sent "+ChatColor.AQUA+GenericFunctions.UserFriendlyMaterialName(i.getItemStack())+((i.getItemStack().getAmount()>1)?ChatColor.YELLOW+" x"+i.getItemStack().getAmount():"")+ChatColor.RESET+" to Recycling Center Node "+rand_node.toString(),3);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log("No Recycling Center Nodes set! All dropped items will continue to be discarded. Use /recyclingcenter to define them.",1);
|
||||
}
|
||||
}
|
||||
TwosideRecyclingCenter.AddItemToRecyclingCenter(i);
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
||||
@ -3928,7 +3906,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
double oldhp=((LivingEntity)ev.getEntity()).getHealth();
|
||||
GenericFunctions.subtractHealth((LivingEntity)ev.getEntity(), NewCombat.getDamagerEntity(ev.getDamager()), dmg);
|
||||
if (NewCombat.getDamagerEntity(ev.getDamager()) instanceof Player) {
|
||||
//GenericFunctions.subtractHealth((LivingEntity)ev.getEntity(), NewCombat.getDamagerEntity(ev.getDamager()), dmg);
|
||||
if (ev.getDamager() instanceof Projectile) {
|
||||
ev.getDamager().remove();
|
||||
}
|
||||
@ -4192,6 +4169,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
}
|
||||
}
|
||||
},20);
|
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
|
||||
pd.hasDied=false;
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
||||
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -173,6 +174,12 @@ public final class TwosideKeeperAPI {
|
||||
public static boolean isWorldShop(Location l) {
|
||||
return WorldShop.shopSignExists(l);
|
||||
}
|
||||
public static boolean hasPermissionToBreakWorldShopSign(Sign s, Player p) {
|
||||
return WorldShop.hasPermissionToBreakWorldShopSign(s,p);
|
||||
}
|
||||
public static void removeWorldShopDisplayItem(Sign s) {
|
||||
WorldShop.removeShopItem(s);
|
||||
}
|
||||
|
||||
//Recycling Center COMMANDS.
|
||||
public static boolean isRecyclingCenter(Block b) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user