Remove some unused code and cleanup

This commit is contained in:
Sam 2016-08-17 22:28:22 +01:00
parent 84e5b38380
commit 8d6e4a5fd3
5 changed files with 138 additions and 93 deletions

View File

@ -41,6 +41,9 @@ import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextBottom;
@ -48,6 +51,7 @@ import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTextTop;
import mineplex.core.common.util.UtilTime;
import mineplex.core.hologram.Hologram;
import mineplex.core.scoreboard.MineplexScoreboard;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.CombatComponent;
@ -79,10 +83,6 @@ public class QuiverPayload extends TeamGame
private static final long GAME_TIMEOUT = 600000;
private static final double PAYLOAD_CAPTURE_RANGE = 4;
private static final double PAYLOAD_INITIAL_VELOCITY = 0.2;
private static final double PAYLOAD_VELOCITY_INCREASE_FACTOR = 1.5;
private static final long PAYLOAD_VELOCITY_INCREASE_TIME = 120000;
private static final long PAYLOAD_APPROACHING_TIME = 20000;
private static final int PAYLOAD_APPROACHING_DISTANCE = 20;
private static final int PAYLOAD_MARKER_MAX_DISTANCE = 2;
private static final int PAYLOAD_RENGERATION_DURATION = 3 * 20;
private static final int PAYLOAD_RENGERATION_AMPLIFIER = 1;
@ -110,18 +110,17 @@ public class QuiverPayload extends TeamGame
private GameTeam _teamDirection;
private Vector _lastDirection;
private double _payloadVelocity;
private long _lastSpeedIncrease;
private int _targetIndex;
private boolean _recentlyChanged;
private double _totalDistance;
private boolean _contested;
private long _lastAnnoucement;
private List<Location> _pathMarkers = new ArrayList<>();
private boolean _hasAnnouncedGameEnd;
private boolean _isEnding;
private boolean _isRestarting;
private int teamAScore;
private int teamBScore;
private int _teamAScore;
private int _teamBScore;
private List<PowerupGenerator> _powerupGenerators = new ArrayList<>();
@ -144,7 +143,7 @@ public class QuiverPayload extends TeamGame
});
this.DeathOut = false;
this.DeathSpectateSecs = 1;
this.DeathSpectateSecs = 5;
this.DamageSelf = false;
this.DamageTeamSelf = false;
this.DamageFall = false;
@ -152,7 +151,7 @@ public class QuiverPayload extends TeamGame
this.TeamArmorHotbar = true;
this.HungerSet = 20;
registerModule(new VersionModule(MinecraftVersion.Version1_9, "One in the Quiver Payload requires minecraft 1.9!"));
registerModule(new VersionModule(MinecraftVersion.Version1_9, "One in the Quiver Payload requires Minecraft 1.9!"));
}
@Override
@ -178,6 +177,10 @@ public class QuiverPayload extends TeamGame
{
Scoreboard.write(C.cDPurpleB + "Contested");
}
else if (_isRestarting)
{
Scoreboard.write("Respawning...");
}
else if (_teamDirection != null)
{
String distance = new DecimalFormat("0.0").format(getTrackDistanceToMarker(getDestination(_teamDirection)));
@ -192,16 +195,13 @@ public class QuiverPayload extends TeamGame
{
Scoreboard.writeNewLine();
// Scoreboard.write(C.cGreenB + "Next Speed Increase");
// Scoreboard.write(UtilTime.MakeStr(PAYLOAD_VELOCITY_INCREASE_TIME - (System.currentTimeMillis() - _lastSpeedIncrease)));
Scoreboard.write(C.cRedB + "Team Red");
Scoreboard.write(teamAScore + " Point" + (teamAScore == 1 ? "" : "s") + " (" + (MAX_SCORE - teamAScore) + " needed)");
Scoreboard.write(_teamAScore + " Point" + (_teamAScore == 1 ? "" : "s") + " (" + (MAX_SCORE - _teamAScore) + " needed)");
Scoreboard.writeNewLine();
Scoreboard.write(C.cAquaB + "Team Blue");
Scoreboard.write(teamBScore + " Point" + (teamBScore == 1 ? "" : "s") + " (" + (MAX_SCORE - teamBScore) + " needed)");
Scoreboard.write(_teamBScore + " Point" + (_teamBScore == 1 ? "" : "s") + " (" + (MAX_SCORE - _teamBScore) + " needed)");
Scoreboard.writeNewLine();
@ -219,10 +219,16 @@ public class QuiverPayload extends TeamGame
if (event.GetState() == GameState.Prepare)
{
// This hides all nametags of the enemy teams.
for (Team team : Scoreboard.getScoreboard().getTeams())
for (MineplexScoreboard scoreboard : Manager.getScoreboardManager().getScoreboards().values())
{
team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS);
for (Team team : scoreboard.getHandle().getTeams())
{
team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS);
}
}
Manager.GetLobby().AddPlayerToScoreboards(null, GetTeamList().get(0));
Manager.GetLobby().AddPlayerToScoreboards(null, GetTeamList().get(1));
CreatureAllowOverride = true;
@ -269,8 +275,6 @@ public class QuiverPayload extends TeamGame
_minecart = location.getWorld().spawn(location, Minecart.class);
_hologram = new Hologram(Manager.getHologramManager(), location.add(0, 1, 0), "None");
_lastSpeedIncrease = System.currentTimeMillis();
_lastAnnoucement = System.currentTimeMillis();
_payloadVelocity = PAYLOAD_INITIAL_VELOCITY;
_minecart.spigot().forceGlowing(true);
@ -280,6 +284,11 @@ public class QuiverPayload extends TeamGame
for (Player player : GetPlayers(true))
{
if (GetKit(player) instanceof KitNewNinja)
{
continue;
}
// Give all players a Super Arrow item.
player.getInventory().addItem(Quiver.SUPER_ARROW);
}
@ -380,7 +389,7 @@ public class QuiverPayload extends TeamGame
* winner and visa versa.
*/
if (teamAScore == teamBScore)
if (_teamAScore == _teamBScore)
{
if (getTrackDistanceToMarker(getDestination(teamA), teamA) < getTrackDistanceToMarker(getDestination(teamB), teamB))
{
@ -391,7 +400,7 @@ public class QuiverPayload extends TeamGame
WinnerTeam = teamB;
}
}
else if (teamAScore > teamBScore)
else if (_teamAScore > _teamBScore)
{
WinnerTeam = teamA;
}
@ -474,23 +483,8 @@ public class QuiverPayload extends TeamGame
}
}
if (event.getType() == UpdateType.FAST && _minecart != null && IsLive())
if (event.getType() == UpdateType.FAST && _minecart != null && !_isRestarting && IsLive())
{
// if (UtilTime.elapsed(_lastSpeedIncrease, PAYLOAD_VELOCITY_INCREASE_TIME))
// {
// _lastSpeedIncrease = System.currentTimeMillis();
// _payloadVelocity *= PAYLOAD_VELOCITY_INCREASE_FACTOR;
//
// String message = C.cGreenB + "The payload\'s speed has been increased!";
//
// UtilTextMiddle.display("", message, 10, 20, 10);
// UtilServer.broadcast(message);
//
// for (Player player : UtilServer.getPlayers())
// {
// player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 0);
// }
// }
/*
* In order to determine which direction the payload will move we
@ -598,26 +592,6 @@ public class QuiverPayload extends TeamGame
}
}
/*
* If PAYLOAD_APPROACHING_TIME milliseconds has past and the
* minecart is within PAYLOAD_APPOACHING_DISTANCE blocks of the
* destination of it's current direction.
*/
// if (UtilTime.elapsed(_lastAnnoucement, PAYLOAD_APPROACHING_TIME) && isMinecartNearMarker(getDestination(_teamDirection), PAYLOAD_APPROACHING_DISTANCE))
// {
// _lastAnnoucement = System.currentTimeMillis();
//
// String message = _teamDirection.GetColor() + C.Bold + "The payload is approaching its destination!";
//
// UtilTextMiddle.display("", message, 10, 20, 10);
// UtilServer.broadcast(message);
//
// for (Player player : UtilServer.getPlayers())
// {
// player.playSound(player.getLocation(), Sound.NOTE_PLING, 1, 0);
// }
// }
/*
* The minecart's velocity is set to the vector between the the
* minecart's current location and the next data point it will
@ -631,24 +605,28 @@ public class QuiverPayload extends TeamGame
_lastDirection = _minecart.getVelocity();
_hologram.setText(_teamDirection.GetFormattedName());
}
else if (event.getType() == UpdateType.FASTER && _isRestarting)
{
UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, _minecart.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 1, 10, ViewDist.LONG);
}
}
@Override
public void EndCheck()
{
if (!IsLive())
if (!IsLive() || _isRestarting)
{
return;
}
boolean end = false;
if (isMinecartNearMarker(_pathMarkers.get(_pathMarkers.size() - 1)) && _teamDirection.equals(GetTeamList().get(0)))
if (isMinecartNearMarker(getDestination(_teamDirection)) && _teamDirection.equals(GetTeamList().get(0)))
{
WinnerTeam = GetTeamList().get(0);
teamAScore++;
_teamAScore++;
if (teamAScore == MAX_SCORE)
if (_teamAScore == MAX_SCORE)
{
end = true;
}
@ -657,12 +635,12 @@ public class QuiverPayload extends TeamGame
resetMinecart(WinnerTeam);
}
}
else if (isMinecartNearMarker(_pathMarkers.get(0)) && _teamDirection.equals(GetTeamList().get(1)))
else if (isMinecartNearMarker(getDestination(_teamDirection)) && _teamDirection.equals(GetTeamList().get(1)))
{
WinnerTeam = GetTeamList().get(1);
teamBScore++;
_teamBScore++;
if (teamBScore == MAX_SCORE)
if (_teamBScore == MAX_SCORE)
{
end = true;
}
@ -684,12 +662,7 @@ public class QuiverPayload extends TeamGame
}
private boolean isMinecartNearMarker(Location marker, double distance)
{
if (_minecart == null)
{
return false;
}
{
return UtilMath.offset(_minecart.getLocation(), marker) < distance;
}
@ -777,36 +750,62 @@ public class QuiverPayload extends TeamGame
private void resetMinecart(GameTeam gameTeam)
{
_isRestarting = true;
setMinecartTeam(null);
_lastDirection = null;
_teamDirection = null;
_recentlyChanged = false;
UtilAction.zeroVelocity(_minecart);
String message = gameTeam.GetFormattedName() + " scored a point! Payload reset";
String message = gameTeam.GetFormattedName() + " scored a point! Payload respawning...";
UtilTextMiddle.display("", message, 10, 20, 10);
UtilServer.broadcast(message);
_minecart.remove();
_minecart = null;
displayPointScoreEffect();
for (Player player : UtilServer.getPlayers())
{
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 0);
}
new BukkitRunnable()
{
Location toTeleport = WorldData.GetDataLocs(DATA_POINT_PAYLOAD).get(0);
@Override
public void run()
{
_minecart = _minecart.getWorld().spawn(WorldData.GetDataLocs(DATA_POINT_PAYLOAD).get(0), Minecart.class);
_hologram.setFollowEntity(_minecart);
UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _minecart.getLocation().add(0, 1, 0), 0, 0, 0, 1, 1, ViewDist.LONG);
UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, toTeleport, 0, 0, 0, 1, 1, ViewDist.LONG);
_minecart.teleport(toTeleport);
_isRestarting = false;
}
}.runTaskLater(Manager.getPlugin(), PAYLOAD_RESPAWN_DELAY_TICKS);
}
private void displayPointScoreEffect()
{
if (_isEnding)
{
return;
}
Location location = _minecart.getLocation().add(0, 1, 0);
UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, location, 0, 0, 0, 1, 1, ViewDist.LONG);
UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, location, 0, 0, 0, 1, 200, ViewDist.LONG);
for (Player player : UtilPlayer.getNearby(_minecart.getLocation(), 15))
{
if (!IsAlive(player))
{
continue;
}
UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), location).normalize().multiply(1 - UtilMath.offset(location, player.getLocation())).setY(1.5));
}
}
private void displayEndEffect()
{
@ -1014,7 +1013,7 @@ public class QuiverPayload extends TeamGame
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event)
{
if (_kitNPCs.containsKey(event.getRightClicked()))
if (_kitNPCs.containsKey(event.getRightClicked()) && IsAlive(event.getPlayer()))
{
ProgressingKit progressingKit = _kitNPCs.get(event.getRightClicked());
@ -1051,18 +1050,26 @@ public class QuiverPayload extends TeamGame
public void setMinecartTeam(GameTeam gameTeam)
{
// String minecartID = _minecart.getUniqueId().toString();
// String teamA = Manager.GetLobby().getTeamId(GetTeamList().get(0), null);
// String teamB = Manager.GetLobby().getTeamId(GetTeamList().get(1), null);
//
// GetScoreboard().getScoreboard().getTeam("Red").removeEntry(minecartID);
// GetScoreboard().getScoreboard().getTeam("Blue").removeEntry(minecartID);
// for (MineplexScoreboard scoreboard : Manager.getScoreboardManager().getScoreboards().values())
// {
// scoreboard.getHandle().getTeam(teamA).removeEntry(minecartID);
// scoreboard.getHandle().getTeam(teamB).removeEntry(minecartID);
// }
//
// if (gameTeam == null)
// {
// return;
// }
//
// String added = GetTeamList().get(0).equals(gameTeam) ? "Red" : "Blue";
// String added = GetTeamList().get(0).equals(gameTeam) ? teamA : teamB;
//
// GetScoreboard().getScoreboard().getTeam(added).addEntry(minecartID);
// for (MineplexScoreboard scoreboard : Manager.getScoreboardManager().getScoreboards().values())
// {
// scoreboard.getHandle().getTeam(added).addEntry(minecartID);
// }
}
public String getTopBar(int teamACount, int teamBCount)

View File

@ -11,6 +11,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
@ -102,7 +103,7 @@ public class PowerupGenerator
_location.getBlock().getRelative(BlockFace.DOWN).setType(Material.IRON_BLOCK);
UtilServer.broadcast(C.cYellowB + player.getName() + C.cWhiteB + " collected the " + C.cYellowB + "Resupply" + C.cWhiteB + " Powerup.");
player.sendMessage(F.main("Game", "You collected the resupply powerup."));
playFirework();

View File

@ -20,6 +20,7 @@ public class KitNewNinja extends ProgressingKit
private static final String[] DESCRIPTION = {
"Zip zap boing around the map!",
"You do not spawn with an arrow!",
"",
C.cYellow + "Right-click " + C.cGreen + "Sword" + C.cWhite + " to dash.",
"",

View File

@ -4,6 +4,7 @@ import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
@ -12,6 +13,7 @@ import nautilus.game.arcade.game.Game;
public class UltimateHeadHunter extends Ultimate
{
private static boolean IS_ACTIVE = false;
private static final double CHARGE_PER_SECOND = 0.4;
private long _length;
@ -26,6 +28,13 @@ public class UltimateHeadHunter extends Ultimate
@Override
public void activate(Player player)
{
if (IS_ACTIVE)
{
player.sendMessage(F.main("Game", "Someone else is currently using " + GetName()));
return;
}
IS_ACTIVE = true;
super.activate(player);
UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, player.getEyeLocation(), 0, 0, 0, 0.1F, 40, ViewDist.NORMAL);
@ -44,6 +53,7 @@ public class UltimateHeadHunter extends Ultimate
@Override
public void cancel(Player player)
{
IS_ACTIVE = false;
super.cancel(player);
Game game = Manager.GetGame();

View File

@ -1012,7 +1012,17 @@ public class GameLobbyManager implements Listener
public void AddPlayerToScoreboards(Player player, GameTeam gameTeam)
{
Rank rank = Manager.GetClients().Get(player).getRealOrDisguisedRank();
Rank rank;
if (player == null)
{
rank = Rank.ALL;
}
else
{
rank = Manager.GetClients().Get(player).getRealOrDisguisedRank();
}
String teamId = getTeamId(gameTeam, player);
for (MineplexScoreboard scoreboard : Manager.getScoreboardManager().getScoreboards().values())
@ -1040,7 +1050,10 @@ public class GameLobbyManager implements Listener
}
}
}
team.addEntry(player.getName());
if (player != null)
{
team.addEntry(player.getName());
}
}
}
@ -1063,14 +1076,27 @@ public class GameLobbyManager implements Listener
public String getTeamId(GameTeam gameTeam, Player player)
{
Rank rank = Manager.GetClients().Get(player).getRealOrDisguisedRank();
String rankName = rank.Name;
boolean rankIsUltra = !rank.has(Rank.ULTRA) &&
Manager.GetDonation().Get(player).OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA");
if (rankIsUltra)
Rank rank;
if (player == null)
{
rankName = Rank.ULTRA.Name;
rank = Rank.ALL;
}
else
{
rank = Manager.GetClients().Get(player).getRealOrDisguisedRank();
}
String rankName = rank.Name;
if (player != null)
{
boolean rankIsUltra = !rank.has(Rank.ULTRA) &&
Manager.GetDonation().Get(player).OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA");
if (rankIsUltra)
{
rankName = Rank.ULTRA.Name;
}
}
String teamId;