#!/usr/bin/env python
""" generated source for module SimpleHelpMap """
from __future__ import print_function
from functools import wraps
from threading import RLock

def lock_for_object(obj, locks={}):
    return locks.setdefault(id(obj), RLock())

def synchronized(call):
    assert call.__code__.co_varnames[0] in ['self', 'cls']
    @wraps(call)
    def inner(*args, **kwds):
        with lock_for_object(args[0]):
            return call(*args, **kwds)
    return inner

# package: org.bukkit.craftbukkit.help
# 
#  * Standard implementation of {@link HelpMap} for CraftBukkit servers.
#  
class SimpleHelpMap(HelpMap):
    """ generated source for class SimpleHelpMap """
    defaultTopic = None
    helpTopics = None
    topicFactoryMap = None
    server = None
    yaml = None

    @SuppressWarnings("unchecked")
    def __init__(self, server):
        """ generated source for method __init__ """
        super(SimpleHelpMap, self).__init__()
        self.helpTopics = TreeMap(HelpTopicComparator.topicNameComparatorInstance())
        #  Using a TreeMap for its explicit sorting on key
        self.topicFactoryMap = HashMap()
        self.server = server
        self.yaml = HelpYamlReader(server)
        indexFilter = Predicates.not_(Predicates.instanceOf(CommandAliasHelpTopic.__class__))
        if not self.yaml.commandTopicsInMasterIndex():
            indexFilter = Predicates.and_(indexFilter, Predicates.not_(IsCommandTopicPredicate()))
        self.defaultTopic = IndexHelpTopic("Index", None, None, Collections2.filter(self.helpTopics.values(), indexFilter), "Use /help [n] to get page n of help.")
        registerHelpTopicFactory(MultipleCommandAlias.__class__, MultipleCommandAliasHelpTopicFactory())

    @synchronized
    def getHelpTopic(self, topicName):
        """ generated source for method getHelpTopic """
        if topicName == "":
            return self.defaultTopic
        if self.helpTopics.containsKey(topicName):
            return self.helpTopics.get(topicName)
        return None

    def getHelpTopics(self):
        """ generated source for method getHelpTopics """
        return self.helpTopics.values()

    @synchronized
    def addTopic(self, topic):
        """ generated source for method addTopic """
        #  Existing topics take priority
        if not self.helpTopics.containsKey(topic.__name__):
            self.helpTopics.put(topic.__name__, topic)

    @synchronized
    def clear(self):
        """ generated source for method clear """
        self.helpTopics.clear()

    def getIgnoredPlugins(self):
        """ generated source for method getIgnoredPlugins """
        return self.yaml.getIgnoredPlugins()

    # 
    #      * Reads the general topics from help.yml and adds them to the help index.
    #      
    @synchronized
    def initializeGeneralTopics(self):
        """ generated source for method initializeGeneralTopics """
        self.yaml = HelpYamlReader(self.server)
        #  Initialize general help topics from the help.yml file
        for topic in yaml.getGeneralTopics():
            self.addTopic(topic)
        #  Initialize index help topics from the help.yml file
        for topic in yaml.getIndexTopics():
            if topic.__name__ == "Default":
                self.defaultTopic = topic
            else:
                self.addTopic(topic)

    # 
    #      * Processes all the commands registered in the server and creates help topics for them.
    #      
    @synchronized
    def initializeCommands(self):
        """ generated source for method initializeCommands """
        #  ** Load topics from highest to lowest priority order **
        ignoredPlugins = HashSet(self.yaml.getIgnoredPlugins())
        #  Don't load any automatic help topics if All is ignored
        if ignoredPlugins.contains("All"):
            return
        #  Initialize help topics from the server's command map
        for command in server.getCommandMap().getCommands():
            if commandInIgnoredPlugin(command, ignoredPlugins):
                continue 
            #  Register a topic
            for c in topicFactoryMap.keySet():
                if c.isAssignableFrom(command.__class__):
                    t = self.topicFactoryMap.get(c).createTopic(command)
                    if t != None:
                        self.addTopic(t)
                    continue 
                if isinstance(command, (PluginCommand, )) and c.isAssignableFrom((command).getExecutor().__class__):
                    t = self.topicFactoryMap.get(c).createTopic(command)
                    if t != None:
                        self.addTopic(t)
                    continue 
            self.addTopic(GenericCommandHelpTopic(command))
        for command in server.getCommandMap().getCommands():
            if commandInIgnoredPlugin(command, ignoredPlugins):
                continue 
            for alias in command.getAliases():
                if self.server.getCommandMap().getCommand(alias) == command:
                    self.addTopic(CommandAliasHelpTopic("/" + alias, "/" + command.getLabel(), self))
        filteredTopics = Collections2.filter(self.helpTopics.values(), Predicates.instanceOf(CommandAliasHelpTopic.__class__))
        if not filteredTopics.isEmpty():
            self.addTopic(IndexHelpTopic("Aliases", "Lists command aliases", None, filteredTopics))
        pluginIndexes = HashMap()
        fillPluginIndexes(pluginIndexes, self.server.getCommandMap().getCommands())
        for entry in pluginIndexes.entrySet():
            self.addTopic(IndexHelpTopic(entry.getKey(), "All commands for " + entry.getKey(), None, entry.getValue(), "Below is a list of all " + entry.getKey() + " commands:"))
        for amendment in yaml.getTopicAmendments():
            if self.helpTopics.containsKey(amendment.getTopicName()):
                self.helpTopics.get(amendment.getTopicName()).amendTopic(amendment.getShortText(), amendment.getFullText())
                if amendment.getPermission() != None:
                    self.helpTopics.get(amendment.getTopicName()).amendCanSee(amendment.getPermission())

    def fillPluginIndexes(self, pluginIndexes, commands):
        """ generated source for method fillPluginIndexes """
        for command in commands:
            pluginName = getCommandPluginName(command)
            if pluginName != None:
                topic = self.getHelpTopic("/" + command.getLabel())
                if topic != None:
                    if not pluginIndexes.containsKey(pluginName):
                        pluginIndexes.put(pluginName, TreeSet(HelpTopicComparator.helpTopicComparatorInstance()))
                    pluginIndexes.get(pluginName).add(topic)

    def getCommandPluginName(self, command):
        """ generated source for method getCommandPluginName """
        if isinstance(command, (VanillaCommandWrapper, )):
            return "Minecraft"
        if isinstance(command, (BukkitCommand, )) or isinstance(command, (VanillaCommand, )):
            return "Bukkit"
        if isinstance(command, (PluginIdentifiableCommand, )):
            return (command).getPlugin().__name__
        return None

    def commandInIgnoredPlugin(self, command, ignoredPlugins):
        """ generated source for method commandInIgnoredPlugin """
        if (isinstance(command, (BukkitCommand, )) or isinstance(command, (VanillaCommand, ))) and ignoredPlugins.contains("Bukkit"):
            return True
        if isinstance(command, (PluginIdentifiableCommand, )) and ignoredPlugins.contains((command).getPlugin().__name__):
            return True
        return False

    def registerHelpTopicFactory(self, commandClass, factory):
        """ generated source for method registerHelpTopicFactory """
        if not Command.__class__.isAssignableFrom(commandClass) and not CommandExecutor.__class__.isAssignableFrom(commandClass):
            raise IllegalArgumentException("commandClass must implement either Command or CommandExecutor!")
        self.topicFactoryMap.put(commandClass, factory)

    class IsCommandTopicPredicate(Predicate, HelpTopic):
        """ generated source for class IsCommandTopicPredicate """
        def apply(self, topic):
            """ generated source for method apply """
            return topic.__name__.charAt(0) == '/'


