Thing
This commit is contained in:
parent
0e00086b9e
commit
c5cf306097
@ -5,15 +5,19 @@ import java.util.Collections;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.SoloGame;
|
||||
import nautilus.game.arcade.game.games.evolution.events.EvolutionBeginEvent;
|
||||
import nautilus.game.arcade.game.games.evolution.events.EvolutionEndEvent;
|
||||
import nautilus.game.arcade.game.games.evolution.events.EvolutionPostEvolveEvent;
|
||||
import nautilus.game.arcade.game.games.evolution.evolve.EvolveManager;
|
||||
import nautilus.game.arcade.game.games.evolution.kits.KitAgility;
|
||||
import nautilus.game.arcade.game.games.evolution.kits.KitHealth;
|
||||
import nautilus.game.arcade.game.games.evolution.kits.KitRecharge;
|
||||
@ -29,8 +33,6 @@ import nautilus.game.arcade.game.games.evolution.mobs.KitSpider;
|
||||
import nautilus.game.arcade.game.games.evolution.mobs.KitWolf;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -39,6 +41,8 @@ import org.bukkit.scoreboard.Objective;
|
||||
|
||||
public class Evolution extends SoloGame
|
||||
{
|
||||
private EvolveManager _evolve;
|
||||
|
||||
private ArrayList<Kit> _boosterKits = new ArrayList<Kit>();
|
||||
private ArrayList<EvoKit> _mobKits = new ArrayList<EvoKit>();
|
||||
|
||||
@ -112,6 +116,11 @@ public class Evolution extends SoloGame
|
||||
_evoObj.setDisplaySlot(DisplaySlot.BELOW_NAME);
|
||||
}
|
||||
|
||||
public EvolveManager getEvolve()
|
||||
{
|
||||
return _evolve;
|
||||
}
|
||||
|
||||
//Double Kit
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void storeTokens(GameStateChangeEvent event)
|
||||
@ -129,6 +138,34 @@ public class Evolution extends SoloGame
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void endNoEvolve(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Prepare)
|
||||
return;
|
||||
|
||||
if (WorldData.GetCustomLocs("RED").size() <= 0)
|
||||
{
|
||||
Announce(C.cWhite + C.Bold + GetName() + " ended, map not set up properly!");
|
||||
SetState(GameState.Dead);
|
||||
return;
|
||||
}
|
||||
|
||||
_evolve = new EvolveManager(this, WorldData.GetCustomLocs("RED").get(0));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void tickEvolve(UpdateEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
if (event.getType() != UpdateType.FASTER)
|
||||
return;
|
||||
|
||||
_evolve.tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean HasKit(Player player, Kit kit)
|
||||
{
|
||||
@ -144,6 +181,38 @@ public class Evolution extends SoloGame
|
||||
return false;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onEvolveDamage(CustomDamageEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
if (!(event.GetDamageeEntity() instanceof Player))
|
||||
return;
|
||||
|
||||
if (_evolve.isEvolving(event.GetDamageePlayer()))
|
||||
event.SetCancelled("Player is evolving!");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void startEvolve(EvolutionBeginEvent event)
|
||||
{
|
||||
Manager.GetCondition().Factory().Cloak("Evolution", event.getPlayer(), null, Double.MAX_VALUE, false, false);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void stopEvolve(EvolutionEndEvent event)
|
||||
{
|
||||
upgradeKit(event.getPlayer(), true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void endEvolve(EvolutionPostEvolveEvent event)
|
||||
{
|
||||
Manager.GetCondition().Clean(event.getPlayer());
|
||||
event.getPlayer().teleport(GetTeam(event.getPlayer()).GetSpawn());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onKill(CombatDeathEvent event)
|
||||
{
|
||||
@ -174,36 +243,21 @@ public class Evolution extends SoloGame
|
||||
End();
|
||||
return;
|
||||
}
|
||||
|
||||
if (upgradeKit(killer, true))
|
||||
return;
|
||||
|
||||
killer.teleport(GetTeam(killer).GetSpawn());
|
||||
UtilFirework.playFirework(killer.getEyeLocation(), Type.BALL, Color.GREEN, false, false);
|
||||
}
|
||||
|
||||
//Boolean ending
|
||||
public boolean upgradeKit(Player player, boolean give)
|
||||
public void upgradeKit(Player player, boolean give)
|
||||
{
|
||||
if (!IsAlive(player))
|
||||
return false;
|
||||
return;
|
||||
|
||||
try
|
||||
EvoKit newKit = _mobKits.get(getScore(player));
|
||||
|
||||
SetKit(player, newKit, false);
|
||||
|
||||
if (give)
|
||||
{
|
||||
EvoKit newKit = _mobKits.get(getScore(player));
|
||||
|
||||
SetKit(player, newKit, false);
|
||||
|
||||
if (give)
|
||||
{
|
||||
newKit.upgradeGive(player);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch (IndexOutOfBoundsException ex)
|
||||
{
|
||||
End();
|
||||
return true;
|
||||
newKit.upgradeGive(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,26 @@
|
||||
package nautilus.game.arcade.game.games.evolution.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
public class EvolutionPostEvolveEvent extends PlayerEvent
|
||||
{
|
||||
private static HandlerList _handlers = new HandlerList();
|
||||
|
||||
public EvolutionPostEvolveEvent(Player who)
|
||||
{
|
||||
super(who);
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return _handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return getHandlerList();
|
||||
}
|
||||
}
|
@ -1,11 +1,15 @@
|
||||
package nautilus.game.arcade.game.games.evolution.evolve;
|
||||
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import nautilus.game.arcade.game.games.evolution.events.EvolutionBeginEvent;
|
||||
import nautilus.game.arcade.game.games.evolution.events.EvolutionEndEvent;
|
||||
import nautilus.game.arcade.game.games.evolution.events.EvolutionPostEvolveEvent;
|
||||
import net.minecraft.server.v1_7_R4.EntityBlaze;
|
||||
import net.minecraft.server.v1_7_R4.EntityChicken;
|
||||
import net.minecraft.server.v1_7_R4.EntityCreeper;
|
||||
@ -22,11 +26,13 @@ import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
|
||||
import net.minecraft.server.v1_7_R4.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class EvolveData
|
||||
{
|
||||
@ -34,6 +40,8 @@ public class EvolveData
|
||||
|
||||
private final EvolveManager _manager;
|
||||
|
||||
private boolean _active = true;
|
||||
|
||||
private final Player _player;
|
||||
|
||||
private final EntityType _from;
|
||||
@ -54,6 +62,8 @@ public class EvolveData
|
||||
|
||||
_from = from;
|
||||
_to = to;
|
||||
|
||||
Bukkit.getServer().getPluginManager().callEvent(new EvolutionBeginEvent(_player));
|
||||
}
|
||||
|
||||
//Boolean completed
|
||||
@ -61,10 +71,28 @@ public class EvolveData
|
||||
{
|
||||
teleport();
|
||||
|
||||
if (!_active)
|
||||
{
|
||||
if (!UtilTime.elapsed(_curtime, 4000))
|
||||
return false;
|
||||
|
||||
Bukkit.getServer().getPluginManager().callEvent(new EvolutionPostEvolveEvent(_player));
|
||||
return true;
|
||||
}
|
||||
|
||||
_stage++;
|
||||
|
||||
if (_stage > 12)
|
||||
return true;
|
||||
{
|
||||
_active = false;
|
||||
|
||||
Bukkit.getServer().getPluginManager().callEvent(new EvolutionEndEvent(_player));
|
||||
|
||||
_curtime = System.currentTimeMillis();
|
||||
|
||||
UtilFirework.playFirework(_manager.getLocation().clone().add(0.0, 1.5, 0.0), Type.BALL, Color.GREEN, false, false);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UtilTime.elapsed(_curtime, 1000 * (6 - (_stage / 2))))
|
||||
return false;
|
||||
@ -93,18 +121,13 @@ public class EvolveData
|
||||
|
||||
private void teleport()
|
||||
{
|
||||
Location newLoc = UtilAlg.getTrajectory(_player.getLocation(), newLoc).normalize().toLocation(_player.getWorld());
|
||||
_player.setFlying(true);
|
||||
_player.setHealth(20.0);
|
||||
|
||||
double lead = i * ((2d * Math.PI)/game.GetTeamList().size());
|
||||
double sizeMod = 4;
|
||||
double oX = -Math.sin(lead) * sizeMod;
|
||||
double oZ = Math.cos(lead) * sizeMod;
|
||||
|
||||
//Location
|
||||
Location entLoc = spawn.clone().add(oX, 0, oZ);
|
||||
Location newLoc = UtilAlg.getTrajectory(_player.getLocation(), _manager.getLocation()).normalize().toLocation(_player.getWorld());
|
||||
newLoc.add(Math.cos((Math.PI / 14) * _player.getTicksLived()) * 4.0, .1, Math.sin((Math.PI / 14) * _player.getTicksLived()) * 4.0);
|
||||
|
||||
_player.teleport(_manager.getLocation());
|
||||
|
||||
}
|
||||
|
||||
private EntityInsentient spawn(EntityType type)
|
||||
|
@ -1,15 +1,24 @@
|
||||
package nautilus.game.arcade.game.games.evolution.evolve;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import nautilus.game.arcade.game.games.evolution.Evolution;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class EvolveManager
|
||||
{
|
||||
private Evolution _host;
|
||||
private final Evolution _host;
|
||||
|
||||
private final Location _evolveLoc;
|
||||
|
||||
private NautHashMap<String, EvolveData> _data = new NautHashMap<String, EvolveData>();
|
||||
|
||||
public EvolveManager(Evolution evolution, Location evolveLoc)
|
||||
{
|
||||
_host = evolution;
|
||||
@ -21,4 +30,45 @@ public class EvolveManager
|
||||
return _evolveLoc;
|
||||
}
|
||||
|
||||
public boolean isEvolving(Player player)
|
||||
{
|
||||
return _data.containsKey(player.getName());
|
||||
}
|
||||
|
||||
public void addEvolve(Player player, EntityType from, EntityType to)
|
||||
{
|
||||
if (!_data.containsKey(player.getName()))
|
||||
return;
|
||||
|
||||
_data.put(player.getName(), new EvolveData(this, player, from, to));
|
||||
}
|
||||
|
||||
public void tick()
|
||||
{
|
||||
Iterator<Entry<String, EvolveData>> iterator = _data.entrySet().iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Entry<String, EvolveData> entry = iterator.next();
|
||||
|
||||
Player player = UtilPlayer.searchExact(entry.getKey());
|
||||
|
||||
if (player == null || !player.isOnline())
|
||||
{
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!_host.IsAlive(player))
|
||||
{
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entry.getValue().tick())
|
||||
{
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user