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,12 +29,20 @@ import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
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.CombatDeathEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
public class CombatManager extends MiniPlugin
{
public enum AttackReason
{
Attack,
CustomWeaponName,
DefaultWeaponName
}
private NautHashMap<Player, CombatLog> _active = new NautHashMap<Player, CombatLog>();
private NautHashMap<String, ClientCombat> _combatClients = new NautHashMap<String, ClientCombat>();
@ -42,6 +50,8 @@ public class CombatManager extends MiniPlugin
protected long ExpireTime = 15000;
protected AttackReason _attackReason = AttackReason.CustomWeaponName;
public CombatManager(JavaPlugin plugin)
{
super("Combat", plugin);
@ -203,6 +213,24 @@ public class CombatManager extends MiniPlugin
{
Player damager = event.GetDamagerPlayer(false);
reason = "Attack";
if (_attackReason == AttackReason.DefaultWeaponName)
{
reason = "Fists";
if (damager.getItemInHand() != null)
{
byte data = 0;
if (damager.getItemInHand().getData() != null)
data = damager.getItemInHand().getData().getData();
reason = ItemStackFactory.Instance.GetName(damager.getItemInHand().getType(), data, false);
}
}
else if (_attackReason == AttackReason.CustomWeaponName)
{
reason = "Fists";
if (damager.getItemInHand() != null)
@ -216,7 +244,9 @@ public class CombatManager extends MiniPlugin
damager.getItemInHand()).getName();
}
}
} else if (event.GetProjectile() != null)
}
}
else if (event.GetProjectile() != null)
{
if (event.GetProjectile() instanceof Arrow)
reason = "Archery";
@ -582,4 +612,14 @@ public class CombatManager extends MiniPlugin
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))
{
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))
if (player.isOnline())
AddGems(player, 10, "Participation", false);
AddGems(player, 10, "Participation", false, false);
}
//End

View File

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

View File

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