ba71e0bf794ebf9fdbd2e06a84ff144b0db509a7
<mask token>


class SimpleHelpMap(HelpMap):
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>

    @SuppressWarnings('unchecked')
    def __init__(self, server):
        """ generated source for method __init__ """
        super(SimpleHelpMap, self).__init__()
        self.helpTopics = TreeMap(HelpTopicComparator.
            topicNameComparatorInstance())
        self.topicFactoryMap = HashMap()
        self.server = server
        self.yaml = HelpYamlReader(server)
        indexFilter = Predicates.not_(Predicates.instanceOf(
            CommandAliasHelpTopic.__class__))
        if not self.yaml.commandTopicsInMasterIndex():
            indexFilter = Predicates.and_(indexFilter, Predicates.not_(
                IsCommandTopicPredicate()))
        self.defaultTopic = IndexHelpTopic('Index', None, None,
            Collections2.filter(self.helpTopics.values(), indexFilter),
            'Use /help [n] to get page n of help.')
        registerHelpTopicFactory(MultipleCommandAlias.__class__,
            MultipleCommandAliasHelpTopicFactory())
    <mask token>

    def getHelpTopics(self):
        """ generated source for method getHelpTopics """
        return self.helpTopics.values()

    @synchronized
    def addTopic(self, topic):
        """ generated source for method addTopic """
        if not self.helpTopics.containsKey(topic.__name__):
            self.helpTopics.put(topic.__name__, topic)

    @synchronized
    def clear(self):
        """ generated source for method clear """
        self.helpTopics.clear()

    def getIgnoredPlugins(self):
        """ generated source for method getIgnoredPlugins """
        return self.yaml.getIgnoredPlugins()

    @synchronized
    def initializeGeneralTopics(self):
        """ generated source for method initializeGeneralTopics """
        self.yaml = HelpYamlReader(self.server)
        for topic in yaml.getGeneralTopics():
            self.addTopic(topic)
        for topic in yaml.getIndexTopics():
            if topic.__name__ == 'Default':
                self.defaultTopic = topic
            else:
                self.addTopic(topic)

    @synchronized
    def initializeCommands(self):
        """ generated source for method initializeCommands """
        ignoredPlugins = HashSet(self.yaml.getIgnoredPlugins())
        if ignoredPlugins.contains('All'):
            return
        for command in server.getCommandMap().getCommands():
            if commandInIgnoredPlugin(command, ignoredPlugins):
                continue
            for c in topicFactoryMap.keySet():
                if c.isAssignableFrom(command.__class__):
                    t = self.topicFactoryMap.get(c).createTopic(command)
                    if t != None:
                        self.addTopic(t)
                    continue
                if isinstance(command, (PluginCommand,)
                    ) and c.isAssignableFrom(command.getExecutor().__class__):
                    t = self.topicFactoryMap.get(c).createTopic(command)
                    if t != None:
                        self.addTopic(t)
                    continue
            self.addTopic(GenericCommandHelpTopic(command))
        for command in server.getCommandMap().getCommands():
            if commandInIgnoredPlugin(command, ignoredPlugins):
                continue
            for alias in command.getAliases():
                if self.server.getCommandMap().getCommand(alias) == command:
                    self.addTopic(CommandAliasHelpTopic('/' + alias, '/' +
                        command.getLabel(), self))
        filteredTopics = Collections2.filter(self.helpTopics.values(),
            Predicates.instanceOf(CommandAliasHelpTopic.__class__))
        if not filteredTopics.isEmpty():
            self.addTopic(IndexHelpTopic('Aliases', 'Lists command aliases',
                None, filteredTopics))
        pluginIndexes = HashMap()
        fillPluginIndexes(pluginIndexes, self.server.getCommandMap().
            getCommands())
        for entry in pluginIndexes.entrySet():
            self.addTopic(IndexHelpTopic(entry.getKey(), 
                'All commands for ' + entry.getKey(), None, entry.getValue(
                ), 'Below is a list of all ' + entry.getKey() + ' commands:'))
        for amendment in yaml.getTopicAmendments():
            if self.helpTopics.containsKey(amendment.getTopicName()):
                self.helpTopics.get(amendment.getTopicName()).amendTopic(
                    amendment.getShortText(), amendment.getFullText())
                if amendment.getPermission() != None:
                    self.helpTopics.get(amendment.getTopicName()).amendCanSee(
                        amendment.getPermission())

    def fillPluginIndexes(self, pluginIndexes, commands):
        """ generated source for method fillPluginIndexes """
        for command in commands:
            pluginName = getCommandPluginName(command)
            if pluginName != None:
                topic = self.getHelpTopic('/' + command.getLabel())
                if topic != None:
                    if not pluginIndexes.containsKey(pluginName):
                        pluginIndexes.put(pluginName, TreeSet(
                            HelpTopicComparator.helpTopicComparatorInstance()))
                    pluginIndexes.get(pluginName).add(topic)

    def getCommandPluginName(self, command):
        """ generated source for method getCommandPluginName """
        if isinstance(command, (VanillaCommandWrapper,)):
            return 'Minecraft'
        if isinstance(command, (BukkitCommand,)) or isinstance(command, (
            VanillaCommand,)):
            return 'Bukkit'
        if isinstance(command, (PluginIdentifiableCommand,)):
            return command.getPlugin().__name__
        return None

    def commandInIgnoredPlugin(self, command, ignoredPlugins):
        """ generated source for method commandInIgnoredPlugin """
        if (isinstance(command, (BukkitCommand,)) or isinstance(command, (
            VanillaCommand,))) and ignoredPlugins.contains('Bukkit'):
            return True
        if isinstance(command, (PluginIdentifiableCommand,)
            ) and ignoredPlugins.contains(command.getPlugin().__name__):
            return True
        return False

    def registerHelpTopicFactory(self, commandClass, factory):
        """ generated source for method registerHelpTopicFactory """
        if not Command.__class__.isAssignableFrom(commandClass
            ) and not CommandExecutor.__class__.isAssignableFrom(commandClass):
            raise IllegalArgumentException(
                'commandClass must implement either Command or CommandExecutor!'
                )
        self.topicFactoryMap.put(commandClass, factory)


    class IsCommandTopicPredicate(Predicate, HelpTopic):
        """ generated source for class IsCommandTopicPredicate """

        def apply(self, topic):
            """ generated source for method apply """
            return topic.__name__.charAt(0) == '/'

