Fixed Ectophial emptying when used while teleblocked

This commit is contained in:
Lila Hioh
2022-08-10 09:26:46 +00:00
committed by Ryan
parent edb9dfe955
commit d545b2a119
2 changed files with 27 additions and 21 deletions
@@ -34,6 +34,8 @@ import core.plugin.Plugin;
import rs09.plugin.ClassScanner; import rs09.plugin.ClassScanner;
import core.tools.RandomFunction; import core.tools.RandomFunction;
import static api.ContentAPIKt.teleport;
/** /**
* Handles the animal magnetism plugin. * Handles the animal magnetism plugin.
* @author Vexia * @author Vexia
@@ -122,25 +124,26 @@ public final class AnimalMagnetismPlugin extends OptionHandler {
* @param item the item. * @param item the item.
*/ */
private void handleEctophial(final Player player, final Item item) { private void handleEctophial(final Player player, final Item item) {
player.getInventory().replace(new Item(4252), item.getSlot()); if(teleport(player,Location.create(3658, 3517, 0), TeleportType.ECTOPHIAL)) {
player.sendMessage("...and the world changes around you.", 4); player.getInventory().replace(new Item(4252), item.getSlot());
player.getTeleporter().send(Location.create(3658, 3517, 0), TeleportType.ECTOPHIAL); player.sendMessage("...and the world changes around you.", 4);
player.getAudioManager().send(4580); player.getAudioManager().send(4580);
player.sendMessage("You empty the ectoplasm onto the ground around your feet..."); player.sendMessage("You empty the ectoplasm onto the ground around your feet...");
player.getPulseManager().run(new Pulse(9, player) { player.getPulseManager().run(new Pulse(9, player) {
@Override @Override
public boolean pulse() { public boolean pulse() {
player.faceLocation(new Location(3659, 3519, 0)); player.faceLocation(new Location(3659, 3519, 0));
if (player.getInventory().containsItem(new Item(4252))) { if (player.getInventory().containsItem(new Item(4252))) {
player.animate(Animation.create(1652)); player.animate(Animation.create(1652));
player.getAudioManager().send(1132); player.getAudioManager().send(1132);
player.getInventory().remove(new Item(4252)); player.getInventory().remove(new Item(4252));
player.getInventory().add(item); player.getInventory().add(item);
player.sendMessage("You refill the ectophial from the Ectofuntus."); player.sendMessage("You refill the ectophial from the Ectofuntus.");
}
return true;
} }
return true; });
} }
});
} }
/** /**
+6 -3
View File
@@ -1064,9 +1064,12 @@ fun runWorldTask(task: () -> Unit): Pulse {
* @param loc the Location object to move them to * @param loc the Location object to move them to
* @param type the teleport type to use (defaults to instant). An enum exists as TeleportManager.TeleportType. * @param type the teleport type to use (defaults to instant). An enum exists as TeleportManager.TeleportType.
*/ */
fun teleport(entity: Entity, loc: Location, type: TeleportManager.TeleportType = TeleportManager.TeleportType.INSTANT) { fun teleport(entity: Entity, loc: Location, type: TeleportManager.TeleportType = TeleportManager.TeleportType.INSTANT) : Boolean {
if (type == TeleportManager.TeleportType.INSTANT) entity.properties.teleportLocation = loc if (type == TeleportManager.TeleportType.INSTANT) {
else entity.teleporter.send(loc, type) entity.properties.teleportLocation = loc
return true
}
else return entity.teleporter.send(loc, type)
} }
/** /**