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
{{ message }}
Repository navigation
Commit 9b113e2
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/API-Reference.md
+8-5Lines changed: 8 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5240,25 +5240,28 @@ This function makes it easy to execute one or more minecraft commands.
5240
5240
#### Parameters
5241
5241
5242
5242
* commands : A String or Array of strings - each string is a command to be executed.
5243
-
* sender: The player or server on whose behalf the commands should be executed.
5243
+
* sender: (optional) The player on whose behalf the commands should be executed. If not specified the commands will be executed as the server console user.
5244
5244
5245
5245
#### Examples
5246
5246
5247
5247
Invoke the `/defaultgamemode creative`command (as server).
5248
5248
5249
5249
```javascript
5250
5250
var slash = require('slash');
5251
-
slash('defaultgamemode creative', server);
5251
+
slash('defaultgamemode creative');
5252
5252
```
5253
5253
5254
-
Set the time of day to Midday and toggle downfall:
5254
+
Set the time of day to Midday and toggle downfall (as player 'JohnDoe'):
Copy file name to clipboardExpand all lines: src/main/js/modules/slash.js
+14-6Lines changed: 14 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -14,25 +14,28 @@ This function makes it easy to execute one or more minecraft commands.
14
14
#### Parameters
15
15
16
16
* commands : A String or Array of strings - each string is a command to be executed.
17
-
* sender: The player or server on whose behalf the commands should be executed.
17
+
* sender: (optional) The player on whose behalf the commands should be executed. If not specified the commands will be executed as the server console user.
18
18
19
19
#### Examples
20
20
21
21
Invoke the `/defaultgamemode creative` command (as server).
22
22
23
23
```javascript
24
24
var slash = require('slash');
25
-
slash('defaultgamemode creative', server);
25
+
slash('defaultgamemode creative');
26
26
```
27
27
28
-
Set the time of day to Midday and toggle downfall:
28
+
Set the time of day to Midday and toggle downfall (as player 'JohnDoe'):
29
29
30
30
```javascript
31
-
var slash = require('slash');
31
+
var slash = require('slash'),
32
+
utils = require('utils');
33
+
var johnDoe = utils.player('John_Doe');
34
+
32
35
slash([
33
36
'time set 6000',
34
37
'toggledownfall'
35
-
], server);
38
+
], johnDoe);
36
39
```
37
40
38
41
***/
@@ -51,7 +54,12 @@ function slash( commands, sender ){
51
54
}
52
55
}
53
56
if(__plugin.bukkit){
54
-
server.dispatchCommand(sender,commands);
57
+
if(!sender){
58
+
// if sender is not specified assume server console
0 commit comments