added func to change attackreason for combatmanager

This commit is contained in:
Chiss 2014-12-19 13:59:18 +11:00
parent 7e6b6bd1b2
commit 184c6cb4ba
4 changed files with 57 additions and 12 deletions

View File

@ -29,18 +29,28 @@ import mineplex.core.common.util.UtilEvent;
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.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.minecraft.game.core.combat.event.ClearCombatEvent; import mineplex.minecraft.game.core.combat.event.ClearCombatEvent;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
public class CombatManager extends MiniPlugin public class CombatManager extends MiniPlugin
{ {
public enum AttackReason
{
Attack,
CustomWeaponName,
DefaultWeaponName
}
private NautHashMap<Player, CombatLog> _active = new NautHashMap<Player, CombatLog>(); private NautHashMap<Player, CombatLog> _active = new NautHashMap<Player, CombatLog>();
private NautHashMap<String, ClientCombat> _combatClients = new NautHashMap<String, ClientCombat>(); private NautHashMap<String, ClientCombat> _combatClients = new NautHashMap<String, ClientCombat>();
private HashSet<Player> _removeList = new HashSet<Player>(); private HashSet<Player> _removeList = new HashSet<Player>();
protected long ExpireTime = 15000; protected long ExpireTime = 15000;
protected AttackReason _attackReason = AttackReason.CustomWeaponName;
public CombatManager(JavaPlugin plugin) public CombatManager(JavaPlugin plugin)
{ {
@ -203,20 +213,40 @@ public class CombatManager extends MiniPlugin
{ {
Player damager = event.GetDamagerPlayer(false); Player damager = event.GetDamagerPlayer(false);
reason = "Fists";
reason = "Attack";
if (damager.getItemInHand() != null)
if (_attackReason == AttackReason.DefaultWeaponName)
{ {
ItemStack itemStack = CraftItemStack.asNMSCopy(damager reason = "Fists";
.getItemInHand());
if (damager.getItemInHand() != null)
if (itemStack != null)
{ {
reason = CraftItemStack.asNMSCopy( byte data = 0;
damager.getItemInHand()).getName(); if (damager.getItemInHand().getData() != null)
data = damager.getItemInHand().getData().getData();
reason = ItemStackFactory.Instance.GetName(damager.getItemInHand().getType(), data, false);
} }
} }
} else if (event.GetProjectile() != null) else if (_attackReason == AttackReason.CustomWeaponName)
{
reason = "Fists";
if (damager.getItemInHand() != null)
{
ItemStack itemStack = CraftItemStack.asNMSCopy(damager
.getItemInHand());
if (itemStack != null)
{
reason = CraftItemStack.asNMSCopy(
damager.getItemInHand()).getName();
}
}
}
}
else if (event.GetProjectile() != null)
{ {
if (event.GetProjectile() instanceof Arrow) if (event.GetProjectile() instanceof Arrow)
reason = "Archery"; reason = "Archery";
@ -582,4 +612,14 @@ public class CombatManager extends MiniPlugin
player.sendMessage(F.main(getName(), nameBuilder.toString())); player.sendMessage(F.main(getName(), nameBuilder.toString()));
} }
public void setUseWeaponName(AttackReason var)
{
_attackReason = var;
}
public AttackReason getUseWeapoName()
{
return _attackReason;
}
} }

View File

@ -1332,12 +1332,12 @@ public abstract class Game implements Listener
if (WinnerTeam != null && team.equals(WinnerTeam)) if (WinnerTeam != null && team.equals(WinnerTeam))
{ {
for (Player player : team.GetPlayers(false)) for (Player player : team.GetPlayers(false))
AddGems(player, 10, "Winning Team", false); AddGems(player, 10, "Winning Team", false, false);
} }
for (Player player : team.GetPlayers(false)) for (Player player : team.GetPlayers(false))
if (player.isOnline()) if (player.isOnline())
AddGems(player, 10, "Participation", false); AddGems(player, 10, "Participation", false, false);
} }
//End //End

View File

@ -11,6 +11,7 @@ import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.CombatComponent; import mineplex.minecraft.game.core.combat.CombatComponent;
import mineplex.minecraft.game.core.combat.CombatManager.AttackReason;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
@ -68,6 +69,8 @@ public class SearchAndDestroy extends TeamGame
DisableKillCommand = false; DisableKillCommand = false;
AllowParticles = false; AllowParticles = false;
DamageSelf = false; DamageSelf = false;
Manager.GetDamage().GetCombatManager().setUseWeaponName(AttackReason.DefaultWeaponName);
} }
public ArrayList<TeamBomb> getBombs() public ArrayList<TeamBomb> getBombs()

View File

@ -10,6 +10,7 @@ import mineplex.core.common.util.UtilTime;
import mineplex.core.timing.TimingManager; import mineplex.core.timing.TimingManager;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.CombatManager.AttackReason;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
@ -161,6 +162,7 @@ public class GameCreationManager implements Listener
Manager.GetExplosion().SetTNTSpread(true); Manager.GetExplosion().SetTNTSpread(true);
// Manager.GetAntiStack().SetEnabled(true); // Manager.GetAntiStack().SetEnabled(true);
Manager.getCosmeticManager().setHideParticles(false); Manager.getCosmeticManager().setHideParticles(false);
Manager.GetDamage().GetCombatManager().setUseWeaponName(AttackReason.CustomWeaponName);
HashMap<String, ChatColor> pastTeams = null; HashMap<String, ChatColor> pastTeams = null;