Made serversigns force its commands into the command map (to replace the java plugin ServerSigns its commands)

This commit is contained in:
Dico200
2016-05-31 16:39:54 +02:00
parent 5d00af8ced
commit f0ada788bf
2 changed files with 21 additions and 2 deletions

View File

@@ -24,7 +24,7 @@ def on_enable():
if "imbusy" in shared["modules"]:
shared["modules"]["imbusy"].replace_ess_commands()
if "serversigns" in shared["modules"]:
shared["modules"]["serversigns"].check_all_signs()
shared["modules"]["serversigns"].check_all_signs_and_force_commands()
info("RedstonerUtils enabled!")

View File

@@ -335,7 +335,26 @@ def can_build2(player, block):
return not event.isCancelled()
def check_all_signs():
def check_all_signs_and_force_commands():
for loc in signs:
if server.getWorld(loc[0]).getBlockAt(loc[1], loc[2], loc[3]).getType() not in (Material.WALL_SIGN, Material.SIGN_POST):
del signs[loc]
try:
map_field = server.getPluginManager().getClass().getDeclaredField("commandMap")
map_field.setAccessible(True)
command_map = map_field.get(server.getPluginManager())
commands_field = command_map.getClass().getDeclaredField("knownCommands")
commands_field.setAccessible(True)
map = commands_field.get(command_map)
rsutils_cmd = map.get("redstonerutils:serversigns")
info(str(rsutils_cmd))
map.put("svs", rsutils_cmd)
map.put("serversigns", rsutils_cmd)
map.put("signsmsg", rsutils_cmd)
except:
error("[Serversigns] failed to force commands")
error(trace())