Started fixing the stat tracking for MS knife

This commit is contained in:
xGamingDudex 2016-05-13 02:39:43 +02:00
parent 2cc609b67e
commit 0544e86cb1
4 changed files with 43 additions and 20 deletions

View File

@ -1166,7 +1166,7 @@ public abstract class Game implements Listener
Player player = teamList.remove(0); Player player = teamList.remove(0);
WinEffectManager.prePlay(this, player, teamList, otherList); WinEffectManager.prePlay(this, player, teamList, otherList);
Location loc = SpectatorSpawn.clone().add(1000, 0, 1000); Location loc = GetSpectatorLocation().clone().add(1000, 0, 1000);
loc.setY(200); loc.setY(200);
WinEffectManager.playWinEffect(loc); WinEffectManager.playWinEffect(loc);
} }
@ -1244,7 +1244,7 @@ public abstract class Game implements Listener
WinEffectManager.prePlay(this, player, teamList, otherList); WinEffectManager.prePlay(this, player, teamList, otherList);
Location loc = SpectatorSpawn.clone().add(1000, 0, 1000); Location loc = GetSpectatorLocation().clone().add(1000, 0, 1000);
loc.setY(200); loc.setY(200);
WinEffectManager.playWinEffect(loc); WinEffectManager.playWinEffect(loc);
} }

View File

@ -29,12 +29,12 @@ import org.bukkit.event.Event;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.entity.ItemDespawnEvent; import org.bukkit.event.entity.ItemDespawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.painting.PaintingBreakEvent; import org.bukkit.event.painting.PaintingBreakEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
@ -46,8 +46,8 @@ import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.inventory.meta.LeatherArmorMeta;
@ -64,18 +64,18 @@ import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
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.ViewDist;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType; import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType;
@ -94,8 +94,8 @@ import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerKitGiveEvent; import nautilus.game.arcade.events.PlayerKitGiveEvent;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.minestrike.data.Bomb; import nautilus.game.arcade.game.games.minestrike.data.Bomb;
import nautilus.game.arcade.game.games.minestrike.data.Bullet; import nautilus.game.arcade.game.games.minestrike.data.Bullet;
import nautilus.game.arcade.game.games.minestrike.items.StrikeItem; import nautilus.game.arcade.game.games.minestrike.items.StrikeItem;
@ -423,14 +423,19 @@ public class MineStrike extends TeamGame
GameModifierMineStrikeSkin knifeSkin = (GameModifierMineStrikeSkin) gadgetManager.getActiveGameModifier(event.getPlayer(), GameModifierMineStrikeSkin knifeSkin = (GameModifierMineStrikeSkin) gadgetManager.getActiveGameModifier(event.getPlayer(),
GameModifierType.MineStrike, GameModifierMineStrikeSkin.getWeaponFilter("Knife")); GameModifierType.MineStrike, GameModifierMineStrikeSkin.getWeaponFilter("Knife"));
ItemStack knife = ItemStackFactory.Instance.CreateStack(Material.IRON_AXE, (byte)0, 1, "Knife"); Material mat = Material.IRON_AXE;
byte data = 0;
String name = "Knife";
if(knifeSkin != null) if(knifeSkin != null)
{ {
knife.setType(knifeSkin.getSkinMaterial()); mat = knifeSkin.getSkinMaterial();
knife.getData().setData(knifeSkin.getSkinData()); data = knifeSkin.getSkinData();
name = knifeSkin.GetName();
} }
ItemStack knife = ItemStackFactory.Instance.CreateStack(mat, data, 1, name);
if (team.GetColor() == ChatColor.RED) if (team.GetColor() == ChatColor.RED)
{ {
if (IsAlive(event.getPlayer())) if (IsAlive(event.getPlayer()))
@ -1534,6 +1539,25 @@ public class MineStrike extends TeamGame
amount = 1500; amount = 1500;
_shopManager.addMoney(killer, amount, "kill with " + event.GetLog().GetLastDamager().GetReason()); _shopManager.addMoney(killer, amount, "kill with " + event.GetLog().GetLastDamager().GetReason());
/*
if(event.GetLog().GetLastDamager().GetReason().contains("Knife"))
{
GadgetManager gadgetManager = Manager.getCosmeticManager().getGadgetManager();
GameModifierMineStrikeSkin knifeSkin = (GameModifierMineStrikeSkin) gadgetManager.getActiveGameModifier(event.getPlayer(),
GameModifierType.MineStrike, GameModifierMineStrikeSkin.getWeaponFilter("Knife"));
if(knifeSkin != null)
{
int kills = GetStats().get(killer).get("")
ItemStack item = killer.getInventory().getItem(2);
ItemMeta im = item.getItemMeta();
im.setDisplayName(C.cYellow + C.Bold + knifeSkin.GetName() + " - Kills: " + kills);
AddStat(killer, "Knife." + knifeSkin.GetName() + ".Kills", 1, false, false);
}
}
*/
} }
} }

View File

@ -332,14 +332,14 @@ public class Gun extends StrikeItem
new BukkitRunnable() { new BukkitRunnable() {
public void run() { public void run() {
PlayerStats remoteStats = game.getArcadeManager().GetStatsManager().Get(player);; PlayerStats remoteStats = game.getArcadeManager().GetStatsManager().Get(player);;
_kills = (int) remoteStats.getStat(game.GetName() + "." + getStatNameKills()); _kills = (int) remoteStats.getStat(game.GetName() + "." + getStatNameKills(true));
Player owner = UtilPlayer.searchExact(getOwnerName()); Player owner = UtilPlayer.searchExact(getOwnerName());
if(owner != null) { if(owner != null) {
HashMap<String, Integer> localStatsMap = game.GetStats().get(owner); HashMap<String, Integer> localStatsMap = game.GetStats().get(owner);
if(localStatsMap != null) if(localStatsMap != null)
{ {
Integer kills = localStatsMap.get(game.GetName() + "." + getStatNameKills()); Integer kills = localStatsMap.get(game.GetName() + "." + getStatNameKills(true));
if(kills != null) if(kills != null)
{ {
_kills += kills.intValue(); _kills += kills.intValue();
@ -563,13 +563,13 @@ public class Gun extends StrikeItem
return _gunStats.getGunType(); return _gunStats.getGunType();
} }
public String getBaseStatName() public String getBaseStatName(boolean withPlayerName)
{ {
return getOwnerName() + "." + getName() + "." + _activeSkinName; return (withPlayerName ? getOwnerName() + "." : "") + getName() + "." + _activeSkinName;
} }
public String getStatNameKills() public String getStatNameKills(boolean withPlayerName)
{ {
return getBaseStatName() + ".Kills"; return getBaseStatName(withPlayerName) + ".Kills";
} }
} }

View File

@ -1,6 +1,5 @@
package nautilus.game.arcade.stats; package nautilus.game.arcade.stats;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -45,7 +44,7 @@ public class MineStrikeGunStats extends StatTracker<Game>
double newHealth = event.getPlayer().getHealth() - dmg; double newHealth = event.getPlayer().getHealth() - dmg;
if(newHealth > 0) return; if(newHealth > 0) return;
String stat = event.getBullet().Gun.getStatNameKills(); String stat = event.getBullet().Gun.getStatNameKills(false);
addStat(event.getBullet().Shooter, stat, 1, false, false); addStat(event.getBullet().Shooter, stat, 1, false, false);
event.getBullet().Gun.incrementKill(); event.getBullet().Gun.incrementKill();