This commit is contained in:
Sam 2018-07-10 22:10:03 +01:00 committed by Alexander Meech
parent 4873ac7b74
commit aa1c53eb31
6 changed files with 432 additions and 653 deletions

View File

@ -116,9 +116,11 @@ public enum GameType implements Voteable
}, false),
DeathTag(DeathTag.class, GameDisplay.DeathTag),
DragonEscape(DragonEscape.class, GameDisplay.DragonEscape),
Dragons(Dragons.class, GameDisplay.Dragons),
DragonsTeams(DragonsTeams.class, GameDisplay.DragonsTeams),
Draw(Draw.class, GameDisplay.Draw, new Pair[]
Dragons(Dragons.class, new GameMode[]
{
new GameMode(DragonsTeams.class, "Teams Mode")
}, GameDisplay.Dragons),
Draw(Draw.class, GameDisplay.Draw, new Pair[]
{
//Pair.create(MinecraftVersion.ALL, "http://file.mineplex.com/ResDrawMyThing.zip")
Pair.create(MinecraftVersion.ALL, "http://198.20.72.74/ResDrawMyThing.zip")

View File

@ -1,153 +0,0 @@
package nautilus.game.arcade.game.games.dragons;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime;
import org.bukkit.Location;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class DragonData
{
public Dragons Host;
public EnderDragon Dragon;
public Entity TargetEntity = null;
public Location Target = null;
public Location Location = null;
public float Pitch = 0;
public Vector Velocity = new Vector(0,0,0);
public double RangeBest = 1000;
public long RangeTime = 0;
public DragonData(Dragons host, EnderDragon dragon)
{
Host = host;
Dragon = dragon;
Velocity = dragon.getLocation().getDirection().setY(0).normalize();
Pitch = UtilAlg.GetPitch(dragon.getLocation().getDirection());
Location = dragon.getLocation();
}
public void Move()
{
Turn();
Location.add(Velocity);
Location.add(0, -Pitch, 0);
Location.setPitch(-1 * Pitch);
Location.setYaw(180 + UtilAlg.GetYaw(Velocity));
Dragon.teleport(Location);
}
private void Turn()
{
//Pitch
float desiredPitch = UtilAlg.GetPitch(UtilAlg.getTrajectory(Location, Target));
if (desiredPitch < Pitch) Pitch = (float)(Pitch - 0.05);
if (desiredPitch > Pitch) Pitch = (float)(Pitch + 0.05);
if (Pitch > 0.5) Pitch = 0.5f;
if (Pitch < -0.5) Pitch = -0.5f;
//Flat
Vector desired = UtilAlg.getTrajectory2d(Location, Target);
desired.subtract(UtilAlg.Normalize(new Vector(Velocity.getX(), 0, Velocity.getZ())));
desired.multiply(0.075);
Velocity.add(desired);
//Speed
UtilAlg.Normalize(Velocity);
}
public void Target()
{
if (TargetEntity != null)
{
if (!TargetEntity.isValid())
{
TargetEntity = null;
}
else
{
Target = TargetEntity.getLocation().subtract(0, 8, 0);
}
return;
}
if (Target == null)
{
TargetSky();
}
if (UtilMath.offset(Location, Target) < 4)
{
//Target Player
if (Target.getY() >= Host.GetSpectatorLocation().getY())
{
TargetPlayer();
}
//Target Sky
else
{
TargetSky();
}
}
TargetTimeout();
}
public void TargetTimeout()
{
if (UtilMath.offset(Location, Target)+1 < RangeBest)
{
RangeTime = System.currentTimeMillis();
RangeBest = UtilMath.offset(Location, Target);
}
else
{
if (UtilTime.elapsed(RangeTime, 10000))
{
TargetSky();
}
}
}
public void TargetSky()
{
RangeBest = 9000;
RangeTime = System.currentTimeMillis();
Target = Host.GetSpectatorLocation().clone().add(50 - UtilMath.r(100), 20 + UtilMath.r(30), 50 - UtilMath.r(100));
}
public void TargetPlayer()
{
RangeBest = 9000;
RangeTime = System.currentTimeMillis();
Player player = Host.GetPlayers(true).get(UtilMath.r(Host.GetPlayers(true).size()));
Target = player.getLocation();
Target.add(UtilAlg.getTrajectory(Location, Target).multiply(4));
}
public void HitByArrow()
{
TargetSky();
}
}

View File

@ -1,20 +1,23 @@
package nautilus.game.arcade.game.games.dragons;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.bukkit.EntityEffect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
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.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import com.mineplex.anticheat.checks.move.Glide;
import com.mineplex.anticheat.checks.move.HeadRoll;
@ -25,7 +28,6 @@ import mineplex.core.antihack.AntiHack;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -33,8 +35,7 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.PlayerStateChangeEvent;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.events.PlayerDeathOutEvent;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.dragons.kits.KitCoward;
import nautilus.game.arcade.game.games.dragons.kits.KitMarksman;
@ -48,33 +49,40 @@ import nautilus.game.arcade.stats.SparklezStatTracker;
public class Dragons extends SoloGame
{
private HashMap<EnderDragon, DragonData> _dragons = new HashMap<EnderDragon, DragonData>();
private ArrayList<Location> _dragonSpawns = new ArrayList<Location>();
private PerkSparkler _sparkler = null;
public Dragons(ArcadeManager manager)
private static final String[] DESCRIPTION =
{
"You have angered the Dragons!",
"Survive as best you can!!!",
"Last player alive wins!"
};
private static final int MAX_DRAGONS = 5;
private final Set<MineplexDragon> _dragons;
private List<Location> _dragonSpawns;
private PerkSparkler _sparkler;
public Dragons(ArcadeManager manager)
{
super(manager, GameType.Dragons,
this(manager, GameType.Dragons, DESCRIPTION);
}
new Kit[]
public Dragons(ArcadeManager manager, GameType gameType, String[] description)
{
super(manager, gameType, new Kit[]
{
new KitCoward(manager),
new KitMarksman(manager),
new KitPyrotechnic(manager)
},
new KitCoward(manager),
new KitMarksman(manager),
new KitPyrotechnic(manager)
}, description);
new String[]
{
"You have angered the Dragons!",
"Survive as best you can!!!",
"Last player alive wins!"
});
this.DamagePvP = false;
this.HungerSet = 20;
this.WorldWaterDamage = 4;
this.PlayerGameMode = GameMode.ADVENTURE;
_dragons = new HashSet<>(MAX_DRAGONS);
DamagePvP = false;
HungerSet = 20;
WorldWaterDamage = 4;
PlayerGameMode = GameMode.ADVENTURE;
registerStatTrackers(
new SparklezStatTracker(this)
@ -88,9 +96,6 @@ public class Dragons extends SoloGame
);
new CompassModule()
.setGiveCompass(true)
.setGiveCompassToSpecs(true)
.setGiveCompassToAlive(false)
.register(this);
// Disable specific GWEN checks for this game
@ -99,19 +104,12 @@ public class Dragons extends SoloGame
antiHack.addIgnoredCheck(Glide.class);
antiHack.addIgnoredCheck(HeadRoll.class);
}
@Override
public void ParseData()
public void ParseData()
{
_dragonSpawns = WorldData.GetDataLocs("RED");
}
@EventHandler
public void SparklerAttract(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (_sparkler == null)
{
for (Kit kit : GetKits())
@ -120,34 +118,155 @@ public class Dragons extends SoloGame
{
if (perk instanceof PerkSparkler)
{
_sparkler = (PerkSparkler)perk;
_sparkler = (PerkSparkler) perk;
}
}
}
}
for (Item item : _sparkler.GetItems())
{
if (item.getLocation().getY() < 4 || item.getLocation().getBlock().isLiquid())
continue;
for (DragonData data : _dragons.values())
{
if (UtilMath.offset(data.Location, item.getLocation()) < 48)
{
data.TargetEntity = item;
}
}
}
}
private void giveSurvivedGems(Player player)
@EventHandler
public void dragonSpawn(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC_05 || !IsLive())
{
return;
}
_dragons.removeIf(dragon -> !dragon.getEntity().isValid());
if (_dragons.size() < MAX_DRAGONS)
{
CreatureAllowOverride = true;
Location location = UtilAlg.Random(_dragonSpawns);
if (location == null)
{
return;
}
EnderDragon dragon = location.getWorld().spawn(location, EnderDragon.class);
UtilEnt.vegetate(dragon);
location.getWorld().playSound(location, Sound.ENDERDRAGON_GROWL, 20f, 1f);
_dragons.add(new MineplexDragon(this, dragon));
CreatureAllowOverride = false;
}
}
@EventHandler
public void dragonTarget(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTEST || !IsLive())
{
return;
}
_dragons.forEach(MineplexDragon::updateTarget);
for (Item item : _sparkler.GetItems())
{
Location location = item.getLocation();
if (location.getY() < 4 || location.getBlock().isLiquid())
{
continue;
}
_dragons.forEach(dragon -> dragon.targetSparkler(location));
}
}
@EventHandler
public void dragonTarget(EntityTargetEvent event)
{
if (!IsLive())
{
return;
}
event.setCancelled(true);
}
@EventHandler
public void dragonArrowDamage(CustomDamageEvent event)
{
if (event.GetProjectile() == null)
{
return;
}
for (MineplexDragon dragon : _dragons)
{
if (dragon.getEntity().equals(event.GetDamageeEntity()))
{
dragon.targetSky();
return;
}
}
}
@EventHandler
public void knockback(CustomDamageEvent event)
{
if (event.IsCancelled())
{
return;
}
Entity damager = event.GetDamagerEntity(true);
Player damagee = event.GetDamageePlayer();
if (damagee == null || damager == null)
{
return;
}
event.SetCancelled("Dragon");
event.SetKnockback(false);
damagee.playEffect(EntityEffect.HURT);
UtilAction.velocity(damagee, UtilAlg.getTrajectory(damager, damagee), 1, false, 0, 0.6, 2, true);
}
@EventHandler
public void fallDamage(CustomDamageEvent event)
{
if (event.IsCancelled() || event.GetCause() != DamageCause.FALL)
{
return;
}
event.AddMod(GetName(), "Fall Reduction", -1, false);
}
@EventHandler(priority = EventPriority.LOW)
public void itemSpawn(ItemSpawnEvent event)
{
if (event.getEntity().getItemStack().getType() == Material.EMERALD)
{
return;
}
event.setCancelled(true);
}
@EventHandler
public void playerOut(PlayerDeathOutEvent event)
{
giveSurvivedGems(event.GetPlayer());
}
protected void giveSurvivedGems(Player player)
{
long time = (System.currentTimeMillis() - GetStateTime());
double gems = time/10000d;
double gems = time / 10000d;
String reason = "Survived for " + UtilTime.MakeStr(time);
this.AddGems(player, gems, reason, false, false);
AddGems(player, gems, reason, false, false);
}
@Override
@ -158,144 +277,4 @@ public class Dragons extends SoloGame
super.AnnounceEnd(places);
}
@EventHandler
public void Death(PlayerStateChangeEvent event)
{
if (event.GetState() != PlayerState.OUT)
{
return;
}
giveSurvivedGems(event.GetPlayer());
}
@EventHandler
public void DragonSpawn(UpdateEvent event)
{
if (event.getType() != UpdateType.SLOW)
return;
if (GetState() != GameState.Live)
return;
Iterator<EnderDragon> dragonIterator = _dragons.keySet().iterator();
while (dragonIterator.hasNext())
{
EnderDragon ent = dragonIterator.next();
if (!ent.isValid())
{
dragonIterator.remove();
ent.remove();
}
}
if (_dragons.size() < 7)
{
CreatureAllowOverride = true;
EnderDragon ent = GetSpectatorLocation().getWorld().spawn(_dragonSpawns.get(0), EnderDragon.class);
UtilEnt.vegetate(ent);
CreatureAllowOverride = false;
ent.getWorld().playSound(ent.getLocation(), Sound.ENDERDRAGON_GROWL, 20f, 1f);
_dragons.put(ent, new DragonData(this, ent));
}
}
@EventHandler
public void DragonLocation(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (GetState() != GameState.Live)
return;
//Dragon Update!
for (DragonData data : _dragons.values())
{
data.Target();
data.Move();
}
}
@EventHandler
public void DragonTargetCancel(EntityTargetEvent event)
{
event.setCancelled(true);
}
@EventHandler
public void DragonArrowDamage(CustomDamageEvent event)
{
if (event.GetProjectile() == null)
return;
if (!_dragons.containsKey(event.GetDamageeEntity()))
return;
_dragons.get(event.GetDamageeEntity()).HitByArrow();
}
@EventHandler
public void Knockback(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
Player damagee = event.GetDamageePlayer();
if (damagee == null) return;
if (event.GetDamagerEntity(true) == null)
return;
event.SetCancelled("Dragon");
event.AddMod("Dragon", "Damage Reduction", -1 * (event.GetDamageInitial()-1), false);
event.SetKnockback(false);
damagee.playEffect(EntityEffect.HURT);
UtilAction.velocity(damagee, UtilAlg.getTrajectory(event.GetDamagerEntity(true), damagee), 1, false, 0, 0.6, 2, true);
}
@EventHandler
public void FallDamage(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
if (event.GetCause() == DamageCause.FALL)
event.AddMod("Fall Reduction", "Fall Reduction", -1, false);
}
/*
@EventHandler
public void DragonKnockback(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (DragonData data : _dragons.values())
{
UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, data.Dragon.getLocation(), 0f, 0f, 0f, 0, 1);
for (Player player : GetPlayers(true))
{
if (!Recharge.Instance.use(player, "Dragon Hit", 500, false, false))
continue;
if (UtilMath.offset(player, data.Dragon) < 6)
{
UtilAction.velocity(player, UtilAlg.getTrajectory(data.Dragon, player), 1, false, 0, 0.6, 2, true);
player.damage(1);
}
}
}
}
*/
}

