Revert "opponentinfo: Show health bar of actors attacking the player"

This reverts commit 48ea01dd28.
This commit is contained in:
Jordan Atwood
2021-03-09 21:30:58 -08:00
parent 5fc1f0260d
commit 36ec314ab7
2 changed files with 24 additions and 219 deletions

View File

@@ -1,7 +1,6 @@
/*
* Copyright (c) 2016-2018, Adam <Adam@sigterm.info>
* Copyright (c) 2018, Jordan Atwood <jordan.atwood423@gmail.com>
* Copyright (c) 2021, Andre Araya <araya.andre7@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -138,50 +137,33 @@ public class OpponentInfoPlugin extends Plugin
@Subscribe
public void onInteractingChanged(InteractingChanged event)
{
final Actor player = client.getLocalPlayer();
if (player == null)
if (event.getSource() != client.getLocalPlayer())
{
return;
}
final Actor opponent = player.getInteracting();
final Actor source = event.getSource();
final Actor target = event.getTarget();
if (source == player)
{
// You have attacked an enemy
if (target != null)
{
lastOpponent = target;
lastTime = null;
}
// You have stopped attacking an enemy which is not attacking you
else if (lastOpponent != null && lastOpponent.getInteracting() != player)
{
lastTime = Instant.now();
}
}
// You are attacked while not attacking anything
else if (target == player && opponent == null)
{
lastOpponent = source;
lastTime = null;
}
// An enemy which was previously attacking you (which you were not attacking back) has changed its target
else if (source == lastOpponent && opponent != lastOpponent)
Actor opponent = event.getTarget();
if (opponent == null)
{
lastTime = Instant.now();
return;
}
lastOpponent = opponent;
}
@Subscribe
public void onGameTick(GameTick gameTick)
{
if (lastTime != null
&& Duration.between(lastTime, Instant.now()).compareTo(WAIT) > 0)
if (lastOpponent != null
&& lastTime != null
&& client.getLocalPlayer().getInteracting() == null)
{
lastOpponent = null;
lastTime = null;
if (Duration.between(lastTime, Instant.now()).compareTo(WAIT) > 0)
{
lastOpponent = null;
}
}
}