Fix movable NPCs

This commit is contained in:
Sam 2017-06-23 01:51:16 +01:00
parent 21c7b082b0
commit 2912968295
2 changed files with 23 additions and 14 deletions

View File

@ -27,6 +27,7 @@ import nautilus.game.arcade.game.games.moba.shop.warrior.MobaWarriorShop;
import nautilus.game.arcade.game.games.moba.util.MobaConstants;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@ -131,7 +132,7 @@ public class MobaShop implements Listener
LivingEntity entity = entry.getKey();
Location location = entry.getValue();
((CraftLivingEntity) entity).getHandle().setPosition(location.getX(), location.getY(), location.getZ());
((CraftEntity) entity).getHandle().setPosition(location.getX(), location.getY(), location.getZ());
}
}
@ -253,7 +254,7 @@ public class MobaShop implements Listener
public void clearPurchases(Player player)
{
_upgrades.remove(player);
_upgrades.put(player, new ArrayList<>());
}
@EventHandler
@ -327,6 +328,11 @@ public class MobaShop implements Listener
Player player = event.getPlayer();
List<MobaItem> items = _upgrades.get(player);
if (items == null)
{
return;
}
for (MobaItem item : items)
{
if (item.getEffects() == null)

View File

@ -21,6 +21,7 @@ import nautilus.game.arcade.game.games.moba.MobaPlayer;
import nautilus.game.arcade.game.games.moba.kit.HeroKit;
import nautilus.game.arcade.game.modules.CustomScoreboardModule;
import nautilus.game.arcade.game.modules.TrainingGameModule;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.scoreboard.GameScoreboard;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@ -34,11 +35,10 @@ import org.bukkit.entity.Villager.Profession;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import java.util.HashSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
@ -110,7 +110,7 @@ public class MobaTraining extends Moba
private Location _selectKit;
private LivingEntity _selectKitEntity;
private final Set<LivingEntity> _entities = new HashSet<>();
private final Map<LivingEntity, Location> _entities = new HashMap<>();
public MobaTraining(ArcadeManager manager)
{
@ -347,7 +347,7 @@ public class MobaTraining extends Moba
spawnDummies();
spawnNPCs();
for (LivingEntity entity : _entities)
for (LivingEntity entity : _entities.keySet())
{
entity.setCustomNameVisible(true);
UtilEnt.vegetate(entity);
@ -361,7 +361,7 @@ public class MobaTraining extends Moba
@EventHandler
public void entityDamage(CustomDamageEvent event)
{
if (!_entities.contains(event.GetDamageeEntity()))
if (!_entities.containsKey(event.GetDamageeEntity()))
{
return;
}
@ -391,9 +391,11 @@ public class MobaTraining extends Moba
return;
}
for (LivingEntity entity : _entities)
for (Entry<LivingEntity, Location> entry : _entities.entrySet())
{
Location location = entity.getLocation();
LivingEntity entity = entry.getKey();
Location location = entry.getValue();
((CraftEntity) entity).getHandle().setPosition(location.getX(), location.getY(), location.getZ());
}
}
@ -430,7 +432,7 @@ public class MobaTraining extends Moba
skeleton.setCustomName(C.cDRedB + "Pumpkin King");
UtilEnt.CreatureLook(skeleton, 90);
_entities.add(skeleton);
_entities.put(skeleton, skeleton.getLocation());
}
{
Location location = WorldData.GetCustomLocs("DUMMY_WITHER").get(0);
@ -446,7 +448,7 @@ public class MobaTraining extends Moba
disguise.setCustomNameVisible(true);
Manager.GetDisguise().disguise(disguise);
_entities.add(stand);
_entities.put(stand, stand.getLocation());
}
{
Location location = WorldData.GetCustomLocs("DUMMY_SHOP").get(0);
@ -454,7 +456,7 @@ public class MobaTraining extends Moba
villager.setProfession(Profession.LIBRARIAN);
villager.setCustomName(C.cGoldB + "Gold Upgrades");
_entities.add(villager);
_entities.put(villager, villager.getLocation());
}
}
@ -464,13 +466,14 @@ public class MobaTraining extends Moba
villager.setCustomName(C.cYellowB + "Select A Hero");
UtilEnt.CreatureLook(villager, GetTeam(ChatColor.YELLOW).GetSpawns().get(0));
_entities.add(villager);
_entities.put(villager, villager.getLocation());
_selectKitEntity = villager;
}
public void teleportIntoArena(Player player, HeroKit kit)
{
if (!kit.equals(GetKit(player)))
Kit currentKit = GetKit(player);
if (currentKit == null || !kit.equals(currentKit))
{
_shop.clearPurchases(player);
}