+ virtual bool ResolveModeConflict(std::string &their_param, const std::string &our_param, Channel* channel);
+
+ /**
+ * When a MODETYPE_USER mode handler is being removed, the core will call this method for every user on the server.
+ * The usermode will be removed using the appropiate server mode using InspIRCd::SendMode().
+ * @param user The user which the server wants to remove your mode from
+ */
+ void RemoveMode(User* user);
+
+ /**
+ * When a MODETYPE_CHANNEL mode handler is being removed, the server will call this method for every channel on the server.
+ * The mode handler has to populate the given modestacker with mode changes that remove the mode from the channel.
+ * The default implementation of this method can remove all kinds of channel modes except listmodes.
+ * In the case of listmodes, the entire list of items must be added to the modestacker (which is handled by ListModeBase,
+ * so if you inherit from it or your mode can be removed by the default implementation then you do not have to implement
+ * this function).
+ * @param channel The channel which the server wants to remove your mode from
+ * @param changelist Mode change list to populate with the removal of this mode
+ */
+ virtual void RemoveMode(Channel* channel, Modes::ChangeList& changelist);
+
+ inline unsigned int GetLevelRequired() const { return levelrequired; }
+
+ friend class ModeParser;
+};
+
+/**
+ * Prefix modes are channel modes that grant a specific rank to members having prefix mode set.
+ * They require a parameter when setting and unsetting; the parameter is always a member of the channel.
+ * A prefix mode may be set on any number of members on a channel, but for a given member a given prefix
+ * mode is either set or not set, in other words members cannot have the same prefix mode set more than once.
+ *
+ * A rank of a member is defined as the rank given by the 'strongest' prefix mode that member has.
+ * Other parts of the IRCd use this rank to determine whether a channel action is allowable for a user or not.
+ * The rank of a prefix mode is constant, i.e. the same rank value is given to all users having that prefix mode set.
+ *
+ * Note that it is possible that the same action requires a different rank on a different channel;
+ * for example changing the topic on a channel having +t set requires a rank that is >= than the rank of a halfop,
+ * but there is no such restriction when +t isn't set.
+ */
+class CoreExport PrefixMode : public ModeHandler
+{
+ protected:
+ /** The prefix character granted by this mode. '@' for op, '+' for voice, etc.
+ * If 0, this mode does not have a visible prefix character.
+ */
+ char prefix;
+
+ /** The prefix rank of this mode, used to compare prefix
+ * modes
+ */
+ unsigned int prefixrank;
+
+ public:
+ /**
+ * Constructor
+ * @param Creator The module creating this mode
+ * @param Name The user-friendly one word name of the prefix mode, e.g.: "op", "voice"
+ * @param ModeLetter The mode letter of this mode
+ * @param Rank Rank given by this prefix mode, see explanation above
+ * @param PrefixChar Prefix character, or 0 if the mode has no prefix character
+ */
+ PrefixMode(Module* Creator, const std::string& Name, char ModeLetter, unsigned int Rank = 0, char PrefixChar = 0);
+
+ /**
+ * Handles setting and unsetting the prefix mode.
+ * Finds the given member of the given channel, if it's not found an error message is sent to 'source'
+ * and MODEACTION_DENY is returned. Otherwise the mode change is attempted.
+ * @param source Source of the mode change, an error message is sent to this user if the target is not found
+ * @param dest Unused
+ * @param channel The channel the mode change is happening on
+ * @param param The nickname or uuid of the target user
+ * @param adding True when the mode is being set, false when it is being unset
+ * @return MODEACTION_ALLOW if the change happened, MODEACTION_DENY if no change happened
+ * The latter occurs either when the member cannot be found or when the member already has this prefix set
+ * (when setting) or doesn't have this prefix set (when unsetting).
+ */
+ ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string& param, bool adding);
+
+ /**
+ * Removes this prefix mode from all users on the given channel
+ * @param channel The channel which the server wants to remove your mode from
+ * @param changelist Mode change list to populate with the removal of this mode
+ */
+ void RemoveMode(Channel* channel, Modes::ChangeList& changelist);
+
+ /**
+ * Mode prefix or 0. If this is defined, you should
+ * also implement GetPrefixRank() to return an integer
+ * value for this mode prefix.
+ */
+ char GetPrefix() const { return prefix; }
+
+ /**
+ * Get the 'value' of this modes prefix.
+ * determines which to display when there are multiple.
+ * The mode with the highest value is ranked first. See the
+ * PrefixModeValue enum and Channel::GetPrefixValue() for
+ * more information.
+ */
+ unsigned int GetPrefixRank() const { return prefixrank; }
+};
+
+/** A prebuilt mode handler which handles a simple user mode, e.g. no parameters, usable by any user, with no extra
+ * behaviour to the mode beyond the basic setting and unsetting of the mode, not allowing the mode to be set if it
+ * is already set and not allowing it to be unset if it is already unset.
+ * An example of a simple user mode is user mode +w.
+ */
+class CoreExport SimpleUserModeHandler : public ModeHandler
+{
+ public:
+ SimpleUserModeHandler(Module* Creator, const std::string& Name, char modeletter)
+ : ModeHandler(Creator, Name, modeletter, PARAM_NONE, MODETYPE_USER) {}
+ virtual ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding);
+};
+
+/** A prebuilt mode handler which handles a simple channel mode, e.g. no parameters, usable by any user, with no extra
+ * behaviour to the mode beyond the basic setting and unsetting of the mode, not allowing the mode to be set if it
+ * is already set and not allowing it to be unset if it is already unset.
+ * An example of a simple channel mode is channel mode +s.
+ */
+class CoreExport SimpleChannelModeHandler : public ModeHandler
+{
+ public:
+ SimpleChannelModeHandler(Module* Creator, const std::string& Name, char modeletter)
+ : ModeHandler(Creator, Name, modeletter, PARAM_NONE, MODETYPE_CHANNEL) {}
+ virtual ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding);