mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-01 14:39:13 -06:00
Void recovery added to ActivityPlugin.
Hard coded POH to recovery.
This commit is contained in:
parent
2419bdb65e
commit
33f84c5f9d
12 changed files with 83 additions and 6 deletions
|
|
@ -215,6 +215,7 @@ public final class HouseManager {
|
|||
if (house.isInHouse(player)) {
|
||||
player.animate(Animation.RESET);
|
||||
player.getProperties().setTeleportLocation(house.location.getExitLocation());
|
||||
player.removeAttribute("lastActivity");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ public final class HouseZone extends MapZone {
|
|||
public boolean enter(Entity e) {
|
||||
if (e instanceof Player) {
|
||||
Player pl = (Player) e;
|
||||
pl.setAttribute("/save:lastActivity","POH-Activity");
|
||||
if (house == pl.getHouseManager()) {
|
||||
previousRegion = house.getHouseRegion().getId();
|
||||
if (house.getDungeonRegion() != null)
|
||||
|
|
@ -74,6 +75,7 @@ public final class HouseZone extends MapZone {
|
|||
}
|
||||
registerLogoutListener(pl, "houselogout", (p) -> {
|
||||
p.setLocation(house.getLocation().getExitLocation());
|
||||
p.removeAttribute("lastActivity");
|
||||
return kotlin.Unit.INSTANCE;
|
||||
});
|
||||
}
|
||||
|
|
@ -142,13 +144,14 @@ public final class HouseZone extends MapZone {
|
|||
clearLogoutListener(p, "houselogout");
|
||||
if (!getAttribute(p, "kidnapped-by-random", false)) {
|
||||
removeAttribute(p, "/save:original-loc");
|
||||
removeAttribute(p,"lastActivity");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void remove_items(Player p) {
|
||||
public static void remove_items(Player p) {
|
||||
for (int item = Items.KETTLE_7688; item <= Items.CHEFS_DELIGHT_7755; item++) {//Removes all PoH versions of tea and beer barrel-related items
|
||||
removeAll(p, item, Container.INVENTORY);
|
||||
removeAll(p, item, Container.BoB);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package content.minigame.fishingtrawler
|
||||
|
||||
import core.api.MapArea
|
||||
import core.api.sendMessage
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.system.task.Pulse
|
||||
import core.game.world.GameWorld
|
||||
|
|
@ -66,6 +67,7 @@ class FishingTrawlerActivity : ActivityPlugin("fishing trawler",false,false,true
|
|||
override fun start(player: Player?, login: Boolean, vararg args: Any?): Boolean {
|
||||
player ?: return false
|
||||
waitingPlayers.add(player)
|
||||
super.start(player, login, *args)
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
@ -74,11 +76,14 @@ class FishingTrawlerActivity : ActivityPlugin("fishing trawler",false,false,true
|
|||
nextStart = GameWorld.ticks + WAIT_TIME
|
||||
player.dialogueInterpreter.sendDialogue("Trawler will leave in 2 minutes.","If you have a team get them on board now!")
|
||||
}
|
||||
waitingPlayers.add(player)
|
||||
//waitingPlayers.add(player)
|
||||
start(player,true)
|
||||
}
|
||||
|
||||
|
||||
fun removePlayer(player: Player){
|
||||
waitingPlayers.remove(player)
|
||||
player.removeAttribute("lastActivity")
|
||||
}
|
||||
|
||||
override fun newInstance(p: Player?): ActivityPlugin {
|
||||
|
|
|
|||
|
|
@ -158,6 +158,7 @@ class FishingTrawlerSession(val activity: FishingTrawlerActivity? = null) : MapA
|
|||
player.removeAttribute("ft-session")
|
||||
player.setAttribute("/save:ft-rolls", rolls)
|
||||
clearLogoutListener(player, "ft-logout")
|
||||
player.removeAttribute("lastActivity")
|
||||
}
|
||||
session.zone.unregister(getRegionBorders(session.region.id))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -252,9 +252,22 @@ public final class PestControlActivityPlugin extends ActivityPlugin {
|
|||
}
|
||||
waitingPlayers.add(p);
|
||||
openLanderInterface(p);
|
||||
super.start(p, login, args);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recovers the player from void should they get left there.
|
||||
* Is called during login.
|
||||
* @param player The player.
|
||||
*/
|
||||
@Override
|
||||
public void recover(Player player) {
|
||||
player.setLocation(getLeaveLocation());
|
||||
//player.setLocation(getSpawnLocation());
|
||||
player.removeAttribute("lastActivity");
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the lander interface.
|
||||
* @param p The player.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package content.region.misthalin.draynor.handlers;
|
||||
|
||||
import core.ServerConstants;
|
||||
import core.game.component.Component;
|
||||
import core.game.activity.ActivityPlugin;
|
||||
import core.game.activity.CutscenePlugin;
|
||||
|
|
@ -233,7 +234,7 @@ public final class DBRCutscenePlugin extends CutscenePlugin {
|
|||
|
||||
@Override
|
||||
public Location getSpawnLocation() {
|
||||
return null;
|
||||
return Location.create(3087, 3248, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ public class WLBelowCutscene extends CutscenePlugin {
|
|||
|
||||
@Override
|
||||
public Location getSpawnLocation() {
|
||||
return null;
|
||||
return Location.create(3209, 3495, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -525,7 +525,7 @@ public class BorkNPC extends AbstractNPC {
|
|||
|
||||
@Override
|
||||
public Location getSpawnLocation() {
|
||||
return null;
|
||||
return Location.create(3143, 5545, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package core.game.activity;
|
||||
|
||||
import content.global.skill.construction.HouseZone;
|
||||
import core.ServerConstants;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.tools.Log;
|
||||
import core.tools.SystemLogger;
|
||||
|
|
@ -8,7 +10,7 @@ import core.game.world.GameWorld;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static core.api.ContentAPIKt.log;
|
||||
import static core.api.ContentAPIKt.*;
|
||||
|
||||
/**
|
||||
* Manages the activities.
|
||||
|
|
@ -79,4 +81,33 @@ public final class ActivityManager {
|
|||
public static ActivityPlugin getActivity(String name) {
|
||||
return ACTIVITIES.get(name);
|
||||
}
|
||||
|
||||
public static void ActivityRecover(Player player) {
|
||||
String activityName = player.getAttribute("lastActivity", null);
|
||||
if (activityName == null) return;
|
||||
//sendMessage(player,player.getUsername() + " recovering from " + activityName);
|
||||
if (activityName.equals("POH-Activity")) {
|
||||
HouseZone.remove_items(player);
|
||||
player.setLocation(player.getHouseManager().getLocation().getExitLocation());
|
||||
player.removeAttribute("/save:original-loc");
|
||||
player.removeAttribute("lastActivity");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
ActivityPlugin plugin = ACTIVITIES.get(activityName);
|
||||
if (plugin != null) {
|
||||
if (plugin.isInstanced()) {
|
||||
plugin = plugin.newInstance(player);
|
||||
}
|
||||
plugin.recover(player);
|
||||
} else {
|
||||
player.setLocation(ServerConstants.HOME_LOCATION);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
player.setLocation(ServerConstants.HOME_LOCATION);
|
||||
}
|
||||
|
||||
player.removeAttribute("lastActivity");
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,10 @@ import core.game.world.map.zone.impl.MultiwayCombatZone;
|
|||
import core.plugin.Plugin;
|
||||
import core.plugin.PluginManifest;
|
||||
import core.plugin.PluginType;
|
||||
import core.tools.Log;
|
||||
|
||||
import static core.api.ContentAPIKt.log;
|
||||
import static core.api.ContentAPIKt.sendMessage;
|
||||
|
||||
/**
|
||||
* A plugin implementation used for activity plugins.
|
||||
|
|
@ -130,6 +134,8 @@ public abstract class ActivityPlugin extends MapZone implements Plugin<Player> {
|
|||
*/
|
||||
public boolean start(Player player, boolean login, Object... args) {
|
||||
this.player = player;
|
||||
player.setAttribute("/save:lastActivity", this.getName());
|
||||
player.sendMessage(this.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -157,6 +163,7 @@ public abstract class ActivityPlugin extends MapZone implements Plugin<Player> {
|
|||
e.getProperties().setSafeZone(false);
|
||||
e.getProperties().safeRespawn = ServerConstants.HOME_LOCATION;
|
||||
e.removeAttribute("activity");
|
||||
e.removeAttribute("lastActivity");
|
||||
return super.leave(e, logout);
|
||||
}
|
||||
|
||||
|
|
@ -166,6 +173,18 @@ public abstract class ActivityPlugin extends MapZone implements Plugin<Player> {
|
|||
public void register() {
|
||||
}
|
||||
|
||||
public void recover(Player player) {
|
||||
Location spawn = getSpawnLocation();
|
||||
if (spawn == null) {
|
||||
String lastActivity = player.getAttribute("lastActivity", null);
|
||||
sendMessage(player, "You were safely removed from an invalid location.");
|
||||
sendMessage(player, "Activity: " + lastActivity + ", please report this!");
|
||||
spawn = ServerConstants.HOME_LOCATION;
|
||||
}
|
||||
player.setLocation(spawn);
|
||||
player.removeAttribute("lastActivity");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object fireEvent(String identifier, Object... args) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -142,6 +142,7 @@ public abstract class CutscenePlugin extends ActivityPlugin {
|
|||
player.getInterfaceManager().restoreTabs();
|
||||
player.unlock();// incase he was locked.
|
||||
player.getWalkingQueue().reset();
|
||||
player.removeAttribute("lastActivity");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import content.global.skill.construction.decoration.pohstorage.StorageState;
|
|||
import content.global.skill.runecrafting.PouchManager;
|
||||
import content.global.skill.slayer.SlayerEquipmentFlags;
|
||||
import core.api.ContentAPIKt;
|
||||
import core.game.activity.ActivityManager;
|
||||
import core.game.component.Component;
|
||||
import core.game.container.Container;
|
||||
import core.game.container.impl.BankContainer;
|
||||
|
|
@ -345,6 +346,7 @@ public class Player extends Entity {
|
|||
if (!artificial) {
|
||||
log(this.getClass(), Log.INFO, getUsername() + " initialising...");
|
||||
getDetails().getSession().setObject(this);
|
||||
ActivityManager.ActivityRecover(this);
|
||||
}
|
||||
super.init();
|
||||
LoginConfiguration.configureLobby(this);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue