/pluginversions is broken, Fixed mail send colours.

I attempted to fix /pluginversions but ended up just commenting it out.
The problem is in retrieving the plugins where instead of object type
Plugin it returns "array.array"? I tried a whole bunch of things but I
didn't succeed to make it work.
This commit is contained in:
Dico200
2015-04-10 23:55:30 +02:00
parent b232cbf5cf
commit ce3b911b35
3 changed files with 30 additions and 23 deletions

1
.gitignore vendored
View File

@@ -4,6 +4,7 @@
*.bat* *.bat*
secrets.py secrets.py
excluded.txt excluded.txt
.idea
# these are player/ingame specific # these are player/ingame specific
files/ files/

50
misc.py
View File

@@ -5,8 +5,6 @@ from sys import exc_info
import thread import thread
import org.bukkit.inventory.ItemStack as ItemStack import org.bukkit.inventory.ItemStack as ItemStack
import org.bukkit.Bukkit as Bukkit import org.bukkit.Bukkit as Bukkit
import org.bukkit.event.player.PlayerChatEvent as PlayerChatEvent
import basecommands
from basecommands import simplecommand from basecommands import simplecommand
@@ -41,16 +39,16 @@ def on_join(event):
@simplecommand("sudo", @simplecommand("sudo",
usage = "<player> [cmd..]", usage = "<player> [cmd..]",
description = "Makes <player> write [cmd..] in chat", description = "Makes <player> write [cmd..] in chat",
amin = 2, amin = 2,
helpNoargs = True) helpNoargs = True)
def on_sudo_command(sender, command, label, args): def on_sudo_command(sender, command, label, args):
target = args[0] target = args[0]
cmd = " ".join(args[1:]) cmd = " ".join(args[1:])
msg(sender, "&2[SUDO] &rRunning '&e%s&r' as &3%s" % (cmd, target)) msg(sender, "&2[SUDO] &rRunning '&e%s&r' as &3%s" % (cmd, target))
is_cmd = cmd[0] == "/" is_cmd = cmd[0] == "/"
is_console = target.lower() == "server" or target.lower() == "console" is_console = target.lower() in ("server", "console")
if is_console: if is_console:
server.dispatchCommand(server.getConsoleSender(), cmd[1:] if is_cmd else cmd) server.dispatchCommand(server.getConsoleSender(), cmd[1:] if is_cmd else cmd)
return None return None
@@ -62,13 +60,14 @@ def on_sudo_command(sender, command, label, args):
@simplecommand("me", @simplecommand("me",
usage = "[message..]", usage = "[message..]",
description = "Sends a message in third person", description = "Sends a message in third person",
helpNoargs = True) helpNoargs = True)
def on_me_command(sender, command, label, args): def on_me_command(sender, command, label, args):
broadcast("utils.me", "&7- %s &7%s %s" % (sender.getDisplayName() if isinstance(sender, Player) else "&9CONSOLE", u"\u21E6", " ".join(args))) broadcast("utils.me", "&7- %s &7%s %s" % (sender.getDisplayName() if isinstance(sender, Player) else "&9CONSOLE", u"\u21E6", " ".join(args)))
return None return None
#
#@hook.command("gm") #@hook.command("gm")
#def on_gm_command(sender, args): #def on_gm_command(sender, args):
# """ # """
@@ -115,20 +114,25 @@ def on_player_entity_interact(event):
entity.getWorld().dropItemNaturally(entity.getLocation(), ItemStack(bukkit.Material.getMaterial("WOOL"))) entity.getWorld().dropItemNaturally(entity.getLocation(), ItemStack(bukkit.Material.getMaterial("WOOL")))
sender.playSound(entity.getLocation(), "mob.cow.say", 1, 1) sender.playSound(entity.getLocation(), "mob.cow.say", 1, 1)
"""
@hook.command("pluginversions") @hook.command("pluginversions")
def on_pluginversions_command(sender, command, label, args): def on_pluginversions_command(sender, command, label, args):
""" ""
/pluginversions /pluginversions
print all plugins + versions; useful when updating plugins print all plugins + versions; useful when updating plugins
""" ""
plugin_header(sender, "Plugin versions") try:
plugins = list(server.getPluginManager().getPlugins()) plugin_header(sender, "Plugin versions")
plugins.sort(key = lambda pl: pl.getDescription().getName()) plugins = [pl.getDescription() for pl in list(ArrayList(java_array_to_list(server.getPluginManager().getPlugins())))]
msg(sender, "&3Listing all " + str(len(plugins)) + " plugins and their version:") info(type(plugins[0]).__name__)
for plugin in plugins: plugins.sort(key = lambda pl: pl.getDescription().getName())
msg(sender, "&6" + plugin.getDescription().getName() + "&r: &e" + plugin.getDescription().getVersion()) msg(sender, "&3Listing all " + str(len(plugins)) + " plugins and their version:")
return True for plugin in plugins:
msg(sender, "&6" + pl.getDescription().getName() + "&r: &e" + pl.getDescription().getVersion())
return True
except:
error(trace())
"""
@hook.command("echo") @hook.command("echo")
@@ -157,6 +161,7 @@ def eval_thread(sender, code):
msg(sender, ">>> %s: %s" % (eclass.__name__, e) + "\n ", False, "c") msg(sender, ">>> %s: %s" % (eclass.__name__, e) + "\n ", False, "c")
thread.exit() thread.exit()
"""
def eval_argument_thread(event): def eval_argument_thread(event):
words = event.getMessage()[5:].split(" ") words = event.getMessage()[5:].split(" ")
for i in range(len(words)): for i in range(len(words)):
@@ -176,7 +181,7 @@ def eval_argument_thread(event):
words[i] = result words[i] = result
event.setMessage(" ".join(words)) event.setMessage(" ".join(words))
thread.exit() thread.exit()
"""
@simplecommand("pyeval", @simplecommand("pyeval",
usage = "[code..]", usage = "[code..]",
@@ -208,7 +213,7 @@ def on_player_teleport(event):
event.setCancelled(True) event.setCancelled(True)
msg(event.getPlayer(), "&cSpectator teleportation is disabled") msg(event.getPlayer(), "&cSpectator teleportation is disabled")
"""
@hook.event("player.AsyncPlayerChatEvent", "lowest") @hook.event("player.AsyncPlayerChatEvent", "lowest")
def on_chat(event): def on_chat(event):
user = event.getPlayer() user = event.getPlayer()
@@ -223,3 +228,4 @@ def on_cmd(event):
def is_pyeval_call(string): def is_pyeval_call(string):
return len(string) > 5 and string[:5] == "EVAL:" return len(string) > 5 and string[:5] == "EVAL:"
"""

View File

@@ -90,7 +90,7 @@ def message_reporter(sender, report, action):
plugin_header(reporter, "Reports") plugin_header(reporter, "Reports")
msg(reporter, message) msg(reporter, message)
else: else:
server.dispatchCommand(sender, "mail send %s %s" % (reporter.getName(), message)) server.dispatchCommand(sender, "mail send %s %s" % (reporter.getName(), colorify(message)))
def save_reports(): def save_reports():