Fixed a lot of major reported bugs.
This commit is contained in:
parent
b713263a66
commit
e511406a0c
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
name: TwosideKeeper
|
||||
main: sig.plugin.TwosideKeeper.TwosideKeeper
|
||||
version: 3.10.0a
|
||||
version: 3.10.0b
|
||||
commands:
|
||||
money:
|
||||
description: Tells the player the amount of money they are holding.
|
||||
|
@ -1385,13 +1385,14 @@ public class CustomDamage {
|
||||
@SuppressWarnings("deprecation")
|
||||
public static double CalculateDodgeChance(Player p, Entity damager) {
|
||||
double dodgechance = 0.0d;
|
||||
dodgechance+=(ArtifactAbility.calculateValue(ArtifactAbility.DODGE, p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ArtifactAbility.DODGE, p.getEquipment().getItemInMainHand()))/100d);
|
||||
|
||||
for (int i=0;i<p.getEquipment().getArmorContents().length;i++) {
|
||||
if (ArtifactAbility.containsEnchantment(ArtifactAbility.SHADOWWALKER, p.getEquipment().getArmorContents()[i]) &&
|
||||
for (ItemStack it : GenericFunctions.getArmor(p)) {
|
||||
if (it!=null) {
|
||||
if (ArtifactAbility.containsEnchantment(ArtifactAbility.SHADOWWALKER, it) &&
|
||||
p.isOnGround() && p.getLocation().getY()>=0 && p.getLocation().add(0,0,0).getBlock().getLightLevel()<=4) {
|
||||
dodgechance+=0.01*p.getEquipment().getArmorContents()[i].getEnchantmentLevel(Enchantment.LUCK);
|
||||
dodgechance+=0.01*it.getEnchantmentLevel(Enchantment.LUCK);
|
||||
}
|
||||
dodgechance+=(ArtifactAbility.calculateValue(ArtifactAbility.DODGE, it.getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ArtifactAbility.DODGE, it))/100d);
|
||||
|
||||
/*ItemStack equip = p.getEquipment().getArmorContents()[i];
|
||||
if (GenericFunctions.isRanger(p) && equip!=null
|
||||
&& equip.getType()!=Material.AIR &&
|
||||
@ -1410,6 +1411,7 @@ public class CustomDamage {
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
dodgechance+=ItemSet.GetTotalBaseAmount(GenericFunctions.getEquipment(p), p, ItemSet.ALIKAHN)/100d;
|
||||
dodgechance+=ItemSet.GetTotalBaseAmount(GenericFunctions.getEquipment(p), p, ItemSet.DARNYS)/100d;
|
||||
dodgechance+=ItemSet.GetTotalBaseAmount(GenericFunctions.getEquipment(p), p, ItemSet.JAMDAK)/100d;
|
||||
|
@ -7,32 +7,57 @@ import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.InventoryUtils;
|
||||
|
||||
public class DropDeathItems implements Runnable{
|
||||
|
||||
Player p = null;
|
||||
Location deathloc = null;
|
||||
List<ItemStack> contents;
|
||||
Inventory inv_contents;
|
||||
|
||||
DropDeathItems(Player p, List<ItemStack> contents, Location deathloc) {
|
||||
this.p=p;
|
||||
this.deathloc=deathloc;
|
||||
this.contents=contents;
|
||||
this.inv_contents = Bukkit.createInventory(p, 36);
|
||||
for (ItemStack it : contents) {
|
||||
if (it!=null) {
|
||||
inv_contents.addItem(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!AttemptToDropItems(p,deathloc)) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin,new DropDeathItems(p,contents,deathloc),1); //Keep trying until the chunk is loaded!!!
|
||||
TwosideKeeper.temporary_chunks.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean AttemptToDropItems(Player p, Location deathloc) {
|
||||
deathloc.getWorld().loadChunk(deathloc.getChunk());
|
||||
TwosideKeeper.temporary_chunks.add(deathloc.getChunk());
|
||||
deathloc.getChunk().load();
|
||||
if (deathloc.getChunk().isLoaded()) {
|
||||
TwosideKeeper.log("Respawn and Dropping...", 2);
|
||||
while (contents.size()>0) {
|
||||
while (!InventoryUtils.hasEmptyInventory(inv_contents)) {
|
||||
if (deathloc.getChunk().isLoaded()) {
|
||||
Item it = deathloc.getWorld().dropItemNaturally(deathloc, InventoryUtils.getFirstItemThatIsNotEmpty(inv_contents));
|
||||
if (it!=null) {
|
||||
inv_contents.removeItem(it.getItemStack());
|
||||
TwosideKeeper.log("Dropping "+it.getItemStack().toString()+" at Death location "+deathloc,2);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/*while (contents.size()>0) {
|
||||
if (deathloc.getChunk().isLoaded()) {
|
||||
Item it = null;
|
||||
do {
|
||||
@ -41,11 +66,12 @@ public class DropDeathItems implements Runnable{
|
||||
TwosideKeeper.temporary_chunks.add(deathloc.getChunk());} while (it==null || !it.isValid());
|
||||
it.setInvulnerable(true);
|
||||
TwosideKeeper.log("Dropping "+contents.get(0).toString()+" at Death location "+deathloc,2);
|
||||
contents.remove(0);
|
||||
//contents.remove(0);
|
||||
|
||||
} else {
|
||||
deathloc.getWorld().loadChunk(deathloc.getChunk());
|
||||
}
|
||||
}
|
||||
}*/
|
||||
for (Chunk c : TwosideKeeper.temporary_chunks) {
|
||||
c.unload(true);
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ public class SigDrop extends Drop{
|
||||
item = Loot.GenerateMegaPiece(item.getType(), isHardened);
|
||||
}break;
|
||||
default:{
|
||||
TwosideKeeper.log("Something went terrible wrong generating the item! DIRT is being returned! Check your switch statement for 'isWeapon'.", 0);
|
||||
TwosideKeeper.log("Something went terribly wrong generating the item! DIRT is being returned! Check your switch statement for 'isWeapon'.", 0);
|
||||
item = new ItemStack(Material.DIRT);
|
||||
}
|
||||
}
|
||||
|
@ -4253,7 +4253,8 @@ public class GenericFunctions {
|
||||
|
||||
public static void PerformAssassinate(Player player, Material name) {
|
||||
//Try to find a target to look at.
|
||||
LivingEntity target = aPlugin.API.rayTraceTargetEntity(player, 100);
|
||||
//LivingEntity target = aPlugin.API.rayTraceTargetEntity(player, 100);
|
||||
LivingEntity target = aPlugin.API.getTargetEntity(player, 100);
|
||||
if (target!=null && !target.isDead()) {
|
||||
//We found a target, try to jump behind them now.
|
||||
double mult = 0.0;
|
||||
@ -4340,7 +4341,8 @@ public class GenericFunctions {
|
||||
}
|
||||
|
||||
public static boolean isIsolatedTarget(LivingEntity m, Player p) {
|
||||
return (GenericFunctions.GetNearbyMonsterCount(m, 12)==0) &&
|
||||
return (p.getWorld().equals(m.getWorld()) && p.getLocation().distanceSquared(m.getLocation())<=1024 &&
|
||||
GenericFunctions.GetNearbyMonsterCount(m, 12)==0) &&
|
||||
PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER;
|
||||
}
|
||||
|
||||
|
@ -102,4 +102,32 @@ public class InventoryUtils {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static boolean hasEmptyInventory(Inventory inv) {
|
||||
ItemStack[] inventory = inv.getContents();
|
||||
for (ItemStack i : inventory) {
|
||||
if (i!=null && i.getType()!=Material.AIR) {
|
||||
TwosideKeeper.log("Item is "+i, 0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static boolean hasEmptyInventory(Player p) {
|
||||
ItemStack[] inv = p.getInventory().getStorageContents();
|
||||
for (ItemStack i : inv) {
|
||||
if (i!=null && i.getType()!=Material.AIR) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static ItemStack getFirstItemThatIsNotEmpty(Inventory inv) {
|
||||
ItemStack[] inventory = inv.getContents();
|
||||
for (ItemStack it : inventory) {
|
||||
if (it!=null && it.getType()!=Material.AIR) {
|
||||
return it;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package sig.plugin.TwosideKeeper.HelperStructures.Utils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -103,4 +104,13 @@ public class ItemUtils {
|
||||
return (item!=null && item.hasItemMeta());
|
||||
}
|
||||
|
||||
public static boolean isArtifactDust(ItemStack item) {
|
||||
if (isValidLoreItem(item) &&
|
||||
LoreContainsSubstring(item,ChatColor.BLUE+""+ChatColor.MAGIC)) {
|
||||
//TwosideKeeper.log("This is Artifact Dust.", 0);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,13 +83,11 @@ public class LivingEntityStructure {
|
||||
|
||||
public void setGlow(Player p, GlowAPI.Color col) {
|
||||
glowcolorlist.put(p, col);
|
||||
GlowAPI.setGlowing(m, col, p);
|
||||
}
|
||||
|
||||
public void setGlobalGlow(GlowAPI.Color col) {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
glowcolorlist.put(p, col);
|
||||
GlowAPI.setGlowing(m, col, p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,6 +119,7 @@ public class LivingEntityStructure {
|
||||
//No glow.
|
||||
setGlow(p,null);
|
||||
}
|
||||
GlowAPI.setGlowing(m, glowcolorlist.get(p), p);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,6 @@ public class MonsterController {
|
||||
return false;
|
||||
} else {
|
||||
if (isZombieLeader(ent)) {
|
||||
|
||||
convertLivingEntity(ent,LivingEntityDifficulty.NORMAL);
|
||||
}
|
||||
return true;
|
||||
@ -129,7 +128,6 @@ public class MonsterController {
|
||||
return false;
|
||||
} else {
|
||||
if (isZombieLeader(ent)) {
|
||||
|
||||
convertLivingEntity(ent,LivingEntityDifficulty.NORMAL);
|
||||
}
|
||||
return true;
|
||||
|
@ -19,6 +19,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
|
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.ItemUtils;
|
||||
|
||||
public class RecyclingCenter {
|
||||
//Each Recycling center has nodes which contain all the chests.
|
||||
@ -60,7 +61,7 @@ public class RecyclingCenter {
|
||||
|
||||
public boolean IsItemAllowed(ItemStack item) {
|
||||
//Artifact type of items are not allowed to be sent to the Recycling Center. Only artifact equipment will be sent over.
|
||||
if (Artifact.isArtifact(item) && !GenericFunctions.isArtifactEquip(item)) {
|
||||
if (Artifact.isArtifact(item) && !GenericFunctions.isArtifactEquip(item) && !ItemUtils.isArtifactDust(item)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -181,8 +182,8 @@ public class RecyclingCenter {
|
||||
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.getType())) {
|
||||
if (oldItem!=null && Math.random()*100<=TwosideKeeper.RECYCLECHANCE) {
|
||||
if (!isCommon(i.getType()) || mustBeRecycled(i)) {
|
||||
if (oldItem!=null && (Math.random()*100<=TwosideKeeper.RECYCLECHANCE || mustBeRecycled(i))) {
|
||||
int itemslot2 = (int)Math.floor(Math.random()*27);
|
||||
c.getBlockInventory().setItem(itemslot2, oldItem);
|
||||
}
|
||||
@ -202,6 +203,14 @@ public class RecyclingCenter {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean mustBeRecycled(ItemStack it) {
|
||||
if (GenericFunctions.isArtifactEquip(it) || ItemUtils.isArtifactDust(it)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isCommon(Material m) {
|
||||
if (itemmap.containsKey(m)) {
|
||||
int amt = itemmap.get(m);
|
||||
|
@ -1032,6 +1032,17 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
}
|
||||
}
|
||||
}break;
|
||||
case "GLOWNEARBY":{
|
||||
List<Entity> nearby = p.getNearbyEntities(10, 10, 10);
|
||||
for (Entity e : nearby) {
|
||||
if (!(e instanceof Player)) {
|
||||
if (e.getCustomName()!=null) {
|
||||
e.setCustomName(ChatColor.AQUA+e.getCustomName());
|
||||
}
|
||||
GlowAPI.setGlowing(e, GlowAPI.Color.AQUA, p);
|
||||
}
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
//LivingEntity m = MonsterController.convertMonster((Monster)p.getWorld().spawnEntity(p.getLocation(),EntityType.ZOMBIE), MonsterDifficulty.ELITE);
|
||||
@ -5449,6 +5460,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
||||
public void updateHealthbarRespawnEvent(PlayerRespawnEvent ev) {
|
||||
final Player p = ev.getPlayer();
|
||||
//ev.setRespawnLocation(new Location(Bukkit.getWorld("world"),Math.random()*2000-1000,72,Math.random()*2000-1000));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
|
||||
public void run() {
|
||||
if (p!=null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user