- Fixed all formatting
This commit is contained in:
parent
f23ef8eea0
commit
218aa8c584
@ -104,8 +104,6 @@ public class CaptureTheFlag extends TeamGame
|
||||
_redFlag = WorldData.GetDataLocs("RED").get(0);
|
||||
_blueFlag = WorldData.GetDataLocs("BLUE").get(0);
|
||||
|
||||
/*ItemDropAllow.add(Material.REDSTONE_BLOCK.getId());
|
||||
ItemDropAllow.add(Material.LAPIS_BLOCK.getId());*/
|
||||
CreatureAllowOverride = true;
|
||||
|
||||
for (GameTeam team : GetTeamList())
|
||||
@ -141,7 +139,7 @@ public class CaptureTheFlag extends TeamGame
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void CustomTeamGeneration(GameStateChangeEvent event)
|
||||
public void customTeamGeneration(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Recruit)
|
||||
return;
|
||||
@ -152,7 +150,7 @@ public class CaptureTheFlag extends TeamGame
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void blockliquidFlow(BlockPhysicsEvent event)
|
||||
public void blockLiquidFlow(BlockPhysicsEvent event)
|
||||
{
|
||||
Material matOfBlock = event.getBlock().getType();
|
||||
|
||||
@ -175,7 +173,7 @@ public class CaptureTheFlag extends TeamGame
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Updates(UpdateEvent event)
|
||||
public void updates(UpdateEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
@ -183,7 +181,7 @@ public class CaptureTheFlag extends TeamGame
|
||||
if (event.getType() == UpdateType.FASTEST)
|
||||
{
|
||||
for (Flag flag : _flags)
|
||||
flag.Update();
|
||||
flag.update();
|
||||
|
||||
for (Player player : _hotbars.keySet())
|
||||
if (!player.isOnline() || UtilPlayer.isSpectator(player) || !IsAlive(player))
|
||||
@ -199,13 +197,13 @@ public class CaptureTheFlag extends TeamGame
|
||||
if (flag.getCarrier() == null)
|
||||
for (Player player : GetPlayers(true))
|
||||
if (UtilMath.offset(player.getLocation(), flag.getPlacedLocation()) < 3)
|
||||
flag.Pickup(player);
|
||||
flag.pickup(player);
|
||||
}
|
||||
else
|
||||
ProgressTime();
|
||||
progressTime();
|
||||
}
|
||||
|
||||
public void ProgressTime()
|
||||
public void progressTime()
|
||||
{
|
||||
if (_suddenDeath) return;
|
||||
|
||||
@ -214,9 +212,9 @@ public class CaptureTheFlag extends TeamGame
|
||||
if (remain <= 0)
|
||||
{
|
||||
if (_redScore > _blueScore)
|
||||
EndCheckScore(_redScore);
|
||||
endCheckScore(_redScore);
|
||||
else if(_redScore < _blueScore)
|
||||
EndCheckScore(_blueScore);
|
||||
endCheckScore(_blueScore);
|
||||
else
|
||||
{
|
||||
_suddenDeath = true;
|
||||
@ -227,19 +225,19 @@ public class CaptureTheFlag extends TeamGame
|
||||
}
|
||||
}
|
||||
|
||||
public void AddCapture(GameTeam team)
|
||||
public void addCapture(GameTeam team)
|
||||
{
|
||||
if (_suddenDeath)
|
||||
{
|
||||
if (team.GetColor() == ChatColor.RED)
|
||||
{
|
||||
_redScore = _redScore + 1;
|
||||
EndCheckScore(_redScore);
|
||||
endCheckScore(_redScore);
|
||||
}
|
||||
else
|
||||
{
|
||||
_blueScore = _blueScore + 1;
|
||||
EndCheckScore(_blueScore);
|
||||
endCheckScore(_blueScore);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -253,11 +251,11 @@ public class CaptureTheFlag extends TeamGame
|
||||
_blueScore = Math.min(_victoryCaps, _blueScore + 1);
|
||||
}
|
||||
|
||||
EndCheckScore(_victoryCaps);
|
||||
endCheckScore(_victoryCaps);
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveInventory(Player player)
|
||||
public void saveInventory(Player player)
|
||||
{
|
||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
for (int i = 0; i < 9; i++)
|
||||
@ -272,7 +270,7 @@ public class CaptureTheFlag extends TeamGame
|
||||
_helmets.put(player, player.getInventory().getHelmet());
|
||||
}
|
||||
|
||||
public void ResetInventory(Player player)
|
||||
public void resetInventory(Player player)
|
||||
{
|
||||
if (_hotbars.containsKey(player))
|
||||
{
|
||||
@ -335,10 +333,10 @@ public class CaptureTheFlag extends TeamGame
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
ScoreboardWrite();
|
||||
scoreboardWrite();
|
||||
}
|
||||
|
||||
private void ScoreboardWrite()
|
||||
private void scoreboardWrite()
|
||||
{
|
||||
if (!InProgress())
|
||||
return;
|
||||
@ -373,7 +371,7 @@ public class CaptureTheFlag extends TeamGame
|
||||
Scoreboard.Draw();
|
||||
}
|
||||
|
||||
public void EndCheckScore(int needed)
|
||||
public void endCheckScore(int needed)
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
@ -388,7 +386,7 @@ public class CaptureTheFlag extends TeamGame
|
||||
if (winner == null)
|
||||
return;
|
||||
|
||||
ScoreboardWrite();
|
||||
scoreboardWrite();
|
||||
|
||||
//Announce
|
||||
AnnounceEnd(winner);
|
||||
@ -458,19 +456,19 @@ public class CaptureTheFlag extends TeamGame
|
||||
return 1;
|
||||
}
|
||||
|
||||
public String GetMode()
|
||||
public String getMode()
|
||||
{
|
||||
return "Capture the Flag";
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void RespawnRegen(PlayerGameRespawnEvent event)
|
||||
public void respawnRegen(PlayerGameRespawnEvent event)
|
||||
{
|
||||
Manager.GetCondition().Factory().Regen("Respawn", event.GetPlayer(), event.GetPlayer(), 8, 3, false, false, false);
|
||||
Manager.GetCondition().Factory().Protection("Respawn", event.GetPlayer(), event.GetPlayer(), 8, 3, false, false, false);
|
||||
}
|
||||
|
||||
public PlayerData GetStats(Player player)
|
||||
public PlayerData getStats(Player player)
|
||||
{
|
||||
if (!_stats.containsKey(player.getName()))
|
||||
_stats.put(player.getName(), new PlayerData(player.getName()));
|
||||
@ -479,7 +477,7 @@ public class CaptureTheFlag extends TeamGame
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void StatsKillAssistDeath(CombatDeathEvent event)
|
||||
public void statsKillAssistDeath(CombatDeathEvent event)
|
||||
{
|
||||
Game game = Manager.GetGame();
|
||||
if (game == null) return;
|
||||
@ -488,14 +486,14 @@ public class CaptureTheFlag extends TeamGame
|
||||
return;
|
||||
|
||||
Player killed = (Player)event.GetEvent().getEntity();
|
||||
GetStats(killed).Deaths++;
|
||||
getStats(killed).Deaths++;
|
||||
|
||||
if (event.GetLog().GetKiller() != null)
|
||||
{
|
||||
Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
|
||||
|
||||
if (killer != null && !killer.equals(killed))
|
||||
GetStats(killer).Kills++;
|
||||
getStats(killer).Kills++;
|
||||
}
|
||||
|
||||
for (CombatComponent log : event.GetLog().GetAttackers())
|
||||
@ -507,58 +505,35 @@ public class CaptureTheFlag extends TeamGame
|
||||
|
||||
//Assist
|
||||
if (assist != null)
|
||||
GetStats(assist).Assists++;
|
||||
getStats(assist).Assists++;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void StatsKillAssistDeath(CustomDamageEvent event)
|
||||
public void statsKillAssistDeath(CustomDamageEvent event)
|
||||
{
|
||||
Player damager = event.GetDamagerPlayer(true);
|
||||
if (damager != null)
|
||||
{
|
||||
GetStats(damager).DamageDealt += event.GetDamage();
|
||||
getStats(damager).DamageDealt += event.GetDamage();
|
||||
}
|
||||
|
||||
Player damagee = event.GetDamageePlayer();
|
||||
if (damagee != null)
|
||||
{
|
||||
GetStats(damagee).DamageTaken += event.GetDamage();
|
||||
getStats(damagee).DamageTaken += event.GetDamage();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void UsableInteract(PlayerInteractEvent event)
|
||||
public void usableInteract(PlayerInteractEvent event)
|
||||
{
|
||||
if (UtilBlock.usable(event.getClickedBlock()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
/*@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void GrabFlag(PlayerInteractEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
if (!IsAlive(event.getPlayer()))
|
||||
return;
|
||||
|
||||
for (String blocked : _blockedItems)
|
||||
{
|
||||
if (event.getPlayer().getItemInHand().getType().toString().contains(blocked))
|
||||
return;
|
||||
}
|
||||
|
||||
for (Flag flag : _flags)
|
||||
if (flag.Pickup(event.getPlayer(), event.getClickedBlock()))
|
||||
event.setCancelled(true);
|
||||
}*/
|
||||
|
||||
@EventHandler
|
||||
public void SelectKit(PlayerKitApplyEvent event)
|
||||
public void selectKit(PlayerKitApplyEvent event)
|
||||
{
|
||||
if (this instanceof ChampionsCTF)
|
||||
{
|
||||
@ -574,7 +549,7 @@ public class CaptureTheFlag extends TeamGame
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void DropFlag(PlayerDropItemEvent event)
|
||||
public void dropFlag(PlayerDropItemEvent event)
|
||||
{
|
||||
for (Flag flag : _flags)
|
||||
if ((flag.getRepresentation().getType() == event.getItemDrop().getItemStack().getType()) || (event.getItemDrop().getItemStack().getType() == Material.COMPASS))
|
||||
@ -583,8 +558,8 @@ public class CaptureTheFlag extends TeamGame
|
||||
{
|
||||
event.setCancelled(false);
|
||||
event.getItemDrop().remove();
|
||||
flag.Drop(event.getPlayer());
|
||||
ResetInventory(event.getPlayer());
|
||||
flag.drop(event.getPlayer());
|
||||
resetInventory(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class Flag
|
||||
{
|
||||
private CaptureTheFlag Host;
|
||||
private CaptureTheFlag _host;
|
||||
|
||||
private Location _spawn;
|
||||
|
||||
@ -50,9 +50,9 @@ public class Flag
|
||||
|
||||
private String _displayName;
|
||||
|
||||
public Flag (CaptureTheFlag host, Location spawn, GameTeam team)
|
||||
public Flag(CaptureTheFlag host, Location spawn, GameTeam team)
|
||||
{
|
||||
Host = host;
|
||||
_host = host;
|
||||
_spawn = spawn;
|
||||
_team = team;
|
||||
_displayName = team.GetColor() + team.GetName() + "'s Flag".replace("s's", "s'");
|
||||
@ -69,10 +69,10 @@ public class Flag
|
||||
|
||||
_representation = i;
|
||||
|
||||
_name = new Hologram(Host.getArcadeManager().getHologramManager(), spawn, team.GetColor() + team.GetName() + "'s Flag".replace("s's", "s'"));
|
||||
_time = new Hologram(Host.getArcadeManager().getHologramManager(), spawn, "");
|
||||
_name = new Hologram(_host.getArcadeManager().getHologramManager(), spawn, team.GetColor() + team.GetName() + "'s Flag".replace("s's", "s'"));
|
||||
_time = new Hologram(_host.getArcadeManager().getHologramManager(), spawn, "");
|
||||
|
||||
SpawnFlag(spawn, team.GetColor() == ChatColor.RED);
|
||||
spawnFlag(spawn, team.GetColor() == ChatColor.RED);
|
||||
}
|
||||
|
||||
public GameTeam getTeam()
|
||||
@ -106,30 +106,30 @@ public class Flag
|
||||
return _displayName;
|
||||
}
|
||||
|
||||
private void AnnounceSteal(Player cap, boolean steal)
|
||||
private void announceSteal(Player cap, boolean steal)
|
||||
{
|
||||
if (steal)
|
||||
UtilTextMiddle.display("", Host.GetTeam(cap).GetColor() + cap.getName() + C.cWhite + " stole " + _team.GetColor() + _team.GetName() + " Flag!", 0, 60, 10);
|
||||
UtilTextMiddle.display("", _host.GetTeam(cap).GetColor() + cap.getName() + C.cWhite + " stole " + _team.GetColor() + _team.GetName() + " Flag!", 0, 60, 10);
|
||||
else
|
||||
UtilTextMiddle.display("", Host.GetTeam(cap).GetColor() + cap.getName() + C.cWhite + " picked up " + _team.GetColor() + _team.GetName() + " Flag!", 0, 60, 10);
|
||||
UtilTextMiddle.display("", _host.GetTeam(cap).GetColor() + cap.getName() + C.cWhite + " picked up " + _team.GetColor() + _team.GetName() + " Flag!", 0, 60, 10);
|
||||
}
|
||||
|
||||
private void AnnounceDrop(Player player)
|
||||
private void announceDrop(Player player)
|
||||
{
|
||||
UtilTextMiddle.display("", Host.GetTeam(player).GetColor() + player.getName() + C.cWhite + " dropped " + _team.GetColor() + _team.GetName() + " Flag!", 0, 60, 10);
|
||||
UtilTextMiddle.display("", _host.GetTeam(player).GetColor() + player.getName() + C.cWhite + " dropped " + _team.GetColor() + _team.GetName() + " Flag!", 0, 60, 10);
|
||||
}
|
||||
|
||||
private void AnnounceCapture(Player player)
|
||||
private void announceCapture(Player player)
|
||||
{
|
||||
UtilTextMiddle.display("", Host.GetTeam(player).GetColor() + player.getName() + C.cWhite + " scored for " + Host.GetTeam(player).GetColor() + Host.GetTeam(player).GetName(), 0, 60, 10);
|
||||
UtilTextMiddle.display("", _host.GetTeam(player).GetColor() + player.getName() + C.cWhite + " scored for " + _host.GetTeam(player).GetColor() + _host.GetTeam(player).GetName(), 0, 60, 10);
|
||||
}
|
||||
|
||||
private void AnnounceReturn()
|
||||
private void announceReturn()
|
||||
{
|
||||
UtilTextMiddle.display("", _team.GetColor() + _team.GetName() + " Flag " + C.cWhite + " has returned to base", 0, 60, 10);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
public void update()
|
||||
{
|
||||
if (!_moved || _dropped)
|
||||
for (Block block : _flagBlocks)
|
||||
@ -141,7 +141,7 @@ public class Flag
|
||||
{
|
||||
Integer r = (int)(System.currentTimeMillis() - _dropTime) / 1000;
|
||||
Integer re = 15 - r;
|
||||
_time.setText(RemainColor(re) + re.toString());
|
||||
_time.setText(remainColor(re) + re.toString());
|
||||
|
||||
if (!UtilTime.elapsed(_dropTime, 15000))
|
||||
return;
|
||||
@ -149,13 +149,13 @@ public class Flag
|
||||
_name.stop();
|
||||
_time.stop();
|
||||
|
||||
DeleteFlag();
|
||||
deleteFlag();
|
||||
|
||||
_moved = false;
|
||||
_dropped = false;
|
||||
SpawnFlag(_spawn, _team.GetColor() == ChatColor.RED);
|
||||
spawnFlag(_spawn, _team.GetColor() == ChatColor.RED);
|
||||
|
||||
AnnounceReturn();
|
||||
announceReturn();
|
||||
|
||||
UtilFirework.playFirework(_spawn.clone().add(0, 1, 0), FireworkEffect.builder().flicker(false).withColor(_team.GetColorBase()).with(Type.BURST).trail(true).build());
|
||||
return;
|
||||
@ -163,19 +163,19 @@ public class Flag
|
||||
|
||||
if (!_holding.isOnline())
|
||||
{
|
||||
Drop(_holding);
|
||||
drop(_holding);
|
||||
return;
|
||||
}
|
||||
|
||||
if (UtilPlayer.isSpectator(_holding))
|
||||
{
|
||||
Drop(_holding);
|
||||
drop(_holding);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Host.IsAlive(_holding))
|
||||
if (!_host.IsAlive(_holding))
|
||||
{
|
||||
Drop(_holding);
|
||||
drop(_holding);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -194,23 +194,23 @@ public class Flag
|
||||
ViewDist.MAX, UtilServer.getPlayers());
|
||||
}
|
||||
|
||||
if (Host.GetTeam(_holding).GetColor() == ChatColor.RED)
|
||||
_holding.setCompassTarget(Host.getRedFlag());
|
||||
if (_host.GetTeam(_holding).GetColor() == ChatColor.RED)
|
||||
_holding.setCompassTarget(_host.getRedFlag());
|
||||
else
|
||||
_holding.setCompassTarget(Host.getBlueFlag());
|
||||
_holding.setCompassTarget(_host.getBlueFlag());
|
||||
|
||||
Score(_holding);
|
||||
}
|
||||
}
|
||||
|
||||
private ChatColor RemainColor(int remain)
|
||||
private ChatColor remainColor(int remain)
|
||||
{
|
||||
if (remain >= 9) return ChatColor.GREEN;
|
||||
if ((remain < 9) && (remain >= 6)) return ChatColor.YELLOW;
|
||||
return ChatColor.RED;
|
||||
}
|
||||
|
||||
public void SpawnFlag(Location loc, boolean red)
|
||||
public void spawnFlag(Location loc, boolean red)
|
||||
{
|
||||
_flagBlocks = new Block[]
|
||||
{
|
||||
@ -234,13 +234,13 @@ public class Flag
|
||||
_name.start();
|
||||
Integer r = (int)(System.currentTimeMillis() - _dropTime) / 1000;
|
||||
Integer re = 15 - r;
|
||||
_time.setText(RemainColor(re) + re.toString());
|
||||
_time.setText(remainColor(re) + re.toString());
|
||||
_time.setLocation(loc.getBlock().getLocation().clone().add(0.5, 2.5, 0.5));
|
||||
_time.start();
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteFlag()
|
||||
private void deleteFlag()
|
||||
{
|
||||
for (Block flagBlock : _flagBlocks)
|
||||
{
|
||||
@ -250,7 +250,7 @@ public class Flag
|
||||
_time.stop();
|
||||
}
|
||||
|
||||
public boolean Pickup(Player player)
|
||||
public boolean pickup(Player player)
|
||||
{
|
||||
if (_holding == null)
|
||||
{
|
||||
@ -259,13 +259,13 @@ public class Flag
|
||||
if (!Recharge.Instance.use(player, "Flag Pickup", 3000, false, false))
|
||||
return false;
|
||||
|
||||
if (Host.IsAlive(player))
|
||||
if (_host.IsAlive(player))
|
||||
{
|
||||
if (Host.GetTeam(player) != _team)
|
||||
if (_host.GetTeam(player) != _team)
|
||||
{
|
||||
DeleteFlag();
|
||||
deleteFlag();
|
||||
|
||||
Host.SaveInventory(player);
|
||||
_host.saveInventory(player);
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
player.getInventory().setItem(i, _representation);
|
||||
@ -285,9 +285,9 @@ public class Flag
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 1000000, 0));
|
||||
|
||||
if (_moved)
|
||||
AnnounceSteal(player, false);
|
||||
announceSteal(player, false);
|
||||
else
|
||||
AnnounceSteal(player, true);
|
||||
announceSteal(player, true);
|
||||
|
||||
_holding = player;
|
||||
_dropped = false;
|
||||
@ -303,7 +303,7 @@ public class Flag
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Drop(Player player)
|
||||
public void drop(Player player)
|
||||
{
|
||||
if (_moved)
|
||||
{
|
||||
@ -313,8 +313,8 @@ public class Flag
|
||||
{
|
||||
Recharge.Instance.recharge(player, "Flag Pickup");
|
||||
Recharge.Instance.use(player, "Flag Pickup", 3000, false, false);
|
||||
SpawnFlag(player.getLocation(), _team.GetColor() == ChatColor.RED);
|
||||
AnnounceDrop(player);
|
||||
spawnFlag(player.getLocation(), _team.GetColor() == ChatColor.RED);
|
||||
announceDrop(player);
|
||||
_holding = null;
|
||||
_dropped = true;
|
||||
_dropTime = System.currentTimeMillis();
|
||||
@ -332,12 +332,12 @@ public class Flag
|
||||
if (_holding.getUniqueId() == player.getUniqueId())
|
||||
{
|
||||
if (_team.GetColor() == ChatColor.RED)
|
||||
if (!Host.isInZone(player.getLocation(), false)) return;
|
||||
if (!_host.isInZone(player.getLocation(), false)) return;
|
||||
|
||||
if (_team.GetColor() == ChatColor.BLUE)
|
||||
if (!Host.isInZone(player.getLocation(), true)) return;
|
||||
if (!_host.isInZone(player.getLocation(), true)) return;
|
||||
|
||||
if (!Host.isAtHome(_team.GetColor() == ChatColor.RED ? ChatColor.BLUE : ChatColor.RED))
|
||||
if (!_host.isAtHome(_team.GetColor() == ChatColor.RED ? ChatColor.BLUE : ChatColor.RED))
|
||||
{
|
||||
if (Recharge.Instance.use(player, "No Cap Message", 1000, false, false))
|
||||
UtilTextMiddle.display("", C.cRed + "Your flag must be at home to capture!", player);
|
||||
@ -345,18 +345,18 @@ public class Flag
|
||||
return;
|
||||
}
|
||||
|
||||
Host.ResetInventory(player);
|
||||
AnnounceCapture(player);
|
||||
Host.AddGems(player, 10, "Enemy Flag Captured", true, true);
|
||||
_host.resetInventory(player);
|
||||
announceCapture(player);
|
||||
_host.AddGems(player, 10, "Enemy Flag Captured", true, true);
|
||||
PlayerCaptureFlagEvent event = new PlayerCaptureFlagEvent(player);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
Host.AddCapture(Host.GetTeam(player));
|
||||
_host.addCapture(_host.GetTeam(player));
|
||||
|
||||
_moved = false;
|
||||
_dropped = false;
|
||||
_dropTime = 0;
|
||||
_holding = null;
|
||||
SpawnFlag(_spawn, _team.GetColor() == ChatColor.RED);
|
||||
spawnFlag(_spawn, _team.GetColor() == ChatColor.RED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user