Everything hooked into Listeners
This commit is contained in:
@@ -105,6 +105,9 @@ public class Interaction {
|
|||||||
if (player.getLocks().isInteractionLocked() || player.getZoneMonitor().interact(node, option)) {
|
if (player.getLocks().isInteractionLocked() || player.getZoneMonitor().interact(node, option)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if(Listeners.run(node.getId(),0,option.getName(),player,node)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (option.getHandler() == null || !option.getHandler().handle(player, node, option.getName().toLowerCase())) {
|
if (option.getHandler() == null || !option.getHandler().handle(player, node, option.getName().toLowerCase())) {
|
||||||
player.getPacketDispatch().sendMessage("Nothing interesting happens.");
|
player.getPacketDispatch().sendMessage("Nothing interesting happens.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,4 +17,27 @@ object Listeners {
|
|||||||
fun get(id: Int, type: Int, option: String): ((Player,Node) -> Boolean)?{
|
fun get(id: Int, type: Int, option: String): ((Player,Node) -> Boolean)?{
|
||||||
return listeners[(StringUtils.stringToLong(option.toLowerCase()) + id) shl type]
|
return listeners[(StringUtils.stringToLong(option.toLowerCase()) + id) shl type]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun run(id: Int, type: Int, option: String, player: Player, node: Node): Boolean{
|
||||||
|
val flag = when(type){
|
||||||
|
2 -> DestinationFlag.ENTITY
|
||||||
|
1 -> DestinationFlag.OBJECT
|
||||||
|
else -> DestinationFlag.OBJECT
|
||||||
|
}
|
||||||
|
|
||||||
|
val method = get(id,type,option) ?: return false
|
||||||
|
|
||||||
|
if(type != 0) {
|
||||||
|
player.pulseManager.run(object : MovementPulse(player, node, flag) {
|
||||||
|
override fun pulse(): Boolean {
|
||||||
|
method.invoke(player,node)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
method.invoke(player,node)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -185,6 +185,9 @@ public final class InteractionPacket implements IncomingPacket {
|
|||||||
player.debug("spawn=" + npc.getProperties().getSpawnLocation() + ".");
|
player.debug("spawn=" + npc.getProperties().getSpawnLocation() + ".");
|
||||||
player.debug("Varp ID= " + npc.getDefinition().getConfigId() + " Offset=" + npc.getDefinition().getVarbitOffset() + " Size=" + npc.getDefinition().getVarbitSize());
|
player.debug("Varp ID= " + npc.getDefinition().getConfigId() + " Offset=" + npc.getDefinition().getVarbitOffset() + " Size=" + npc.getDefinition().getVarbitSize());
|
||||||
handleAIPLegion(player, 0, optionIndex, index);
|
handleAIPLegion(player, 0, optionIndex, index);
|
||||||
|
if(Listeners.run(shown.getId(),2, option.getName(),player,shown)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(PluginInteractionManager.handle(player,shown,option)){
|
if(PluginInteractionManager.handle(player,shown,option)){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -266,18 +269,7 @@ public final class InteractionPacket implements IncomingPacket {
|
|||||||
}
|
}
|
||||||
handleAIPLegion(player, 1, optionIndex, x, y, objectId);
|
handleAIPLegion(player, 1, optionIndex, x, y, objectId);
|
||||||
|
|
||||||
if(Listeners.get(object.getId(),1, option.getName()) != null){
|
if(Listeners.run(object.getId(),1, option.getName(),player,object)){
|
||||||
GameObject finalObject = object;
|
|
||||||
player.getPulseManager().run(new MovementPulse(player, finalObject,DestinationFlag.OBJECT) {
|
|
||||||
@Override
|
|
||||||
public boolean pulse() {
|
|
||||||
player.faceLocation(finalObject.getLocation());
|
|
||||||
if(!Listeners.get(finalObject.getId(),1,option.getName()).invoke(player, finalObject)){
|
|
||||||
player.sendMessage("Nothing interesting happens.");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(PluginInteractionManager.handle(player,object)){
|
if(PluginInteractionManager.handle(player,object)){
|
||||||
|
|||||||
Reference in New Issue
Block a user