View File

@ -1,345 +1,181 @@
package nautilus.game.arcade.game.games.dragons;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import org.bukkit.EntityEffect;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime;
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.PlayerStateChangeEvent;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.dragons.kits.*;
import nautilus.game.arcade.game.modules.TeamArmorModule;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkSparkler;
import nautilus.game.arcade.managers.chat.ChatStatData;
public class DragonsTeams extends TeamGame
public class DragonsTeams extends Dragons
{
private HashMap<EnderDragon, DragonTeamsData> _dragons = new HashMap<EnderDragon, DragonTeamsData>();
private ArrayList<Location> _dragonSpawns = new ArrayList<Location>();
private ArrayList<String> _lastScoreboard = new ArrayList<String>();
private HashMap<GameTeam, Integer> _teamScore = new HashMap<GameTeam, Integer>();
private PerkSparkler _sparkler = null;
public DragonsTeams(ArcadeManager manager)
private final Map<GameTeam, Integer> _scores;
public DragonsTeams(ArcadeManager manager)
{
super(manager, GameType.DragonsTeams,
super(manager, GameType.Dragons, new String[]
{
"You have angered the Dragons!",
"Survive as best you can!!!",
"Team with longest time survived wins!"
});
new Kit[]
{
new KitCoward(manager),
new KitMarksman(manager),
new KitPyrotechnic(manager)
},
new String[]
{
"You have angered the Dragons!",
"Survive as best you can!!!",
"Team with longest time survived wins!"
});
this.DamagePvP = false;
this.HungerSet = 20;
this.WorldWaterDamage = 4;
this.PrepareFreeze = false;
registerChatStats(
Deaths,
DamageTaken,
BlankLine,
new ChatStatData("kit", "Kit", true)
);
_scores = new HashMap<>();
new TeamArmorModule()
.giveTeamArmor()
.giveHotbarItem()
.register(this);
}
@Override
public void ParseData()
{
_dragonSpawns = WorldData.GetDataLocs("RED");
}
@EventHandler
public void SparklerAttract(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (_sparkler == null)
{
for (Kit kit : GetKits())
{
for (Perk perk : kit.GetPerks())
{
if (perk instanceof PerkSparkler)
{
_sparkler = (PerkSparkler)perk;
}
}
}
}
for (Item item : _sparkler.GetItems())
{
for (DragonTeamsData data : _dragons.values())
{
if (UtilMath.offset(data.Location, item.getLocation()) < 48)
{
data.TargetEntity = item;
}
}
}
}
private void giveSurvivedGems(Player player)
{
long time = (System.currentTimeMillis() - GetStateTime());
double gems = time/10000d;
String reason = "Survived for " + UtilTime.MakeStr(time);
this.AddGems(player, gems, reason, false, false);
}
@Override
public void AnnounceEnd(List<Player> places)
{
// Give the winner gems for surviving the latest
giveSurvivedGems(places.get(0));
super.AnnounceEnd(places);
}
@EventHandler
public void Death(PlayerStateChangeEvent event)
public void CustomTeamGeneration(GameStateChangeEvent event)
{
if (event.GetState() != PlayerState.OUT)
if (event.GetState() != GameState.Recruit)
{
return;
}
giveSurvivedGems(event.GetPlayer());
GameTeam team = GetTeamList().get(0);
GetTeamList().clear();
List<Location> spawns = team.GetSpawns();
AddTeam(new GameTeam(this, "Red", ChatColor.RED, spawns));
AddTeam(new GameTeam(this, "Yellow", ChatColor.YELLOW, spawns));
AddTeam(new GameTeam(this, "Green", ChatColor.GREEN, spawns));
AddTeam(new GameTeam(this, "Blue", ChatColor.AQUA, spawns));
}
@EventHandler
public void DragonSpawn(UpdateEvent event)
public void prepare(GameStateChangeEvent event)
{
if (event.getType() != UpdateType.SLOW)
return;
if (GetState() != GameState.Live)
return;
Iterator<EnderDragon> dragonIterator = _dragons.keySet().iterator();
while (dragonIterator.hasNext())
if (event.GetState() != GameState.Prepare)
{
EnderDragon ent = dragonIterator.next();
if (!ent.isValid())
return;
}
GetTeamList().forEach(team -> _scores.put(team, 0));
}
@EventHandler
public void updateScores(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC || !IsLive())
{
return;
}
for (GameTeam team : GetTeamList())
{
List<Player> alive = team.GetPlayers(true);
if (alive.isEmpty())
{
dragonIterator.remove();
ent.remove();
continue;
}
}
if (_dragons.size() < 7)
{
CreatureAllowOverride = true;
EnderDragon ent = GetSpectatorLocation().getWorld().spawn(_dragonSpawns.get(0), EnderDragon.class);
UtilEnt.vegetate(ent);
CreatureAllowOverride = false;
ent.getWorld().playSound(ent.getLocation(), Sound.ENDERDRAGON_GROWL, 20f, 1f);
_dragons.put(ent, new DragonTeamsData(this, ent));
_scores.put(team, _scores.get(team) + alive.size());
}
}
@EventHandler
public void DragonLocation(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (GetState() != GameState.Live)
return;
//Dragon Update!
for (DragonTeamsData data : _dragons.values())
{
data.Target();
data.Move();
}
}
@EventHandler
public void DragonTargetCancel(EntityTargetEvent event)
{
event.setCancelled(true);
}
@EventHandler
public void DragonArrowDamage(CustomDamageEvent event)
{
if (event.GetProjectile() == null)
return;
if (!_dragons.containsKey(event.GetDamageeEntity()))
return;
_dragons.get(event.GetDamageeEntity()).HitByArrow();
}
@EventHandler
public void Knockback(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
Player damagee = event.GetDamageePlayer();
if (damagee == null) return;
if (event.GetDamagerEntity(true) == null)
return;
event.SetCancelled("Dragon");
event.AddMod("Dragon", "Damage Reduction", -1 * (event.GetDamageInitial()-1), false);
event.SetKnockback(false);
damagee.playEffect(EntityEffect.HURT);
UtilAction.velocity(damagee, UtilAlg.getTrajectory(event.GetDamagerEntity(true), damagee), 1, false, 0, 0.6, 2, true);
}
@EventHandler
public void FallDamage(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
if (event.GetCause() == DamageCause.FALL)
event.AddMod("Fall Reduction", "Fall Reduction", -1, false);
}
@Override
@EventHandler
public void ScoreboardUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
if (IsLive())
for (GameTeam team : GetTeamList())
{
if (!_teamScore.containsKey(team))
_teamScore.put(team, 0);
if (team.IsTeamAlive())
_teamScore.put(team, _teamScore.get(team) + team.GetPlayers(true).size());
}
WriteScoreboard();
}
private void WriteScoreboard()
{
//Wipe Last
Scoreboard.reset();
for (GameTeam team : _teamScore.keySet())
if (event.getType() != UpdateType.SEC || !InProgress())
{
//Time
int seconds = _teamScore.get(team);
Scoreboard.writeNewLine();
Scoreboard.write(team.GetColor() + team.GetName());
Scoreboard.write(team.GetColor() + "" + seconds + " Seconds");
return;
}
Scoreboard.writeNewLine();
_scores.forEach((team, score) ->
{
Scoreboard.write(team.GetFormattedName());
Scoreboard.write(score + " Points");
Scoreboard.writeNewLine();
});
Scoreboard.draw();
}
@Override
public void EndCheck()
{
if (!IsLive())
return;
ArrayList<GameTeam> teamsAlive = new ArrayList<GameTeam>();
for (GameTeam team : this.GetTeamList())
if (team.GetPlayers(true).size() > 0)
teamsAlive.add(team);
if (teamsAlive.size() <= 0)
{
//Get Winner
GameTeam winner = null;
int bestTime = 0;
for (GameTeam team : _teamScore.keySet())
{
if (winner == null || _teamScore.get(team) > bestTime)
{
winner = team;
bestTime = _teamScore.get(team);
}
}
//Announce
if (winner != null)
{
AnnounceEnd(winner);
this.SetCustomWinLine("Survived " + bestTime + " Seconds!");
}
for (GameTeam team : GetTeamList())
{
if (WinnerTeam != null && team.equals(WinnerTeam))
{
for (Player player : team.GetPlayers(false))
AddGems(player, 10, "Winning Team", false, false);
}
for (Player player : team.GetPlayers(false))
if (player.isOnline())
AddGems(player, 10, "Participation", false, false);
}
//End
SetState(GameState.End);
return;
}
for (GameTeam team : _scores.keySet())
{
if (team.IsTeamAlive())
{
return;
}
}
List<GameTeam> placements = _scores.entrySet().stream()
// Reversed natural ordering
.sorted((o1, o2) -> o2.getValue().compareTo(o1.getValue()))
.map(Entry::getKey)
.collect(Collectors.toList());
if (placements.isEmpty())
{
return;
}
GetPlayers(true).forEach(this::giveSurvivedGems);
AnnounceEnd(placements.get(0));
SetState(GameState.End);
}
@Override
public List<Player> getWinners()
{
if (WinnerTeam == null)
{
return Collections.emptyList();
}
return WinnerTeam.GetPlayers(true);
}
@Override
public List<Player> getLosers()
{
if (WinnerTeam == null)
{
return Collections.emptyList();
}
List<Player> losers = GetPlayers(false);
losers.removeAll(getWinners());
return losers;
}
@Override
public String GetMode()
{
return "Teams Mode";
}
}

