You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Saving part that runs on quit runs these 2 functions with a 10 tick wait between them to maker sure it saves without breaking the file
if json file "saves\%{_p}%\%{_slot}%.json" exists:
set {_json} to json from json file "saves\%{_p}%\%{_slot}%.json"
set value of json object "data::save::stats::maxMana" in {_json} to {stats::%{_p}%::maxMana}
set value of json object "data::save::stats::maxHealth" in {_json} to {stats::%{_p}%::maxHealth}
set value of json object "data::save::class" in {_json} to {classes::%{_p}%::class}
set value of json object "data::save::money" in {_json} to {currency::%{_p}%::cash}
write json from {_json} to json file "saves\%{_p}%\%{_slot}%.json"
delete {stats::%{_p}%::maxMana}
delete {stats::%{_p}%::maxHealth}
delete {classes::%{_p}%::class}
delete {classes::%{_p}%::class::formatted}
delete {currency::%{_p}%::cash}
function saveLastLocation(p: player, slot: integer, loc: location):
if json file "saves\%{_p}%\%{_slot}%.json" exists:
set {_json} to json from json file "saves\%{_p}%\%{_slot}%.json"
set value of json object "data::save::lastLocation::x" in {_json} to x-coordinate of {_loc}
set value of json object "data::save::lastLocation::y" in {_json} to y-coordinate of {_loc}
set value of json object "data::save::lastLocation::z" in {_json} to z-coordinate of {_loc}
set value of json object "data::save::inventory" in {_json} to inventory of {_p}
write json from {_json} to json file "saves\%{_p}%\%{_slot}%.json"
delete {saves::%{_p}%::slot}
To load the save, we do
if json file "saves\%{_p}%\%{_slot}%.json" exists:
set {_json} to json from json file "saves\%{_p}%\%{_slot}%.json"
set {stats::%{_p}%::maxMana} to value "data::save::stats::maxMana" of {_json}
set {stats::%{_p}%::maxHealth} to value "data::save::stats::maxHealth" of {_json}
set {classes::%{_p}%::class} to value "data::save::class" of {_json}
set {currency::%{_p}%::cash} to value "data::save::money" of {_json}
set {saves::%{_p}%::slot} to {_slot}
tpToLastLocation({_p}, {_slot})
function tpToLastLocation(p: player, slot: integer):
if json file "saves\%{_p}%\%{_slot}%.json" exists:
set {_json} to json from json file "saves\%{_p}%\%{_slot}%.json"
if value "data::save::lastLocation::x" of {_json} is set:
teleport {_p} to location(value "data::save::lastLocation::x" of {_json}, value "data::save::lastLocation::y" of {_json}, value "data::save::lastLocation::z" of {_json})
wait 2 ticks
# this sets the items to the respective slots but doesn't keep enchants.
loop values "data::save::inventory::contents" of {_json}:
set {_slot} to "%json-key.replace("Slot ", "")%" parsed as integer
set slot {_slot} of {_p}'s inventory to json-value
# Cannnot set inventory with
# set {_inv} to value "data::save::inventory" of {_json}
# set {_p}'s inventory to {_inv}
when trying to set it directly, i got this error after
[11:47:10 ERROR]: #!#!
[11:47:10 ERROR]: #!#! [Skript] Severe Error:
[11:47:10 ERROR]: #!#!
[11:47:10 ERROR]: #!#! Something went horribly wrong with Skript.
[11:47:10 ERROR]: #!#! This issue is NOT your fault! You probably can't fix it yourself, either.
[11:47:10 ERROR]: #!#! It looks like you are using some plugin(s) that alter how Skript works (addons).
[11:47:10 ERROR]: #!#! Here is full list of them:
[11:47:10 ERROR]: #!#! skript-reflect v2.5.1 (https://github.com/SkriptLang/skript-reflect) SkJson v4.0.1 SkBee v3.6.6 (https://github.com/SkriptHub/SkBee) SkEssentials v1.0.5
[11:47:10 ERROR]: #!#! We could not identify which of those are specially related, so this might also be Skript issue.
[11:47:10 ERROR]: #!#! You should try disabling those plugins one by one, trying to find which one causes it.
[11:47:10 ERROR]: #!#! If the error doesn't disappear even after disabling all listed plugins, it is probably Skript issue.
[11:47:10 ERROR]: #!#! In that case, you will be given instruction on how should you report it.
[11:47:10 ERROR]: #!#! On the other hand, if the error disappears when disabling some plugin, report it to author of that plugin.
[11:47:10 ERROR]: #!#! Only if the author tells you to do so, report it to Skript's issue tracker.
[11:47:10 ERROR]: #!#!
[11:47:10 ERROR]: #!#! Stack trace:
[11:47:10 ERROR]: #!#! java.lang.ClassCastException: class org.bukkit.craftbukkit.inventory.CraftInventoryCustom cannot be cast to class org.bukkit.inventory.ItemStack (org.bukkit.craftbukkit.inventory.CraftInventoryCustom and org.bukkit.inventory.ItemStack are in unnamed module of loader java.net.URLClassLoader @4dcbadb4)
[11:47:10 ERROR]: #!#! at Skript-2.9.5.jar//org.skriptlang.skript.lang.converter.ChainedConverter.convert(ChainedConverter.java:58)
[11:47:10 ERROR]: #!#! at Skript-2.9.5.jar//org.skriptlang.skript.lang.converter.Converters.convert(Converters.java:412)
[11:47:10 ERROR]: #!#! at Skript-2.9.5.jar//ch.njol.skript.lang.Variable.getConverted(Variable.java:486)
[11:47:10 ERROR]: #!#! at Skript-2.9.5.jar//ch.njol.skript.lang.Variable.getAll(Variable.java:707)
[11:47:10 ERROR]: #!#! at Skript-2.9.5.jar//ch.njol.skript.lang.Variable.getArray(Variable.java:699)
[11:47:10 ERROR]: #!#! at Skript-2.9.5.jar//ch.njol.skript.effects.EffChange.execute(EffChange.java:284)
[11:47:10 ERROR]: #!#! at Skript-2.9.5.jar//ch.njol.skript.lang.Effect.run(Effect.java:49)
[11:47:10 ERROR]: #!#! at Skript-2.9.5.jar//ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:61)
[11:47:10 ERROR]: #!#! at Skript-2.9.5.jar//ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:88)
[11:47:10 ERROR]: #!#! at Skript-2.9.5.jar//ch.njol.skript.effects.Delay.lambda$walk$0(Delay.java:107)
[11:47:10 ERROR]: #!#! at org.bukkit.craftbukkit.scheduler.CraftTask.run(CraftTask.java:78)
[11:47:10 ERROR]: #!#! at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:474)
[11:47:10 ERROR]: #!#! at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1659)
[11:47:10 ERROR]: #!#! at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1529)
[11:47:10 ERROR]: #!#! at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1251)
[11:47:10 ERROR]: #!#! at net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:310)
[11:47:10 ERROR]: #!#! at java.base/java.lang.Thread.run(Thread.java:1570)
[11:47:10 ERROR]: #!#!
[11:47:10 ERROR]: #!#! Version Information:
[11:47:10 ERROR]: #!#! Skript: 2.9.5 (latest)
[11:47:10 ERROR]: #!#! Flavor: skriptlang-github
[11:47:10 ERROR]: #!#! Date: 19:09:25.858356200
[11:47:10 ERROR]: #!#! Bukkit: 1.21.4-R0.1-SNAPSHOT
[11:47:10 ERROR]: #!#! Minecraft: 1.21.4
[11:47:10 ERROR]: #!#! Java: 22.0.2 (Java HotSpot(TM) 64-Bit Server VM 22.0.2+9-70)
[11:47:10 ERROR]: #!#! OS: Windows 10 amd64 10.0
[11:47:10 ERROR]: #!#!
[11:47:10 ERROR]: #!#! Server platform: Paper
[11:47:10 ERROR]: #!#!
[11:47:10 ERROR]: #!#! Current node: null
[11:47:10 ERROR]: #!#! Current item: set inventory of {_p} (as java.lang.Object) to {inv::%{_p} (as java.lang.Object)%::contents::slot::%{_slot} (as java.lang.Object)%} (as java.lang.Iterable)
[11:47:10 ERROR]: #!#! Current trigger: function tpToLastLocation (simple event) (save\savehandler.sk, line 40)
[11:47:10 ERROR]: #!#!
[11:47:10 ERROR]: #!#! Thread: Server thread
[11:47:10 ERROR]: #!#!
[11:47:10 ERROR]: #!#! Language: english
[11:47:10 ERROR]: #!#! Link parse mode: DISABLED
[11:47:10 ERROR]: #!#!
[11:47:10 ERROR]: #!#! End of Error.
[11:47:10 ERROR]: #!#!
is there any issues with how I am implementing this or is this an issue worth while?
The text was updated successfully, but these errors were encountered:
When trying to set the player's inventory to a inventory stored at logout, the inventory cannot be restored. even though this is saved under a file.
When restoring contents of the inventory manually, the enchants do not get reapplied to the items.
Example save file:
The Saving part that runs on quit runs these 2 functions with a 10 tick wait between them to maker sure it saves without breaking the file
To load the save, we do
when trying to set it directly, i got this error after
is there any issues with how I am implementing this or is this an issue worth while?
The text was updated successfully, but these errors were encountered: