OnPrayerIcon changed and OnPlayerSkull changed events.
This needs 2 be tested
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package net.runelite.api.events.player.headicon;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.HeadIcon;
|
||||
import net.runelite.api.Player;
|
||||
|
||||
public class OverheadPrayerChanged extends PlayerHeadIconChanged
|
||||
{
|
||||
@Getter
|
||||
private final HeadIcon oldHeadIcon;
|
||||
|
||||
@Getter
|
||||
private final HeadIcon newHeadIcon;
|
||||
|
||||
public OverheadPrayerChanged(Player player, HeadIcon changedFrom, HeadIcon changedTo)
|
||||
{
|
||||
super(player);
|
||||
this.oldHeadIcon = changedFrom;
|
||||
this.newHeadIcon = changedTo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package net.runelite.api.events.player.headicon;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.events.Event;
|
||||
|
||||
public abstract class PlayerHeadIconChanged implements Event
|
||||
{
|
||||
@Getter
|
||||
private final Player player;
|
||||
|
||||
public PlayerHeadIconChanged(Player player)
|
||||
{
|
||||
this.player = player;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package net.runelite.api.events.player.headicon;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.SkullIcon;
|
||||
|
||||
public class PlayerSkullChanged extends PlayerHeadIconChanged
|
||||
{
|
||||
@Getter
|
||||
private final SkullIcon oldSkullIcon;
|
||||
|
||||
@Getter
|
||||
private final SkullIcon newSkullIcon;
|
||||
|
||||
public PlayerSkullChanged(Player player, SkullIcon changedFrom, SkullIcon changedTo)
|
||||
{
|
||||
super(player);
|
||||
this.oldSkullIcon = changedFrom;
|
||||
this.newSkullIcon = changedTo;
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ package net.runelite.mixins;
|
||||
import java.awt.Polygon;
|
||||
import java.awt.Shape;
|
||||
import java.util.ArrayList;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.Head;
|
||||
import net.runelite.api.HeadIcon;
|
||||
import static net.runelite.api.HeadIcon.MAGIC;
|
||||
import static net.runelite.api.HeadIcon.MELEE;
|
||||
@@ -46,6 +47,8 @@ import static net.runelite.api.SkullIcon.SKULL;
|
||||
import static net.runelite.api.SkullIcon.SKULL_FIGHT_PIT;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.events.PlayerAppearanceChanged;
|
||||
import net.runelite.api.events.player.headicon.OverheadPrayerChanged;
|
||||
import net.runelite.api.events.player.headicon.PlayerSkullChanged;
|
||||
import net.runelite.api.mixins.Copy;
|
||||
import net.runelite.api.mixins.Inject;
|
||||
import net.runelite.api.mixins.MethodHook;
|
||||
@@ -67,6 +70,12 @@ public abstract class RSPlayerMixin implements RSPlayer
|
||||
@Inject
|
||||
private boolean friended;
|
||||
|
||||
@Inject
|
||||
private HeadIcon oldHeadIcon = null;
|
||||
|
||||
@Inject
|
||||
private SkullIcon oldSkullIcon = null;
|
||||
|
||||
@Inject
|
||||
@Override
|
||||
public String getName()
|
||||
@@ -92,7 +101,41 @@ public abstract class RSPlayerMixin implements RSPlayer
|
||||
@Override
|
||||
public HeadIcon getOverheadIcon()
|
||||
{
|
||||
switch (getRsOverheadIcon())
|
||||
final HeadIcon headIcon = getHeadIcon(getRsOverheadIcon());
|
||||
if (headIcon == null && oldHeadIcon == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (headIcon != oldHeadIcon)
|
||||
{
|
||||
client.getCallbacks().post(OverheadPrayerChanged.class,
|
||||
new OverheadPrayerChanged(this, oldHeadIcon, headIcon));
|
||||
}
|
||||
oldHeadIcon = headIcon;
|
||||
return headIcon;
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Override
|
||||
public SkullIcon getSkullIcon()
|
||||
{
|
||||
final SkullIcon skullIcon = skullFromInt(getRsSkullIcon());
|
||||
if (oldSkullIcon == null && skullIcon == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (skullIcon != oldSkullIcon)
|
||||
{
|
||||
client.getCallbacks().post(PlayerSkullChanged.class,
|
||||
new PlayerSkullChanged(this, oldSkullIcon, skullIcon));
|
||||
}
|
||||
oldSkullIcon = skullIcon;
|
||||
return skullIcon;
|
||||
}
|
||||
|
||||
private HeadIcon getHeadIcon(int overheadIcon)
|
||||
{
|
||||
switch (overheadIcon)
|
||||
{
|
||||
case 0:
|
||||
return MELEE;
|
||||
@@ -111,11 +154,9 @@ public abstract class RSPlayerMixin implements RSPlayer
|
||||
}
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Override
|
||||
public SkullIcon getSkullIcon()
|
||||
private SkullIcon skullFromInt(int skull)
|
||||
{
|
||||
switch (getRsSkullIcon())
|
||||
switch (skull)
|
||||
{
|
||||
case 0:
|
||||
return SKULL;
|
||||
|
||||
Reference in New Issue
Block a user