Add Overtime
This commit is contained in:
parent
47df09b770
commit
1bfebf358f
@ -12,6 +12,8 @@ import java.util.UUID;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Minecart;
|
||||
@ -40,6 +42,7 @@ import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
@ -112,20 +115,29 @@ public class QuiverPayload extends TeamGame
|
||||
|
||||
private static final long OBJECTIVE_PARTICLES_TIME = 10000;
|
||||
|
||||
public static final String DATA_POINT_MARKER_START = "PINK";
|
||||
public static final String DATA_POINT_RED = "RED";
|
||||
public static final String DATA_POINT_BLUE = "BLUE";
|
||||
public static final String DATA_POINT_PAYLOAD = "BLACK";
|
||||
public static final String DATA_POINT_POWERUP = "YELLOW";
|
||||
public static final String DATA_POINT_KIT_RED = "ORANGE";
|
||||
public static final String DATA_POINT_KIT_BLUE = "LIGHT_BLUE";
|
||||
private static final int GEMS_KILL = 9;
|
||||
private static final int GEMS_ASSIST = 3;
|
||||
private static final int GEMS_SCORE = 3;
|
||||
private static final int GEMS_KILLSTREAK = 5;
|
||||
|
||||
private static final String DATA_POINT_MARKER_START = "PINK";
|
||||
private static final String DATA_POINT_RED = "RED";
|
||||
private static final String DATA_POINT_BLUE = "BLUE";
|
||||
private static final String DATA_POINT_PAYLOAD = "BLACK";
|
||||
private static final String DATA_POINT_POWERUP = "YELLOW";
|
||||
private static final String DATA_POINT_KIT_RED = "ORANGE";
|
||||
private static final String DATA_POINT_KIT_BLUE = "LIGHT_BLUE";
|
||||
|
||||
private static final String OVERTIME = C.cGold + "!!! " + C.cDRedB + "OVERTIME" + C.cGold + " !!!";
|
||||
|
||||
private Minecart _minecart;
|
||||
private GameTeam _teamDirection;
|
||||
private int _targetIndex;
|
||||
private boolean _hasMoved;
|
||||
private boolean _isOvertime;
|
||||
private boolean _recentlyChanged;
|
||||
private double _totalDistance;
|
||||
private List<Block> _lastOvertimeTrack = new ArrayList<>();
|
||||
private List<Location> _pathMarkers = new ArrayList<>();
|
||||
|
||||
private PayloadState _payloadState;
|
||||
@ -171,7 +183,7 @@ public class QuiverPayload extends TeamGame
|
||||
this.HungerSet = 20;
|
||||
|
||||
registerModule(new VersionModule(MinecraftVersion.Version1_9, "One in the Quiver Payload requires Minecraft 1.9!"));
|
||||
|
||||
|
||||
_payloadState = PayloadState.NONE;
|
||||
}
|
||||
|
||||
@ -220,17 +232,50 @@ public class QuiverPayload extends TeamGame
|
||||
{
|
||||
Scoreboard.writeNewLine();
|
||||
|
||||
for (GameTeam gameTeam : _teamScore.keySet())
|
||||
if (_isOvertime)
|
||||
{
|
||||
int score = Math.min(_teamScore.get(gameTeam), MAX_SCORE);
|
||||
|
||||
Scoreboard.write(gameTeam.GetColor() + C.Bold + "Team " + gameTeam.getDisplayName());
|
||||
Scoreboard.write(score + " Point" + (score == 1 ? "" : "s") + " (" + (MAX_SCORE - score) + ")");
|
||||
Scoreboard.writeNewLine();
|
||||
for (GameTeam gameTeam : _teamScore.keySet())
|
||||
{
|
||||
Scoreboard.write(gameTeam.GetColor() + C.Bold + "Team " + gameTeam.getDisplayName());
|
||||
|
||||
int alivePlayers = 0;
|
||||
|
||||
for (Player player : gameTeam.GetPlayers(true))
|
||||
{
|
||||
if (UtilPlayer.isSpectator(player))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
alivePlayers++;
|
||||
}
|
||||
|
||||
Scoreboard.write(alivePlayers + "/" + gameTeam.GetPlayers(true).size() + " Alive");
|
||||
Scoreboard.writeNewLine();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (GameTeam gameTeam : _teamScore.keySet())
|
||||
{
|
||||
int score = Math.min(_teamScore.get(gameTeam), MAX_SCORE);
|
||||
|
||||
Scoreboard.write(gameTeam.GetColor() + C.Bold + "Team " + gameTeam.getDisplayName());
|
||||
Scoreboard.write(score + " Point" + (score == 1 ? "" : "s") + " (" + (MAX_SCORE - score) + ")");
|
||||
Scoreboard.writeNewLine();
|
||||
}
|
||||
}
|
||||
|
||||
Scoreboard.write(C.cRedB + "Game End");
|
||||
Scoreboard.write(UtilTime.MakeStr(GAME_TIMEOUT - (System.currentTimeMillis() - GetStateTime())));
|
||||
|
||||
if (_isOvertime)
|
||||
{
|
||||
Scoreboard.write(OVERTIME);
|
||||
}
|
||||
else
|
||||
{
|
||||
Scoreboard.write(UtilTime.MakeStr(GAME_TIMEOUT - (System.currentTimeMillis() - GetStateTime())));
|
||||
}
|
||||
}
|
||||
|
||||
Scoreboard.writeNewLine();
|
||||
@ -249,7 +294,7 @@ public class QuiverPayload extends TeamGame
|
||||
{
|
||||
_teamScore.put(gameTeam, 0);
|
||||
}
|
||||
|
||||
|
||||
CreatureAllowOverride = true;
|
||||
|
||||
spawnKitNPCs(WorldData.GetDataLocs(DATA_POINT_KIT_RED));
|
||||
@ -268,7 +313,7 @@ public class QuiverPayload extends TeamGame
|
||||
Location location = WorldData.GetDataLocs(DATA_POINT_PAYLOAD).get(0);
|
||||
|
||||
_minecart = location.getWorld().spawn(location, Minecart.class);
|
||||
|
||||
|
||||
_minecart.spigot().forceGlowing(true);
|
||||
_minecart.setDisplayBlock(new MaterialData(Material.TNT));
|
||||
_payloadTeam.addEntry(_minecart.getUniqueId().toString());
|
||||
@ -351,28 +396,28 @@ public class QuiverPayload extends TeamGame
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (event.GetState() == GameState.End)
|
||||
{
|
||||
{
|
||||
for (UUID uuid : _ultimatePercentage.keySet())
|
||||
{
|
||||
Player player = UtilPlayer.searchExact(uuid);
|
||||
|
||||
|
||||
for (Perk perk : GetKit(player).GetPerks())
|
||||
{
|
||||
if (!(perk instanceof Ultimate))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Ultimate ultimate = (Ultimate) perk;
|
||||
|
||||
if (ultimate.getLastUltimate().containsKey(player.getUniqueId()))
|
||||
|
||||
if (ultimate.getLastUltimate().containsKey(player.getUniqueId()))
|
||||
{
|
||||
ultimate.cancel(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -403,6 +448,7 @@ public class QuiverPayload extends TeamGame
|
||||
/*
|
||||
* If a particular gameTeam has scored the most points they are
|
||||
* the winners otherwise if all gameTeam's scores are the same,
|
||||
* the game goes into overtime and after OVERTIME milliseconds
|
||||
* the distance from the minecart and that gameTeams destination
|
||||
* is used to determine the winner.
|
||||
*/
|
||||
@ -431,18 +477,24 @@ public class QuiverPayload extends TeamGame
|
||||
|
||||
if (same)
|
||||
{
|
||||
double shortest = Double.MAX_VALUE;
|
||||
|
||||
for (GameTeam gameTeam : _teamScore.keySet())
|
||||
{
|
||||
double distance = getTrackDistanceToMarker(getDestination(gameTeam), gameTeam);
|
||||
|
||||
if (distance < shortest)
|
||||
{
|
||||
shortest = distance;
|
||||
WinnerTeam = gameTeam;
|
||||
}
|
||||
}
|
||||
UtilTextMiddle.display(OVERTIME, "", 10, 30, 10);
|
||||
UtilServer.broadcast(OVERTIME);
|
||||
|
||||
_isOvertime = true;
|
||||
return;
|
||||
|
||||
// double shortest = Double.MAX_VALUE;
|
||||
//
|
||||
// for (GameTeam gameTeam : _teamScore.keySet())
|
||||
// {
|
||||
// double distance = getTrackDistanceToMarker(getDestination(gameTeam), gameTeam);
|
||||
//
|
||||
// if (distance < shortest)
|
||||
// {
|
||||
// shortest = distance;
|
||||
// WinnerTeam = gameTeam;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
AnnounceEnd(WinnerTeam);
|
||||
@ -549,7 +601,7 @@ public class QuiverPayload extends TeamGame
|
||||
}
|
||||
|
||||
if (event.getType() == UpdateType.FAST)
|
||||
{
|
||||
{
|
||||
if (GetPlayers(true).size() >= TEAM_KILL_MINIMUM_PLAYERS)
|
||||
{
|
||||
for (GameTeam gameTeam : GetTeamList())
|
||||
@ -596,9 +648,6 @@ public class QuiverPayload extends TeamGame
|
||||
|
||||
switch (kills)
|
||||
{
|
||||
case 2:
|
||||
name = "DOUBLE";
|
||||
break;
|
||||
case 3:
|
||||
name = "TRIPLE";
|
||||
break;
|
||||
@ -617,6 +666,7 @@ public class QuiverPayload extends TeamGame
|
||||
other.playSound(other.getLocation(), Sound.ENDERDRAGON_GROWL, 1F + kills, 1f + kills);
|
||||
}
|
||||
|
||||
AddGems(player, GEMS_KILLSTREAK * kills, name + " Killstreak", true, true);
|
||||
UtilServer.broadcast(C.cRedB + player.getName() + C.cWhite + " got a " + C.cRedB + name + " KILL" + C.cWhite + "!");
|
||||
}
|
||||
}
|
||||
@ -699,7 +749,7 @@ public class QuiverPayload extends TeamGame
|
||||
{
|
||||
_payloadState = PayloadState.NONE;
|
||||
}
|
||||
|
||||
|
||||
setMinecartTeam(_payloadState);
|
||||
_minecart.setVelocity(new Vector(0, 0, 0));
|
||||
return;
|
||||
@ -749,6 +799,53 @@ public class QuiverPayload extends TeamGame
|
||||
{
|
||||
UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, _minecart.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 1, 10, ViewDist.LONG);
|
||||
}
|
||||
|
||||
if (event.getType() == UpdateType.SEC && _isOvertime)
|
||||
{
|
||||
if (_lastOvertimeTrack.isEmpty())
|
||||
{
|
||||
_lastOvertimeTrack.add(_pathMarkers.get(0).getBlock().getRelative(BlockFace.DOWN));
|
||||
_lastOvertimeTrack.add(_pathMarkers.get(_pathMarkers.size() - 1).getBlock().getRelative(BlockFace.DOWN));
|
||||
}
|
||||
|
||||
Iterator<Block> iterator = _lastOvertimeTrack.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Block block = iterator.next();
|
||||
|
||||
if (isMinecartNearMarker(block.getLocation()))
|
||||
{
|
||||
Location locationA = UtilAlg.findClosest(_minecart.getLocation(), WorldData.GetDataLocs(DATA_POINT_RED));
|
||||
Location locationB = UtilAlg.findClosest(_minecart.getLocation(), WorldData.GetDataLocs(DATA_POINT_BLUE));
|
||||
|
||||
if (UtilMath.offset(_minecart.getLocation(), locationA) < UtilMath.offset(_minecart.getLocation(), locationB))
|
||||
{
|
||||
WinnerTeam = GetTeam(org.bukkit.ChatColor.AQUA);
|
||||
}
|
||||
else
|
||||
{
|
||||
WinnerTeam = GetTeam(org.bukkit.ChatColor.RED);
|
||||
}
|
||||
|
||||
WinnerTeam = _teamDirection;
|
||||
_payloadState = PayloadState.RESTARTING;
|
||||
displayEndEffect();
|
||||
return;
|
||||
}
|
||||
|
||||
for (Block other : UtilBlock.getSurrounding(block, true))
|
||||
{
|
||||
if (other.getType() == Material.RAILS)
|
||||
{
|
||||
block.setType(Material.AIR);
|
||||
iterator.remove();
|
||||
_lastOvertimeTrack.add(other);
|
||||
UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.05F, 30, ViewDist.NORMAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -891,6 +988,11 @@ public class QuiverPayload extends TeamGame
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (GetTeam(player).equals(_teamDirection))
|
||||
{
|
||||
AddGems(player, GEMS_SCORE, "Points", true, true);
|
||||
}
|
||||
|
||||
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 0);
|
||||
}
|
||||
|
||||
@ -1069,7 +1171,7 @@ public class QuiverPayload extends TeamGame
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Player player = event.getPlayer();
|
||||
ProgressingKit kit = (ProgressingKit) GetKit(player);
|
||||
|
||||
@ -1210,7 +1312,7 @@ public class QuiverPayload extends TeamGame
|
||||
{
|
||||
_payloadTeam.setPrefix(gameTeam.GetColor().toString());
|
||||
}
|
||||
|
||||
|
||||
public void setMinecartTeam(PayloadState payloadState)
|
||||
{
|
||||
switch (payloadState)
|
||||
@ -1272,7 +1374,7 @@ public class QuiverPayload extends TeamGame
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Entity entity = GetKits()[i].SpawnEntity(location);
|
||||
ProgressingKit progressingKit = (ProgressingKit) GetKits()[i++];
|
||||
|
||||
@ -1311,8 +1413,20 @@ public class QuiverPayload extends TeamGame
|
||||
_teamScore.put(gameTeam, Integer.parseInt(event.getMessage().split(" ")[1]));
|
||||
}
|
||||
}
|
||||
else if (event.getMessage().startsWith("/overtime"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
_isOvertime = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double GetKillsGems(Player killer, Player killed, boolean assist)
|
||||
{
|
||||
return assist ? GEMS_ASSIST : GEMS_KILL;
|
||||
}
|
||||
|
||||
private static enum PayloadState
|
||||
{
|
||||
NONE, MOVING, CONTESTED, RESTARTING;
|
||||
|
Loading…
Reference in New Issue
Block a user