- Added achievement and stat stuff

- Fixed banner bugs
This commit is contained in:
AlexTheCoder 2015-09-24 23:16:44 -04:00
parent d5ef15cd6d
commit 5b42d25bff
8 changed files with 210 additions and 50 deletions

View File

@ -311,6 +311,12 @@ public enum Achievement
new int[]{1}, new int[]{1},
AchievementCategory.CHAMPIONS), AchievementCategory.CHAMPIONS),
CHAMPIONS_CAPTURES("Sticky Fingers", 2500,
new String[]{"Champions Capture the Flag.Captures"},
new String[]{"Capture the Enemy Flag 20 times"},
new int[]{20},
AchievementCategory.CHAMPIONS),
//Paintball //Paintball
SUPER_PAINTBALL_WINS("Paintball King", 600, SUPER_PAINTBALL_WINS("Paintball King", 600,
new String[]{"Super Paintball.Wins"}, new String[]{"Super Paintball.Wins"},

View File

@ -61,7 +61,7 @@ public enum AchievementCategory
Material.BOOK_AND_QUILL, 0, GameCategory.CLASSICS, "Extra Tools Kit"), Material.BOOK_AND_QUILL, 0, GameCategory.CLASSICS, "Extra Tools Kit"),
CHAMPIONS("Champions", new String[] {"Champions Domination", "Champions TDM", "Champions Capture the Flag"}, CHAMPIONS("Champions", new String[] {"Champions Domination", "Champions TDM", "Champions Capture the Flag"},
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED, new StatDisplay("Flags Captured", "Captures") },
Material.BEACON, 0, GameCategory.CHAMPIONS, "Extra Class Skills"), Material.BEACON, 0, GameCategory.CHAMPIONS, "Extra Class Skills"),
MASTER_BUILDERS("Master Builders", null, MASTER_BUILDERS("Master Builders", null,

View File

@ -22,6 +22,7 @@ import nautilus.game.arcade.game.games.champions.kits.KitMage;
import nautilus.game.arcade.game.games.champions.kits.KitRanger; import nautilus.game.arcade.game.games.champions.kits.KitRanger;
import nautilus.game.arcade.game.games.common.CaptureTheFlag; import nautilus.game.arcade.game.games.common.CaptureTheFlag;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.stats.CapturesStatTracker;
import nautilus.game.arcade.stats.ElectrocutionStatTracker; import nautilus.game.arcade.stats.ElectrocutionStatTracker;
import nautilus.game.arcade.stats.KillReasonStatTracker; import nautilus.game.arcade.stats.KillReasonStatTracker;
import nautilus.game.arcade.stats.SeismicSlamStatTracker; import nautilus.game.arcade.stats.SeismicSlamStatTracker;
@ -72,7 +73,8 @@ public class ChampionsCTF extends CaptureTheFlag
new KillReasonStatTracker(this, "Backstab", "Assassination", false), new KillReasonStatTracker(this, "Backstab", "Assassination", false),
new ElectrocutionStatTracker(this), new ElectrocutionStatTracker(this),
new TheLongestShotStatTracker(this), new TheLongestShotStatTracker(this),
new SeismicSlamStatTracker(this) new SeismicSlamStatTracker(this),
new CapturesStatTracker(this, "Captures")
); );
} }

View File

@ -250,7 +250,7 @@ public class CaptureTheFlag extends TeamGame
@EventHandler @EventHandler
public void handleFlagItem(GameStateChangeEvent event) public void handleFlagItem(GameStateChangeEvent event)
{ {
if (event.GetState() == GameState.Live) if (event.GetState() == GameState.Recruit)
{ {
getArcadeManager().getPacketHandler().addPacketHandler( getArcadeManager().getPacketHandler().addPacketHandler(
_flagItemListener); _flagItemListener);
@ -357,11 +357,16 @@ public class CaptureTheFlag extends TeamGame
_helmets.remove(player); _helmets.remove(player);
} }
else if (event.getType() == UpdateType.TICK) else if (event.getType() == UpdateType.TICK)
{
for (Flag flag : _flags) for (Flag flag : _flags)
if (flag.getCarrier() == null) if (flag.getCarrier() == null)
for (Player player : GetPlayers(true)) for (Player player : GetPlayers(true))
if (UtilMath.offset(player.getLocation(), flag.getPlacedLocation()) < 1) if (UtilMath.offset(player.getLocation(), flag.getPlacedLocation()) < 1)
flag.Pickup(player); flag.Pickup(player);
}
else if (event.getType() == UpdateType.SEC)
for (Flag flag : _flags)
flag.UpdateEntity();
else else
ProgressTime(); ProgressTime();
} }
@ -523,7 +528,7 @@ public class CaptureTheFlag extends TeamGame
if (_suddenDeath) if (_suddenDeath)
{ {
Scoreboard.Write(C.cDPurple + "Sudden Death"); Scoreboard.Write(C.cDPurple + C.Bold + "Sudden Death");
} }
else else
{ {
@ -738,7 +743,7 @@ public class CaptureTheFlag extends TeamGame
public void DropFlag(PlayerDropItemEvent event) public void DropFlag(PlayerDropItemEvent event)
{ {
for (Flag flag : _flags) for (Flag flag : _flags)
if (flag.getRepresentation().getType() == event.getItemDrop().getItemStack().getType()) if ((flag.getRepresentation().getType() == event.getItemDrop().getItemStack().getType()) || (event.getItemDrop().getItemStack().getType() == Material.COMPASS))
if (flag.getCarrier() != null) if (flag.getCarrier() != null)
if (flag.getCarrier().getName().equals(event.getPlayer().getName())) if (flag.getCarrier().getName().equals(event.getPlayer().getName()))
{ {
@ -767,8 +772,9 @@ public class CaptureTheFlag extends TeamGame
else else
data.add(new RadarData(f.getCarrier().getLocation(), f.getTeam().GetColor() + "")); data.add(new RadarData(f.getCarrier().getLocation(), f.getTeam().GetColor() + ""));
} }
//data.add(new RadarData(getRedFlag(), C.cRed + "F"));
//data.add(new RadarData(getBlueFlag(), C.cAqua + "F")); data.add(new RadarData(_redFlag, C.cRed + ""));
data.add(new RadarData(_blueFlag, C.cBlue + ""));
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
UtilRadar.displayRadar(player, data); UtilRadar.displayRadar(player, data);
@ -789,13 +795,4 @@ public class CaptureTheFlag extends TeamGame
} }
} }
} }
@EventHandler
public void flagDamage(CustomDamageEvent event)
{
if (event.GetDamageeEntity() != null)
for (Flag f : _flags)
if (f.isFlagEntity(event.GetDamageeEntity()))
event.SetCancelled("Flag Entity");
}
} }

