Cleanup SnowFight
This commit is contained in:
parent
ff05953c1d
commit
e0d8f7aed5
@ -1,473 +1,380 @@
|
||||
package nautilus.game.arcade.game.games.snowfight;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
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.GameTeam;
|
||||
import nautilus.game.arcade.game.TeamGame;
|
||||
import nautilus.game.arcade.game.games.snowfight.kits.KitTactician;
|
||||
import nautilus.game.arcade.game.games.snowfight.kits.KitMedic;
|
||||
import nautilus.game.arcade.game.games.snowfight.kits.KitSportsman;
|
||||
import nautilus.game.arcade.game.modules.TeamArmorModule;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.Snowball;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.account.permissions.Permission;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.MapUtil;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
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.TeamGame;
|
||||
import nautilus.game.arcade.game.games.snowfight.kits.KitMedic;
|
||||
import nautilus.game.arcade.game.games.snowfight.kits.KitSportsman;
|
||||
import nautilus.game.arcade.game.games.snowfight.kits.KitTactician;
|
||||
import nautilus.game.arcade.game.modules.TeamArmorModule;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
|
||||
public class SnowFight extends TeamGame
|
||||
{
|
||||
private long _meteorTime = 360000;
|
||||
private boolean _meteors = false;
|
||||
|
||||
private HashSet<FallingBlock> _meteorSet = new HashSet<FallingBlock>();
|
||||
|
||||
public enum Perm implements Permission
|
||||
{
|
||||
DEBUG_COMMANDS
|
||||
}
|
||||
|
||||
private static final String[] DESCRIPTION =
|
||||
{
|
||||
"Collect " + C.cAqua + "Snow Balls" + C.cWhite + " by punching the ground.",
|
||||
"Use them to defeat the enemy teams.",
|
||||
"You regenerate " + C.cRed + "❤" + C.cWhite + " when out of combat.",
|
||||
"Last team standing wins!"
|
||||
};
|
||||
private static final int MAX_SNOW_BALLS = 16;
|
||||
private static final int MAX_SNOW_HEIGHT = 8;
|
||||
private static final double SNOW_BALL_DAMAGE = 3.25;
|
||||
private static final ItemStack SNOW_BALL = new ItemStack(Material.SNOW_BALL);
|
||||
private static final long GUN_MODE_TIME = TimeUnit.MINUTES.toMillis(3);
|
||||
private static final long BLIZZARD_TIME = TimeUnit.MINUTES.toMillis(5);
|
||||
private static final ItemStack GUN = new ItemBuilder(Material.DIAMOND_BARDING)
|
||||
.setTitle(C.cAquaB + "Snowball Launcher 8000")
|
||||
.build();
|
||||
private static final int GUN_BULLETS = 5;
|
||||
private static final long COMBAT_TIME = TimeUnit.SECONDS.toMillis(8);
|
||||
private static final PotionEffect REGENERATION = new PotionEffect(PotionEffectType.REGENERATION, Integer.MAX_VALUE, 1);
|
||||
|
||||
private boolean _gunMode;
|
||||
private long _gunModeTime = GUN_MODE_TIME;
|
||||
|
||||
private boolean _blizzard;
|
||||
private long _blizzardTime = BLIZZARD_TIME;
|
||||
|
||||
private final Map<Player, Long> _lastDamage;
|
||||
|
||||
public SnowFight(ArcadeManager manager)
|
||||
{
|
||||
super(manager, GameType.SnowFight,
|
||||
super(manager, GameType.SnowFight, new Kit[]
|
||||
{
|
||||
new KitSportsman(manager),
|
||||
new KitTactician(manager),
|
||||
new KitMedic(manager)
|
||||
}, DESCRIPTION);
|
||||
|
||||
new Kit[]
|
||||
{
|
||||
new KitSportsman(manager),
|
||||
new KitTactician(manager),
|
||||
new KitMedic(manager)
|
||||
},
|
||||
|
||||
new String[]
|
||||
{
|
||||
"Defeat your foes with Snowballs",
|
||||
"Last team alive wins!"
|
||||
});
|
||||
_lastDamage = new HashMap<>();
|
||||
|
||||
this.PrepareFreeze = false;
|
||||
|
||||
this.HungerSet = 20;
|
||||
PrepareFreeze = false;
|
||||
HungerSet = 20;
|
||||
|
||||
new CompassModule()
|
||||
.setGiveCompassToAlive(true)
|
||||
.setGiveCompass(false)
|
||||
.register(this);
|
||||
|
||||
registerChatStats(//damage, collected
|
||||
registerChatStats(
|
||||
Kills,
|
||||
Assists,
|
||||
BlankLine,
|
||||
DamageTaken,
|
||||
DamageDealt
|
||||
);
|
||||
|
||||
new TeamArmorModule()
|
||||
.giveTeamArmor()
|
||||
.giveHotbarItem()
|
||||
.register(this);
|
||||
|
||||
// this.WorldWeatherEnabled = true;
|
||||
// this.WorldTimeSet = 4000;
|
||||
|
||||
new CompassModule()
|
||||
.register(this);
|
||||
|
||||
registerDebugCommand("launchers", Perm.DEBUG_COMMANDS, PermissionGroup.ADMIN, (player, args) -> _gunModeTime = 0);
|
||||
registerDebugCommand("blizzard", Perm.DEBUG_COMMANDS, PermissionGroup.ADMIN, (player, args) -> _blizzardTime = 0);
|
||||
}
|
||||
|
||||
// @EventHandler
|
||||
// public void weather(UpdateEvent event)
|
||||
// {
|
||||
// if (event.getType() != UpdateType.SEC)
|
||||
// return;
|
||||
//
|
||||
// WorldData.World.setStorm(true);
|
||||
// WorldData.World.setThundering(false);
|
||||
// WorldData.World.setWeatherDuration(12);
|
||||
// }
|
||||
@EventHandler
|
||||
public void weatherUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SLOW)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
World world = WorldData.World;
|
||||
|
||||
if (_blizzard)
|
||||
{
|
||||
world.setStorm(true);
|
||||
world.setThundering(false);
|
||||
}
|
||||
else if (GetState() == GameState.End)
|
||||
{
|
||||
world.setStorm(false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void battleAnnounce(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() == GameState.Prepare)
|
||||
{
|
||||
UtilTextMiddle.display(C.cGreen + "Prepare", "Collect Snowballs!", 0, 60, 20, UtilServer.getPlayers());
|
||||
UtilTextMiddle.display(C.cGreenB + "Get Ready", "Collect Snowballs!", 0, 60, 10, UtilServer.getPlayers());
|
||||
}
|
||||
if (event.GetState() == GameState.Live)
|
||||
else if (event.GetState() == GameState.Live)
|
||||
{
|
||||
for(Player player : GetPlayers(false))
|
||||
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1F, 1F);
|
||||
for (Player player : UtilServer.getPlayersCollection())
|
||||
{
|
||||
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 1);
|
||||
}
|
||||
|
||||
UtilTextMiddle.display(C.cRed + "FIGHT", "", 0, 40, 20, UtilServer.getPlayers());
|
||||
UtilTextMiddle.display(C.cRedB + "FIGHT", "Good Luck!", 0, 40, 10, UtilServer.getPlayers());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void blockDamage(PlayerInteractEvent event)
|
||||
{
|
||||
if (!InProgress() || !UtilEvent.isAction(event, ActionType.L_BLOCK) || _gunMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getClickedBlock();
|
||||
|
||||
if (!InProgress())
|
||||
if (!IsAlive(player) || !isSnow(block) || player.getInventory().contains(Material.SNOW_BALL, MAX_SNOW_BALLS))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UtilEvent.isAction(event, ActionType.L_BLOCK))
|
||||
return;
|
||||
|
||||
if (!IsPlaying(player) || !IsAlive(player))
|
||||
return;
|
||||
|
||||
if (!isSnow(event.getClickedBlock()))
|
||||
return;
|
||||
|
||||
if (UtilInv.contains(player, Material.SNOW_BALL, (byte) 0, 16))
|
||||
return;
|
||||
|
||||
UtilInv.insert(player, new ItemStack(Material.SNOW_BALL));
|
||||
|
||||
// Snow Height
|
||||
snowDecrease(event.getClickedBlock(), 1);
|
||||
|
||||
// Effect
|
||||
event.getClickedBlock().getWorld().playEffect(event.getClickedBlock().getLocation(), Effect.STEP_SOUND, 80);
|
||||
player.getInventory().addItem(SNOW_BALL);
|
||||
snowDecrease(block, 1);
|
||||
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.SNOW_BLOCK);
|
||||
}
|
||||
|
||||
private void snowDecrease(Block block, int height)
|
||||
{
|
||||
if (height <= 0)
|
||||
return;
|
||||
|
||||
if (!isSnow(block))
|
||||
if (height <= 0 || !isSnow(block))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Shuffle Up
|
||||
while (isSnow(block.getRelative(BlockFace.UP)))
|
||||
{
|
||||
block = block.getRelative(BlockFace.UP);
|
||||
}
|
||||
|
||||
// Snow Block
|
||||
int snowLevel = 8;
|
||||
if (block.getTypeId() == 78)
|
||||
int snowLevel = MAX_SNOW_HEIGHT;
|
||||
|
||||
if (block.getType() == Material.SNOW)
|
||||
{
|
||||
snowLevel = block.getData() + 1;
|
||||
}
|
||||
|
||||
// Lower
|
||||
if (height >= snowLevel)
|
||||
{
|
||||
block.setTypeIdAndData(0, (byte) 0, false);
|
||||
MapUtil.QuickChangeBlockAt(block.getLocation(), Material.AIR);
|
||||
snowDecrease(block.getRelative(BlockFace.DOWN), height - snowLevel);
|
||||
}
|
||||
else
|
||||
{
|
||||
block.setTypeIdAndData(78, (byte) (snowLevel - height - 1), false);
|
||||
MapUtil.QuickChangeBlockAt(block.getLocation(), Material.SNOW, (byte) (snowLevel - height - 1));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void healthRegen(EntityRegainHealthEvent event)
|
||||
public void healthRegen(EntityRegainHealthEvent event)
|
||||
{
|
||||
if(event.getRegainReason() == RegainReason.SATIATED)
|
||||
if (event.getRegainReason() == RegainReason.SATIATED)
|
||||
{
|
||||
event.setAmount(1);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void generallDamage(CustomDamageEvent event)
|
||||
{
|
||||
if(event.GetCause() == DamageCause.ENTITY_ATTACK)
|
||||
event.SetCancelled("No Melee");
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void snowballEggDamage(CustomDamageEvent event)
|
||||
public void snowballDamage(CustomDamageEvent event)
|
||||
{
|
||||
if (event.IsCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.GetCause() != DamageCause.PROJECTILE)
|
||||
if (event.GetCause() == DamageCause.ENTITY_ATTACK)
|
||||
{
|
||||
event.SetCancelled("No Melee");
|
||||
return;
|
||||
}
|
||||
|
||||
Projectile proj = event.GetProjectile();
|
||||
if (proj == null)
|
||||
Projectile projectile = event.GetProjectile();
|
||||
|
||||
if (projectile == null || !(projectile instanceof Snowball))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(proj instanceof Fireball)
|
||||
return;
|
||||
Player damagee = event.GetDamageePlayer();
|
||||
|
||||
if(proj instanceof Snowball)
|
||||
event.AddMod("Snowball", "Snowball", 2, true);
|
||||
if (damagee != null)
|
||||
{
|
||||
_lastDamage.put(damagee, System.currentTimeMillis());
|
||||
damagee.removePotionEffect(PotionEffectType.REGENERATION);
|
||||
}
|
||||
|
||||
event.SetIgnoreRate(true);
|
||||
Player shooter = (Player) projectile.getShooter();
|
||||
|
||||
event.AddMod(GetName(), "Snowball", SNOW_BALL_DAMAGE, true);
|
||||
event.SetIgnoreArmor(true);
|
||||
|
||||
// Effect
|
||||
proj.getWorld().playEffect(proj.getLocation(), Effect.STEP_SOUND, 80);
|
||||
((Player) proj.getShooter()).playSound(((Player) proj.getShooter()).getLocation(), Sound.SUCCESSFUL_HIT, 1, 1);
|
||||
projectile.getWorld().playEffect(projectile.getLocation(), Effect.STEP_SOUND, Material.SNOW_BLOCK);
|
||||
shooter.playSound(shooter.getLocation(), Sound.SUCCESSFUL_HIT, 1, 1);
|
||||
|
||||
if (_blizzard)
|
||||
{
|
||||
UtilPlayer.hunger(shooter, 2);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSnow(Block block)
|
||||
{
|
||||
return block.getTypeId() == 78 || block.getTypeId() == 80;
|
||||
}
|
||||
|
||||
private boolean isOnIce(Player player)
|
||||
{
|
||||
//Side Standing
|
||||
double xMod = player.getLocation().getX() % 1;
|
||||
if (player.getLocation().getX() < 0)
|
||||
xMod += 1;
|
||||
|
||||
double zMod = player.getLocation().getZ() % 1;
|
||||
if (player.getLocation().getZ() < 0)
|
||||
zMod += 1;
|
||||
|
||||
int xMin = 0;
|
||||
int xMax = 0;
|
||||
int zMin = 0;
|
||||
int zMax = 0;
|
||||
|
||||
if (xMod < 0.3) xMin = -1;
|
||||
if (xMod > 0.7) xMax = 1;
|
||||
|
||||
if (zMod < 0.3) zMin = -1;
|
||||
if (zMod > 0.7) zMax = 1;
|
||||
|
||||
for (int x=xMin ; x<=xMax ; x++)
|
||||
{
|
||||
for (int z=zMin ; z<=zMax ; z++)
|
||||
{
|
||||
if (player.getLocation().add(x, -0.5, z).getBlock().getType() == Material.PACKED_ICE)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private Location getMeteorTargetLocation()
|
||||
{
|
||||
ArrayList<Player> players = GetPlayers(true);
|
||||
|
||||
//50 attempts, otherwise skip
|
||||
for (int a = 0; a < 50; a++)
|
||||
{
|
||||
Player player = UtilAlg.Random(players);
|
||||
|
||||
Location location = player.getLocation();
|
||||
|
||||
//random offset to player location
|
||||
if (Math.random() > 0.1)
|
||||
location.add(
|
||||
(Math.random() - 0.5) * 32,
|
||||
0,
|
||||
(Math.random() - 0.5) * 32);
|
||||
|
||||
//highest block!
|
||||
location = WorldData.World.getHighestBlockAt(location).getLocation().add(0.5, 0, 0.5);
|
||||
|
||||
if (location.getBlock().getType() == Material.AIR)
|
||||
{
|
||||
location.add(0, -1, 0);
|
||||
}
|
||||
|
||||
if (location.getBlockY() > 0 && location.getBlock().getType() != Material.AIR)
|
||||
{
|
||||
location.setY(player.getLocation().getY() + 80);
|
||||
|
||||
return location;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void meteorSpawn(UpdateEvent event)
|
||||
{
|
||||
if(event.getType() != UpdateType.SEC)
|
||||
return;
|
||||
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
if(System.currentTimeMillis() <= getGameLiveTime() + _meteorTime)
|
||||
return;
|
||||
|
||||
//Announce
|
||||
if(!_meteors)
|
||||
{
|
||||
for(Player player : GetPlayers(false))
|
||||
{
|
||||
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1F, 1F);
|
||||
UtilTextMiddle.display(C.cAqua + C.Bold + "Ice Meteors", "Avoid the Ice Fields!", player);
|
||||
}
|
||||
|
||||
_meteors = true;
|
||||
}
|
||||
|
||||
//Spawn Meteor
|
||||
Location loc = getMeteorTargetLocation();
|
||||
|
||||
if (loc == null)
|
||||
return;
|
||||
|
||||
FallingBlock fallingblock = loc.getWorld().spawnFallingBlock(loc, Material.ICE, (byte) 0);
|
||||
|
||||
fallingblock.setMetadata("Meteor", new FixedMetadataValue(getArcadeManager().getPlugin(), 20f));
|
||||
|
||||
_meteorSet.add(fallingblock);
|
||||
return block.getType() == Material.SNOW || block.getType() == Material.SNOW_BLOCK;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void meteorUpdate(UpdateEvent event)
|
||||
public void updateEvents(UpdateEvent event)
|
||||
{
|
||||
if(event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
if(!IsLive())
|
||||
return;
|
||||
|
||||
Iterator<FallingBlock> blockIter = _meteorSet.iterator();
|
||||
|
||||
while (blockIter.hasNext())
|
||||
if (event.getType() != UpdateType.SEC || !IsLive())
|
||||
{
|
||||
FallingBlock block = blockIter.next();
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.isValid())
|
||||
{
|
||||
//Particle
|
||||
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, block.getLocation(), 0.3F, 0.3F, 0.3F, 0, 3,
|
||||
ViewDist.MAX, UtilServer.getPlayers());
|
||||
if (!_gunMode && UtilTime.elapsed(GetStateTime(), _gunModeTime))
|
||||
{
|
||||
List<Player> alive = GetPlayers(true);
|
||||
|
||||
//Sound
|
||||
if (block.getTicksLived() % 6 == 0)
|
||||
block.getWorld().playSound(block.getLocation(), Sound.CAT_HISS, 0.5F, 0F);
|
||||
}
|
||||
//Clean
|
||||
else
|
||||
Announce(F.main("Game", F.name("Snowball Launchers") + " given to everyone!"));
|
||||
UtilTextMiddle.display(C.cAquaB + "Snowball Launchers", "Hold down to fire snowballs!", 0, 40, 10, alive.toArray(new Player[0]));
|
||||
|
||||
alive.forEach(player -> player.getInventory().setItem(0, GUN));
|
||||
_gunMode = true;
|
||||
}
|
||||
else if (UtilTime.elapsed(GetStateTime(), _blizzardTime))
|
||||
{
|
||||
if (!_blizzard)
|
||||
{
|
||||
meteorExplode(block);
|
||||
|
||||
block.remove();
|
||||
blockIter.remove();
|
||||
List<Player> alive = GetPlayers(true);
|
||||
|
||||
Announce(F.main("Game", F.color("Blizzard", C.cRedB) + " incoming! Attack players to restore hunger."));
|
||||
UtilTextMiddle.display(C.cRedB + "Blizzard", "Attack players to restore hunger", 0, 40, 10, alive.toArray(new Player[0]));
|
||||
HungerSet = -1;
|
||||
WorldWeatherEnabled = true;
|
||||
_blizzard = true;
|
||||
}
|
||||
|
||||
GetPlayers(true).forEach(player ->
|
||||
{
|
||||
if (player.getFoodLevel() == 0)
|
||||
{
|
||||
Manager.GetDamage().NewDamageEvent(player, null, null,
|
||||
DamageCause.STARVATION, 1, false, true, true,
|
||||
GetName(), "Blizzard"
|
||||
);
|
||||
}
|
||||
|
||||
player.setSaturation(0);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void meteorHit(EntityChangeBlockEvent event)
|
||||
public void gunInteract(PlayerInteractEvent event)
|
||||
{
|
||||
if (!UtilEvent.isAction(event, ActionType.R) || !_gunMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
ItemStack itemStack = player.getItemInHand();
|
||||
|
||||
if (itemStack == null || !itemStack.equals(GUN))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
Entity projectile = event.getEntity();
|
||||
Location location = player.getEyeLocation();
|
||||
player.playSound(location, Sound.CHICKEN_EGG_POP, 1, 1);
|
||||
|
||||
if (projectile.hasMetadata("Meteor"))
|
||||
for (int i = 0; i < GUN_BULLETS; i++)
|
||||
{
|
||||
meteorExplode(projectile);
|
||||
_meteorSet.remove(projectile);
|
||||
Snowball snowball = player.launchProjectile(Snowball.class);
|
||||
Vector vector = location.getDirection().add(new Vector(
|
||||
(Math.random() - 0.5) / 3,
|
||||
(Math.random() - 0.2) / 3,
|
||||
(Math.random() - 0.5) / 3
|
||||
)).multiply(1.3);
|
||||
|
||||
UtilAction.velocity(snowball, vector);
|
||||
}
|
||||
}
|
||||
|
||||
public void meteorExplode(Entity meteor)
|
||||
{
|
||||
float timePassed = (System.currentTimeMillis() - (getGameLiveTime() + _meteorTime))/1000f;
|
||||
|
||||
float multiplier = 1 + Math.min(3f, timePassed / 60f);
|
||||
|
||||
float size = 1.5f + multiplier;
|
||||
|
||||
//Effect
|
||||
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, meteor.getLocation(), 0.5f, 0.5f, 0.5f, 0, 5, ViewDist.MAX, UtilServer.getPlayers());
|
||||
for(Player player : UtilServer.getPlayers())
|
||||
player.playSound(meteor.getLocation(), Sound.EXPLODE, 1, 1);
|
||||
|
||||
|
||||
//Damage
|
||||
HashMap<Player, Double> players = UtilPlayer.getInRadius(meteor.getLocation(), size + 3);
|
||||
for (Player player : players.keySet())
|
||||
{
|
||||
//Damage Event
|
||||
Manager.GetDamage().NewDamageEvent(player, null, null,
|
||||
DamageCause.CUSTOM, size * players.get(player), false, true, false,
|
||||
"Ice Meteor", "Ice Meteor", false);
|
||||
|
||||
//Vel
|
||||
UtilAction.velocity(player, UtilAlg.getTrajectory(meteor, player), 1.2 * players.get(player), false, 0, 0.4, 1, true);
|
||||
}
|
||||
|
||||
//Convert to Ice
|
||||
for(Block block : UtilBlock.getInRadius(meteor.getLocation(), size).keySet())
|
||||
{
|
||||
int i = 20;
|
||||
while (block.getY() > 0 && i>0)
|
||||
{
|
||||
if (block.getType() == Material.LADDER ||
|
||||
block.getType() == Material.STAINED_GLASS ||
|
||||
block.getType() == Material.STAINED_GLASS_PANE)
|
||||
block.breakNaturally();
|
||||
|
||||
|
||||
//Has air above it
|
||||
if ((UtilBlock.solid(block) && UtilBlock.isVisible(block)) || block.isLiquid())
|
||||
block.setType(Material.PACKED_ICE);
|
||||
|
||||
//shuffle down
|
||||
block = block.getRelative(BlockFace.DOWN);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
meteor.remove();
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void iceDamage(UpdateEvent event)
|
||||
public void updateRegeneration(UpdateEvent event)
|
||||
{
|
||||
if(event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
if(!IsLive())
|
||||
return;
|
||||
|
||||
for(Player player : GetPlayers(true))
|
||||
if (event.getType() != UpdateType.SEC || !IsLive())
|
||||
{
|
||||
if(isOnIce(player))
|
||||
{
|
||||
Bukkit.getPluginManager().callEvent(new CustomDamageEvent(player, null, null, null, DamageCause.CUSTOM, 1, false, true, true, "Ice", "Ice", false));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
_lastDamage.entrySet().removeIf(entry ->
|
||||
{
|
||||
Player player = entry.getKey();
|
||||
long lastDamage = entry.getValue();
|
||||
|
||||
if (UtilTime.elapsed(lastDamage, COMBAT_TIME) && !player.hasPotionEffect(PotionEffectType.REGENERATION))
|
||||
{
|
||||
player.addPotionEffect(REGENERATION);
|
||||
}
|
||||
|
||||
return !IsAlive(player);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -475,60 +382,58 @@ public class SnowFight extends TeamGame
|
||||
public void ScoreboardUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
{
|
||||
return;
|
||||
|
||||
Scoreboard.reset();
|
||||
|
||||
Scoreboard.writeNewLine();
|
||||
if(GetPlayers(true).size() <= 8)
|
||||
{
|
||||
for (GameTeam team : this.GetTeamList())
|
||||
{
|
||||
if (!team.IsTeamAlive())
|
||||
continue;
|
||||
|
||||
for(Player player : team.GetPlayers(true))
|
||||
{
|
||||
Scoreboard.write(team.GetColor() + player.getName());
|
||||
}
|
||||
|
||||
Scoreboard.writeNewLine();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (GameTeam team : this.GetTeamList())
|
||||
{
|
||||
Scoreboard.write(team.GetColor() + C.Bold + team.GetName());
|
||||
Scoreboard.write(team.GetColor() + "" + team.GetPlayers(true).size() + " Alive");
|
||||
Scoreboard.writeNewLine();
|
||||
}
|
||||
}
|
||||
|
||||
long time = _meteorTime - (System.currentTimeMillis() - this.GetStateTime());
|
||||
Scoreboard.writeNewLine();
|
||||
|
||||
if(IsLive())
|
||||
if (GetPlayers(true).size() <= 8)
|
||||
{
|
||||
if (time > 0)
|
||||
GetTeamList().forEach(team ->
|
||||
{
|
||||
Scoreboard.write(C.cYellow + C.Bold + "Meteors in");
|
||||
Scoreboard.write(UtilTime.MakeStr(time, 0));
|
||||
if (!team.IsTeamAlive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
team.GetPlayers(true).forEach(player -> Scoreboard.write(team.GetColor() + player.getName()));
|
||||
|
||||
Scoreboard.writeNewLine();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
GetTeamList().forEach(team ->
|
||||
{
|
||||
Scoreboard.write(team.GetFormattedName());
|
||||
Scoreboard.write(team.GetColor() + String.valueOf(team.GetPlayers(true).size()) + " Alive");
|
||||
Scoreboard.writeNewLine();
|
||||
});
|
||||
}
|
||||
|
||||
if (IsLive())
|
||||
{
|
||||
long delta = System.currentTimeMillis() - GetStateTime();
|
||||
long gunTime = _gunModeTime - delta;
|
||||
long blizzardTime = _blizzardTime - delta;
|
||||
|
||||
if (gunTime > 0)
|
||||
{
|
||||
Scoreboard.write(C.cAquaB + "Launchers");
|
||||
Scoreboard.write(UtilTime.MakeStr(gunTime));
|
||||
}
|
||||
else if (blizzardTime > 0)
|
||||
{
|
||||
Scoreboard.write(C.cRedB + "Blizzard");
|
||||
Scoreboard.write(UtilTime.MakeStr(blizzardTime));
|
||||
}
|
||||
else
|
||||
{
|
||||
Scoreboard.write(C.cGold + C.Bold + "Meteors!");
|
||||
}
|
||||
Scoreboard.write(C.cRedB + "Blizzard!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Scoreboard.draw();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void meteorStart(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (event.getPlayer().isOp() && event.getMessage().equals("/meteor"))
|
||||
_meteorTime = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,8 +30,7 @@ public class KitMedic extends ProgressingKit
|
||||
C.cWhite + "Receive" + C.cGreen + " 1 " + C.cWhite + "Warmth Potion every" + C.cGreen + " 16 seconds. Maximum of 1.",
|
||||
};
|
||||
|
||||
private static final Perk[] PERKS = {
|
||||
};
|
||||
private static final Perk[] PERKS = {};
|
||||
|
||||
private static final ItemStack IN_HAND = new ItemStack(Material.POTION);
|
||||
|
||||
@ -95,4 +94,10 @@ public class KitMedic extends ProgressingKit
|
||||
stack.setItemMeta(meta);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usesXp()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,6 @@ public class KitSportsman extends ProgressingKit
|
||||
public KitSportsman(ArcadeManager manager)
|
||||
{
|
||||
super(manager, "Sportsman", "snowfightsportsman", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.SKELETON, IN_HAND);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -59,4 +58,10 @@ public class KitSportsman extends ProgressingKit
|
||||
ent.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
|
||||
ent.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usesXp()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ public class KitTactician extends ProgressingKit
|
||||
ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP, (byte) 0, 1, ChatColor.RESET + "Hearty Winter Stew"),
|
||||
ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP, (byte) 0, 1, ChatColor.RESET + "Hearty Winter Stew"),
|
||||
ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP, (byte) 0, 1, ChatColor.RESET + "Hearty Winter Stew"),
|
||||
ItemStackFactory.Instance.CreateStack(Material.COMPASS, (byte) 0, 1, "§a§lTracking Compass")
|
||||
};
|
||||
|
||||
public KitTactician(ArcadeManager manager)
|
||||
@ -60,4 +59,10 @@ public class KitTactician extends ProgressingKit
|
||||
ent.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
|
||||
ent.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usesXp()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user