<mask token>


class SimpleHelpMap(HelpMap):
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>

    @SuppressWarnings('unchecked')
    def __init__(self, server):
        """ generated source for method __init__ """
        super(SimpleHelpMap, self).__init__()
        self.helpTopics = TreeMap(HelpTopicComparator.
            topicNameComparatorInstance())
        self.topicFactoryMap = HashMap()
        self.server = server
        self.yaml = HelpYamlReader(server)
        indexFilter = Predicates.not_(Predicates.instanceOf(
            CommandAliasHelpTopic.__class__))
        if not self.yaml.commandTopicsInMasterIndex():
            indexFilter = Predicates.and_(indexFilter, Predicates.not_(
                IsCommandTopicPredicate()))
        self.defaultTopic = IndexHelpTopic('Index', None, None,
            Collections2.filter(self.helpTopics.values(), indexFilter),
            'Use /help [n] to get page n of help.')
        registerHelpTopicFactory(MultipleCommandAlias.__class__,
            MultipleCommandAliasHelpTopicFactory())

    @synchronized
    def getHelpTopic(self, topicName):
        """ generated source for method getHelpTopic """
        if topicName == '':
            return self.defaultTopic
        if self.helpTopics.containsKey(topicName):
            return self.helpTopics.get(topicName)
        return None

    def getHelpTopics(self):
        """ generated source for method getHelpTopics """
        return self.helpTopics.values()

    @synchronized
    def addTopic(self, topic):
        """ generated source for method addTopic """
        if not self.helpTopics.containsKey(topic.__name__):
            self.helpTopics.put(topic.__name__, topic)

    @synchronized
    def clear(self):
        """ generated source for method clear """
        self.helpTopics.clear()

    def getIgnoredPlugins(self):
        """ generated source for method getIgnoredPlugins """
        return self.yaml.getIgnoredPlugins()

    @synchronized
    def initializeGeneralTopics(self):
        """ generated source for method initializeGeneralTopics """
        self.yaml = HelpYamlReader(self.server)
        for topic in yaml.getGeneralTopics():
            self.addTopic(topic)
        for topic in yaml.getIndexTopics():
            if topic.__name__ == 'Default':
                self.defaultTopic = topic
            else:
                self.addTopic(topic)

    @synchronized
    def initializeCommands(self):
        """ generated source for method initializeCommands """
        ignoredPlugins = HashSet(self.yaml.getIgnoredPlugins())
        if ignoredPlugins.contains('All'):
            return
        for command in server.getCommandMap().getCommands():
            if commandInIgnoredPlugin(command, ignoredPlugins):
                continue
            for c in topicFactoryMap.keySet():
                if c.isAssignableFrom(command.__class__):
                    t = self.topicFactoryMap.get(c).createTopic(command)
                    if t != None:
                        self.addTopic(t)
                    continue
                if isinstance(command, (PluginCommand,)
                    ) and c.isAssignableFrom(command.getExecutor().__class__):
                    t = self.topicFactoryMap.get(c).createTopic(command)
                    if t != None:
                        self.addTopic(t)
                    continue
            self.addTopic(GenericCommandHelpTopic(command))
        for command in server.getCommandMap().getCommands():
            if commandInIgnoredPlugin(command, ignoredPlugins):
                continue
            for alias in command.getAliases():
                if self.server.getCommandMap().getCommand(alias) == command:
                    self.addTopic(CommandAliasHelpTopic('/' + alias, '/' +
                        command.getLabel(), self))
        filteredTopics = Collections2.filter(self.helpTopics.values(),
            Predicates.instanceOf(CommandAliasHelpTopic.__class__))
        if not filteredTopics.isEmpty():
            self.addTopic(IndexHelpTopic('Aliases', 'Lists command aliases',
                None, filteredTopics))
        pluginIndexes = HashMap()
        fillPluginIndexes(pluginIndexes, self.server.getCommandMap().
            getCommands())
        for entry in pluginIndexes.entrySet():
            self.addTopic(IndexHelpTopic(entry.getKey(), 
                'All commands for ' + entry.getKey(), None, entry.getValue(
                ), 'Below is a list of all ' + entry.getKey() + ' commands:'))
        for amendment in yaml.getTopicAmendments():
            if self.helpTopics.containsKey(amendment.getTopicName()):
                self.helpTopics.get(amendment.getTopicName()).amendTopic(
                    amendment.getShortText(), amendment.getFullText())
                if amendment.getPermission() != None:
                    self.helpTopics.get(amendment.getTopicName()).amendCanSee(
                        amendment.getPermission())

    def fillPluginIndexes(self, pluginIndexes, commands):
        """ generated source for method fillPluginIndexes """
        for command in commands:
            pluginName = getCommandPluginName(command)
            if pluginName != None:
                topic = self.getHelpTopic('/' + command.getLabel())
                if topic != None:
                    if not pluginIndexes.containsKey(pluginName):
                        pluginIndexes.put(pluginName, TreeSet(
                            HelpTopicComparator.helpTopicComparatorInstance()))
                    pluginIndexes.get(pluginName).add(topic)

    def getCommandPluginName(self, command):
        """ generated source for method getCommandPluginName """
        if isinstance(command, (VanillaCommandWrapper,)):
            return 'Minecraft'
        if isinstance(command, (BukkitCommand,)) or isinstance(command, (
            VanillaCommand,)):
            return 'Bukkit'
        if isinstance(command, (PluginIdentifiableCommand,)):
            return command.getPlugin().__name__
        return None

    def commandInIgnoredPlugin(self, command, ignoredPlugins):
        """ generated source for method commandInIgnoredPlugin """
        if (isinstance(command, (BukkitCommand,)) or isinstance(command, (
            VanillaCommand,))) and ignoredPlugins.contains('Bukkit'):
            return True
        if isinstance(command, (PluginIdentifiableCommand,)
            ) and ignoredPlugins.contains(command.getPlugin().__name__):
            return True
        return False

    def registerHelpTopicFactory(self, commandClass, factory):
        """ generated source for method registerHelpTopicFactory """
        if not Command.__class__.isAssignableFrom(commandClass
            ) and not CommandExecutor.__class__.isAssignableFrom(commandClass):
            raise IllegalArgumentException(
                'commandClass must implement either Command or CommandExecutor!'
                )
        self.topicFactoryMap.put(commandClass, factory)


    class IsCommandTopicPredicate(Predicate, HelpTopic):
        """ generated source for class IsCommandTopicPredicate """

        def apply(self, topic):
            """ generated source for method apply """
            return topic.__name__.charAt(0) == '/'

