Fix Elite Zombies causing players to be kicked. Items dropped will

always be invulnerable.
This commit is contained in:
sigonasr2 2016-08-13 01:55:22 -05:00
parent 692bb92bd1
commit c4e49639c6
4 changed files with 22 additions and 38 deletions

Binary file not shown.

View File

@ -279,11 +279,14 @@ public class EliteMonster {
targetlist.add((Player)damager); targetlist.add((Player)damager);
} }
if (!participantlist.contains(damager) && (damager instanceof Player)) { if (!participantlist.contains(damager) && (damager instanceof Player)) {
String name = "";
participantlist.add((Player)damager); participantlist.add((Player)damager);
} }
if (damager instanceof Player) { if (damager instanceof Player) {
Player p = (Player)damager; Player p = (Player)damager;
p.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS,20*2,9),true); if (!p.hasPotionEffect(PotionEffectType.WEAKNESS)) {
p.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS,20*2,9),true);
}
} }
last_regen_time=TwosideKeeper.getServerTickTime(); last_regen_time=TwosideKeeper.getServerTickTime();
double randomrate = 0d; double randomrate = 0d;

View File

@ -3352,7 +3352,7 @@ public class GenericFunctions {
TwosideKeeper.log("Dealt "+basedmg+" raw damage.", 5); TwosideKeeper.log("Dealt "+basedmg+" raw damage.", 5);
//DealDamageToMob(NewCombat.CalculateDamageReduction(basedmg,p,null),(LivingEntity)nearbyentities.get(i),null,null,"Slam"); //DealDamageToMob(NewCombat.CalculateDamageReduction(basedmg,p,null),(LivingEntity)nearbyentities.get(i),null,null,"Slam");
TwosideKeeperAPI.DealDamageToEntity(NewCombat.CalculateDamageReduction(((fullcalculation)?NewCombat.CalculateWeaponDamage(damager, p):1.0)*basedmg,p,null), (Player)players.get(i), damager); TwosideKeeperAPI.DealDamageToEntity(NewCombat.CalculateDamageReduction(((fullcalculation)?NewCombat.CalculateWeaponDamage(damager, p):1.0)*basedmg,p,null), (Player)players.get(i), damager);
if (knockup) { if (knockup && p.getHealth()>0) { //Prevent knockups if we die to the attack.
p.setVelocity(new Vector(0,knockupamt,0)); p.setVelocity(new Vector(0,knockupamt,0));
} }
} else { } else {

View File

@ -3304,25 +3304,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}*/ }*/
} }
} }
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
public void onPlayerKick(PlayerKickEvent ev) {
if (DeathManager.deathStructureExists(ev.getPlayer())) {
DeathStructure ds = DeathManager.getDeathStructure(ev.getPlayer());
Location deathloc = ds.deathloc;
Player p = ev.getPlayer();
deathloc.getWorld().loadChunk(deathloc.getChunk());
for (int i=0;i<p.getOpenInventory().getTopInventory().getSize();i++) {
if (p.getOpenInventory().getTopInventory().getItem(i)!=null &&
p.getOpenInventory().getTopInventory().getItem(i).getType()!=Material.AIR) {
deathloc.getWorld().dropItemNaturally(deathloc, p.getOpenInventory().getTopInventory().getItem(i));
log("Dropping "+p.getOpenInventory().getTopInventory().getItem(i).toString()+" at Death location "+deathloc,3);
}
}
DeathManager.removeDeathStructure(p);
DeathManager.removeDeathStructure(ev.getPlayer());
}
}
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true) @EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
public void onInventoryClick(InventoryClickEvent ev) { public void onInventoryClick(InventoryClickEvent ev) {
@ -3737,9 +3718,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
it.setCustomName((it.getItemStack().getItemMeta().hasDisplayName())?it.getItemStack().getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(it.getItemStack())); it.setCustomName((it.getItemStack().getItemMeta().hasDisplayName())?it.getItemStack().getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(it.getItemStack()));
it.setCustomNameVisible(true); it.setCustomNameVisible(true);
} }
if (GenericFunctions.isArtifactEquip(it.getItemStack())) { it.setInvulnerable(true);
it.setInvulnerable(true);
}
} }
/** /**
@ -4662,21 +4641,23 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
StringBuilder participants_list = new StringBuilder(); StringBuilder participants_list = new StringBuilder();
for (int i=0;i<participants.size();i++) { for (int i=0;i<participants.size();i++) {
Player pl = participants.get(i); Player pl = participants.get(i);
ExperienceOrb exp = GenericFunctions.spawnXP(pl.getLocation(), ev.getDroppedExp()*300); if (pl!=null && pl.isValid() && pl.isOnline()) {
exp.setInvulnerable(true); ExperienceOrb exp = GenericFunctions.spawnXP(pl.getLocation(), ev.getDroppedExp()*300);
GenericFunctions.giveItem(pl,aPlugin.API.getEliteBox()); exp.setInvulnerable(true);
log("Dropping "+aPlugin.API.getEliteBox().toString(),2); GenericFunctions.giveItem(pl,aPlugin.API.getEliteBox());
if (participants_list.length()<1) { log("Dropping "+aPlugin.API.getEliteBox().toString(),2);
participants_list.append(pl.getName()); if (participants_list.length()<1) {
} else { participants_list.append(pl.getName());
if (i==participants.size()-1) {
if (participants.size()==2) {
participants_list.append(" and "+pl.getName());
} else {
participants_list.append(", and "+pl.getName());
}
} else { } else {
participants_list.append(", "+pl.getName()); if (i==participants.size()-1) {
if (participants.size()==2) {
participants_list.append(" and "+pl.getName());
} else {
participants_list.append(", and "+pl.getName());
}
} else {
participants_list.append(", "+pl.getName());
}
} }
} }
} }