Skip to content

Commit 01db94a

Browse files
committed
unload/unloadall commands
1 parent 6bb3fc0 commit 01db94a

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

scripts/dmodels_command.dsc

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dmodels_command:
1414
type: command
1515
debug: false
1616
name: dmodels
17-
usage: /dmodels [load/loadall/spawn/remove/animate/stopanimate/npcmodel]
17+
usage: /dmodels [load/loadall/spawn/remove/animate/stopanimate/npcmodel/unload/unloadall]
1818
description: Manages Denizen Models.
1919
permission: dmodels.help
2020
tab completions:
@@ -61,6 +61,29 @@ dmodels_command:
6161
- debug log "[DModels] <&[emphasis]><player.name||server> <&[base]>is loading <[files].size.custom_color[emphasis]> model files: <[files].formatted.custom_color[emphasis]>"
6262
- ~run dmodels_multi_load def.list:<[files]>
6363
- narrate <&[base]>Done!
64+
- case unload:
65+
- if !<player.has_permission[dmodels.unload]>:
66+
- narrate "<&[error]>You do not have permission for that."
67+
- stop
68+
- if !<context.args.get[2].exists>:
69+
- narrate "<&[warning]>/dmodels unload [model] <&[error]>- unloads a model's data from memory."
70+
- stop
71+
- define model <context.args.get[2]>
72+
- if !<[model].to_lowercase.matches_character_set[<script[dmodels_cmd_data].data_key[valid_chars]>]>:
73+
- narrate "<&[error]>Given model name has an invalid format."
74+
- stop
75+
- if !<server.has_flag[dmodels_data.model_<[model]>]>:
76+
- narrate "<&[error]>No such model exists, or that model has never been loaded."
77+
- stop
78+
- flag server dmodels_data.model_<[model]>:!
79+
- flag server dmodels_data.animations_<[model]>:!
80+
- narrate "<&[base]>Removed model <[model].custom_color[emphasis]> from memory."
81+
- case unloadall:
82+
- if !<player.has_permission[dmodels.unloadall]>:
83+
- narrate "<&[error]>You do not have permission for that."
84+
- stop
85+
- flag server dmodels_data:!
86+
- narrate "<&[base]>Removed all DModels data from meory."
6487
- case spawn:
6588
- if !<player.has_permission[dmodels.spawn]>:
6689
- narrate "<&[error]>You do not have permission for that."
@@ -154,6 +177,10 @@ dmodels_command:
154177
- narrate "<&[warning]>/dmodels load [path] <&[error]>- loads a model from file based on filename"
155178
- if <player.has_permission[dmodels.loadall]||true>:
156179
- narrate "<&[warning]>/dmodels loadall <&[error]>- loads all models in the source folder"
180+
- if <player.has_permission[dmodels.unload]||true>:
181+
- narrate "<&[warning]>/dmodels unload [model] <&[error]>- unloads a specific model from memory"
182+
- if <player.has_permission[dmodels.unloadall]||true>:
183+
- narrate "<&[warning]>/dmodels unloadall <&[error]>- unloads all DModels data from memory"
157184
- if <player.has_permission[dmodels.spawn]||true>:
158185
- narrate "<&[warning]>/dmodels spawn [model] <&[error]>- spawns a model at your position (must be loaded)"
159186
- if <player.has_permission[dmodels.remove]||true>:
@@ -180,8 +207,8 @@ dmodels_tab_1:
180207
debug: false
181208
script:
182209
- define list <list>
183-
- foreach load|loadall|spawn|remove|animate|stopanimate|npcmodel|help as:key:
184-
- if <player.has_permission[<[key]>]||true>:
210+
- foreach load|loadall|spawn|remove|animate|stopanimate|npcmodel|help|unload|unloadall as:key:
211+
- if <player.has_permission[dmodels.<[key]>]||true>:
185212
- define list:->:<[key]>
186213
- determine <[list]>
187214

scripts/dmodels_main.dsc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# @contributors Max^
1010
# @thanks Darwin, Max^, kalebbroo, sharklaserss - for helping with reference models, testing, ideas, etc
1111
# @date 2022/06/01
12-
# @updated 2022/07/20
12+
# @updated 2022/07/25
1313
# @denizen-build REL-1773
1414
# @script-version 1.5
1515
#
@@ -46,6 +46,10 @@
4646
# /dmodels help - "dmodels.help" - Shows help information about the dModels command
4747
# /dmodels load [path] - "dmodels.load" - Loads a single model based on model file name input
4848
# /dmodels loadall - "dmodels.loadall" - Loads all models in the models folder
49+
# /dmodels unload [model] - "dmodels.unload" - Unloads a single model from memory based on model name input.
50+
###### - This will not properly remove any spawned instances of that model, which may now be glitched as a result.
51+
###### - This also does not remove any data from the resource pack currently.
52+
# /dmodels unloadall - "dmodels.unloadall" - Unloads any/all DModels data from memory
4953
# /dmodels spawn [model] - "dmodels.spawn" - Spawns a static instance of a model at your location
5054
# /dmodels remove - "dmodels.remove" - Removes whichever real-spawned model is closest to your location
5155
# /dmodels animate [animation] - "dmodels.animate" - Causes your nearest real-spawned model to play the specified animation

0 commit comments

Comments
 (0)