<mask token>


class SimpleHelpMap(HelpMap):
    <mask token>
    defaultTopic = None
    helpTopics = None
    topicFactoryMap = None
    server = None
    yaml = None

    @SuppressWarnings('unchecked')
    def __init__(self, server):
        """ generated source for method __init__ """
        super(SimpleHelpMap, self).__init__()
        self.helpTopics = TreeMap(HelpTopicComparator.
            topicNameComparatorInstance())
        self.topicFactoryMap = HashMap()
        self.server = server
        self.yaml = HelpYamlReader(server)
        indexFilter = Predicates.not_(Predicates.instanceOf(
            CommandAliasHelpTopic.__class__))
        if not self.yaml.commandTopicsInMasterIndex():
            indexFilter = Predicates.and_(indexFilter, Predicates.not_(
                IsCommandTopicPredicate()))
        self.defaultTopic = IndexHelpTopic('Index', None, None,
            Collections2.filter(self.helpTopics.values(), indexFilter),
            'Use /help [n] to get page n of help.')
        registerHelpTopicFactory(MultipleCommandAlias.__class__,
            MultipleCommandAliasHelpTopicFactory())

    @synchronized
    def getHelpTopic(self, topicName):
        """ generated source for method getHelpTopic """
        if topicName == '':
            return self.defaultTopic
        if self.helpTopics.containsKey(topicName):
            return self.helpTopics.get(topicName)
        return None

    def getHelpTopics(self):
        """ generated source for method getHelpTopics """
        return self.helpTopics.values()

    @synchronized
    def addTopic(self, topic):
        """ generated source for method addTopic """
        if not self.helpTopics.containsKey(topic.__name__):
            self.helpTopics.put(topic.__name__, topic)

    @synchronized
    def clear(self):
        """ generated source for method clear """
        self.helpTopics.clear()

    def getIgnoredPlugins(self):
        """ generated source for method getIgnoredPlugins """
        return self.yaml.getIgnoredPlugins()

    @synchronized
    def initializeGeneralTopics(self):
        """ generated source for method initializeGeneralTopics """
        self.yaml = HelpYamlReader(self.server)
        for topic in yaml.getGeneralTopics():
            self.addTopic(topic)
        for topic in yaml.getIndexTopics():
            if topic.__name__ == 'Default':
                self.defaultTopic = topic
            else:
                self.addTopic(topic)

    @synchronized
    def initializeCommands(self):
        """ generated source for method initializeCommands """
        ignoredPlugins = HashSet(self.yaml.getIgnoredPlugins())
        if ignoredPlugins.contains('All'):
            return
        for command in server.getCommandMap().getCommands():
            if commandInIgnoredPlugin(command, ignoredPlugins):
                continue
            for c in topicFactoryMap.keySet():
                if c.isAssignableFrom(command.__class__):
                    t = self.topicFactoryMap.get(c).createTopic(command)
                    if t != None:
                        self.addTopic(t)
                    continue
                if isinstance(command, (PluginCommand,)
                    ) and c.isAssignableFrom(command.getExecutor().__class__):
                    t = self.topicFactoryMap.get(c).createTopic(command)
                    if t != None:
                        self.addTopic(t)
                    continue
            self.addTopic(GenericCommandHelpTopic(command))
        for command in server.getCommandMap().getCommands():
            if commandInIgnoredPlugin(command, ignoredPlugins):
                continue
            for alias in command.getAliases():
                if self.server.getCommandMap().getCommand(alias) == command:
                    self.addTopic(CommandAliasHelpTopic('/' + alias, '/' +
                        command.getLabel(), self))
        filteredTopics = Collections2.filter(self.helpTopics.values(),
            Predicates.instanceOf(CommandAliasHelpTopic.__class__))
        if not filteredTopics.isEmpty():
            self.addTopic(IndexHelpTopic('Aliases', 'Lists command aliases',
                None, filteredTopics))
        pluginIndexes = HashMap()
        fillPluginIndexes(pluginIndexes, self.server.getCommandMap().
            getCommands())
        for entry in pluginIndexes.entrySet():
            self.addTopic(IndexHelpTopic(entry.getKey(), 
                'All commands for ' + entry.getKey(), None, entry.getValue(
                ), 'Below is a list of all ' + entry.getKey() + ' commands:'))
        for amendment in yaml.getTopicAmendments():
            if self.helpTopics.containsKey(amendment.getTopicName()):
                self.helpTopics.get(amendment.getTopicName()).amendTopic(
                    amendment.getShortText(), amendment.getFullText())
                if amendment.getPermission() != None:
                    self.helpTopics.get(amendment.getTopicName()).amendCanSee(
                        amendment.getPermission())

    def fillPluginIndexes(self, pluginIndexes, commands):
        """ generated source for method fillPluginIndexes """
        for command in commands:
            pluginName = getCommandPluginName(command)
            if pluginName != None:
                topic = self.getHelpTopic('/' + command.getLabel())
                if topic != None:
                    if not pluginIndexes.containsKey(pluginName):
                        pluginIndexes.put(pluginName, TreeSet(
                            HelpTopicComparator.helpTopicComparatorInstance()))
                    pluginIndexes.get(pluginName).add(topic)

    def getCommandPluginName(self, command):
        """ generated source for method getCommandPluginName """
        if isinstance(command, (VanillaCommandWrapper,)):
            return 'Minecraft'
        if isinstance(command, (BukkitCommand,)) or isinstance(command, (
            VanillaCommand,)):
            return 'Bukkit'
        if isinstance(command, (PluginIdentifiableCommand,)):
            return command.getPlugin().__name__
        return None

    def commandInIgnoredPlugin(self, command, ignoredPlugins):
        """ generated source for method commandInIgnoredPlugin """
        if (isinstance(command, (BukkitCommand,)) or isinstance(command, (
            VanillaCommand,))) and ignoredPlugins.contains('Bukkit'):
            return True
        if isinstance(command, (PluginIdentifiableCommand,)
            ) and ignoredPlugins.contains(command.getPlugin().__name__):
            return True
        return False

    def registerHelpTopicFactory(self, commandClass, factory):
        """ generated source for method registerHelpTopicFactory """
        if not Command.__class__.isAssignableFrom(commandClass
            ) and not CommandExecutor.__class__.isAssignableFrom(commandClass):
            raise IllegalArgumentException(
                'commandClass must implement either Command or CommandExecutor!'
                )
        self.topicFactoryMap.put(commandClass, factory)


    class IsCommandTopicPredicate(Predicate, HelpTopic):
        """ generated source for class IsCommandTopicPredicate """

        def apply(self, topic):
            """ generated source for method apply """
            return topic.__name__.charAt(0) == '/'

<mask token>


def synchronized(call):
    assert call.__code__.co_varnames[0] in ['self', 'cls']

    @wraps(call)
    def inner(*args, **kwds):
        with lock_for_object(args[0]):
            return call(*args, **kwds)
    return inner


class SimpleHelpMap(HelpMap):
    """ generated source for class SimpleHelpMap """
    defaultTopic = None
    helpTopics = None
    topicFactoryMap = None
    server = None
    yaml = None

    @SuppressWarnings('unchecked')
    def __init__(self, server):
        """ generated source for method __init__ """
        super(SimpleHelpMap, self).__init__()
        self.helpTopics = TreeMap(HelpTopicComparator.
            topicNameComparatorInstance())
        self.topicFactoryMap = HashMap()
        self.server = server
        self.yaml = HelpYamlReader(server)
        indexFilter = Predicates.not_(Predicates.instanceOf(
            CommandAliasHelpTopic.__class__))
        if not self.yaml.commandTopicsInMasterIndex():
            indexFilter = Predicates.and_(indexFilter, Predicates.not_(
                IsCommandTopicPredicate()))
        self.defaultTopic = IndexHelpTopic('Index', None, None,
            Collections2.filter(self.helpTopics.values(), indexFilter),
            'Use /help [n] to get page n of help.')
        registerHelpTopicFactory(MultipleCommandAlias.__class__,
            MultipleCommandAliasHelpTopicFactory())

    @synchronized
    def getHelpTopic(self, topicName):
        """ generated source for method getHelpTopic """
        if topicName == '':
            return self.defaultTopic
        if self.helpTopics.containsKey(topicName):
            return self.helpTopics.get(topicName)
        return None

    def getHelpTopics(self):
        """ generated source for method getHelpTopics """
        return self.helpTopics.values()

    @synchronized
    def addTopic(self, topic):
        """ generated source for method addTopic """
        if not self.helpTopics.containsKey(topic.__name__):
            self.helpTopics.put(topic.__name__, topic)

    @synchronized
    def clear(self):
        """ generated source for method clear """
        self.helpTopics.clear()

    def getIgnoredPlugins(self):
        """ generated source for method getIgnoredPlugins """
        return self.yaml.getIgnoredPlugins()

    @synchronized
    def initializeGeneralTopics(self):
        """ generated source for method initializeGeneralTopics """
        self.yaml = HelpYamlReader(self.server)
        for topic in yaml.getGeneralTopics():
            self.addTopic(topic)
        for topic in yaml.getIndexTopics():
            if topic.__name__ == 'Default':
                self.defaultTopic = topic
            else:
                self.addTopic(topic)

    @synchronized
    def initializeCommands(self):
        """ generated source for method initializeCommands """
        ignoredPlugins = HashSet(self.yaml.getIgnoredPlugins())
        if ignoredPlugins.contains('All'):
            return
        for command in server.getCommandMap().getCommands():
            if commandInIgnoredPlugin(command, ignoredPlugins):
                continue
            for c in topicFactoryMap.keySet():
                if c.isAssignableFrom(command.__class__):
                    t = self.topicFactoryMap.get(c).createTopic(command)
                    if t != None:
                        self.addTopic(t)
                    continue
                if isinstance(command, (PluginCommand,)
                    ) and c.isAssignableFrom(command.getExecutor().__class__):
                    t = self.topicFactoryMap.get(c).createTopic(command)
                    if t != None:
                        self.addTopic(t)
                    continue
            self.addTopic(GenericCommandHelpTopic(command))
        for command in server.getCommandMap().getCommands():
            if commandInIgnoredPlugin(command, ignoredPlugins):
                continue
            for alias in command.getAliases():
                if self.server.getCommandMap().getCommand(alias) == command:
                    self.addTopic(CommandAliasHelpTopic('/' + alias, '/' +
                        command.getLabel(), self))
        filteredTopics = Collections2.filter(self.helpTopics.values(),
            Predicates.instanceOf(CommandAliasHelpTopic.__class__))
        if not filteredTopics.isEmpty():
            self.addTopic(IndexHelpTopic('Aliases', 'Lists command aliases',
                None, filteredTopics))
        pluginIndexes = HashMap()
        fillPluginIndexes(pluginIndexes, self.server.getCommandMap().
            getCommands())
        for entry in pluginIndexes.entrySet():
            self.addTopic(IndexHelpTopic(entry.getKey(), 
                'All commands for ' + entry.getKey(), None, entry.getValue(
                ), 'Below is a list of all ' + entry.getKey() + ' commands:'))
        for amendment in yaml.getTopicAmendments():
            if self.helpTopics.containsKey(amendment.getTopicName()):
                self.helpTopics.get(amendment.getTopicName()).amendTopic(
                    amendment.getShortText(), amendment.getFullText())
                if amendment.getPermission() != None:
                    self.helpTopics.get(amendment.getTopicName()).amendCanSee(
                        amendment.getPermission())

    def fillPluginIndexes(self, pluginIndexes, commands):
        """ generated source for method fillPluginIndexes """
        for command in commands:
            pluginName = getCommandPluginName(command)
            if pluginName != None:
                topic = self.getHelpTopic('/' + command.getLabel())
                if topic != None:
                    if not pluginIndexes.containsKey(pluginName):
                        pluginIndexes.put(pluginName, TreeSet(
                            HelpTopicComparator.helpTopicComparatorInstance()))
                    pluginIndexes.get(pluginName).add(topic)

    def getCommandPluginName(self, command):
        """ generated source for method getCommandPluginName """
        if isinstance(command, (VanillaCommandWrapper,)):
            return 'Minecraft'
        if isinstance(command, (BukkitCommand,)) or isinstance(command, (
            VanillaCommand,)):
            return 'Bukkit'
        if isinstance(command, (PluginIdentifiableCommand,)):
            return command.getPlugin().__name__
        return None

    def commandInIgnoredPlugin(self, command, ignoredPlugins):
        """ generated source for method commandInIgnoredPlugin """
        if (isinstance(command, (BukkitCommand,)) or isinstance(command, (
            VanillaCommand,))) and ignoredPlugins.contains('Bukkit'):
            return True
        if isinstance(command, (PluginIdentifiableCommand,)
            ) and ignoredPlugins.contains(command.getPlugin().__name__):
            return True
        return False

    def registerHelpTopicFactory(self, commandClass, factory):
        """ generated source for method registerHelpTopicFactory """
        if not Command.__class__.isAssignableFrom(commandClass
            ) and not CommandExecutor.__class__.isAssignableFrom(commandClass):
            raise IllegalArgumentException(
                'commandClass must implement either Command or CommandExecutor!'
                )
        self.topicFactoryMap.put(commandClass, factory)


    class IsCommandTopicPredicate(Predicate, HelpTopic):
        """ generated source for class IsCommandTopicPredicate """

        def apply(self, topic):
            """ generated source for method apply """
            return topic.__name__.charAt(0) == '/'

