Fixed Death drop bugs. Fixed Autoforging bugs. Modified Sound pickup
algorithm to sound less plain and more varied.
This commit is contained in:
parent
cee9753b7f
commit
77021cf042
Binary file not shown.
@ -43,7 +43,9 @@ public class DeathManager {
|
|||||||
}},1);
|
}},1);
|
||||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
|
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
|
||||||
//pd.deathloot.clear();
|
//pd.deathloot.clear();
|
||||||
|
if (pd!=null) {
|
||||||
pd.hasDied=false;
|
pd.hasDied=false;
|
||||||
|
}
|
||||||
p.setCollidable(true);
|
p.setCollidable(true);
|
||||||
}
|
}
|
||||||
public static boolean deathStructureExists(Player p) {
|
public static boolean deathStructureExists(Player p) {
|
||||||
|
@ -3,6 +3,7 @@ package sig.plugin.TwosideKeeper;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -33,7 +34,11 @@ public class DropDeathItems implements Runnable{
|
|||||||
TwosideKeeper.log("Respawn and Dropping...", 2);
|
TwosideKeeper.log("Respawn and Dropping...", 2);
|
||||||
while (contents.size()>0) {
|
while (contents.size()>0) {
|
||||||
if (deathloc.getChunk().isLoaded()) {
|
if (deathloc.getChunk().isLoaded()) {
|
||||||
Item it = deathloc.getWorld().dropItemNaturally(deathloc, contents.get(0));
|
Item it = null;
|
||||||
|
do {
|
||||||
|
deathloc.getWorld().loadChunk(deathloc.getChunk());
|
||||||
|
it=deathloc.getWorld().dropItemNaturally(deathloc, contents.get(0));
|
||||||
|
TwosideKeeper.temporary_chunks.add(deathloc.getChunk());} while (it==null || !it.isValid());
|
||||||
it.setInvulnerable(true);
|
it.setInvulnerable(true);
|
||||||
TwosideKeeper.log("Dropping "+contents.get(0).toString()+" at Death location "+deathloc,2);
|
TwosideKeeper.log("Dropping "+contents.get(0).toString()+" at Death location "+deathloc,2);
|
||||||
contents.remove(0);
|
contents.remove(0);
|
||||||
@ -41,6 +46,10 @@ public class DropDeathItems implements Runnable{
|
|||||||
deathloc.getWorld().loadChunk(deathloc.getChunk());
|
deathloc.getWorld().loadChunk(deathloc.getChunk());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (Chunk c : TwosideKeeper.temporary_chunks) {
|
||||||
|
c.unload(true);
|
||||||
|
}
|
||||||
|
TwosideKeeper.temporary_chunks.clear();
|
||||||
DeathManager.removeDeathStructure(p);
|
DeathManager.removeDeathStructure(p);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3838,7 +3838,9 @@ public class GenericFunctions {
|
|||||||
public static boolean giveItem(Player p, ItemStack... items) {
|
public static boolean giveItem(Player p, ItemStack... items) {
|
||||||
HashMap<Integer,ItemStack> remaining = p.getInventory().addItem(items);
|
HashMap<Integer,ItemStack> remaining = p.getInventory().addItem(items);
|
||||||
if (remaining.isEmpty()) {
|
if (remaining.isEmpty()) {
|
||||||
SoundUtils.playGlobalSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f);
|
if (items[0]!=null) {
|
||||||
|
SoundUtils.playGlobalSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(items[0]));
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
for (Integer i : remaining.keySet()) {
|
for (Integer i : remaining.keySet()) {
|
||||||
|
@ -6,6 +6,7 @@ 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.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -92,4 +93,13 @@ public class InventoryUtils {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
public static boolean hasFullInventory(Player p) {
|
||||||
|
ItemStack[] inv = p.getInventory().getStorageContents();
|
||||||
|
for (ItemStack i : inv) {
|
||||||
|
if (i==null || i.getType()==Material.AIR) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
package sig.plugin.TwosideKeeper.HelperStructures.Utils;
|
package sig.plugin.TwosideKeeper.HelperStructures.Utils;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import sig.plugin.TwosideKeeper.TwosideKeeper;
|
||||||
|
|
||||||
public class SoundUtils {
|
public class SoundUtils {
|
||||||
|
|
||||||
@ -42,4 +47,14 @@ public class SoundUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static float DetermineItemPitch(ItemStack item) {
|
||||||
|
double pitch = 1.0f;
|
||||||
|
double variance = 0.1f;
|
||||||
|
Random r = new Random();
|
||||||
|
r.setSeed(item.getType().name().hashCode());
|
||||||
|
double newnumb = r.nextFloat();
|
||||||
|
double newpitch = pitch+variance-(newnumb*(variance*2d));
|
||||||
|
TwosideKeeper.log("Next float:"+newnumb+" | Pitch: "+newpitch, 5);
|
||||||
|
return (float)newpitch;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -367,15 +367,15 @@ public class PlayerStructure {
|
|||||||
this.lastattacked = TwosideKeeper.getServerTickTime();
|
this.lastattacked = TwosideKeeper.getServerTickTime();
|
||||||
this.lastcombat = TwosideKeeper.getServerTickTime();
|
this.lastcombat = TwosideKeeper.getServerTickTime();
|
||||||
|
|
||||||
/*if (this.hasDied) {
|
if (this.hasDied) {
|
||||||
List<ItemStack> deathlootlist = new ArrayList<ItemStack>();
|
List<ItemStack> deathlootlist = new ArrayList<ItemStack>();
|
||||||
ConfigurationSection deathlootsection = workable.getConfigurationSection("deathloot");
|
//ConfigurationSection deathlootsection = workable.getConfigurationSection("deathloot");
|
||||||
for (int i=0;i<deathlootsection.getKeys(false).size();i++) {
|
/*for (int i=0;i<deathlootsection.getKeys(false).size();i++) {
|
||||||
ItemStack item = deathlootsection.getItemStack((String)(deathlootsection.getKeys(false).toArray()[i]));
|
ItemStack item = deathlootsection.getItemStack((String)(deathlootsection.getKeys(false).toArray()[i]));
|
||||||
deathlootlist.add(item);
|
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));
|
|
||||||
}*/
|
}*/
|
||||||
|
DeathManager.addNewDeathStructure(deathlootlist, new Location(Bukkit.getWorld(this.deathloc_world),this.deathloc_x,this.deathloc_y,this.deathloc_z), Bukkit.getPlayer(name));
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
workable.save(config);
|
workable.save(config);
|
||||||
|
@ -411,6 +411,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
public static boolean restarting_server=false;
|
public static boolean restarting_server=false;
|
||||||
public static List<String> log_messages=new ArrayList<String>();
|
public static List<String> log_messages=new ArrayList<String>();
|
||||||
public static List<TemporaryLava> temporary_lava_list = new ArrayList<TemporaryLava>();
|
public static List<TemporaryLava> temporary_lava_list = new ArrayList<TemporaryLava>();
|
||||||
|
public static List<Chunk> temporary_chunks = new ArrayList<Chunk>();
|
||||||
|
|
||||||
long LastClearStructureTime = 0;
|
long LastClearStructureTime = 0;
|
||||||
|
|
||||||
@ -872,6 +873,21 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
log(ChatColor.YELLOW+" "+(System.currentTimeMillis()-betweentime)+"ms",CLEANUP_DEBUG);
|
log(ChatColor.YELLOW+" "+(System.currentTimeMillis()-betweentime)+"ms",CLEANUP_DEBUG);
|
||||||
betweentime = System.currentTimeMillis();
|
betweentime = System.currentTimeMillis();
|
||||||
|
log("Cleaning up Open Player Death Inventories ["+Bukkit.getOnlinePlayers().size()+"]",CLEANUP_DEBUG);
|
||||||
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (p.getOpenInventory()!=null && p.getOpenInventory().getTopInventory()!=null &&
|
||||||
|
p.getOpenInventory().getTopInventory().getTitle()!=null &&
|
||||||
|
DeathManager.deathStructureExists(p) && p.getOpenInventory().getTopInventory().getTitle().contains("Death Loot")) {
|
||||||
|
Location deathloc = DeathManager.getDeathStructure(p).deathloc;
|
||||||
|
DropDeathInventoryContents(p, deathloc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log(ChatColor.YELLOW+" "+(System.currentTimeMillis()-betweentime)+"ms",CLEANUP_DEBUG);
|
||||||
|
betweentime = System.currentTimeMillis();
|
||||||
|
log("Cleaning up Temporary Chunks ["+temporary_chunks.size()+"]",CLEANUP_DEBUG);
|
||||||
|
temporary_chunks.clear();
|
||||||
|
log(ChatColor.YELLOW+" "+(System.currentTimeMillis()-betweentime)+"ms",CLEANUP_DEBUG);
|
||||||
|
betweentime = System.currentTimeMillis();
|
||||||
long endtime = System.currentTimeMillis();
|
long endtime = System.currentTimeMillis();
|
||||||
log("Cleanup Maintenance completed. Total Time: "+(endtime-starttime)+"ms.",CLEANUP_DEBUG);
|
log("Cleanup Maintenance completed. Total Time: "+(endtime-starttime)+"ms.",CLEANUP_DEBUG);
|
||||||
}
|
}
|
||||||
@ -1539,6 +1555,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
||||||
public void onPlayerLeave(PlayerQuitEvent ev) {
|
public void onPlayerLeave(PlayerQuitEvent ev) {
|
||||||
|
Player p = ev.getPlayer();
|
||||||
TwosideSpleefGames.PassEvent(ev);
|
TwosideSpleefGames.PassEvent(ev);
|
||||||
for (EliteMonster em : elitemonsters) {
|
for (EliteMonster em : elitemonsters) {
|
||||||
em.runPlayerLeaveEvent(ev.getPlayer());
|
em.runPlayerLeaveEvent(ev.getPlayer());
|
||||||
@ -1549,11 +1566,12 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
les.setGlow(ev.getPlayer(), null);
|
les.setGlow(ev.getPlayer(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Player p :Bukkit.getOnlinePlayers()) {
|
for (Player pl :Bukkit.getOnlinePlayers()) {
|
||||||
if (p!=null) {
|
if (pl!=null) {
|
||||||
SoundUtils.playLocalSound(p, Sound.BLOCK_NOTE_PLING, 8, 0.7f);
|
SoundUtils.playLocalSound(pl, Sound.BLOCK_NOTE_PLING, 8, 0.7f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new ShutdownServerForUpdate(),5);
|
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new ShutdownServerForUpdate(),5);
|
||||||
|
|
||||||
//Find the player that is getting removed.
|
//Find the player that is getting removed.
|
||||||
@ -3576,27 +3594,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
amounttotake = diff;
|
amounttotake = diff;
|
||||||
givePlayerBankMoney(p,-amounttotake);
|
givePlayerBankMoney(p,-amounttotake);
|
||||||
}
|
}
|
||||||
Inventory contents = Bukkit.createInventory(p, 45);
|
DropDeathInventoryContents(p, deathloc, 1);
|
||||||
log("Contents list includes ",2);
|
|
||||||
for (int i=0;i<p.getOpenInventory().getTopInventory().getSize();i++) {
|
|
||||||
if (p.getOpenInventory().getTopInventory().getItem(i)!=null) {
|
|
||||||
//p.sendMessage("Saving item "+p.getOpenInventory().getTopInventory().getItem(i).toString()+" in slot "+i);
|
|
||||||
log(p.getOpenInventory().getTopInventory().getItem(i).toString(),2);
|
|
||||||
contents.addItem(p.getOpenInventory().getTopInventory().getItem(i));
|
|
||||||
} else {
|
|
||||||
//p.sendMessage("Saving item AIR in slot "+i);
|
|
||||||
contents.addItem(new ItemStack(Material.AIR));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log("-------",2);
|
|
||||||
List<ItemStack> list=new ArrayList<ItemStack>();
|
|
||||||
for (int i=0;i<contents.getSize();i++) {
|
|
||||||
if (contents.getItem(i)!=null &&
|
|
||||||
contents.getItem(i).getType()!=Material.AIR) {
|
|
||||||
list.add(contents.getItem(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this,new DropDeathItems(p,list,deathloc),1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerStructure pd = (PlayerStructure) playerdata.get(p.getUniqueId());
|
PlayerStructure pd = (PlayerStructure) playerdata.get(p.getUniqueId());
|
||||||
@ -3651,6 +3649,56 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void DropDeathInventoryContents(Player p, Location deathloc) {
|
||||||
|
List<ItemStack> list = PrepareDropItems(p);
|
||||||
|
deathloc.getWorld().loadChunk(deathloc.getChunk());
|
||||||
|
while (list.size()>0) {
|
||||||
|
if (deathloc.getChunk().isLoaded()) {
|
||||||
|
Item it = null;
|
||||||
|
do {
|
||||||
|
deathloc.getWorld().loadChunk(deathloc.getChunk());
|
||||||
|
it=deathloc.getWorld().dropItemNaturally(deathloc, list.get(0));
|
||||||
|
TwosideKeeper.temporary_chunks.add(deathloc.getChunk());
|
||||||
|
} while (it==null || !it.isValid());
|
||||||
|
it.setInvulnerable(true);
|
||||||
|
TwosideKeeper.log("Dropping "+list.get(0).toString()+" at Death location "+deathloc,2);
|
||||||
|
list.remove(0);
|
||||||
|
} else {
|
||||||
|
deathloc.getWorld().loadChunk(deathloc.getChunk());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Chunk c : TwosideKeeper.temporary_chunks) {
|
||||||
|
c.unload(true);
|
||||||
|
}
|
||||||
|
TwosideKeeper.temporary_chunks.clear();
|
||||||
|
}
|
||||||
|
public void DropDeathInventoryContents(Player p, Location deathloc, int tickdelay) {
|
||||||
|
List<ItemStack> list = PrepareDropItems(p);
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(this,new DropDeathItems(p,list,deathloc),tickdelay);
|
||||||
|
}
|
||||||
|
public List<ItemStack> PrepareDropItems(Player p) {
|
||||||
|
Inventory contents = Bukkit.createInventory(p, 45);
|
||||||
|
log("Contents list includes ",2);
|
||||||
|
for (int i=0;i<p.getOpenInventory().getTopInventory().getSize();i++) {
|
||||||
|
if (p.getOpenInventory().getTopInventory().getItem(i)!=null) {
|
||||||
|
//p.sendMessage("Saving item "+p.getOpenInventory().getTopInventory().getItem(i).toString()+" in slot "+i);
|
||||||
|
log(p.getOpenInventory().getTopInventory().getItem(i).toString(),2);
|
||||||
|
contents.addItem(p.getOpenInventory().getTopInventory().getItem(i));
|
||||||
|
} else {
|
||||||
|
//p.sendMessage("Saving item AIR in slot "+i);
|
||||||
|
contents.addItem(new ItemStack(Material.AIR));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log("-------",2);
|
||||||
|
List<ItemStack> list=new ArrayList<ItemStack>();
|
||||||
|
for (int i=0;i<contents.getSize();i++) {
|
||||||
|
if (contents.getItem(i)!=null &&
|
||||||
|
contents.getItem(i).getType()!=Material.AIR) {
|
||||||
|
list.add(contents.getItem(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
public void AttemptToDropItems(Player p, Location deathloc) {
|
public void AttemptToDropItems(Player p, Location deathloc) {
|
||||||
deathloc.getWorld().loadChunk(deathloc.getChunk());
|
deathloc.getWorld().loadChunk(deathloc.getChunk());
|
||||||
@ -4326,6 +4374,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
ItemCubeUtils.SomeoneHasAFilterCubeOpen()) {
|
ItemCubeUtils.SomeoneHasAFilterCubeOpen()) {
|
||||||
ev.setCancelled(true);
|
ev.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
if (temporary_chunks.contains(c)) {
|
||||||
|
ev.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMonsterFlags(LivingEntity m) {
|
public void updateMonsterFlags(LivingEntity m) {
|
||||||
@ -5725,7 +5776,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
if (a.hasMetadata("DOUBLE_DAMAGE_ARR")) {item=Recipes.getArrowFromMeta("DOUBLE_DAMAGE_ARR"); specialarrow=true;}
|
if (a.hasMetadata("DOUBLE_DAMAGE_ARR")) {item=Recipes.getArrowFromMeta("DOUBLE_DAMAGE_ARR"); specialarrow=true;}
|
||||||
if (specialarrow) {
|
if (specialarrow) {
|
||||||
ev.getItem().remove();
|
ev.getItem().remove();
|
||||||
SoundUtils.playGlobalSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f);
|
SoundUtils.playGlobalSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(item));
|
||||||
ev.setCancelled(true);
|
ev.setCancelled(true);
|
||||||
AddToPlayerInventory(item, p);
|
AddToPlayerInventory(item, p);
|
||||||
//ev.getItem().setItemStack(item);
|
//ev.getItem().setItemStack(item);
|
||||||
@ -5734,7 +5785,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
ItemStack collect = CustomItem.convertArrowEntityFromMeta(ev.getArrow());
|
ItemStack collect = CustomItem.convertArrowEntityFromMeta(ev.getArrow());
|
||||||
if (collect!=null) {
|
if (collect!=null) {
|
||||||
ev.getItem().remove();
|
ev.getItem().remove();
|
||||||
SoundUtils.playGlobalSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f);
|
SoundUtils.playGlobalSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(item));
|
||||||
AddToPlayerInventory(collect, p);
|
AddToPlayerInventory(collect, p);
|
||||||
ev.setCancelled(true);
|
ev.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -5776,7 +5827,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
log("Added "+ev.getItem().getItemStack().getAmount()+" arrow"+((ev.getItem().getItemStack().getAmount()==1)?"":"s")+" to quiver in slot "+arrowquiver_slot+". New amount: "+playerGetArrowQuiverAmt(p,arrowquiver_slot),4);
|
log("Added "+ev.getItem().getItemStack().getAmount()+" arrow"+((ev.getItem().getItemStack().getAmount()==1)?"":"s")+" to quiver in slot "+arrowquiver_slot+". New amount: "+playerGetArrowQuiverAmt(p,arrowquiver_slot),4);
|
||||||
//If we added it here, we destroy the item stack.
|
//If we added it here, we destroy the item stack.
|
||||||
p.sendMessage(ChatColor.DARK_GRAY+""+ev.getItem().getItemStack().getAmount()+" arrow"+((ev.getItem().getItemStack().getAmount()==1)?"":"s")+" "+((ev.getItem().getItemStack().getAmount()==1)?"was":"were")+" added to your arrow quiver. Arrow Count: "+ChatColor.GRAY+playerGetArrowQuiverAmt(p,arrowquiver_slot));
|
p.sendMessage(ChatColor.DARK_GRAY+""+ev.getItem().getItemStack().getAmount()+" arrow"+((ev.getItem().getItemStack().getAmount()==1)?"":"s")+" "+((ev.getItem().getItemStack().getAmount()==1)?"was":"were")+" added to your arrow quiver. Arrow Count: "+ChatColor.GRAY+playerGetArrowQuiverAmt(p,arrowquiver_slot));
|
||||||
ev.getPlayer().playSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f);
|
ev.getPlayer().playSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.6f, 1.0f);
|
||||||
ev.getItem().remove();
|
ev.getItem().remove();
|
||||||
ev.setCancelled(true);
|
ev.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -5806,8 +5857,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
|
|
||||||
if (GenericFunctions.isValidArrow(ev.getItem().getItemStack())) {
|
if (GenericFunctions.isValidArrow(ev.getItem().getItemStack())) {
|
||||||
ev.setCancelled(true);
|
ev.setCancelled(true);
|
||||||
|
SoundUtils.playGlobalSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(ev.getItem().getItemStack()));
|
||||||
ev.getItem().remove();
|
ev.getItem().remove();
|
||||||
SoundUtils.playGlobalSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f);
|
|
||||||
AddToPlayerInventory(ev.getItem().getItemStack(), p);
|
AddToPlayerInventory(ev.getItem().getItemStack(), p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -5821,8 +5872,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
ItemStack[] remaining = InventoryUtils.insertItemsInVacuumCube(p, ev.getItem().getItemStack());
|
ItemStack[] remaining = InventoryUtils.insertItemsInVacuumCube(p, ev.getItem().getItemStack());
|
||||||
if (remaining.length==0) {
|
if (remaining.length==0) {
|
||||||
ev.setCancelled(true);
|
ev.setCancelled(true);
|
||||||
|
SoundUtils.playGlobalSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(ev.getItem().getItemStack()));
|
||||||
ev.getItem().remove();
|
ev.getItem().remove();
|
||||||
SoundUtils.playGlobalSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f);
|
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
ev.getItem().setItemStack(remaining[0]);
|
ev.getItem().setItemStack(remaining[0]);
|
||||||
@ -5834,8 +5885,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
ItemStack[] remaining = InventoryUtils.insertItemsInFilterCube(p, ev.getItem().getItemStack());
|
ItemStack[] remaining = InventoryUtils.insertItemsInFilterCube(p, ev.getItem().getItemStack());
|
||||||
if (remaining.length==0) {
|
if (remaining.length==0) {
|
||||||
ev.setCancelled(true);
|
ev.setCancelled(true);
|
||||||
|
SoundUtils.playGlobalSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(ev.getItem().getItemStack()));
|
||||||
ev.getItem().remove();
|
ev.getItem().remove();
|
||||||
SoundUtils.playGlobalSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f);
|
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
ev.getItem().setItemStack(remaining[0]);
|
ev.getItem().setItemStack(remaining[0]);
|
||||||
@ -5887,7 +5938,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
!PlayerMode.isSlayer(p)) {
|
!PlayerMode.isSlayer(p)) {
|
||||||
p.getEquipment().setBoots(armor);
|
p.getEquipment().setBoots(armor);
|
||||||
p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(item.getItemMeta().hasDisplayName()?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item)));
|
p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(item.getItemMeta().hasDisplayName()?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item)));
|
||||||
SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f);
|
SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(armor));
|
||||||
GenericFunctions.playProperEquipSound(p,armor.getType());
|
GenericFunctions.playProperEquipSound(p,armor.getType());
|
||||||
p.updateInventory();
|
p.updateInventory();
|
||||||
return true;
|
return true;
|
||||||
@ -5898,7 +5949,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
!PlayerMode.isSlayer(p)) {
|
!PlayerMode.isSlayer(p)) {
|
||||||
p.getEquipment().setLeggings(armor);
|
p.getEquipment().setLeggings(armor);
|
||||||
p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(item.getItemMeta().hasDisplayName()?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item)));
|
p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(item.getItemMeta().hasDisplayName()?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item)));
|
||||||
SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f);
|
SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(armor));
|
||||||
GenericFunctions.playProperEquipSound(p,armor.getType());
|
GenericFunctions.playProperEquipSound(p,armor.getType());
|
||||||
p.updateInventory();
|
p.updateInventory();
|
||||||
return true;
|
return true;
|
||||||
@ -5909,7 +5960,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
!PlayerMode.isSlayer(p)) {
|
!PlayerMode.isSlayer(p)) {
|
||||||
p.getEquipment().setChestplate(armor);
|
p.getEquipment().setChestplate(armor);
|
||||||
p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(item.getItemMeta().hasDisplayName()?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item)));
|
p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(item.getItemMeta().hasDisplayName()?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item)));
|
||||||
SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f);
|
SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(armor));
|
||||||
GenericFunctions.playProperEquipSound(p,armor.getType());
|
GenericFunctions.playProperEquipSound(p,armor.getType());
|
||||||
p.updateInventory();
|
p.updateInventory();
|
||||||
return true;
|
return true;
|
||||||
@ -5920,7 +5971,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
!PlayerMode.isSlayer(p)) {
|
!PlayerMode.isSlayer(p)) {
|
||||||
p.getEquipment().setHelmet(armor);
|
p.getEquipment().setHelmet(armor);
|
||||||
p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(item.getItemMeta().hasDisplayName()?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item)));
|
p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(item.getItemMeta().hasDisplayName()?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item)));
|
||||||
SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f);
|
SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(armor));
|
||||||
GenericFunctions.playProperEquipSound(p,armor.getType());
|
GenericFunctions.playProperEquipSound(p,armor.getType());
|
||||||
p.updateInventory();
|
p.updateInventory();
|
||||||
return true;
|
return true;
|
||||||
@ -5935,7 +5986,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
p.getInventory().setExtraContents(new ItemStack[]{armor});
|
p.getInventory().setExtraContents(new ItemStack[]{armor});
|
||||||
}
|
}
|
||||||
p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(item.getItemMeta().hasDisplayName()?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item)));
|
p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(item.getItemMeta().hasDisplayName()?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item)));
|
||||||
SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f);
|
SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(armor));
|
||||||
GenericFunctions.playProperEquipSound(p,armor.getType());
|
GenericFunctions.playProperEquipSound(p,armor.getType());
|
||||||
p.updateInventory();
|
p.updateInventory();
|
||||||
return true;
|
return true;
|
||||||
@ -5948,7 +5999,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
p.getInventory().setExtraContents(new ItemStack[]{armor});
|
p.getInventory().setExtraContents(new ItemStack[]{armor});
|
||||||
}
|
}
|
||||||
p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(item.getItemMeta().hasDisplayName()?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item)));
|
p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(item.getItemMeta().hasDisplayName()?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item)));
|
||||||
SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f);
|
SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(armor));
|
||||||
GenericFunctions.playProperEquipSound(p,armor.getType());
|
GenericFunctions.playProperEquipSound(p,armor.getType());
|
||||||
p.updateInventory();
|
p.updateInventory();
|
||||||
return true;
|
return true;
|
||||||
@ -5956,7 +6007,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
if (ArrowQuiver.isValidQuiver(armor) && p.getInventory().getExtraContents()[0]==null) {
|
if (ArrowQuiver.isValidQuiver(armor) && p.getInventory().getExtraContents()[0]==null) {
|
||||||
p.getInventory().setExtraContents(new ItemStack[]{armor});
|
p.getInventory().setExtraContents(new ItemStack[]{armor});
|
||||||
p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(item.getItemMeta().hasDisplayName()?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item)));
|
p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(item.getItemMeta().hasDisplayName()?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item)));
|
||||||
SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f);
|
SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(armor));
|
||||||
GenericFunctions.playProperEquipSound(p,armor.getType());
|
GenericFunctions.playProperEquipSound(p,armor.getType());
|
||||||
p.updateInventory();
|
p.updateInventory();
|
||||||
return true;
|
return true;
|
||||||
|
@ -4,6 +4,7 @@ import java.text.DecimalFormat;
|
|||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -352,21 +353,23 @@ final class runServerHeartbeat implements Runnable {
|
|||||||
|
|
||||||
|
|
||||||
public static void runFilterCubeCollection(Player p) {
|
public static void runFilterCubeCollection(Player p) {
|
||||||
if (InventoryUtils.isCarryingFilterCube(p)) {
|
if (InventoryUtils.hasFullInventory(p) && InventoryUtils.isCarryingFilterCube(p)) {
|
||||||
List<Entity> ents = p.getNearbyEntities(0.25, 0.25, 0.25);
|
List<Entity> ents = p.getNearbyEntities(0.25, 0.25, 0.25);
|
||||||
for (Entity ent : ents) {
|
for (Entity ent : ents) {
|
||||||
if (ent instanceof Item && GenericFunctions.itemCanBeSuckedUp((Item)ent)) {
|
if (ent instanceof Item && GenericFunctions.itemCanBeSuckedUp((Item)ent)) {
|
||||||
Item it = (Item)ent;
|
Item it = (Item)ent;
|
||||||
|
if (it.getPickupDelay()<it.getTicksLived()) {
|
||||||
ItemStack[] remaining = InventoryUtils.insertItemsInFilterCube(p, it.getItemStack());
|
ItemStack[] remaining = InventoryUtils.insertItemsInFilterCube(p, it.getItemStack());
|
||||||
if (remaining.length==0) {
|
if (remaining.length==0) {
|
||||||
|
SoundUtils.playGlobalSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(it.getItemStack()));
|
||||||
it.remove();
|
it.remove();
|
||||||
SoundUtils.playGlobalSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void runVacuumCubeSuckup(Player p) {
|
public static void runVacuumCubeSuckup(Player p) {
|
||||||
if (InventoryUtils.isCarryingVacuumCube(p)) {
|
if (InventoryUtils.isCarryingVacuumCube(p)) {
|
||||||
@ -402,12 +405,14 @@ final class runServerHeartbeat implements Runnable {
|
|||||||
}
|
}
|
||||||
if (Math.abs(deltax)<0.25 &&
|
if (Math.abs(deltax)<0.25 &&
|
||||||
Math.abs(deltay)<0.25 &&
|
Math.abs(deltay)<0.25 &&
|
||||||
Math.abs(deltaz)<0.25) {
|
Math.abs(deltaz)<0.25 &&
|
||||||
|
InventoryUtils.hasFullInventory(p) &&
|
||||||
|
((Item)ent).getPickupDelay()<((Item)ent).getTicksLived()) {
|
||||||
//Collect this item.
|
//Collect this item.
|
||||||
if (((Item)ent).getItemStack().getType().isBlock()) {
|
if (((Item)ent).getItemStack().getType().isBlock()) {
|
||||||
ItemStack[] remaining = InventoryUtils.insertItemsInVacuumCube(p, ((Item) ent).getItemStack());
|
ItemStack[] remaining = InventoryUtils.insertItemsInVacuumCube(p, ((Item) ent).getItemStack());
|
||||||
if (remaining.length==0) {
|
if (remaining.length==0) {
|
||||||
SoundUtils.playGlobalSound(ent.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.4f);
|
SoundUtils.playGlobalSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(((Item) ent).getItemStack()));
|
||||||
ent.remove();
|
ent.remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user