mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-09 16:45:44 -07:00
Added ::permadeath [player] admin command to wipe a player's save
Fixed some HCIM death bugs where state was not cleared
This commit is contained in:
parent
2da47d8353
commit
ee9d386bc9
4 changed files with 86 additions and 31 deletions
47
Server/src/main/core/api/utils/Permadeath.kt
Normal file
47
Server/src/main/core/api/utils/Permadeath.kt
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
package core.api.utils.Permadeath
|
||||||
|
|
||||||
|
import core.api.*
|
||||||
|
import core.game.node.entity.player.Player
|
||||||
|
import core.game.node.entity.player.VarpManager
|
||||||
|
import core.game.node.entity.player.info.login.PlayerSaver
|
||||||
|
import core.game.node.entity.player.link.SavedData
|
||||||
|
import core.game.node.entity.player.link.diary.DiaryType
|
||||||
|
import core.game.node.entity.player.link.quest.QuestRepository
|
||||||
|
import core.game.node.entity.skill.Skills
|
||||||
|
import core.game.world.map.Location
|
||||||
|
|
||||||
|
fun permadeath(target: Player) {
|
||||||
|
teleport(target, Location.create(3094, 3107, 0))
|
||||||
|
target.equipment.clear()
|
||||||
|
target.inventory.clear()
|
||||||
|
if (isUsingSecondaryBankAccount(target)) {
|
||||||
|
toggleBankAccount(target)
|
||||||
|
}
|
||||||
|
target.bank.clear()
|
||||||
|
target.bankSecondary.clear()
|
||||||
|
target.skills = Skills(target)
|
||||||
|
target.clearAttributes()
|
||||||
|
target.savedData = SavedData(target)
|
||||||
|
target.questRepository = QuestRepository(target)
|
||||||
|
target.varpManager = VarpManager(target)
|
||||||
|
target.varpMap.clear()
|
||||||
|
target.saveVarp.clear()
|
||||||
|
if (target.familiarManager.hasFamiliar()) {
|
||||||
|
target.familiarManager.dismiss()
|
||||||
|
}
|
||||||
|
val petKeys = target.familiarManager.petDetails.keys.toList()
|
||||||
|
for (key in petKeys) {
|
||||||
|
target.familiarManager.removeDetails(key)
|
||||||
|
}
|
||||||
|
for (type in DiaryType.values()) {
|
||||||
|
val diary = target.achievementDiaryManager.getDiary(type)
|
||||||
|
for (level in 0 until diary.levelStarted.size) {
|
||||||
|
for (task in 0 until diary.taskCompleted[level].size) {
|
||||||
|
diary.resetTask(target, level, task)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
target.musicPlayer.clearUnlocked()
|
||||||
|
PlayerSaver(target).save()
|
||||||
|
target.clear()
|
||||||
|
}
|
||||||
|
|
@ -69,7 +69,6 @@ import core.game.node.entity.combat.CombatSwingHandler;
|
||||||
import content.global.handlers.item.equipment.EquipmentDegrader;
|
import content.global.handlers.item.equipment.EquipmentDegrader;
|
||||||
import core.game.node.entity.combat.graves.Grave;
|
import core.game.node.entity.combat.graves.Grave;
|
||||||
import core.game.node.entity.combat.graves.GraveController;
|
import core.game.node.entity.combat.graves.GraveController;
|
||||||
import core.game.node.entity.player.info.login.PlayerSaver;
|
|
||||||
import core.game.node.entity.state.State;
|
import core.game.node.entity.state.State;
|
||||||
import core.game.node.entity.state.StateRepository;
|
import core.game.node.entity.state.StateRepository;
|
||||||
import core.game.world.GameWorld;
|
import core.game.world.GameWorld;
|
||||||
|
|
@ -88,6 +87,7 @@ import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static core.api.ContentAPIKt.*;
|
import static core.api.ContentAPIKt.*;
|
||||||
|
import static core.api.utils.Permadeath.PermadeathKt.permadeath;
|
||||||
import static core.game.system.command.sets.StatAttributeKeysKt.STATS_BASE;
|
import static core.game.system.command.sets.StatAttributeKeysKt.STATS_BASE;
|
||||||
import static core.game.system.command.sets.StatAttributeKeysKt.STATS_DEATHS;
|
import static core.game.system.command.sets.StatAttributeKeysKt.STATS_DEATHS;
|
||||||
import static core.tools.GlobalsKt.colorize;
|
import static core.tools.GlobalsKt.colorize;
|
||||||
|
|
@ -626,19 +626,7 @@ public class Player extends Entity {
|
||||||
String gender = this.isMale() ? "man " : "woman ";
|
String gender = this.isMale() ? "man " : "woman ";
|
||||||
if (getAttributes().containsKey("permadeath")) {
|
if (getAttributes().containsKey("permadeath")) {
|
||||||
Repository.sendNews("Permadeath Hardcore Iron" + gender + " " + this.getUsername() + " has fallen. Total Level: " + this.getSkills().getTotalLevel()); // Not enough room for XP
|
Repository.sendNews("Permadeath Hardcore Iron" + gender + " " + this.getUsername() + " has fallen. Total Level: " + this.getSkills().getTotalLevel()); // Not enough room for XP
|
||||||
equipment.clear();
|
permadeath(this);
|
||||||
inventory.clear();
|
|
||||||
bank.clear();
|
|
||||||
skills = new Skills(this);
|
|
||||||
clearAttributes();
|
|
||||||
setAttribute("/save:permadeath", true);
|
|
||||||
savedData = new SavedData(this);
|
|
||||||
questRepository = new QuestRepository(this);
|
|
||||||
varpManager = new VarpManager(this);
|
|
||||||
varpMap.clear();
|
|
||||||
saveVarp.clear();
|
|
||||||
new PlayerSaver(this).save();
|
|
||||||
clear();
|
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
Repository.sendNews("Hardcore Iron " + gender + " " + this.getUsername() + " has fallen. Total Level: " + this.getSkills().getTotalLevel()); // Not enough room for XP
|
Repository.sendNews("Hardcore Iron " + gender + " " + this.getUsername() + " has fallen. Total Level: " + this.getSkills().getTotalLevel()); // Not enough room for XP
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,13 @@ public final class MusicPlayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the unlocked songs. This should only be used in the permadeath code.
|
||||||
|
*/
|
||||||
|
public void clearUnlocked() {
|
||||||
|
this.unlocked.clear();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the player has enough songs unlocked for the Air guitar emote.
|
* Checks if the player has enough songs unlocked for the Air guitar emote.
|
||||||
* @return {@code True} if so.
|
* @return {@code True} if so.
|
||||||
|
|
|
||||||
|
|
@ -1,42 +1,39 @@
|
||||||
package core.game.system.command.sets
|
package core.game.system.command.sets
|
||||||
|
|
||||||
|
import content.global.handlers.iface.RulesAndInfo
|
||||||
|
import content.global.skill.farming.timers.*
|
||||||
|
import content.minigame.fishingtrawler.TrawlerLoot
|
||||||
|
import content.region.misthalin.draynor.quest.anma.AnmaCutscene
|
||||||
|
import core.ServerConstants
|
||||||
import core.api.*
|
import core.api.*
|
||||||
import core.api.InputType
|
import core.api.utils.Permadeath.permadeath
|
||||||
import core.cache.def.impl.NPCDefinition
|
import core.cache.def.impl.NPCDefinition
|
||||||
import core.cache.def.impl.SceneryDefinition
|
import core.cache.def.impl.SceneryDefinition
|
||||||
import core.cache.def.impl.VarbitDefinition
|
import core.cache.def.impl.VarbitDefinition
|
||||||
|
import core.game.bots.AIRepository
|
||||||
import core.game.component.Component
|
import core.game.component.Component
|
||||||
|
import core.game.ge.GrandExchange
|
||||||
import core.game.node.entity.npc.NPC
|
import core.game.node.entity.npc.NPC
|
||||||
import core.game.node.entity.player.Player
|
import core.game.node.entity.player.Player
|
||||||
import core.game.node.entity.player.info.Rights
|
import core.game.node.entity.player.info.Rights
|
||||||
import core.game.node.entity.skill.Skills
|
import core.game.node.entity.skill.Skills
|
||||||
import core.game.node.item.Item
|
import core.game.node.item.Item
|
||||||
import core.game.node.scenery.Scenery
|
import core.game.node.scenery.Scenery
|
||||||
|
import core.game.system.command.CommandMapping
|
||||||
|
import core.game.system.command.Privilege
|
||||||
import core.game.system.communication.CommunicationInfo
|
import core.game.system.communication.CommunicationInfo
|
||||||
import core.game.world.map.RegionManager
|
import core.game.world.map.RegionManager
|
||||||
import core.game.world.map.build.DynamicRegion
|
import core.game.world.map.build.DynamicRegion
|
||||||
|
import core.game.world.repository.Repository
|
||||||
import core.plugin.Initializable
|
import core.plugin.Initializable
|
||||||
|
import core.tools.Log
|
||||||
import core.tools.StringUtils
|
import core.tools.StringUtils
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.rs09.consts.Components
|
import org.rs09.consts.Components
|
||||||
import core.ServerConstants
|
|
||||||
import core.game.bots.AIRepository
|
|
||||||
import core.api.utils.PlayerCamera
|
|
||||||
import content.global.ame.RandomEvents
|
|
||||||
import content.region.misthalin.draynor.quest.anma.AnmaCutscene
|
|
||||||
import core.game.ge.GrandExchange
|
|
||||||
import content.global.handlers.iface.RulesAndInfo
|
|
||||||
import content.minigame.fishingtrawler.TrawlerLoot
|
|
||||||
import core.game.system.command.CommandMapping
|
|
||||||
import core.game.system.command.Privilege
|
|
||||||
import core.game.world.repository.Repository
|
|
||||||
import core.tools.Log
|
|
||||||
import core.tools.colorize
|
|
||||||
import java.awt.HeadlessException
|
import java.awt.HeadlessException
|
||||||
import java.awt.Toolkit
|
import java.awt.Toolkit
|
||||||
import java.awt.datatransfer.StringSelection
|
import java.awt.datatransfer.StringSelection
|
||||||
import content.global.skill.farming.timers.*
|
|
||||||
|
|
||||||
@Initializable
|
@Initializable
|
||||||
class MiscCommandSet : CommandSet(Privilege.ADMIN){
|
class MiscCommandSet : CommandSet(Privilege.ADMIN){
|
||||||
|
|
@ -377,6 +374,22 @@ class MiscCommandSet : CommandSet(Privilege.ADMIN){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Permadeaths a player, resetting their save
|
||||||
|
*/
|
||||||
|
define("permadeath", Privilege.ADMIN, "::permadeath <lt>PLAYER<gt>", "Permadeaths PLAYER (self if omitted), completely wiping their save."){player,args ->
|
||||||
|
var target = player
|
||||||
|
if (args.size > 1) {
|
||||||
|
val n = args.slice(1 until args.size).joinToString("_")
|
||||||
|
val foundtarget = Repository.getPlayerByName(n)
|
||||||
|
if (foundtarget == null) {
|
||||||
|
reject(player, "Invalid player \"${n}\" or player not online")
|
||||||
|
}
|
||||||
|
target = foundtarget!!
|
||||||
|
}
|
||||||
|
permadeath(target)
|
||||||
|
}
|
||||||
|
|
||||||
define("log", Privilege.ADMIN){player,_ ->
|
define("log", Privilege.ADMIN){player,_ ->
|
||||||
var log: ArrayList<String>? = player.getAttribute("loc-log")
|
var log: ArrayList<String>? = player.getAttribute("loc-log")
|
||||||
log = log ?: ArrayList<String>()
|
log = log ?: ArrayList<String>()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue