|
18 | 18 | import com.laytonsmith.core.constructs.Construct; |
19 | 19 | import com.laytonsmith.core.constructs.Target; |
20 | 20 | import com.laytonsmith.core.environments.Environment; |
| 21 | +import com.laytonsmith.core.exceptions.ConfigCompileException; |
21 | 22 | import com.laytonsmith.core.exceptions.ConfigRuntimeException; |
22 | 23 | import com.laytonsmith.core.functions.Exceptions.ExceptionType; |
23 | 24 |
|
@@ -276,6 +277,41 @@ public String docs() { |
276 | 277 | public Version since() { |
277 | 278 | return CHVersion.V3_3_1; |
278 | 279 | } |
| 280 | + |
| 281 | + @Override |
| 282 | + public ExampleScript[] examples() throws ConfigCompileException { |
| 283 | + return new ExampleScript[]{ |
| 284 | + new ExampleScript("Register the /hug <player> command.", |
| 285 | + "register_command('hug', array(\n" |
| 286 | + + "\t'description': 'Spread the love!',\n" |
| 287 | + + "\t'usage': '/hug <player>',\n" |
| 288 | + + "\t'permission': 'perms.hugs',\n" |
| 289 | + + "\t'noPermMsg': 'You do not have permission to give hugs to players (Sorry :o).',\n" |
| 290 | + + "\t'tabcompleter': closure(@alias, @sender, @args) {\n" |
| 291 | + + "\t\t\tif(array_size(@args) == 0) {\n" |
| 292 | + + "\t\t\t\treturn(all_players());\n" |
| 293 | + + "\t\t\t}\n" |
| 294 | + + "\t\t\t@search = @args[array_size(@args) - 1];\n" |
| 295 | + + "\t\t\treturn(array_filter(all_players(), closure(@index, @player) {\n" |
| 296 | + + "\t\t\t\treturn(equals_ic(@search, substr(@player, 0, length(@search))));\n" |
| 297 | + + "\t\t\t}));\n" |
| 298 | + + "\t\t},\n" |
| 299 | + + "\t'aliases':array('hugg', 'hugs'),\n" |
| 300 | + + "\t'executor': closure(@alias, @sender, @args) {\n" |
| 301 | + + "\t\t\tif(array_size(@args) == 1) {\n" |
| 302 | + + "\t\t\t\tif(!ponline(@args[0])) {\n" |
| 303 | + + "\t\t\t\t\tbroadcast(colorize('&4'.@sender.' &6hugs &4'.@args[0]));\n" |
| 304 | + + "\t\t\t\t} else {\n" |
| 305 | + + "\t\t\t\t\ttmsg(@sender, colorize('&cThe given player is not online.'));\n" |
| 306 | + + "\t\t\t\t}\n" |
| 307 | + + "\t\t\t\treturn(true);\n" |
| 308 | + + "\t\t\t}\n" |
| 309 | + + "\t\t\treturn(false);\n" |
| 310 | + + "\t\t}\n" |
| 311 | + + "));", |
| 312 | + "Registers the /hug command.") |
| 313 | + }; |
| 314 | + } |
279 | 315 | } |
280 | 316 |
|
281 | 317 | @api |
|
0 commit comments