@@ -47,20 +47,40 @@ func init() {
4747 if err := c .plug .AttachFileSystem (files ); err != nil {
4848 panic (err )
4949 }
50+
5051 //
5152 // Register any user/mob commands
5253 //
53- c .plug .AddUserCommand (`trash` , c .trashCommand , false , false )
54- c .plug .AddUserCommand (`bury` , c .buryCommand , false , false )
54+ c .plug .AddUserCommand ("trash" , c .trashCommand , false , false )
55+ c .plug .AddUserCommand ("bury" , c .buryCommand , false , false )
56+
57+ c .plug .AddMobCommand ("trash" , c .mobTrash , false )
58+ c .plug .AddMobCommand ("bury" , c .mobBury , false )
5559
56- c .plug .AddMobCommand (`trash` , c .mobTrash , false )
57- c .plug .AddMobCommand (`bury` , c .mobBury , false )
5860}
5961
6062// Using a struct gives a way to store longer term data.
6163type CleanupModule struct {
6264 // Keep a reference to the plugin when we create it so that we can call ReadBytes() and WriteBytes() on it.
6365 plug * plugins.Plugin
66+
67+ TrashExperienceEnabled bool
68+ DefaultTrashExperienceValue int
69+ }
70+
71+ func (c * CleanupModule ) loadConfig () {
72+
73+ if trashExperienceEnabled , ok := c .plug .Config .Get ("TrashExperienceEnabled" ).(bool ); ok {
74+ c .TrashExperienceEnabled = trashExperienceEnabled
75+ }
76+
77+ if trashExperienceValue , ok := c .plug .Config .Get ("TrashDefaultExperienceValue" ).(int ); ok {
78+ if trashExperienceValue < 1 {
79+ trashExperienceValue = 1
80+ }
81+ c .DefaultTrashExperienceValue = trashExperienceValue
82+ }
83+
6484}
6585
6686func (c * CleanupModule ) trashCommand (rest string , user * users.UserRecord , room * rooms.Room , flags events.EventFlag ) (bool , error ) {
@@ -72,6 +92,8 @@ func (c *CleanupModule) trashCommand(rest string, user *users.UserRecord, room *
7292 user .SendText (fmt .Sprintf (`You don't have a "%s" to trash.` , rest ))
7393 } else {
7494
95+ c .loadConfig ()
96+
7597 isSneaking := user .Character .HasBuffFlag (buffs .Hidden )
7698
7799 user .Character .RemoveItem (matchItem )
@@ -91,13 +113,18 @@ func (c *CleanupModule) trashCommand(rest string, user *users.UserRecord, room *
91113 user .UserId )
92114 }
93115
94- iSpec := matchItem .GetSpec ()
116+ if c .TrashExperienceEnabled {
117+
118+ // Grant experience equal to a tenth of the item value
119+ iSpec := matchItem .GetSpec ()
120+
121+ xpGrant := int (float64 (iSpec .Value ) / 10 )
122+ if xpGrant < 1 {
123+ xpGrant = c .DefaultTrashExperienceValue
124+ }
125+ user .GrantXP (xpGrant , `trash cleanup` )
95126
96- xpGrant := int (float64 (iSpec .Value ) / 10 )
97- if xpGrant < 1 {
98- xpGrant = 1
99127 }
100- user .GrantXP (xpGrant , `trash cleanup` )
101128
102129 }
103130
0 commit comments