Fix Recycling Centers, fix teleportation into nether portals on death,

fix elites going into nether portals.
This commit is contained in:
sigonasr2 2016-08-14 14:36:45 -05:00
parent 551fd81699
commit 8e083867e8
5 changed files with 41 additions and 14 deletions

Binary file not shown.

View File

@ -361,7 +361,7 @@ public class EliteMonster {
m.eject();
}
LivingEntity l = m.getTarget();
if (l!=null) {
if (l!=null && l.getWorld().equals(m.getWorld())) {
if (l.isDead()) {
targetlist.remove(l);
if (targetlist.size()>0) {

View File

@ -3026,7 +3026,7 @@ public class GenericFunctions {
if (damager!=null) {
if (md.hitlist.containsKey(damager.getUniqueId())) {
long time = md.hitlist.get(damager.getUniqueId());
TwosideKeeper.log("Last hit on "+time+". Current time: "+TwosideKeeper.getServerTickTime(), 2);
TwosideKeeper.log("Last hit on "+time+". Current time: "+TwosideKeeper.getServerTickTime(), 5);
if (time+10<TwosideKeeper.getServerTickTime()) {
return true;
}
@ -3036,7 +3036,7 @@ public class GenericFunctions {
} else {
if (md.hitlist.containsKey(m.getUniqueId())) {
long time = md.hitlist.get(m.getUniqueId());
TwosideKeeper.log("->Last hit on "+time+". Current time: "+TwosideKeeper.getServerTickTime(), 2);
TwosideKeeper.log("->Last hit on "+time+". Current time: "+TwosideKeeper.getServerTickTime(), 5);
if (time+10<TwosideKeeper.getServerTickTime()) {
return true;
}
@ -3050,7 +3050,7 @@ public class GenericFunctions {
!(entity instanceof Player)) {
return true;
}
TwosideKeeper.log("Returning false... "+TwosideKeeper.getServerTickTime(), 2);
TwosideKeeper.log("Returning false... "+TwosideKeeper.getServerTickTime(), 5);
return false;
}
@ -3631,16 +3631,34 @@ public class GenericFunctions {
public static Location FindRandomFreeLocation(Location loc) {
Location testloc = loc;
if ((testloc.getBlock().getType()==Material.PORTAL ||
testloc.getBlock().getType()==Material.ENDER_PORTAL) ||
testloc.getBlock().getType()==Material.ENDER_PORTAL ||
testloc.getBlock().getType()==Material.OBSIDIAN) ||
(testloc.getBlock().getRelative(0, 0, 1).getType()==Material.PORTAL ||
testloc.getBlock().getRelative(0, 0, 1).getType()==Material.ENDER_PORTAL) ||
testloc.getBlock().getRelative(0, 0, 1).getType()==Material.ENDER_PORTAL ||
testloc.getBlock().getRelative(0, 0, 1).getType()==Material.OBSIDIAN) ||
(testloc.getBlock().getRelative(0, 0, -1).getType()==Material.PORTAL ||
testloc.getBlock().getRelative(0, 0, -1).getType()==Material.ENDER_PORTAL) ||
testloc.getBlock().getRelative(0, 0, -1).getType()==Material.ENDER_PORTAL ||
testloc.getBlock().getRelative(0, 0, -1).getType()==Material.OBSIDIAN) ||
(testloc.getBlock().getRelative(-1, 0, 0).getType()==Material.PORTAL ||
testloc.getBlock().getRelative(-1, 0, 0).getType()==Material.ENDER_PORTAL) ||
testloc.getBlock().getRelative(-1, 0, 0).getType()==Material.ENDER_PORTAL ||
testloc.getBlock().getRelative(-1, 0, 0).getType()==Material.OBSIDIAN) ||
(testloc.getBlock().getRelative(1, 0, 0).getType()==Material.PORTAL ||
testloc.getBlock().getRelative(1, 0, 0).getType()==Material.ENDER_PORTAL) ||
testloc.getBlock().getRelative(0, 1, 0).getType()!=Material.AIR) {
testloc.getBlock().getRelative(1, 0, 0).getType()==Material.ENDER_PORTAL ||
testloc.getBlock().getRelative(1, 0, 0).getType()==Material.OBSIDIAN) ||
(testloc.getBlock().getRelative(0, 0, 2).getType()==Material.PORTAL ||
testloc.getBlock().getRelative(0, 0, 2).getType()==Material.ENDER_PORTAL ||
testloc.getBlock().getRelative(0, 0, 2).getType()==Material.OBSIDIAN) ||
(testloc.getBlock().getRelative(0, 0, -2).getType()==Material.PORTAL ||
testloc.getBlock().getRelative(0, 0, -2).getType()==Material.ENDER_PORTAL ||
testloc.getBlock().getRelative(0, 0, -2).getType()==Material.OBSIDIAN) ||
(testloc.getBlock().getRelative(-2, 0, 0).getType()==Material.PORTAL ||
testloc.getBlock().getRelative(-2, 0, 0).getType()==Material.ENDER_PORTAL ||
testloc.getBlock().getRelative(-2, 0, 0).getType()==Material.OBSIDIAN) ||
(testloc.getBlock().getRelative(2, 0, 0).getType()==Material.PORTAL ||
testloc.getBlock().getRelative(2, 0, 0).getType()==Material.ENDER_PORTAL ||
testloc.getBlock().getRelative(2, 0, 0).getType()==Material.OBSIDIAN) ||
testloc.getBlock().getRelative(0, 1, 0).getType()!=Material.AIR ||
!testloc.getBlock().getRelative(0, 0, 0).getType().isSolid()) {
do {
testloc = testloc.add(2-Math.random()*4,2-Math.random()*4,2-Math.random()*4);
TwosideKeeper.log("Testing block "+testloc.getBlock().getType(), 2);
@ -3648,6 +3666,6 @@ public class GenericFunctions {
testloc.getBlock().getType()==Material.ENDER_PORTAL) ||
testloc.getBlock().getRelative(0, 1, 0).getType()!=Material.AIR);
}
return testloc;
return testloc.getBlock().getLocation().add(0.5, 1.5, 0.5);
}
}

View File

@ -167,8 +167,7 @@ public class RecyclingCenter {
public void AddItemToRecyclingCenter(Item i) {
//There is a % chance of it going to a recycling center.
if ((GenericFunctions.isArtifactEquip(i.getItemStack())) &&
IsItemAllowed(i.getItemStack())) {
if (IsItemAllowed(i.getItemStack())) {
//Recycle allowed. Now figure out which node to go to.
if (getNumberOfNodes()>0) {
Location rand_node=getRandomNode();

View File

@ -86,6 +86,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityPortalEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
@ -4180,9 +4181,18 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}
}
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
public void onEliteTeleport(EntityPortalEvent ev) {
if (ev.getEntity() instanceof Monster && MonsterController.getMonsterDifficulty((Monster)ev.getEntity()).equals(MonsterDifficulty.ELITE)) {
ev.setTo(ev.getFrom());
ev.setCancelled(true);
}
}
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
public void onEndermanTeleport(EntityTeleportEvent ev) {
if (elitemonsters.contains(ev.getEntity())) {
if (ev.getEntity() instanceof Monster && MonsterController.getMonsterDifficulty((Monster)ev.getEntity()).equals(MonsterDifficulty.ELITE)) {
ev.setTo(ev.getFrom());
ev.setCancelled(true);
}