Change a bit of how Wizards works

This commit is contained in:
Sam 2018-09-12 01:32:47 +01:00 committed by Alexander Meech
parent 99b37097c6
commit 5b9f5e1678
10 changed files with 48 additions and 25 deletions

View File

@ -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)

View File

@ -135,7 +135,7 @@ public class GameCompassComponent extends GameComponent<Game>
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());
}

View File

@ -23,7 +23,7 @@ public class DoubleJumpComponent extends GameComponent<Game>
public DoubleJumpComponent(Game game)
{
super(game, GameState.Live);
super(game, GameState.Live, GameState.End);
}
@Override
@ -47,7 +47,7 @@ public class DoubleJumpComponent extends GameComponent<Game>
@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<Game>
return;
}
if (!getGame().isLive())
{
event.setCancelled(true);
player.setAllowFlight(false);
return;
}
Vector velocity = player.getLocation().getDirection();
if (_directional)

View File

@ -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);
});
}

View File

@ -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!"),

View File

@ -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;
}

View File

@ -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));
}
}

View File

@ -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

View File

@ -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);
}
}

View File

@ -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);
}