#!/usr/bin/env python
""" generated source for module SimpleHelpMap """
from __future__ import print_function
from functools import wraps
from threading import RLock

def lock_for_object(obj, locks={}):
    return locks.setdefault(id(obj), RLock())

def synchronized(call):
    assert call.__code__.co_varnames[0] in ['self', 'cls']
    @wraps(call)
    def inner(*args, **kwds):
        with lock_for_object(args[0]):
            return call(*args, **kwds)
    return inner

# package: org.bukkit.craftbukkit.help
# 
#  * Standard implementation of {@link HelpMap} for CraftBukkit servers.
#  
class SimpleHelpMap(HelpMap):
    """ generated source for class SimpleHelpMap """
    defaultTopic = None
    helpTopics = None
    topicFactoryMap = None
    server = None
    yaml = None

    @SuppressWarnings("unchecked")
    def __init__(self, server):
        """ generated source for method __init__ """
        super(SimpleHelpMap, self).__init__()
        self.helpTopics = TreeMap(HelpTopicComparator.topicNameComparatorInstance())
        #  Using a TreeMap for its explicit sorting on key
        self.topicFactoryMap = HashMap()
        self.server = server
        self.yaml = HelpYamlReader(server)
        indexFilter = Predicates.not_(Predicates.instanceOf(CommandAliasHelpTopic.__class__))
        if not self.yaml.commandTopicsInMasterIndex():
            indexFilter = Predicates.and_(indexFilter, Predicates.not_(IsCommandTopicPredicate()))
        self.defaultTopic = IndexHelpTopic("Index", None, None, Collections2.filter(self.helpTopics.values(), indexFilter), "Use /help [n] to get page n of help.")
        registerHelpTopicFactory(MultipleCommandAlias.__class__, MultipleCommandAliasHelpTopicFactory())

    @synchronized
    def getHelpTopic(self, topicName):
        """ generated source for method getHelpTopic """
        if topicName == "":
            return self.defaultTopic
        if self.helpTopics.containsKey(topicName):
            return self.helpTopics.get(topicName)
        return None

    def getHelpTopics(self):
        """ generated source for method getHelpTopics """
        return self.helpTopics.values()

    @synchronized
    def addTopic(self, topic):
        """ generated source for method addTopic """
        #  Existing topics take priority
        if not self.helpTopics.containsKey(topic.__name__):
            self.helpTopics.put(topic.__name__, topic)

    @synchronized
    def clear(self):
        """ generated source for method clear """
        self.helpTopics.clear()

    def getIgnoredPlugins(self):
        """ generated source for method getIgnoredPlugins """
        return self.yaml.getIgnoredPlugins()

    # 
    #      * Reads the general topics from help.yml and adds them to the help index.
    #      
    @synchronized
    def initializeGeneralTopics(self):
        """ generated source for method initializeGeneralTopics """
        self.yaml = HelpYamlReader(self.server)
        #  Initialize general help topics from the help.yml file
        for topic in yaml.getGeneralTopics():
            self.addTopic(topic)
        #  Initialize index help topics from the help.yml file
        for topic in yaml.getIndexTopics():
            if topic.__name__ == "Default":
                self.defaultTopic = topic
            else:
                self.addTopic(topic)

    # 
    #      * Processes all the commands registered in the server and creates help topics for them.
    #      
    @synchronized
    def initializeCommands(self):
        """ generated source for method initializeCommands """
        #  ** Load topics from highest to lowest priority order **
        ignoredPlugins = HashSet(self.yaml.getIgnoredPlugins())
        #  Don't load any automatic help topics if All is ignored
        if ignoredPlugins.contains("All"):
            return
        #  Initialize help topics from the server's command map
        for command in server.getCommandMap().getCommands():
            if commandInIgnoredPlugin(command, ignoredPlugins):
                continue 
            #  Register a topic
            for c in topicFactoryMap.keySet():
                if c.isAssignableFrom(command.__class__):
                    t = self.topicFactoryMap.get(c).createTopic(command)
                    if t != None:
                        self.addTopic(t)
                    continue 
                if isinstance(command, (PluginCommand, )) and c.isAssignableFrom((command).getExecutor().__class__):
                    t = self.topicFactoryMap.get(c).createTopic(command)
                    if t != None:
                        self.addTopic(t)
                    continue 
            self.addTopic(GenericCommandHelpTopic(command))
        for command in server.getCommandMap().getCommands():
            if commandInIgnoredPlugin(command, ignoredPlugins):
                continue 
            for alias in command.getAliases():
                if self.server.getCommandMap().getCommand(alias) == command:
                    self.addTopic(CommandAliasHelpTopic("/" + alias, "/" + command.getLabel(), self))
        filteredTopics = Collections2.filter(self.helpTopics.values(), Predicates.instanceOf(CommandAliasHelpTopic.__class__))
        if not filteredTopics.isEmpty():
            self.addTopic(IndexHelpTopic("Aliases", "Lists command aliases", None, filteredTopics))
        pluginIndexes = HashMap()
        fillPluginIndexes(pluginIndexes, self.server.getCommandMap().getCommands())
        for entry in pluginIndexes.entrySet():
            self.addTopic(IndexHelpTopic(entry.getKey(), "All commands for " + entry.getKey(), None, entry.getValue(), "Below is a list of all " + entry.getKey() + " commands:"))
        for amendment in yaml.getTopicAmendments():
            if self.helpTopics.containsKey(amendment.getTopicName()):
                self.helpTopics.get(amendment.getTopicName()).amendTopic(amendment.getShortText(), amendment.getFullText())
                if amendment.getPermission() != None:
                    self.helpTopics.get(amendment.getTopicName()).amendCanSee(amendment.getPermission())

    def fillPluginIndexes(self, pluginIndexes, commands):
        """ generated source for method fillPluginIndexes """
        for command in commands:
            pluginName = getCommandPluginName(command)
            if pluginName != None:
                topic = self.getHelpTopic("/" + command.getLabel())
                if topic != None:
                    if not pluginIndexes.containsKey(pluginName):
                        pluginIndexes.put(pluginName, TreeSet(HelpTopicComparator.helpTopicComparatorInstance()))
                    pluginIndexes.get(pluginName).add(topic)

    def getCommandPluginName(self, command):
        """ generated source for method getCommandPluginName """
        if isinstance(command, (VanillaCommandWrapper, )):
            return "Minecraft"
        if isinstance(command, (BukkitCommand, )) or isinstance(command, (VanillaCommand, )):
            return "Bukkit"
        if isinstance(command, (PluginIdentifiableCommand, )):
            return (command).getPlugin().__name__
        return None

    def commandInIgnoredPlugin(self, command, ignoredPlugins):
        """ generated source for method commandInIgnoredPlugin """
        if (isinstance(command, (BukkitCommand, )) or isinstance(command, (VanillaCommand, ))) and ignoredPlugins.contains("Bukkit"):
            return True
        if isinstance(command, (PluginIdentifiableCommand, )) and ignoredPlugins.contains((command).getPlugin().__name__):
            return True
        return False

    def registerHelpTopicFactory(self, commandClass, factory):
        """ generated source for method registerHelpTopicFactory """
        if not Command.__class__.isAssignableFrom(commandClass) and not CommandExecutor.__class__.isAssignableFrom(commandClass):
            raise IllegalArgumentException("commandClass must implement either Command or CommandExecutor!")
        self.topicFactoryMap.put(commandClass, factory)

    class IsCommandTopicPredicate(Predicate, HelpTopic):
        """ generated source for class IsCommandTopicPredicate """
        def apply(self, topic):
            """ generated source for method apply """
            return topic.__name__.charAt(0) == '/'

