Created a new way to Evolve.
• Getting a kill presents you the option "Hold Shift to Evolve" • Holding shift for about 5 seconds evolves you as normal.
This commit is contained in:
parent
d9a8830e75
commit
158dcdc01e
@ -7,17 +7,21 @@ import java.util.Iterator;
|
|||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.common.util.UtilAlg;
|
import mineplex.core.common.util.UtilAlg;
|
||||||
|
import mineplex.core.common.util.UtilBlock;
|
||||||
|
import mineplex.core.common.util.UtilEnt;
|
||||||
import mineplex.core.common.util.UtilEvent;
|
import mineplex.core.common.util.UtilEvent;
|
||||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||||
import mineplex.core.common.util.UtilGear;
|
|
||||||
import mineplex.core.common.util.UtilInv;
|
|
||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
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.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.common.util.UtilTextMiddle;
|
import mineplex.core.common.util.UtilTextMiddle;
|
||||||
import mineplex.core.itemstack.ItemBuilder;
|
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
import mineplex.minecraft.game.core.combat.CombatComponent;
|
||||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||||
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
||||||
import mineplex.minecraft.game.core.condition.ConditionActive;
|
import mineplex.minecraft.game.core.condition.ConditionActive;
|
||||||
@ -42,15 +46,17 @@ import nautilus.game.arcade.game.games.evolution.mobs.KitSpider;
|
|||||||
import nautilus.game.arcade.game.games.evolution.mobs.KitWolf;
|
import nautilus.game.arcade.game.games.evolution.mobs.KitWolf;
|
||||||
import nautilus.game.arcade.kit.Kit;
|
import nautilus.game.arcade.kit.Kit;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public class Evolution extends SoloGame
|
public class Evolution extends SoloGame
|
||||||
@ -70,7 +76,6 @@ public class Evolution extends SoloGame
|
|||||||
private NautHashMap<Location, Location> _evoPlatforms = new NautHashMap<Location, Location>();
|
private NautHashMap<Location, Location> _evoPlatforms = new NautHashMap<Location, Location>();
|
||||||
|
|
||||||
private ArrayList<Player> _evolutionsAvailable = new ArrayList<Player>();
|
private ArrayList<Player> _evolutionsAvailable = new ArrayList<Player>();
|
||||||
private ArrayList<Player> _attemptingEvolve = new ArrayList<Player>();
|
|
||||||
|
|
||||||
public Evolution(ArcadeManager manager)
|
public Evolution(ArcadeManager manager)
|
||||||
{
|
{
|
||||||
@ -79,7 +84,8 @@ public class Evolution extends SoloGame
|
|||||||
new Kit[0],
|
new Kit[0],
|
||||||
new String[]
|
new String[]
|
||||||
{
|
{
|
||||||
"You evolve when you get a kill.",
|
"You recieve an Evolution token every 2 kills.",
|
||||||
|
"Use it to Evolve into a new mob.",
|
||||||
"Each evolution has unique skills.",
|
"Each evolution has unique skills.",
|
||||||
"First to get through 10 evolutions wins!"
|
"First to get through 10 evolutions wins!"
|
||||||
});
|
});
|
||||||
@ -182,6 +188,9 @@ public class Evolution extends SoloGame
|
|||||||
_tokens.put(player.getName(), new EvoToken(player));
|
_tokens.put(player.getName(), new EvoToken(player));
|
||||||
|
|
||||||
upgradeKit(player, false);
|
upgradeKit(player, false);
|
||||||
|
|
||||||
|
player.setLevel(0);
|
||||||
|
player.setExp(0F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,12 +296,23 @@ public class Evolution extends SoloGame
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (increaseScore(event.getPlayer()) >= 10)
|
||||||
|
{
|
||||||
|
ScoreboardUpdate(new UpdateEvent(UpdateType.FAST));
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
End();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
upgradeKit(event.getPlayer(), true);
|
upgradeKit(event.getPlayer(), true);
|
||||||
event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.LEVEL_UP, 1, 0.6F);
|
event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.LEVEL_UP, 1, 0.6F);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void endEvolve(EvolutionPostEvolveEvent event)
|
public void endEvolve(final EvolutionPostEvolveEvent event)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -300,7 +320,31 @@ public class Evolution extends SoloGame
|
|||||||
}
|
}
|
||||||
catch (NullPointerException ex){}
|
catch (NullPointerException ex){}
|
||||||
|
|
||||||
event.getPlayer().teleport(GetTeam(event.getPlayer()).GetSpawn());
|
if (getScore(event.getPlayer()) >= 10)
|
||||||
|
{
|
||||||
|
End();
|
||||||
|
}
|
||||||
|
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugins()[0], new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
GetKit(event.getPlayer()).ApplyKit(event.getPlayer());
|
||||||
|
}
|
||||||
|
}, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onDeath(PlayerDeathEvent event)
|
||||||
|
{
|
||||||
|
if (!IsLive())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_evolutionsAvailable.contains(event.getEntity()))
|
||||||
|
{
|
||||||
|
_evolutionsAvailable.remove(event.getEntity());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -309,54 +353,54 @@ public class Evolution extends SoloGame
|
|||||||
if (!IsLive())
|
if (!IsLive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!event.GetLog().GetKiller().IsPlayer())
|
CombatComponent damager = event.GetLog().GetKiller();
|
||||||
|
|
||||||
|
if (!damager.IsPlayer())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
|
Player player = UtilPlayer.searchExact(damager.GetName());
|
||||||
|
|
||||||
if (killer == null || !killer.isOnline())
|
if (player == null || !player.isOnline())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!IsAlive(killer))
|
if (!IsAlive(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (killer == event.GetEvent().getEntity())
|
if (((Player) event.GetEvent().getEntity()) == player)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
increaseScore(killer);
|
if (!_evolutionsAvailable.contains(player))
|
||||||
|
|
||||||
ScoreboardUpdate(new UpdateEvent(UpdateType.FAST));
|
|
||||||
|
|
||||||
if (getScore(killer) >= 10)
|
|
||||||
{
|
{
|
||||||
End();
|
_evolutionsAvailable.add(player);
|
||||||
return;
|
|
||||||
|
player.setLevel(0);
|
||||||
|
player.setExp(0F);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_evolutionsAvailable.add(killer);
|
@EventHandler
|
||||||
// EvoToken token = _tokens.get(killer.getName());
|
public void onEgg(PlayerInteractEvent event)
|
||||||
//
|
{
|
||||||
// try
|
if (!IsLive())
|
||||||
// {
|
return;
|
||||||
// EvoKit from = _mobKits.get(token.Kills - 1); //Account for the score increase
|
|
||||||
// EvoKit to = _mobKits.get(token.Kills);
|
if (!UtilEvent.isAction(event, ActionType.R_BLOCK) && !UtilEvent.isAction(event, ActionType.L_BLOCK))
|
||||||
//
|
return;
|
||||||
// _evolve.addEvolve(killer, from, to);
|
|
||||||
// }
|
if (event.getClickedBlock().getType() == Material.DRAGON_EGG)
|
||||||
// catch (IndexOutOfBoundsException ex)
|
{
|
||||||
// {
|
event.setCancelled(true);
|
||||||
// End();
|
return;
|
||||||
// return;
|
}
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void updateAvailableEvolutions(UpdateEvent event)
|
public void updateAvailableEvolutions(UpdateEvent event)
|
||||||
{
|
{
|
||||||
if (event.getType() != UpdateType.TICK)
|
if (!IsLive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!IsLive())
|
if (event.getType() != UpdateType.TICK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Iterator<Player> iterator = _evolutionsAvailable.iterator();
|
Iterator<Player> iterator = _evolutionsAvailable.iterator();
|
||||||
@ -367,87 +411,81 @@ public class Evolution extends SoloGame
|
|||||||
if (player == null || !player.isOnline())
|
if (player == null || !player.isOnline())
|
||||||
{
|
{
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsAlive(player))
|
if (!IsAlive(player))
|
||||||
{
|
{
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_attemptingEvolve.contains(player))
|
if (player.isSneaking())
|
||||||
{
|
{
|
||||||
UtilTextMiddle.display("", C.cGreen + C.Bold + "Evolution Available!");
|
if (onEvolveAttempting(player))
|
||||||
|
{
|
||||||
|
iterator.remove();
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!UtilGear.isMat(player.getInventory().getItem(7), Material.STAINED_CLAY))
|
|
||||||
{
|
|
||||||
player.getInventory().setItem(7, new ItemBuilder(Material.STAINED_CLAY).build());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Rainbow effect on the clay
|
if (player.getExp() != 0F)
|
||||||
ItemStack item = player.getInventory().getItem(7);
|
player.setExp(0F);
|
||||||
byte data = UtilInv.GetData(item);
|
|
||||||
|
|
||||||
data++;
|
if (player.getLevel() != 0)
|
||||||
|
player.setLevel(0);
|
||||||
|
|
||||||
if (data > 15)
|
if (Recharge.Instance.use(player, "Evolve Available", 2000, false, false))
|
||||||
data = 0;
|
|
||||||
|
|
||||||
item.setDurability(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onInteractWithEvolve(PlayerInteractEvent event)
|
|
||||||
{
|
{
|
||||||
if (!UtilEvent.isAction(event, ActionType.R))
|
UtilTextMiddle.display("", C.cGreen + C.Bold + "Hold Shift to Evolve", 0, 60, 20, player);
|
||||||
return;
|
}
|
||||||
|
}
|
||||||
if (!IsLive())
|
}
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.getItem().getType() != Material.STAINED_CLAY)
|
|
||||||
return;
|
|
||||||
|
|
||||||
//Make sure it's the 7 slot
|
|
||||||
if (event.getPlayer().getInventory().getItem(7) != event.getItem())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (_attemptingEvolve.contains(event.getPlayer()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
_attemptingEvolve.add(event.getPlayer());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
//Boolean remove
|
||||||
public void updateAttemptingEvolve(UpdateEvent event)
|
@SuppressWarnings("deprecation")
|
||||||
|
private boolean onEvolveAttempting(Player player)
|
||||||
{
|
{
|
||||||
if (event.getType() != UpdateType.TICK)
|
//No evolving in midair
|
||||||
return;
|
if (!player.isOnGround() || !UtilEnt.isGrounded(player) || !UtilBlock.solid(player.getLocation().getBlock().getRelative(BlockFace.DOWN)))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!IsLive())
|
if (player.getExp() >= .9999F)
|
||||||
return;
|
|
||||||
|
|
||||||
Iterator<Player> iterator = _attemptingEvolve.iterator();
|
|
||||||
while (iterator.hasNext())
|
|
||||||
{
|
{
|
||||||
Player player = iterator.next();
|
UtilTextMiddle.display("", "", player);
|
||||||
|
|
||||||
|
player.setExp(0F);
|
||||||
|
player.setLevel(0);
|
||||||
|
|
||||||
|
EvoToken token = _tokens.get(player.getName());
|
||||||
|
|
||||||
|
EvoKit from = _mobKits.get(token.Level);
|
||||||
|
EvoKit to = _mobKits.get((token.Level + 1) >= _mobKits.size() ? token.Level : token.Level + 1); //Account for the score increase after evolve
|
||||||
|
|
||||||
|
_evolve.addEvolve(Manager.getHologramManager(), player, from, to);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
`}
|
|
||||||
|
|
||||||
public void increaseScore(Player player)
|
player.setExp(Math.min(player.getExp() + .008F, .9999F));
|
||||||
|
|
||||||
|
UtilTextMiddle.display("", UtilTextMiddle.progress(player.getExp()).trim(), player);
|
||||||
|
|
||||||
|
UtilParticle.PlayParticle(ParticleType.PORTAL, player.getLocation().clone().add(0, 1, 0), 0.5F, 1.0F, 0.5F, 0, 5, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int increaseScore(Player player)
|
||||||
{
|
{
|
||||||
if (!IsAlive(player))
|
if (!IsAlive(player))
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
if (!_tokens.containsKey(player.getName()))
|
if (!_tokens.containsKey(player.getName()))
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
_tokens.get(player.getName()).Level++;
|
_tokens.get(player.getName()).Level++;
|
||||||
|
return getScore(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getScore(Player player)
|
public int getScore(Player player)
|
||||||
@ -485,6 +523,10 @@ public class Evolution extends SoloGame
|
|||||||
if (player.isOnline())
|
if (player.isOnline())
|
||||||
AddGems(player, 10, "Participation", false, false);
|
AddGems(player, 10, "Participation", false, false);
|
||||||
|
|
||||||
|
_tokens.clear();
|
||||||
|
_evoPlatforms.clear();
|
||||||
|
_evolutionsAvailable.clear();
|
||||||
|
|
||||||
_evolve.end();
|
_evolve.end();
|
||||||
SetState(GameState.End);
|
SetState(GameState.End);
|
||||||
AnnounceEnd(players);
|
AnnounceEnd(players);
|
||||||
|
@ -1,16 +1,19 @@
|
|||||||
package nautilus.game.arcade.game.games.evolution.events;
|
package nautilus.game.arcade.game.games.evolution.events;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.player.PlayerEvent;
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
|
|
||||||
public class EvolutionEndEvent extends PlayerEvent
|
public class EvolutionEndEvent extends PlayerEvent implements Cancellable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @author Mysticate
|
* @author Mysticate
|
||||||
*/
|
*/
|
||||||
private static HandlerList _handlers = new HandlerList();
|
private static HandlerList _handlers = new HandlerList();
|
||||||
|
|
||||||
|
private boolean _cancelled = false;
|
||||||
|
|
||||||
public EvolutionEndEvent(Player who)
|
public EvolutionEndEvent(Player who)
|
||||||
{
|
{
|
||||||
super(who);
|
super(who);
|
||||||
@ -26,4 +29,16 @@ public class EvolutionEndEvent extends PlayerEvent
|
|||||||
{
|
{
|
||||||
return getHandlerList();
|
return getHandlerList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled()
|
||||||
|
{
|
||||||
|
return _cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean flag)
|
||||||
|
{
|
||||||
|
_cancelled = flag;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,21 @@
|
|||||||
package nautilus.game.arcade.game.games.evolution.evolve;
|
package nautilus.game.arcade.game.games.evolution.evolve;
|
||||||
|
|
||||||
|
import java.util.AbstractMap.SimpleEntry;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.UtilAction;
|
||||||
|
import mineplex.core.common.util.UtilAlg;
|
||||||
import mineplex.core.common.util.UtilFirework;
|
import mineplex.core.common.util.UtilFirework;
|
||||||
import mineplex.core.common.util.UtilParticle;
|
import mineplex.core.common.util.UtilParticle;
|
||||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
|
import mineplex.core.hologram.Hologram;
|
||||||
|
import mineplex.core.hologram.HologramManager;
|
||||||
import nautilus.game.arcade.game.games.evolution.EvoKit;
|
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.EvolutionBeginEvent;
|
||||||
import nautilus.game.arcade.game.games.evolution.events.EvolutionEndEvent;
|
import nautilus.game.arcade.game.games.evolution.events.EvolutionEndEvent;
|
||||||
@ -30,6 +40,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.FireworkEffect.Type;
|
import org.bukkit.FireworkEffect.Type;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -45,23 +56,40 @@ public class EvolveData
|
|||||||
private final long _timestamp = System.currentTimeMillis();
|
private final long _timestamp = System.currentTimeMillis();
|
||||||
private long _endTime = System.currentTimeMillis();
|
private long _endTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
private final long _preEvolve;
|
||||||
|
private final long _postEvolve;
|
||||||
|
|
||||||
private final PlatformToken _token;
|
private final PlatformToken _token;
|
||||||
|
|
||||||
private boolean _active = true;
|
private boolean _active = true;
|
||||||
|
|
||||||
private final Player _player;
|
private final Player _player;
|
||||||
|
|
||||||
|
private final Location _eggLoc;
|
||||||
|
private final SimpleEntry<Material, Byte> _eggLocData;
|
||||||
|
|
||||||
|
private final Hologram _eggHolo;
|
||||||
|
|
||||||
private final EvoKit _to;
|
private final EvoKit _to;
|
||||||
|
|
||||||
private final EntityInsentient _eFrom;
|
private final EntityInsentient _eFrom;
|
||||||
private EntityInsentient _eTo;
|
private EntityInsentient _eTo;
|
||||||
|
|
||||||
public EvolveData(PlatformToken token, Player player, EvoKit from, EvoKit to)
|
@SuppressWarnings("deprecation")
|
||||||
|
public EvolveData(HologramManager holo, PlatformToken token, Player player, EvoKit from, EvoKit to)
|
||||||
{
|
{
|
||||||
|
_preEvolve = 3200;
|
||||||
|
_postEvolve = 3400;
|
||||||
|
|
||||||
_token = token;
|
_token = token;
|
||||||
|
|
||||||
_player = player;
|
_player = player;
|
||||||
|
|
||||||
|
_eggLoc = player.getLocation().getBlock().getLocation();
|
||||||
|
_eggLocData = new SimpleEntry<Material, Byte>(_eggLoc.getBlock().getType(), _eggLoc.getBlock().getData());
|
||||||
|
|
||||||
|
_eggHolo = new Hologram(holo, _eggLoc.clone().add(0.5, 1.0, 0.5), C.cYellow + _player.getName()).setViewDistance(20).start();
|
||||||
|
|
||||||
_to = to;
|
_to = to;
|
||||||
|
|
||||||
_eFrom = spawn(from.getEntity(), token.Platform, false);
|
_eFrom = spawn(from.getEntity(), token.Platform, false);
|
||||||
@ -69,11 +97,24 @@ public class EvolveData
|
|||||||
Bukkit.getServer().getPluginManager().callEvent(new EvolutionBeginEvent(_player));
|
Bukkit.getServer().getPluginManager().callEvent(new EvolutionBeginEvent(_player));
|
||||||
|
|
||||||
setupPlayer();
|
setupPlayer();
|
||||||
|
setupEgg();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupEgg()
|
||||||
|
{
|
||||||
|
_eggLoc.getBlock().setType(Material.DRAGON_EGG);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
private void restoreEgg()
|
||||||
|
{
|
||||||
|
_eggLoc.getBlock().setType(_eggLocData.getKey());
|
||||||
|
_eggLoc.getBlock().setData(_eggLocData.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupPlayer()
|
private void setupPlayer()
|
||||||
{
|
{
|
||||||
_player.teleport(_token.Viewing);
|
_player.teleport(_token.Viewing.clone().add(0.5, 0.0, 0.5));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Boolean completed
|
//Boolean completed
|
||||||
@ -86,22 +127,29 @@ public class EvolveData
|
|||||||
}
|
}
|
||||||
|
|
||||||
teleport();
|
teleport();
|
||||||
|
// updateHologram();
|
||||||
|
|
||||||
//Hasn't ended yet
|
//Hasn't ended yet
|
||||||
if (_active)
|
if (_active)
|
||||||
{
|
{
|
||||||
//If 3 seconds past
|
//If 3 seconds past
|
||||||
if (UtilTime.elapsed(_timestamp, 3200))
|
if (UtilTime.elapsed(_timestamp, _preEvolve))
|
||||||
{
|
{
|
||||||
_active = false;
|
_active = false;
|
||||||
_endTime = System.currentTimeMillis();
|
_endTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
EvolutionEndEvent event = new EvolutionEndEvent(_player);
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
if (event.isCancelled())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
_eTo = spawn(_to.getEntity(), _token.Platform, false);
|
_eTo = spawn(_to.getEntity(), _token.Platform, false);
|
||||||
despawn(_eFrom);
|
despawn(_eFrom);
|
||||||
|
|
||||||
UtilFirework.playFirework(_token.Platform.clone().add(0.0, 1.5, 0.0), Type.BALL, Color.GREEN, false, false);
|
UtilFirework.playFirework(_token.Platform.clone().add(0.0, 1.5, 0.0), Type.BALL, Color.GREEN, false, false);
|
||||||
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new EvolutionEndEvent(_player));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -109,18 +157,33 @@ public class EvolveData
|
|||||||
if (UtilTime.elapsed(_timestamp, 500))
|
if (UtilTime.elapsed(_timestamp, 500))
|
||||||
{
|
{
|
||||||
UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, _token.Platform.clone().add(0.0, 1.0, 0.0), 0.5F, 1.0F, 0.5F, 0, 5, ViewDist.SHORT, _player);
|
UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, _token.Platform.clone().add(0.0, 1.0, 0.0), 0.5F, 1.0F, 0.5F, 0, 5, ViewDist.SHORT, _player);
|
||||||
|
UtilParticle.PlayParticle(ParticleType.PORTAL, _eggLoc, 0.5F, 1.0F, 0.5F, 0, 5, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!UtilTime.elapsed(_endTime, 3000))
|
if (!UtilTime.elapsed(_endTime, _postEvolve))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
despawn(_eTo);
|
despawn(_eTo);
|
||||||
|
_eggHolo.stop();
|
||||||
|
|
||||||
|
restoreEgg();
|
||||||
|
_player.teleport(_eggLoc);
|
||||||
|
|
||||||
|
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, _eggLoc.clone().add(0.0, 1.0, 0.0), 2.0F, 2.0F, 2.0F, 0, 8, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||||
|
knockback();
|
||||||
|
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugins()[0], new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new EvolutionPostEvolveEvent(_player));
|
Bukkit.getServer().getPluginManager().callEvent(new EvolutionPostEvolveEvent(_player));
|
||||||
|
}
|
||||||
|
}, 4);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,6 +199,10 @@ public class EvolveData
|
|||||||
if (_eTo != null)
|
if (_eTo != null)
|
||||||
despawn(_eTo);
|
despawn(_eTo);
|
||||||
|
|
||||||
|
_eggHolo.stop();
|
||||||
|
restoreEgg();
|
||||||
|
|
||||||
|
_player.teleport(_eggLoc.clone().add(0.5, 0.0, 0.5));
|
||||||
_ended = true;
|
_ended = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,6 +211,19 @@ public class EvolveData
|
|||||||
setupPlayer();
|
setupPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void knockback()
|
||||||
|
{
|
||||||
|
HashMap<Player, Double> radius = UtilPlayer.getInRadius(_eggLoc, 8.0);
|
||||||
|
|
||||||
|
for (Entry<Player, Double> entry : radius.entrySet())
|
||||||
|
{
|
||||||
|
if (entry.getKey() == _player)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
UtilAction.velocity(entry.getKey(), UtilAlg.getTrajectory2d(_eggLoc, entry.getKey().getLocation()), 1.6 - (entry.getValue() / 10), true, 0.8, 0, 10, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private EntityInsentient spawn(EntityType type, Location loc, boolean invisible)
|
private EntityInsentient spawn(EntityType type, Location loc, boolean invisible)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -7,6 +7,7 @@ import java.util.Map.Entry;
|
|||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.hologram.HologramManager;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
@ -58,12 +59,12 @@ public class EvolveManager implements Listener
|
|||||||
return _data.containsKey(player.getName());
|
return _data.containsKey(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addEvolve(Player player, EvoKit from, EvoKit to)
|
public void addEvolve(HologramManager holo, Player player, EvoKit from, EvoKit to)
|
||||||
{
|
{
|
||||||
if (_data.containsKey(player.getName()))
|
if (_data.containsKey(player.getName()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_data.put(player.getName(), new EvolveData(getLocation(), player, from, to));
|
_data.put(player.getName(), new EvolveData(holo, getLocation(), player, from, to));
|
||||||
}
|
}
|
||||||
|
|
||||||
public EvolveData getEvolve(Player player)
|
public EvolveData getEvolve(Player player)
|
||||||
|
Loading…
Reference in New Issue
Block a user