Made player immovable whilst evolving.
This commit is contained in:
parent
75a4b3d568
commit
53395a7700
@ -1,5 +1,6 @@
|
||||
package nautilus.game.arcade.game.games.evolution;
|
||||
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
@ -51,6 +52,7 @@ import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
@ -69,7 +71,7 @@ public class Evolution extends SoloGame
|
||||
|
||||
private NautHashMap<String, EvoToken> _tokens = new NautHashMap<String, EvoToken>();
|
||||
|
||||
private NautHashMap<Location, Location> _evoPlatforms = new NautHashMap<Location, Location>();
|
||||
private NautHashMap<Location, SimpleEntry<Location, Location>> _evoPlatforms = new NautHashMap<Location, SimpleEntry<Location, Location>>();
|
||||
private ArrayList<Location> _spawns = new ArrayList<Location>();
|
||||
|
||||
private ArrayList<Player> _evolutionsAvailable = new ArrayList<Player>();
|
||||
@ -137,22 +139,26 @@ public class Evolution extends SoloGame
|
||||
public void ParseData()
|
||||
{
|
||||
for (Location platform : WorldData.GetDataLocs("RED"))
|
||||
{
|
||||
{
|
||||
platform.getBlock().setType(Material.AIR);
|
||||
|
||||
Iterator<Location> green = WorldData.GetDataLocs("GREEN").iterator();
|
||||
while (green.hasNext())
|
||||
{
|
||||
Location viewing = green.next();
|
||||
|
||||
for (Location viewing : WorldData.GetDataLocs("GREEN"))
|
||||
{
|
||||
viewing.getBlock().setType(Material.AIR);
|
||||
|
||||
if (UtilMath.offset2d(platform, viewing) > 8.0)
|
||||
continue;
|
||||
|
||||
green.remove();
|
||||
_evoPlatforms.put(platform, loadAngle(platform, viewing));
|
||||
break;
|
||||
Iterator<Location> iS = WorldData.GetDataLocs("YELLOW").iterator();
|
||||
while (iS.hasNext())
|
||||
{
|
||||
Location store = iS.next();
|
||||
|
||||
store.getBlock().setType(Material.AIR);
|
||||
|
||||
if (UtilMath.offset(store, viewing) > 8 || UtilMath.offset(store, platform) > 8 || UtilMath.offset(platform, viewing) > 8)
|
||||
continue;
|
||||
|
||||
iS.remove();
|
||||
_evoPlatforms.put(platform, new SimpleEntry<Location, Location>(loadAngle(platform, viewing), store));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -383,7 +389,7 @@ public class Evolution extends SoloGame
|
||||
}
|
||||
|
||||
//Buffs
|
||||
Manager.GetCondition().Factory().Speed("Kill", player, null, 2, 0, true, false, false);
|
||||
Manager.GetCondition().Factory().Speed("Kill", player, null, 3, 0, true, false, false);
|
||||
UtilPlayer.health(player, player.getMaxHealth() / 2);
|
||||
}
|
||||
|
||||
@ -421,6 +427,16 @@ public class Evolution extends SoloGame
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEggFall(BlockPhysicsEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
if (event.getChangedType() == Material.DRAGON_EGG)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler
|
||||
public void updateAvailableEvolutions(UpdateEvent event)
|
||||
@ -514,13 +530,14 @@ public class Evolution extends SoloGame
|
||||
|
||||
int kills = _tokens.get(player.getName()).LifeKills;
|
||||
|
||||
_chargingExp.put(player.getName(), (float) Math.min(exp + Math.max(.002, .012F - .003 * kills), .9999F));
|
||||
_chargingExp.put(player.getName(), (float) Math.min(exp + Math.min(.022, .012 + (kills <= 0 ? 0 : (.002 * (kills - 1)))), .9999F));
|
||||
|
||||
UtilTextMiddle.display("", UtilTextMiddle.progress(_chargingExp.get(player.getName())).trim(), player);
|
||||
|
||||
UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, player.getLocation().clone().add(0, 1, 0), 0.4F, 0.56F, 0.4F, 0, 3, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean hasEvolvingEffects(Player player)
|
||||
{
|
||||
if (!Manager.GetCondition().GetActiveConditions().containsKey(player))
|
||||
|
@ -8,6 +8,7 @@ import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.MapUtil;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
@ -18,6 +19,7 @@ import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
import mineplex.core.hologram.Hologram.HologramTarget;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.packethandler.PacketPlayOutCamera;
|
||||
import nautilus.game.arcade.game.games.evolution.EvoKit;
|
||||
import nautilus.game.arcade.game.games.evolution.events.EvolutionBeginEvent;
|
||||
import nautilus.game.arcade.game.games.evolution.events.EvolutionEndEvent;
|
||||
@ -44,8 +46,10 @@ import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftZombie;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class EvolveData
|
||||
@ -62,6 +66,7 @@ public class EvolveData
|
||||
private final long _preEvolve;
|
||||
private final long _postEvolve;
|
||||
|
||||
private EvolveManager _manager;
|
||||
private HologramManager _holoManager;
|
||||
|
||||
private final PlatformToken _token;
|
||||
@ -69,6 +74,7 @@ public class EvolveData
|
||||
private boolean _active = true;
|
||||
|
||||
private final Player _player;
|
||||
private Zombie _zombie;
|
||||
|
||||
private final Location _eggLoc;
|
||||
private final SimpleEntry<Material, Byte> _eggLocData;
|
||||
@ -83,11 +89,12 @@ public class EvolveData
|
||||
private EntityInsentient _eTo;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public EvolveData(HologramManager holo, PlatformToken token, Player player, EvoKit from, EvoKit to)
|
||||
public EvolveData(EvolveManager manager, HologramManager holo, PlatformToken token, Player player, EvoKit from, EvoKit to)
|
||||
{
|
||||
_preEvolve = 3200;
|
||||
_postEvolve = 3400;
|
||||
|
||||
_manager = manager;
|
||||
_holoManager = holo;
|
||||
|
||||
_token = token;
|
||||
@ -106,6 +113,8 @@ public class EvolveData
|
||||
Bukkit.getServer().getPluginManager().callEvent(new EvolutionBeginEvent(_player));
|
||||
|
||||
setupViewingToken(_eFrom);
|
||||
spawnZombie();
|
||||
setupZombie();
|
||||
setupPlayer();
|
||||
setupEgg();
|
||||
setupHologram(holo, _eFrom, from);
|
||||
@ -132,9 +141,25 @@ public class EvolveData
|
||||
_token.Viewing.setPitch(UtilAlg.GetPitch(viewing));
|
||||
}
|
||||
|
||||
private void spawnZombie()
|
||||
{
|
||||
_manager.Host.CreatureAllowOverride = true;
|
||||
_zombie = (Zombie) _player.getWorld().spawnEntity(_token.Viewing, EntityType.ZOMBIE);
|
||||
_manager.Host.CreatureAllowOverride = true;
|
||||
UtilEnt.Vegetate(_zombie, true);
|
||||
UtilEnt.ghost(_zombie, true, true);
|
||||
}
|
||||
|
||||
private void setupZombie()
|
||||
{
|
||||
((CraftZombie) _zombie).getHandle().getControllerLook().a(((CraftZombie) _zombie).getHandle(), _token.Viewing.getYaw(), _token.Viewing.getPitch());
|
||||
}
|
||||
|
||||
private void setupPlayer()
|
||||
{
|
||||
_player.teleport(_token.Viewing);
|
||||
_player.teleport(_token.Store);
|
||||
|
||||
UtilPlayer.sendPacket(_player, new PacketPlayOutCamera(_zombie.getEntityId()));
|
||||
}
|
||||
|
||||
private void setupHologram(HologramManager manager, EntityInsentient entity, EvoKit kit)
|
||||
@ -163,8 +188,8 @@ public class EvolveData
|
||||
return true;
|
||||
}
|
||||
|
||||
setupZombie();
|
||||
teleport();
|
||||
// updateHologram();
|
||||
|
||||
//Hasn't ended yet
|
||||
if (_active)
|
||||
@ -187,6 +212,7 @@ public class EvolveData
|
||||
despawn(_eFrom);
|
||||
|
||||
setupViewingToken(_eTo);
|
||||
setupZombie();
|
||||
setupPlayer();
|
||||
|
||||
setupHologram(_holoManager, _eTo, _to);
|
||||
@ -242,6 +268,9 @@ public class EvolveData
|
||||
if (_holo != null)
|
||||
_holo.stop();
|
||||
|
||||
UtilPlayer.sendPacket(_player, new PacketPlayOutCamera(_player));
|
||||
_zombie.remove();
|
||||
|
||||
try
|
||||
{
|
||||
_player.teleport(_eggLoc.clone().add(0.5, 0.0, 0.5));
|
||||
|
@ -1,5 +1,6 @@
|
||||
package nautilus.game.arcade.game.games.evolution.evolve;
|
||||
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
@ -25,7 +26,6 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class EvolveManager implements Listener
|
||||
{
|
||||
@ -35,11 +35,11 @@ public class EvolveManager implements Listener
|
||||
|
||||
public final Evolution Host;
|
||||
|
||||
private final NautHashMap<Location, Location> _evolveLocs;
|
||||
private final NautHashMap<Location, SimpleEntry<Location, Location>> _evolveLocs;
|
||||
|
||||
private NautHashMap<String, EvolveData> _data = new NautHashMap<String, EvolveData>();
|
||||
|
||||
public EvolveManager(Evolution evolution, NautHashMap<Location, Location> evolveLocs)
|
||||
public EvolveManager(Evolution evolution, NautHashMap<Location, SimpleEntry<Location, Location>> evolveLocs)
|
||||
{
|
||||
Host = evolution;
|
||||
_evolveLocs = evolveLocs;
|
||||
@ -49,10 +49,10 @@ public class EvolveManager implements Listener
|
||||
|
||||
private PlatformToken getLocation()
|
||||
{
|
||||
ArrayList<Entry<Location, Location>> locs = new ArrayList<Entry<Location, Location>>(_evolveLocs.entrySet());
|
||||
Entry<Location, Location> entry = locs.get(UtilMath.r(locs.size()));
|
||||
ArrayList<Entry<Location, SimpleEntry<Location, Location>>> locs = new ArrayList<Entry<Location, SimpleEntry<Location, Location>>>(_evolveLocs.entrySet());
|
||||
Entry<Location, SimpleEntry<Location, Location>> entry = locs.get(UtilMath.r(locs.size()));
|
||||
|
||||
return new PlatformToken(entry.getKey(), entry.getValue());
|
||||
return new PlatformToken(entry.getKey(), entry.getValue().getKey(), entry.getValue().getValue());
|
||||
}
|
||||
|
||||
public boolean isEvolving(Player player)
|
||||
@ -65,7 +65,7 @@ public class EvolveManager implements Listener
|
||||
if (_data.containsKey(player.getName()))
|
||||
return;
|
||||
|
||||
_data.put(player.getName(), new EvolveData(holo, getLocation(), player, from, to));
|
||||
_data.put(player.getName(), new EvolveData(this, holo, getLocation(), player, from, to));
|
||||
}
|
||||
|
||||
public EvolveData getEvolve(Player player)
|
||||
@ -91,18 +91,36 @@ public class EvolveManager implements Listener
|
||||
|
||||
if (player == null || !player.isOnline())
|
||||
{
|
||||
try
|
||||
{
|
||||
entry.getValue().end();
|
||||
}
|
||||
catch (NullPointerException ex) {}
|
||||
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Host.IsAlive(player))
|
||||
{
|
||||
try
|
||||
{
|
||||
entry.getValue().end();
|
||||
}
|
||||
catch (NullPointerException ex) {}
|
||||
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entry.getValue().tick())
|
||||
{
|
||||
{
|
||||
try
|
||||
{
|
||||
entry.getValue().end();
|
||||
}
|
||||
catch (NullPointerException ex) {}
|
||||
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
@ -119,16 +137,6 @@ public class EvolveManager implements Listener
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLogout(PlayerQuitEvent event)
|
||||
{
|
||||
if (!Host.IsLive())
|
||||
return;
|
||||
|
||||
if (isEvolving(event.getPlayer()))
|
||||
getEvolve(event.getPlayer()).end();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onEvolveDamageRecieve(CustomDamageEvent event)
|
||||
{
|
||||
|
@ -11,10 +11,12 @@ public class PlatformToken
|
||||
|
||||
public final Location Platform;
|
||||
public final Location Viewing;
|
||||
public final Location Store;
|
||||
|
||||
public PlatformToken(Location platform, Location viewing)
|
||||
public PlatformToken(Location platform, Location viewing, Location store)
|
||||
{
|
||||
Platform = platform.clone();
|
||||
Viewing = viewing.clone();
|
||||
Store = store.clone();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user