From 5b9f5e1678f913de292dc8cd45359c18824ffc0b Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 12 Sep 2018 01:32:47 +0100 Subject: [PATCH] Change a bit of how Wizards works --- .../game/nano/game/ScoredSoloGame.java | 2 +- .../compass/GameCompassComponent.java | 2 +- .../player/DoubleJumpComponent.java | 11 +++++-- .../nano/game/games/minekart/MineKart.java | 7 +--- .../nano/game/games/quick/ChallengeType.java | 2 +- .../game/nano/game/games/wizards/Spell.java | 5 ++- .../game/nano/game/games/wizards/Wizards.java | 33 +++++++++++++++++-- .../games/wizards/spells/SpellFireball.java | 3 -- .../games/wizards/spells/SpellFortify.java | 6 +--- .../game/games/wizards/spells/SpellTNT.java | 2 +- 10 files changed, 48 insertions(+), 25 deletions(-) diff --git a/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/ScoredSoloGame.java b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/ScoredSoloGame.java index 7f39798ae..646181b6e 100644 --- a/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/ScoredSoloGame.java +++ b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/ScoredSoloGame.java @@ -116,7 +116,7 @@ public abstract class ScoredSoloGame extends SoloGame return; } - _scores.put(player, _scores.getOrDefault(player, 0) + score); + _scores.put(player, Math.max(0, _scores.getOrDefault(player, 0) + score)); } @EventHandler(priority = EventPriority.LOWEST) diff --git a/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/components/compass/GameCompassComponent.java b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/components/compass/GameCompassComponent.java index c50f053de..0662d78eb 100644 --- a/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/components/compass/GameCompassComponent.java +++ b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/components/compass/GameCompassComponent.java @@ -135,7 +135,7 @@ public class GameCompassComponent extends GameComponent private Player getClosest(Player player) { - if (getGame().isAlive(player)) + if (getGame().isAlive(player) && getGame().getTeams().size() > 1) { return UtilPlayer.getClosest(player.getLocation(), getGame().getTeam(player).getAlivePlayers()); } 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 159e2d869..f797b99bc 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 @@ -23,7 +23,7 @@ public class DoubleJumpComponent extends GameComponent public DoubleJumpComponent(Game game) { - super(game, GameState.Live); + super(game, GameState.Live, GameState.End); } @Override @@ -47,7 +47,7 @@ public class DoubleJumpComponent extends GameComponent @EventHandler(priority = EventPriority.HIGH) public void updateJump(UpdateEvent event) { - if (event.getType() != UpdateType.TICK) + if (event.getType() != UpdateType.TICK || !getGame().isLive()) { return; } @@ -76,6 +76,13 @@ public class DoubleJumpComponent extends GameComponent return; } + if (!getGame().isLive()) + { + event.setCancelled(true); + player.setAllowFlight(false); + return; + } + Vector velocity = player.getLocation().getDirection(); if (_directional) diff --git a/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/minekart/MineKart.java b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/minekart/MineKart.java index b32296b80..3f27807e0 100644 --- a/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/minekart/MineKart.java +++ b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/minekart/MineKart.java @@ -149,19 +149,15 @@ public class MineKart extends SoloGame if (checkpoint != null) { - player.sendMessage("Lap node = " + checkpoint.getIndex()); kart.setLapCheckpoint(checkpoint.getIndex()); if (checkpoint.isKey()) { int keyIndex = _keyCheckpoints.indexOf(checkpoint); - player.sendMessage("Lap key node = " + keyIndex + " kart node = " + kart.getLapKeyCheckpoint()); - if (kart.getLapKeyCheckpoint() + 1 == keyIndex) { kart.setLapKeyCheckpoint(keyIndex); - player.sendMessage("Lap key node = " + keyIndex + " goal = " + (_keyCheckpoints.size() - 1)); } } @@ -202,14 +198,13 @@ public class MineKart extends SoloGame double velocityLength = kart.getVelocity().length(); -// player.sendMessage("v=" + velocityLength); - location.add(kart.getVelocity()); location.setDirection(kart.getVelocity()); UtilEnt.setPosition(vehicle, location); UtilEnt.CreatureLook(vehicle, location.getYaw()); location.getWorld().playSound(location, Sound.PIG_IDLE, (float) (.1 + velocityLength / 2), (float) (.5 + velocityLength)); + player.setExp((float) velocityLength); }); } diff --git a/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/quick/ChallengeType.java b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/quick/ChallengeType.java index 1e3c0cd7c..e89431531 100644 --- a/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/quick/ChallengeType.java +++ b/Plugins/Mineplex.Game.Nano/src/mineplex/game/nano/game/games/quick/ChallengeType.java @@ -37,7 +37,7 @@ public enum ChallengeType RED_BLOCKS(ChallengeRedBlocks.class, "Don't fall into the void!"), POLE(ChallengePole.class, "Get as high as you can!"), CROUCH(ChallengeCrouch.class, "Crouch/Sneak!"), - ZOMBIES(ChallengeZombies.class, "Survive the Zombie Hoard!"), + ZOMBIES(ChallengeZombies.class, "Survive the Zombie Horde!"), SPLEEF(ChallengeSpleef.class, "Spleef other players into the void!"), BLOCK_SNAKE(ChallengeBlockSnake.class, "Avoid the Block Snake!"), THROW_EGGS(ChallengeThrowEggs.class, "Throw all your eggs!"), 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 index a30fd1c73..f0931cadd 100644 --- 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 @@ -4,12 +4,11 @@ import java.util.Collections; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; 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; @@ -51,7 +50,7 @@ public abstract class Spell extends ListenerComponent implements Lifetimed @EventHandler public void playerInteract(PlayerInteractEvent event) { - if (!UtilEvent.isAction(event, ActionType.R)) + if (event.getAction() == Action.PHYSICAL) { return; } 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 index e8769ae0c..f108f7eeb 100644 --- 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 @@ -9,8 +9,14 @@ import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import com.mineplex.anticheat.checks.move.Glide; +import com.mineplex.anticheat.checks.move.Speed; import mineplex.core.common.util.C; import mineplex.core.common.util.MapUtil; @@ -33,6 +39,7 @@ 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; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class Wizards extends ScoredSoloGame { @@ -94,13 +101,19 @@ public class Wizards extends ScoredSoloGame .build() }); + _compassComponent.setGiveToAlive(true); + new DoubleJumpComponent(this); + + _manager.getAntiHack().addIgnoredCheck(Speed.class); + _manager.getAntiHack().addIgnoredCheck(Glide.class); } @Override protected void parseData() { - + // Legacy support for old wizard maps + _mineplexWorld.getSpongeLocations(String.valueOf(Material.CHEST.getId())).forEach(location -> MapUtil.QuickChangeBlockAt(location, Material.AIR)); } @EventHandler @@ -112,6 +125,22 @@ public class Wizards extends ScoredSoloGame { player.getInventory().addItem(spell.getItemStack()); } + + player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 0, false, false)); + } + + @EventHandler(priority = EventPriority.HIGH) + public void damage(CustomDamageEvent event) + { + if (event.GetCause() == DamageCause.ENTITY_EXPLOSION) + { + event.SetCancelled("Entity Explosion"); + } + + if (event.GetDamageeEntity().equals(event.GetDamagerEntity(true))) + { + event.AddMod("Self", -event.GetDamage() * 0.75); + } } @EventHandler @@ -161,6 +190,6 @@ public class Wizards extends ScoredSoloGame 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)); + UtilPlayer.getInRadius(location, radius + 2).forEach((player, scale) -> _manager.getDamageManager().NewDamageEvent(player, source, null, DamageCause.CUSTOM, 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 index 8daad4b2c..a8abec286 100644 --- 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 @@ -10,7 +10,6 @@ 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; @@ -29,8 +28,6 @@ public class SpellFireball extends Spell Fireball fireball = player.launchProjectile(Fireball.class); fireball.setVelocity(velocity.clone().multiply(2)); - - UtilAction.velocity(player, velocity.multiply(-0.7)); } @EventHandler 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 index 8e60c6420..a6a184400 100644 --- 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 @@ -7,8 +7,6 @@ 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; @@ -48,8 +46,6 @@ public class SpellFortify extends Spell } location.getWorld().playSound(location, Sound.ZOMBIE_REMEDY, 0.5F, 1); - - UtilPlayer.health(player, 4); - player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 10 * 20, 0)); + UtilPlayer.health(player, 10); } } 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 index e6a4b4c28..e7e958d09 100644 --- 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 @@ -35,7 +35,7 @@ public class SpellTNT extends Spell TNTPrimed tnt = location.getWorld().spawn(location, TNTPrimed.class); tnt.setVelocity(location.getDirection()); - tnt.setFuseTicks(80); + tnt.setFuseTicks(10); _owner.put(tnt, player); }