diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/nano/NanoDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/nano/NanoDisplay.java index 3465f8df9..1cac38ce8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/nano/NanoDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/nano/NanoDisplay.java @@ -33,6 +33,7 @@ public enum NanoDisplay implements Display SPLOOR(21, "Sploor", Material.DIAMOND_BARDING), TERRITORY(22, "Slime Territory", Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.SLIME)), MINEKART(23, "MineKart", Material.COMMAND_MINECART), + WIZARDS(24, "Nano Wizards", Material.BLAZE_ROD), ; public static NanoDisplay getFromId(int gameId) diff --git a/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/GameType.java b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/GameType.java index b88b455aa..cf015d8e9 100644 --- a/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/GameType.java +++ b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/GameType.java @@ -28,6 +28,7 @@ import mineplex.game.nano.game.games.slimecycles.SlimeCycles; import mineplex.game.nano.game.games.spleef.Spleef; import mineplex.game.nano.game.games.sploor.Sploor; import mineplex.game.nano.game.games.territory.Territory; +import mineplex.game.nano.game.games.wizards.Wizards; public enum GameType { @@ -54,7 +55,10 @@ public enum GameType BAWK_BAWK(BawkBawk.class, NanoDisplay.BAWK_BAWK), QUICK(Quick.class, NanoDisplay.QUICK), DROPPER(Dropper.class, NanoDisplay.DROPPER), - MINEKART(MineKart.class, NanoDisplay.MINEKART); + MINEKART(MineKart.class, NanoDisplay.MINEKART), + WIZARDS(Wizards.class, NanoDisplay.WIZARDS, mapsFromArcade(GameDisplay.Wizards)), + + ; private static String maps() { diff --git a/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/components/player/DoubleJumpComponent.java b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/components/player/DoubleJumpComponent.java index eefdbbb84..159e2d869 100644 --- a/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/components/player/DoubleJumpComponent.java +++ b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/components/player/DoubleJumpComponent.java @@ -19,6 +19,7 @@ public class DoubleJumpComponent extends GameComponent { private double _magnitude = 1.2; + private boolean _directional; public DoubleJumpComponent(Game game) { @@ -37,6 +38,12 @@ public class DoubleJumpComponent extends GameComponent return this; } + public DoubleJumpComponent setDirectional(boolean directional) + { + _directional = directional; + return this; + } + @EventHandler(priority = EventPriority.HIGH) public void updateJump(UpdateEvent event) { @@ -70,7 +77,17 @@ public class DoubleJumpComponent extends GameComponent } Vector velocity = player.getLocation().getDirection(); - velocity.setY(velocity.getY() + 0.2).multiply(_magnitude); + + if (_directional) + { + velocity.setY(velocity.getY() + 0.2); + } + else + { + velocity.setY(0.4); + } + + velocity.multiply(_magnitude); UtilAction.velocity(player, velocity); event.setCancelled(true); diff --git a/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/kingslime/KingSlime.java b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/kingslime/KingSlime.java index 13c575b30..344dcdd69 100644 --- a/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/kingslime/KingSlime.java +++ b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/kingslime/KingSlime.java @@ -70,7 +70,7 @@ public class KingSlime extends ScoredSoloGame _endComponent.setTimeout(TimeUnit.SECONDS.toMillis(80)); - new DoubleJumpComponent(this); + new DoubleJumpComponent(this).setDirectional(true); } @Override diff --git a/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/wizards/Spell.java b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/wizards/Spell.java new file mode 100644 index 000000000..a30fd1c73 --- /dev/null +++ b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/wizards/Spell.java @@ -0,0 +1,98 @@ +package mineplex.game.nano.game.games.wizards; + +import java.util.Collections; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.lifetimes.Lifetime; +import mineplex.core.lifetimes.Lifetimed; +import mineplex.core.lifetimes.ListenerComponent; +import mineplex.core.recharge.Recharge; +import mineplex.game.nano.game.Game.GameState; + +public abstract class Spell extends ListenerComponent implements Lifetimed +{ + + public enum SpellType + { + Attack, + Defense, + Utility + } + + protected final Wizards _game; + private final String _name; + private final ItemStack _itemStack; + private final long _cooldown; + + public Spell(Wizards game, String name, SpellType spellType, ItemStack itemStack, long cooldown) + { + _game = game; + _name = name; + _itemStack = new ItemBuilder(itemStack) + .setTitle(C.cGreen + name + C.cGray + " - [" + C.cGold + spellType.toString() + C.cGray + "]") + .addLore("Right-Click to use this spell!") + .build(); + _cooldown = cooldown; + + game.getLifetime().register(this, Collections.singletonList(GameState.Live)); + } + + protected abstract void onSpellUse(Player player); + + @EventHandler + public void playerInteract(PlayerInteractEvent event) + { + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + Player player = event.getPlayer(); + + if (UtilPlayer.isSpectator(player)) + { + return; + } + + ItemStack itemStack = player.getItemInHand(); + + if (!_itemStack.equals(itemStack)) + { + return; + } + + event.setCancelled(true); + + if (!Recharge.Instance.use(player, _name, _cooldown, true, true)) + { + return; + } + + onSpellUse(player); + } + + public String getName() + { + return _name; + } + + public ItemStack getItemStack() + { + return _itemStack; + } + + @Override + public Lifetime getLifetime() + { + return _game.getLifetime(); + } +} diff --git a/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/wizards/Wizards.java b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/wizards/Wizards.java new file mode 100644 index 000000000..e8769ae0c --- /dev/null +++ b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/wizards/Wizards.java @@ -0,0 +1,166 @@ +package mineplex.game.nano.game.games.wizards; + +import java.util.concurrent.TimeUnit; + +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.UtilBlock; +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.itemstack.ItemBuilder; +import mineplex.game.nano.NanoManager; +import mineplex.game.nano.game.GameType; +import mineplex.game.nano.game.ScoredSoloGame; +import mineplex.game.nano.game.components.player.DoubleJumpComponent; +import mineplex.game.nano.game.components.player.GiveItemComponent; +import mineplex.game.nano.game.event.PlayerGameRespawnEvent; +import mineplex.game.nano.game.games.wizards.spells.SpellFireball; +import mineplex.game.nano.game.games.wizards.spells.SpellFortify; +import mineplex.game.nano.game.games.wizards.spells.SpellLevitation; +import mineplex.game.nano.game.games.wizards.spells.SpellTNT; +import mineplex.minecraft.game.core.combat.CombatComponent; +import mineplex.minecraft.game.core.combat.DeathMessageType; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; + +public class Wizards extends ScoredSoloGame +{ + + private final Spell[] _spells; + + public Wizards(NanoManager manager) + { + super(manager, GameType.WIZARDS, new String[] + { + "Use your " + C.cYellow + "Spells" + C.Reset + " to eliminate other players.", + "Points are awarded for " + C.cGreen + "Kills" + C.Reset + " and " + C.cGreen + "Assists" + C.Reset + ".", + "You lose a point for " + C.cRed + "Dying" + C.Reset + "!", + C.cYellow + "Most points" + C.Reset + " wins!" + }); + + _spells = new Spell[] + { + new SpellFireball(this), + new SpellTNT(this), + new SpellLevitation(this), + new SpellFortify(this) + }; + + _prepareComponent.setPrepareFreeze(false); + + _damageComponent.setFall(false); + + _spectatorComponent.setDeathOut(false); + + _endComponent.setTimeout(TimeUnit.MINUTES.toMillis(2)); + + new GiveItemComponent(this) + .setArmour(new ItemStack[] + { + new ItemBuilder(Material.LEATHER_BOOTS) + .setTitle(C.cGold + "Wizard's Boots") + .setColor(Color.MAROON) + .setUnbreakable(true) + .setGlow(true) + .build(), + new ItemBuilder(Material.LEATHER_LEGGINGS) + .setTitle(C.cGold + "Wizard's Leggings") + .setColor(Color.MAROON) + .setUnbreakable(true) + .setGlow(true) + .build(), + new ItemBuilder(Material.LEATHER_CHESTPLATE) + .setTitle(C.cGold + "Wizard's Cloak") + .setColor(Color.MAROON) + .setUnbreakable(true) + .setGlow(true) + .build(), + new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cGold + "Wizard's Cap") + .setColor(Color.MAROON) + .setUnbreakable(true) + .setGlow(true) + .build() + }); + + new DoubleJumpComponent(this); + } + + @Override + protected void parseData() + { + + } + + @EventHandler + public void playerRespawn(PlayerGameRespawnEvent event) + { + Player player = event.getPlayer(); + + for (Spell spell : _spells) + { + player.getInventory().addItem(spell.getItemStack()); + } + } + + @EventHandler + public void combatDeath(CombatDeathEvent event) + { + event.SetBroadcastType(DeathMessageType.Simple); + + Player killed = event.GetEvent().getEntity(); + + incrementScore(killed, -1); + + CombatComponent killer = event.GetLog().GetKiller(); + + if (killer != null) + { + Player killerPlayer = UtilPlayer.searchExact(killer.getUniqueIdOfEntity()); + + if (!killed.equals(killerPlayer)) + { + incrementScore(killerPlayer, 3); + } + } + + for (CombatComponent attacker : event.GetLog().GetAttackers()) + { + if (attacker.equals(killer) || !attacker.IsPlayer()) + { + continue; + } + + Player attackerPlayer = UtilPlayer.searchExact(attacker.getUniqueIdOfEntity()); + + if (attackerPlayer != null) + { + incrementScore(attackerPlayer, 1); + } + } + } + + public void createExplosion(Player source, String reason, Location location, int radius, double damage) + { + UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, location, null, 0.1F, 1, ViewDist.LONG); + location.getWorld().playSound(location, Sound.EXPLODE, 1, 0.7F); + + for (Block block : UtilBlock.getBlocksInRadius(location, radius)) + { + MapUtil.QuickChangeBlockAt(block.getLocation(), Material.AIR); + } + + UtilPlayer.getInRadius(location, radius + 2).forEach((player, scale) -> _manager.getDamageManager().NewDamageEvent(player, source, null, DamageCause.ENTITY_EXPLOSION, damage, true, true, false, source.getName(), reason)); + } +} diff --git a/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/wizards/spells/SpellFireball.java b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/wizards/spells/SpellFireball.java new file mode 100644 index 000000000..8daad4b2c --- /dev/null +++ b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/wizards/spells/SpellFireball.java @@ -0,0 +1,50 @@ +package mineplex.game.nano.game.games.wizards.spells; + +import java.util.concurrent.TimeUnit; + +import org.bukkit.Material; +import org.bukkit.entity.Fireball; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAction; +import mineplex.game.nano.game.games.wizards.Spell; +import mineplex.game.nano.game.games.wizards.Wizards; + +public class SpellFireball extends Spell +{ + + public SpellFireball(Wizards game) + { + super(game, "Fireball", SpellType.Attack, new ItemStack(Material.BLAZE_ROD), TimeUnit.SECONDS.toMillis(1)); + } + + @Override + protected void onSpellUse(Player player) + { + Vector velocity = player.getLocation().getDirection(); + + Fireball fireball = player.launchProjectile(Fireball.class); + fireball.setVelocity(velocity.clone().multiply(2)); + + UtilAction.velocity(player, velocity.multiply(-0.7)); + } + + @EventHandler + public void entityExplode(EntityExplodeEvent event) + { + if (!(event.getEntity() instanceof Fireball)) + { + return; + } + + event.setCancelled(true); + + Player damager = (Player) ((Fireball) event.getEntity()).getShooter(); + + _game.createExplosion(damager, getName(), event.getEntity().getLocation(), 3, 14); + } +} diff --git a/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/wizards/spells/SpellFortify.java b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/wizards/spells/SpellFortify.java new file mode 100644 index 000000000..8e60c6420 --- /dev/null +++ b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/wizards/spells/SpellFortify.java @@ -0,0 +1,55 @@ +package mineplex.game.nano.game.games.wizards.spells; + +import java.util.concurrent.TimeUnit; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +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.game.nano.game.games.wizards.Spell; +import mineplex.game.nano.game.games.wizards.Wizards; + +public class SpellFortify extends Spell +{ + + public SpellFortify(Wizards game) + { + super(game, "Fortify", SpellType.Defense, new ItemStack(Material.IRON_HOE), TimeUnit.SECONDS.toMillis(20)); + } + + @Override + protected void onSpellUse(Player player) + { + Location location = player.getLocation().add(0, 0.1, 0); + double r = 1.5; + + for (int i = 0; i < 13; i++) + { + for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 10) + { + double x = r * Math.cos(theta), z = r * Math.sin(theta); + + location.add(x, 0, z); + + UtilParticle.PlayParticleToAll(ParticleType.DRIP_WATER, location, null, 0, 1, ViewDist.NORMAL); + + location.subtract(x, 0, z); + } + + location.add(0, 0.2, 0); + } + + location.getWorld().playSound(location, Sound.ZOMBIE_REMEDY, 0.5F, 1); + + UtilPlayer.health(player, 4); + player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 10 * 20, 0)); + } +} diff --git a/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/wizards/spells/SpellLevitation.java b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/wizards/spells/SpellLevitation.java new file mode 100644 index 000000000..e3b083bc8 --- /dev/null +++ b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/wizards/spells/SpellLevitation.java @@ -0,0 +1,39 @@ +package mineplex.game.nano.game.games.wizards.spells; + +import java.util.concurrent.TimeUnit; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.game.nano.game.games.wizards.Spell; +import mineplex.game.nano.game.games.wizards.Wizards; + +public class SpellLevitation extends Spell +{ + + public SpellLevitation(Wizards game) + { + super(game, "Whirlwind", SpellType.Utility, new ItemStack(Material.FEATHER), TimeUnit.SECONDS.toMillis(5)); + } + + @Override + protected void onSpellUse(Player player) + { + Location location = player.getLocation(); + + location.getWorld().playSound(location, Sound.BAT_TAKEOFF, 0.5F, 0.5F); + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, location, 0.4F, 0.4F, 0.F, 0.1F, 25, ViewDist.LONG); + + Vector velocity = location.getDirection(); + velocity.setY(Math.max(0, velocity.getY()) + 0.1); + UtilAction.velocity(player, velocity.multiply(2)); + } +} diff --git a/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/wizards/spells/SpellTNT.java b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/wizards/spells/SpellTNT.java new file mode 100644 index 000000000..e6a4b4c28 --- /dev/null +++ b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/wizards/spells/SpellTNT.java @@ -0,0 +1,56 @@ +package mineplex.game.nano.game.games.wizards.spells; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.inventory.ItemStack; + +import mineplex.game.nano.game.games.wizards.Spell; +import mineplex.game.nano.game.games.wizards.Wizards; + +public class SpellTNT extends Spell +{ + + private final Map _owner; + + public SpellTNT(Wizards game) + { + super(game, "Throwing TNT", SpellType.Attack, new ItemStack(Material.TNT), TimeUnit.SECONDS.toMillis(5)); + + _owner = new HashMap<>(); + } + + @Override + protected void onSpellUse(Player player) + { + Location location = player.getEyeLocation(); + TNTPrimed tnt = location.getWorld().spawn(location, TNTPrimed.class); + + tnt.setVelocity(location.getDirection()); + tnt.setFuseTicks(80); + + _owner.put(tnt, player); + } + + @EventHandler + public void entityExplode(EntityExplodeEvent event) + { + Player damager = _owner.remove(event.getEntity()); + + if (damager == null) + { + return; + } + + event.setCancelled(true); + _game.createExplosion(damager, getName(), event.getEntity().getLocation(), 5, 25); + } +}