View File

@ -0,0 +1,125 @@
package nautilus.game.arcade.game.games.dragons;
import net.minecraft.server.v1_8_R3.EntityEnderDragon;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEnderDragon;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
public class MineplexDragon
{
private static final int MAX_SPARKLER_DISTANCE = 48 * 48;
private final Dragons _host;
private final EnderDragon _entity;
MineplexDragon(Dragons host, EnderDragon entity)
{
_host = host;
_entity = entity;
targetSky();
}
void updateTarget()
{
Location location = _entity.getLocation(), spectatorLocation = _host.GetSpectatorLocation();
// Too low (target fell into void?).
if (location.getY() < 10)
{
targetSky();
return;
}
// Not near target.
if (UtilMath.offsetSquared(location, getTarget()) > 36)
{
return;
}
// Too high.
if (location.getY() > spectatorLocation.getY())
{
targetPlayer();
}
// In the middle.
else
{
targetSky();
}
}
void targetPlayer()
{
Player player = UtilAlg.Random(_host.GetPlayers(true));
// No alive player found.
if (player == null)
{
targetSky();
}
else
{
setTargetEntity(player);
}
}
void targetSky()
{
setTargetLocation(_host.GetSpectatorLocation().clone().add(UtilMath.rRange(-50, 50), UtilMath.rRange(20, 40), UtilMath.rRange(-50, 50)));
}
void targetSparkler(Location location)
{
// Too far from sparkler to see
if (UtilMath.offsetSquared(location, _entity.getLocation()) > MAX_SPARKLER_DISTANCE)
{
return;
}
setTargetLocation(location);
}
private void setTargetLocation(Location location)
{
getHandle().setTargetBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
}
private void setTargetEntity(Entity entity)
{
getHandle().setTargetEntity(((CraftEntity) entity).getHandle());
}
private Location getTarget()
{
EntityEnderDragon dragon = getHandle();
if (dragon.target != null)
{
return new Location(_entity.getWorld(), dragon.target.locX, dragon.target.locY, dragon.target.locZ);
}
else
{
// a = targetX, b = targetY, c = targetZ
return new Location(_entity.getWorld(), dragon.a, dragon.b, dragon.c);
}
}
private EntityEnderDragon getHandle()
{
return ((CraftEnderDragon) _entity).getHandle();
}
public EnderDragon getEntity()
{
return _entity;
}
}

View File

@ -18,11 +18,7 @@ import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
@ -211,12 +207,6 @@ public class NewGameLobbyManager extends LobbyManager
return;
}
WORLD.getEntities().stream()
.filter(entity -> !(entity instanceof Player) && !(entity instanceof ArmorStand) && !(entity instanceof Item))
.filter(entity -> entity.isCustomNameVisible() && entity.getCustomName() != null)
.filter(entity -> !getTeams().containsKey(entity))
.forEach(Entity::remove);
List<Kit> kitList = Lists.newArrayList(game.GetKits()).stream()
.filter(kit -> !(kit instanceof NullKit))
.filter(kit -> kit.GetAvailability() != KitAvailability.Hide)
@ -536,7 +526,7 @@ public class NewGameLobbyManager extends LobbyManager
Location amp = _singleLocs.get(DataLoc.AMP.name());
if (amp != null)
{
amp.setYaw(getYawToSpawn(missions, false));
amp.setYaw(getYawToSpawn(amp, false));
setAmpStand(amp);
}
}