View File

@ -1,7 +1,6 @@
package nautilus.game.arcade.game.games.common.ctf_data; package nautilus.game.arcade.game.games.common.ctf_data;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ParticleType;
@ -11,21 +10,17 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.disguise.disguises.DisguiseArmorStand;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.hologram.Hologram; import mineplex.core.hologram.Hologram;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.common.CaptureTheFlag; import nautilus.game.arcade.game.games.common.CaptureTheFlag;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect;
import org.bukkit.FireworkEffect.Type; import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
@ -36,7 +31,7 @@ public class Flag
{ {
private CaptureTheFlag Host; private CaptureTheFlag Host;
private Location _spawn, _current; private Location _spawn;
private GameTeam _team; private GameTeam _team;
@ -52,8 +47,7 @@ public class Flag
private String _displayName; private String _displayName;
private LivingEntity _flagEntity; private FlagEntity _flagEntity;
private DisguiseBase _disguise;
public Flag (CaptureTheFlag host, Location spawn, GameTeam team) public Flag (CaptureTheFlag host, Location spawn, GameTeam team)
{ {
@ -77,6 +71,7 @@ public class Flag
_name = new Hologram(Host.getArcadeManager().getHologramManager(), spawn, team.GetColor() + team.GetName() + "'s Flag".replace("s's", "s'")); _name = new Hologram(Host.getArcadeManager().getHologramManager(), spawn, team.GetColor() + team.GetName() + "'s Flag".replace("s's", "s'"));
_time = new Hologram(Host.getArcadeManager().getHologramManager(), spawn, ""); _time = new Hologram(Host.getArcadeManager().getHologramManager(), spawn, "");
_flagEntity = new FlagEntity(_representation, _spawn, Host.getArcadeManager().GetDisguise());
SpawnFlag(spawn, team.GetColor() == ChatColor.RED, true); SpawnFlag(spawn, team.GetColor() == ChatColor.RED, true);
} }
@ -97,7 +92,7 @@ public class Flag
public Location getPlacedLocation() public Location getPlacedLocation()
{ {
return _current; return _flagEntity.getLocation();
} }
@ -111,12 +106,6 @@ public class Flag
return _displayName; return _displayName;
} }
public boolean isFlagEntity(Entity e)
{
if (_flagEntity == null) return false;
return _flagEntity.getEntityId() == e.getEntityId();
}
private void AnnounceSteal(Player cap, boolean steal) private void AnnounceSteal(Player cap, boolean steal)
{ {
if (steal) if (steal)
@ -140,11 +129,13 @@ public class Flag
UtilTextMiddle.display("", _team.GetColor() + _team.GetName() + " Flag " + C.cWhite + " has returned to base", 0, 60, 10); UtilTextMiddle.display("", _team.GetColor() + _team.GetName() + " Flag " + C.cWhite + " has returned to base", 0, 60, 10);
} }
public void UpdateEntity()
{
_flagEntity.update();
}
public void Update() public void Update()
{ {
if (_holding == null && _disguise != null && _flagEntity != null)
Host.getArcadeManager().GetDisguise().updateDisguise(_disguise);
if (_moved) if (_moved)
{ {
if (_dropped) if (_dropped)
@ -223,14 +214,7 @@ public class Flag
public void SpawnFlag(Location loc, boolean red, boolean initial) public void SpawnFlag(Location loc, boolean red, boolean initial)
{ {
if (!initial) Host.CreatureAllowOverride = true; if (!initial) Host.CreatureAllowOverride = true;
_current = loc; _flagEntity.teleport(loc);
_flagEntity = (LivingEntity) Host.getArcadeManager().GetCreature().SpawnEntity(loc, EntityType.CHICKEN);
UtilEnt.Vegetate(_flagEntity);
DisguiseArmorStand disguise = new DisguiseArmorStand(_flagEntity);
disguise.setInvisible(true);
disguise.setHelmet(_representation);
Host.getArcadeManager().GetDisguise().disguise(disguise, UtilServer.getPlayers());
_disguise = disguise;
if (!initial) Host.CreatureAllowOverride = false; if (!initial) Host.CreatureAllowOverride = false;
if (!_moved) if (!_moved)
@ -252,11 +236,9 @@ public class Flag
private void DeleteFlag() private void DeleteFlag()
{ {
Host.getArcadeManager().GetDisguise().undisguise(_flagEntity); _flagEntity.despawn();
_disguise = null; _name.stop();
_flagEntity.remove(); _time.stop();
_current = null;
_flagEntity = null;
} }
public boolean Pickup(Player player) public boolean Pickup(Player player)
@ -273,8 +255,6 @@ public class Flag
if (Host.GetTeam(player) != _team) if (Host.GetTeam(player) != _team)
{ {
DeleteFlag(); DeleteFlag();
_name.stop();
_time.stop();
Host.SaveInventory(player); Host.SaveInventory(player);
@ -359,6 +339,8 @@ public class Flag
Host.ResetInventory(player); Host.ResetInventory(player);
AnnounceCapture(player); AnnounceCapture(player);
Host.AddGems(player, 10, "Enemy Flag Captured", true, true); 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; _moved = false;

View File

@ -0,0 +1,113 @@
package nautilus.game.arcade.game.games.common.ctf_data;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguiseArmorStand;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game.GameState;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.inventory.ItemStack;
public class FlagEntity implements Listener
{
private ItemStack _holding;
private Location _loc;
private LivingEntity _entity;
private DisguiseManager _manager;
public FlagEntity(ItemStack hand, Location loc, DisguiseManager manager)
{
_manager = manager;
_holding = hand;
_loc = loc;
toggle(true);
}
public Location getLocation()
{
return _loc;
}
public void spawn()
{
_entity = (LivingEntity) _loc.getWorld().spawnEntity(_loc, EntityType.CHICKEN);
//_entity.teleport(_loc.clone().subtract(0, 1.5, 0));
UtilEnt.Vegetate(_entity, true);
UtilEnt.ghost(_entity, true, true);
DisguiseArmorStand disguise = new DisguiseArmorStand(_entity);
disguise.setHelmet(_holding);
disguise.setInvisible(true);
_manager.disguise(disguise, UtilServer.getPlayers());
}
public void despawn()
{
//_manager.undisguise(_entity);
_entity.remove();
_entity = null;
}
public void teleport(Location loc)
{
if (_entity != null) despawn();
_loc = loc;
spawn();
}
public void update()
{
if (_entity != null)
_entity.teleport(_loc);
}
private void toggle(boolean on)
{
if (on)
Bukkit.getPluginManager().registerEvents(this, _manager.getPlugin());
else
HandlerList.unregisterAll(this);
}
@EventHandler
public void onHit(EntityDamageEvent event)
{
if (_entity == null) return;
if (event.getEntity().getEntityId() == _entity.getEntityId())
event.setCancelled(true);
}
@EventHandler
public void onHit(CustomDamageEvent event)
{
if (_entity == null) return;
if (event.GetDamageeEntity() == null) return;
if (event.GetDamageeEntity().getEntityId() == _entity.getEntityId())
event.SetCancelled("Flag Entity");
}
@EventHandler
public void onEnd(GameStateChangeEvent event)
{
if (event.GetGame().GetType() == GameType.ChampionsCTF)
{
if (event.GetState() == GameState.Dead)
{
toggle(false);
}
}
}
}

View File

@ -0,0 +1,31 @@
package nautilus.game.arcade.game.games.common.ctf_data;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class PlayerCaptureFlagEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _player;
public PlayerCaptureFlagEvent(Player player)
{
_player = player;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
public Player GetPlayer()
{
return _player;
}
}

View File

@ -0,0 +1,29 @@
package nautilus.game.arcade.stats;
import nautilus.game.arcade.game.games.common.CaptureTheFlag;
import nautilus.game.arcade.game.games.common.ctf_data.PlayerCaptureFlagEvent;
import org.bukkit.event.EventHandler;
public class CapturesStatTracker extends StatTracker<CaptureTheFlag>
{
private final String _stat;
public CapturesStatTracker(CaptureTheFlag game, String stat)
{
super(game);
_stat = stat;
}
@EventHandler
public void onCapture(PlayerCaptureFlagEvent event)
{
addStat(event.GetPlayer(), getStat(), 1, false, false);
}
public String getStat()
{
return _stat;
}
}