Added arguments command and label to all command executor functions,
hopefully for massive performance increase.
This is due to the following mess in PythonLoader:
``` Java
@Override
public boolean onCommand(CommandSender sender, Command command, String
label, String[] args) {
boolean result;
if (argcount == -1) {
try {
result = call(4, sender, command, label, args);
argcount = 4;
} catch (PyException e) {
//this could goof up someone ... they'll probably yell at us and
eventually read this code ... fuck them
if (e.type == Py.TypeError && (e.value.toString().endsWith("takes
exactly 3 arguments (4 given)") || e.value.toString().endsWith("takes
exactly 4 arguments (5 given)"))) {
result = call(3, sender, command, label, args);
argcount = 3;
} else if (e.type == Py.TypeError && (e.value.toString().endsWith("takes
exactly 2 arguments (4 given)") || e.value.toString().endsWith("takes
exactly 3 arguments (5 given)"))) {
result = call(2, sender, command, label, args);
argcount = 2;
} else {
throw e;
}
}
} else {
result = call(argcount, sender, command, label, args);
}
return result;
}
```
Note: Still WIP on reports - I'm working on making it keep solved
reports to fix issue 10
36 lines
889 B
Python
36 lines
889 B
Python
#pylint: disable = F0401
|
|
from helpers import *
|
|
|
|
default_motd = colorify(server.getMotd())
|
|
motd = default_motd
|
|
|
|
@hook.command("getmotd")
|
|
def on_getmotd_command(sender, command, label, args):
|
|
plugin_header(sender, "MOTD")
|
|
msg(sender, motd, usecolor = False)
|
|
|
|
|
|
@hook.command("setmotd")
|
|
def on_setmotd_command(sender, command, label, args):
|
|
global motd
|
|
if sender.hasPermission("utils.setmotd"):
|
|
if not checkargs(sender, args, 1, -1):
|
|
return True
|
|
|
|
motd = colorify(" ".join(args).replace("\\n", "\n"))
|
|
|
|
if motd == "--reset":
|
|
motd = default_motd
|
|
|
|
broadcast(None, plugin_header(name="MOTD"))
|
|
broadcast(None, "&aNew MOTD:&r\n%s" % motd)
|
|
broadcast(None, " ")
|
|
else:
|
|
noperm(sender)
|
|
return True
|
|
|
|
|
|
@hook.event("server.ServerListPingEvent")
|
|
def on_server_ping(event):
|
|
event.setMotd(motd)
|