Пример #1
0
 public ProgressBlock(BasePlugin.Plugin plugin, string actionTitle, string actionText, int max, int position, bool canCancel)
 {
     _plugin = plugin;
     plugin.OnStartProgress(actionTitle, actionText, max, position, canCancel);
     _inProgress = true;
 }
 public static void Register(BasePlugin plugin)
 {
     Register(Assembly.GetCallingAssembly(), plugin);
 }
Пример #3
0
        public static void PluginCommand(ISender sender, ArgumentList args)
        {
            /*
             * Commands:
             *      list    - shows all plugins
             *      info    - shows a plugin's author & description etc
             *      disable - disables a plugin
             *      enable  - enables a plugin
             *      reload
             *      unload
             *      status
             *      load
             */

            if (args.Count == 0)
            {
                throw new CommandError("Subcommand expected.");
            }

            string command = args[0];

            args.RemoveAt(0); //Allow the commands to use any additional arguments without also getting the command

            lock (_plugins)
                switch (command)
                {
                case "-l":
                case "ls":
                case "list":
                {
                    if (PluginCount == 0)
                    {
                        sender.Message(255, "No plugins loaded.");
                        return;
                    }

                    var msg = new StringBuilder();
                    msg.Append("Plugins: ");

                    int i = 0;
                    foreach (var plugin in EnumeratePlugins)
                    {
                        if (i > 0)
                        {
                            msg.Append(", ");
                        }
                        msg.Append(plugin.Name);

                        if (!String.IsNullOrEmpty(plugin.Version))
                        {
                            msg.Append(" (");
                            msg.Append(plugin.Version);
                            msg.Append(")");
                        }

                        if (!plugin.IsEnabled)
                        {
                            msg.Append("[OFF]");
                        }
                        i++;
                    }
                    msg.Append(".");

                    sender.Message(255, Color.DodgerBlue, msg.ToString());

                    break;
                }

                case "-s":
                case "stat":
                case "status":
                {
                    if (PluginCount == 0)
                    {
                        sender.Message(255, "No plugins loaded.");
                        return;
                    }

                    var msg = new StringBuilder();

                    foreach (var plugin in EnumeratePlugins)
                    {
                        msg.Clear();
                        msg.Append(plugin.IsDisposed ? "[DISPOSED] " : (plugin.IsEnabled ? "[ON]  " : "[OFF] "));
                        msg.Append(plugin.Name);
                        msg.Append(" ");
                        msg.Append(plugin.Version);
                        if (plugin.Status != null && plugin.Status.Length > 0)
                        {
                            msg.Append(" : ");
                            msg.Append(plugin.Status);
                        }
                        sender.Message(255, Color.DodgerBlue, msg.ToString());
                    }

                    break;
                }

                case "-i":
                case "info":
                {
                    string name;
                    args.ParseOne(out name);

                    var fplugin = GetPlugin(name);
                    if (fplugin != null)
                    {
                        var path = Path.GetFileName(fplugin.Path);
                        sender.Message(255, Color.DodgerBlue, fplugin.Name);
                        sender.Message(255, Color.DodgerBlue, "Filename: " + path);
                        sender.Message(255, Color.DodgerBlue, "Version:  " + fplugin.Version);
                        sender.Message(255, Color.DodgerBlue, "Author:   " + fplugin.Author);
                        if (fplugin.Description != null && fplugin.Description.Length > 0)
                        {
                            sender.Message(255, Color.DodgerBlue, fplugin.Description);
                        }
                        sender.Message(255, Color.DodgerBlue, "Status:   " + (fplugin.IsEnabled ? "[ON] " : "[OFF] ") + fplugin.Status);
                    }
                    else
                    {
                        sender.SendMessage("The plugin \"" + args[1] + "\" was not found.");
                    }

                    break;
                }

                case "-d":
                case "disable":
                {
                    string name;
                    args.ParseOne(out name);

                    var fplugin = GetPlugin(name);
                    if (fplugin != null)
                    {
                        if (fplugin.Disable())
                        {
                            sender.Message(255, Color.DodgerBlue, fplugin.Name + " was disabled.");
                        }
                        else
                        {
                            sender.Message(255, Color.DodgerBlue, fplugin.Name + " was disabled, errors occured during the process.");
                        }
                    }
                    else
                    {
                        sender.Message(255, "The plugin \"" + name + "\" could not be found.");
                    }

                    break;
                }

                case "-e":
                case "enable":
                {
                    string name;
                    args.ParseOne(out name);

                    var fplugin = GetPlugin(name);
                    if (fplugin != null)
                    {
                        if (fplugin.Enable())
                        {
                            sender.Message(255, Color.DodgerBlue, fplugin.Name + " was enabled.");
                        }
                        else
                        {
                            sender.Message(255, Color.DodgerBlue, fplugin.Name + " was enabled, errors occured during the process.");
                        }
                    }
                    else
                    {
                        sender.Message(255, "The plugin \"" + name + "\" could not be found.");
                    }

                    break;
                }

                case "-u":
                case "-ua":
                case "unload":
                {
                    string name;

                    if (command == "-ua" || command == "-uca")
                    {
                        name = "all";
                    }
                    else
                    {
                        args.ParseOne(out name);
                    }

                    BasePlugin[] plugs;
                    if (name == "all" || name == "-a")
                    {
                        plugs = _plugins.Values.ToArray();
                    }
                    else
                    {
                        var splugin = PluginManager.GetPlugin(name);

                        if (splugin == null)
                        {
                            sender.Message(255, "The plugin \"" + name + "\" could not be found.");
                            return;
                        }

                        plugs = new BasePlugin[] { splugin };
                    }

                    foreach (var fplugin in plugs)
                    {
                        if (UnloadPlugin(fplugin))
                        {
                            sender.Message(255, Color.DodgerBlue, fplugin.Name + " was unloaded.");
                        }
                        else
                        {
                            sender.Message(255, Color.DodgerBlue, fplugin.Name + " was unloaded, errors occured during the process.");
                        }
                    }

                    break;
                }

                case "-r":
                case "-rc":
                case "-ra":
                case "-rca":
                case "reload":
                {
                    bool save = true;
                    if (command == "-rc" || command == "-rca" || args.TryPop("-c") || args.TryPop("-clean"))
                    {
                        save = false;
                    }

                    string name;

                    if (command == "-ra" || command == "-rca")
                    {
                        name = "all";
                    }
                    else
                    {
                        args.ParseOne(out name);
                    }

                    BasePlugin[] plugs;
                    if (name == "all" || name == "-a")
                    {
                        plugs = _plugins.Values.ToArray();
                    }
                    else
                    {
                        var splugin = PluginManager.GetPlugin(name);

                        if (splugin == null)
                        {
                            sender.Message(255, "The plugin \"" + name + "\" could not be found.");
                            return;
                        }

                        plugs = new BasePlugin[] { splugin };
                    }

                    foreach (var fplugin in plugs)
                    {
                        var nplugin = PluginManager.ReloadPlugin(fplugin, save);
                        if (nplugin == fplugin)
                        {
                            sender.Message(255, Color.DodgerBlue, "Errors occured while reloading plugin " + fplugin.Name + ", old instance kept.");
                        }
                        else if (nplugin == null)
                        {
                            sender.Message(255, Color.DodgerBlue, "Errors occured while reloading plugin " + fplugin.Name + ", it has been unloaded.");
                        }
                    }

                    break;
                }

                case "-L":
                case "-LR":
                case "load":
                {
                    bool replace = command == "-LR" || args.TryPop("-R") || args.TryPop("-replace");
                    bool save    = command != "-LRc" && !args.TryPop("-c") && !args.TryPop("-clean");

                    var    fname = string.Join(" ", args);
                    string path;

                    if (fname == "")
                    {
                        throw new CommandError("File name expected");
                    }

                    if (Path.IsPathRooted(fname))
                    {
                        path = Path.GetFullPath(fname);
                    }
                    else
                    {
                        path = Path.Combine(_pluginPath, fname);
                    }

                    var fi = new FileInfo(path);

                    if (!fi.Exists)
                    {
                        sender.Message(255, "Specified file doesn't exist.");
                        return;
                    }

                    var newPlugin = LoadPluginFromPath(path);

                    if (newPlugin == null)
                    {
                        sender.Message(255, "Unable to load plugin.");
                        return;
                    }

                    var oldPlugin = GetPlugin(newPlugin.Name);
                    if (oldPlugin != null)
                    {
                        if (!replace)
                        {
                            sender.Message(255, "A plugin named {0} is already loaded, use -replace to replace it.", oldPlugin.Name);
                            return;
                        }

                        if (ReplacePlugin(oldPlugin, newPlugin, save))
                        {
                            sender.Message(255, Color.DodgerBlue, "Plugin {0} has been replaced.", oldPlugin.Name);
                        }
                        else if (oldPlugin.IsDisposed)
                        {
                            sender.Message(255, Color.DodgerBlue, "Replacement of plugin {0} failed, it has been unloaded.", oldPlugin.Name);
                        }
                        else
                        {
                            sender.Message(255, Color.DodgerBlue, "Replacement of plugin {0} failed, old instance kept.", oldPlugin.Name);
                        }

                        return;
                    }

                    if (!newPlugin.InitializeAndHookUp())
                    {
                        sender.Message(255, Color.DodgerBlue, "Failed to initialize new plugin instance.");
                    }

                    _plugins.Add(newPlugin.Name.ToLower().Trim(), newPlugin);

                    if (!newPlugin.Enable())
                    {
                        sender.Message(255, Color.DodgerBlue, "Failed to enable new plugin instance.");
                    }

                    break;
                }

                default:
                {
                    throw new CommandError("Subcommand not recognized.");
                }
                }
        }
        private static bool ProcessCommand(BaseFilter newFilter, string command)
        {
            TrimName(ref command);

            if (command.Contains(PARAMETER_IDENTIFIED))
            {
                var identCommand = new IdentifiedItemFilter {
                    BIdentified = command[0] != SYMBOL_NOT
                };
                newFilter.Filters.Add(identCommand);
                return(true);
            }

            if (command.Contains(PARAMETER_ISCORRUPTED))
            {
                var corruptedCommand = new CorruptedItemFilter {
                    BCorrupted = command[0] != SYMBOL_NOT
                };
                newFilter.Filters.Add(corruptedCommand);
                return(true);
            }

            if (command.Contains(PARAMETER_ISELDER))
            {
                var elderCommand = new ElderItemFiler {
                    IsElder = command[0] != SYMBOL_NOT
                };
                newFilter.Filters.Add(elderCommand);
                return(true);
            }

            if (command.Contains(PARAMETER_ISSHAPER))
            {
                var shaperCommand = new ShaperItemFiler {
                    IsShaper = command[0] != SYMBOL_NOT
                };
                newFilter.Filters.Add(shaperCommand);
                return(true);
            }

            if (command.Contains(PARAMETER_ISVEILED))
            {
                var veiledCommand = new VeiledItemFilter {
                    IsVeiled = command[0] != SYMBOL_NOT
                };
                newFilter.Filters.Add(veiledCommand);
                return(true);
            }

            if (command.Contains(PARAMETER_ISINCUBATOR))
            {
                var incubatorCommand = new IncubatorItemFilter {
                    IsIncubator = command[0] != SYMBOL_NOT
                };
                newFilter.Filters.Add(incubatorCommand);
                return(true);
            }

            if (!ParseCommand(command, out var parameter, out var operation, out var value))
            {
                BasePlugin.LogMessage("Filter parser: Can't parse filter part: " + command, 5);
                return(false);
            }

            var stringComp = new FilterParameterCompare {
                CompareString = value
            };
            var isNumeric = int.TryParse(value, out var n);

            if (isNumeric)
            {
                stringComp.CompareInt = n;
            }

            switch (parameter.ToLower())
            {
            case PARAMETER_CLASSNAME:
                stringComp.StringParameter = data => data.ClassName;
                break;

            case PARAMETER_NAME:
                stringComp.StringParameter = data => data.Name;
                break;

            case PARAMETER_BASENAME:
                stringComp.StringParameter = data => data.BaseName;
                break;

            case PARAMETER_PATH:
                stringComp.StringParameter = data => data.Path;
                break;

            case PARAMETER_RARITY:
                stringComp.StringParameter = data => data.Rarity.ToString();
                break;

            case PARAMETER_QUALITY:
                stringComp.IntParameter    = data => data.ItemQuality;
                stringComp.StringParameter = data => data.ItemQuality.ToString();
                break;

            case PARAMETER_MAP_TIER:
                stringComp.IntParameter    = data => data.MapTier;
                stringComp.StringParameter = data => data.MapTier.ToString();
                break;

            case PARAMETER_ILVL:
                stringComp.IntParameter    = data => data.ItemLevel;
                stringComp.StringParameter = data => data.ItemLevel.ToString();
                break;

            case PARAMETER_NUMBER_OF_SOCKETS:
                stringComp.IntParameter    = data => data.NumberOfSockets;
                stringComp.StringParameter = data => data.NumberOfSockets.ToString();
                break;

            case PARAMETER_LARGEST_LINK_SIZE:
                stringComp.IntParameter    = data => data.LargestLinkSize;
                stringComp.StringParameter = data => data.LargestLinkSize.ToString();
                break;

            default:
                BasePlugin.LogMessage(
                    $"Filter parser: Parameter is not defined in code: {parameter}", 10);
                return(false);
            }

            switch (operation.ToLower())
            {
            case OPERATION_EQUALITY:
                stringComp.CompDeleg = data => stringComp.StringParameter(data).Equals(stringComp.CompareString);
                break;

            case OPERATION_NONEQUALITY:
                stringComp.CompDeleg = data => !stringComp.StringParameter(data).Equals(stringComp.CompareString);
                break;

            case OPERATION_CONTAINS:
                stringComp.CompDeleg = data => stringComp.StringParameter(data).Contains(stringComp.CompareString);
                break;

            case OPERATION_NOTCONTAINS:
                stringComp.CompDeleg = data => !stringComp.StringParameter(data).Contains(stringComp.CompareString);
                break;

            case OPERATION_BIGGER:
                if (stringComp.IntParameter == null)
                {
                    BasePlugin.LogMessage(
                        $"Filter parser error: Can't compare string parameter with {OPERATION_BIGGER} (numerical) operation. Statement: {command}",
                        10);
                    return(false);
                }

                stringComp.CompDeleg = data => stringComp.IntParameter(data) > stringComp.CompareInt;
                break;

            case OPERATION_LESS:
                if (stringComp.IntParameter == null)
                {
                    BasePlugin.LogMessage(
                        $"Filter parser error: Can't compare string parameter with {OPERATION_LESS} (numerical) operation. Statement: {command}",
                        10);
                    return(false);
                }

                stringComp.CompDeleg = data => stringComp.IntParameter(data) < stringComp.CompareInt;
                break;

            case OPERATION_LESSEQUAL:
                if (stringComp.IntParameter == null)
                {
                    BasePlugin.LogMessage(
                        $"Filter parser error: Can't compare string parameter with {OPERATION_LESSEQUAL} (numerical) operation. Statement: {command}",
                        10);
                    return(false);
                }

                stringComp.CompDeleg = data => stringComp.IntParameter(data) <= stringComp.CompareInt;
                break;

            case OPERATION_BIGGERQUAL:
                if (stringComp.IntParameter == null)
                {
                    BasePlugin.LogMessage(
                        $"Filter parser error: Can't compare string parameter with {OPERATION_BIGGERQUAL} (numerical) operation. Statement: {command}",
                        10);
                    return(false);
                }

                stringComp.CompDeleg = data => stringComp.IntParameter(data) >= stringComp.CompareInt;
                break;

            default:
                BasePlugin.LogMessage(
                    $"Filter parser: Operation is not defined in code: {operation}", 10);
                return(false);
            }

            newFilter.Filters.Add(stringComp);
            return(true);
        }
        /// <summary>
        /// Adds a new command to the server's command list
        /// </summary>
        /// <param name="prefix">Command text</param>
        /// <returns>New Command</returns>
        public static CommandInfo AddPluginCommand(BasePlugin plugin, string prefix)
        {
            var def = CommandManager.GetOrCreatePluginCommandDefinitions(plugin);

            if (def.commands.ContainsKey(prefix))
                throw new ApplicationException("AddCommand: duplicate command: " + prefix);

            var cmd = new CommandInfo(prefix);
            cmd.BeforeEvent += def.NotifyBeforeCommand;
            cmd.AfterEvent += def.NotifyAfterCommand;

            lock (def.commands)
            {
                def.commands[prefix] = cmd;
                def.commands[string.Concat(plugin.Name.ToLower(), ".", prefix)] = cmd;
            }

            return cmd;
        }
Пример #6
0
 /// <summary>
 /// Enables a plugin.
 /// </summary>
 /// <param name="name">Plugin name</param>
 /// <returns>Returns true on plugin successfully Enabling</returns>
 public static bool EnablePlugin(BasePlugin plugin)
 {
     return(plugin.Enable());
 }
Пример #7
0
        public static bool IsRestrictRunning()
        {
            BasePlugin plg = PluginManager.GetPlugin("Restrict");

            return(plg != null && plg.Author == "UndeadMiner");
        }
 internal abstract void Replace(BasePlugin oldPlugin, BasePlugin newPlugin, Delegate callback, HookOrder order);
Пример #9
0
        private static bool MoveDirectoryFiles(string origDirectory, string sourceDirectory, string targetDirectory)
        {
            bool noErrors            = true;
            var  sourceDirectoryInfo = new DirectoryInfo(sourceDirectory);

            foreach (var file in sourceDirectoryInfo.GetFiles())
            {
                var  destFile  = Path.Combine(targetDirectory, file.Name);
                bool fileExist = File.Exists(destFile);

                try
                {
                    var fileLocalPath = destFile.Replace(origDirectory, "");

                    if (fileExist)
                    {
                        var backupPath    = origDirectory + @"\" + UpdateBackupDir + fileLocalPath;//Do not use Path.Combine due to Path.IsPathRooted checks
                        var backupDirPath = Path.GetDirectoryName(backupPath);

                        if (!Directory.Exists(backupDirPath))
                        {
                            Directory.CreateDirectory(backupDirPath);
                        }

                        File.Copy(destFile, backupPath, true);
                    }

                    File.Copy(file.FullName, destFile, true);
                    File.Delete(file.FullName);//Delete from temp update dir

                    if (fileExist)
                    {
                        PluginUpdateLog.Add("File Replaced:\t\t" + destFile + " vs " + file.FullName);
                    }
                    else
                    {
                        PluginUpdateLog.Add("File Added:\t\t\t" + destFile);
                    }
                }
                catch (Exception ex)
                {
                    noErrors = false;
                    if (fileExist)
                    {
                        BasePlugin.LogError("PoeHUD PluginUpdater: can't replace file: " + destFile + ", Error: " + ex.Message, 10);
                        PluginUpdateLog.Add("Error replacing file: \t" + destFile);
                    }
                    else
                    {
                        BasePlugin.LogError("PoeHUD PluginUpdater: can't move file: " + destFile + ", Error: " + ex.Message, 10);
                        PluginUpdateLog.Add("Error moving file: \t" + destFile);
                    }
                }
            }

            foreach (var directory in sourceDirectoryInfo.GetDirectories())
            {
                var destDir = Path.Combine(targetDirectory, directory.Name);

                if (Directory.Exists(destDir))
                {
                    PluginUpdateLog.Add("Merging directory: \t" + destDir);
                    var curDirProcessNoErrors = MoveDirectoryFiles(origDirectory, directory.FullName, destDir);

                    if (curDirProcessNoErrors)
                    {
                        Directory.Delete(directory.FullName, true);
                    }

                    noErrors = curDirProcessNoErrors || noErrors;
                }
                else
                {
                    Directory.Move(directory.FullName, destDir);
                    PluginUpdateLog.Add("Moving directory: \t" + destDir);
                }
            }
            return(noErrors);
        }
Пример #10
0
 public static Hook Subscribe(string hookname, BasePlugin plugin)
 {
     return new Hook(hookname, args => plugin.Invoke(hookname, args));
 }
 public LeaveChannelPage(BasePlugin program)
     : base("Leave a channel", program)
 {
 }
Пример #12
0
 public CmdSetCurrentLayer(IAppContext context, BasePlugin plugin)
 {
     OnCreate(context);
     _plugin = plugin as IdentifierPlugin;
 }
Пример #13
0
 public ChatCommands(BasePlugin pl)
 {
     plugin = pl;
 }
Пример #14
0
 protected UnsafeCustomRpc(BasePlugin plugin)
 {
     UnsafePlugin = plugin;
     PluginId     = MetadataHelper.GetMetadata(plugin).GUID;
 }
Пример #15
0
 public CmdSetSelectRelation(IAppContext context, BasePlugin plugin)
 {
     OnCreate(context);
     _plugin = plugin as IdentifierPlugin;
 }
 public static void Main(string[] args)
 {
     Plugin = new ExamplePlugin("ADH-aede471e10a05cf1d1ae");
 }
Пример #17
0
 public void LogError(object message, float displayTime)
 {
     BasePlugin.LogError(message, displayTime);
 }
Пример #18
0
        public bool NewEntry()
        {
            try
            {
                var entry = new Entry
                {
                    Id   = DataToString(true),
                    Info = new Info
                    {
                        Date  = DateTime.Now,
                        Level = new Level
                        {
                            CurrentLevel            = LocalPlayer.Level,
                            CurrentLevelPercent     = Main.Instance.Progress(),
                            ExperiencedGained       = Main.Instance.ExperienceGained(),
                            ExperienceGainedPercent = Main.Instance.LevelPercentGained(),
                            LevelUps = (int)(LocalPlayer.Level - Main.Instance.JoinLevel)
                        },
                        Area = new Area
                        {
                            Name            = Main.Instance.JoinArea.DisplayName,
                            LevelDifference = LocalPlayer.Level - Main.Instance.JoinArea.Area.MonsterLevel > 0
                                ? string.Format("+{0}", LocalPlayer.Level - Main.Instance.JoinArea.Area.MonsterLevel)
                                : (LocalPlayer.Level - Main.Instance.JoinArea.Area.MonsterLevel).ToString(),
                            TimeSpent   = Main.Instance.RunTime(),
                            SameAreaEta = new SameAreaEta
                            {
                                Left          = Main.Instance.RunsToNextLevel(),
                                TotalForLevel = Main.Instance.TotalRunsToNextLevel()
                            }
                        }
                    }
                };

                var playerName = LocalPlayer.Name;

                // shit fix for null player name
                if (string.IsNullOrEmpty(playerName))
                {
                    while (string.IsNullOrEmpty(GameController.Instance.Game.IngameState.Data.LocalPlayer.GetComponent <Player>().PlayerName))
                    {
                        Thread.Sleep(5);
                        BasePlugin.LogError("CharacterData: Null or Empty Name", 10);
                    }
                    playerName = GameController.Instance.Game.IngameState.Data.LocalPlayer.GetComponent <Player>().PlayerName;
                }

                var path1 = string.Format("{0}\\Level Entry\\{1}\\", PluginDirectory, playerName);

                var path2         = string.Format("{0}JsonLog.json", path1);
                var directoryName = Path.GetDirectoryName(path1);
                var levelLogs     = new LevelLogs
                {
                    Entries = new List <Entry>()
                };
                if (!Directory.Exists(directoryName) && directoryName != null)
                {
                    Directory.CreateDirectory(directoryName);
                }
                try
                {
                    var str = File.ReadAllText(path2);
                    if (string.IsNullOrEmpty(str.Trim()))
                    {
                        throw new Exception();
                    }
                    if (str == "null")
                    {
                        throw new Exception();
                    }
                    levelLogs = JsonConvert.DeserializeObject <LevelLogs>(str);
                }
                catch
                {
                }

                levelLogs.Entries.Add(entry);
                var str1 = JsonConvert.SerializeObject(levelLogs, (Formatting)1);
                using (var streamWriter = new StreamWriter(File.Create(path2)))
                {
                    streamWriter.Write(str1);
                }
            }
            catch (Exception ex)
            {
                //BasePlugin.LogError("Plugin error save json!\n" + ex, 3f);
            }

            return(true);
        }
Пример #19
0
        public override void Load(IController hud)
        {
            base.Load(hud);

            var expandedHintFont            = Hud.Render.CreateFont("tahoma", 7, 255, 200, 200, 200, true, false, true);
            var expandedHintWidthMultiplier = 3;

            LabelList = new HorizontalTopLabelList(hud);

            LabelList.LeftFunc = () =>
            {
                var ui = Hud.Render.GetUiElement("Root.NormalLayer.game_dialog_backgroundScreenPC.game_window_hud_overlay");
                return(ui.Rectangle.Left + ui.Rectangle.Width * 0.267f);
            };
            LabelList.TopFunc = () =>
            {
                var ui = Hud.Render.GetUiElement("Root.NormalLayer.game_dialog_backgroundScreenPC.game_window_hud_overlay");
                return(ui.Rectangle.Top + ui.Rectangle.Height * 0.318f);
            };
            LabelList.WidthFunc = () =>
            {
                var ui = Hud.Render.GetUiElement("Root.NormalLayer.game_dialog_backgroundScreenPC.game_window_hud_overlay");
                return(Hud.Window.Size.Height * 0.0621f);
            };
            LabelList.HeightFunc = () =>
            {
                var ui = Hud.Render.GetUiElement("Root.NormalLayer.game_dialog_backgroundScreenPC.game_window_hud_overlay");
                return(Hud.Window.Size.Height * 0.025f);
            };

            /// added  // value_format can be 'dyn', 'F0', 'F1'


            /* add Flying Dragon buff in exp bar
             *
             * Hud.RunOnPlugin<AttributeLabelListPlugin>(plugin =>
             * {
             *      var dpsDecorator = plugin.LabelList.LabelDecorators[2];
             *      dpsDecorator.TextFunc = () =>
             *      {
             * var dps = Hud.Game.Me.Offense.SheetDps * (Hud.Game.Me.Powers.BuffIsActive(246562, 1) ? 2 : 1);
             * return ValueToString(dps, ValueFormat.ShortNumber);
             * };
             * var apsDecorator = plugin.LabelList.LabelDecorators[3];
             * apsDecorator.TextFunc = () =>
             * {
             * var aps = Hud.Game.Me.Offense.AttackSpeed * (Hud.Game.Me.Powers.BuffIsActive(246562, 1) ? 2 : 1);
             * return aps.ToString("F2", System.Globalization.CultureInfo.InvariantCulture) + "/s";
             * };
             * });
             */

            // movement 1
            LabelList.LabelDecorators.Add(new TopLabelDecorator(Hud)
            {
                TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 255, 255, 255, true, false, true),
                ExpandedHintFont            = expandedHintFont,
                ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                BackgroundTexture1          = Hud.Texture.ButtonTextureGray,
                BackgroundTexture2          = Hud.Texture.BackgroundTextureBlue,
                BackgroundTextureOpacity2   = 0.70f,
                TextFunc                    = () => (Hud.Game.Me.Stats.MoveSpeed).ToString("F1", CultureInfo.InvariantCulture) + "%",
                HintFunc                    = () => "Move Speed Total",
                ExpandUpLabels              = new List <TopLabelDecorator>()
                {
                    /* new TopLabelDecorator(Hud)
                     * {
                     *  TextFont = Hud.Render.CreateFont("tahoma", 7, 230, 255, 255, 255, true, false, true),
                     *  ExpandedHintFont = expandedHintFont,
                     *  ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                     *                          BackgroundTexture1 = Hud.Texture.ButtonTextureGray,
                     *                          BackgroundTexture2 = Hud.Texture.BackgroundTextureBlue,
                     *  BackgroundTextureOpacity2 = 1.0f,
                     *                          TextFunc = () => (Hud.Game.Me.Stats.MoveSpeed - Hud.Game.Me.Stats.MoveSpeedBonus - 100).ToString("F1", CultureInfo.InvariantCulture) + "%",
                     *                          HintFunc = () => "Move Speed Base",
                     * }, */
                    /* new TopLabelDecorator(Hud)
                     * {
                     *  TextFont = Hud.Render.CreateFont("tahoma", 7, 230, 255, 255, 255, true, false, true),
                     *  ExpandedHintFont = expandedHintFont,
                     *  ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                     *                          BackgroundTexture1 = Hud.Texture.ButtonTextureGray,
                     *                          BackgroundTexture2 = Hud.Texture.BackgroundTextureBlue,
                     *  BackgroundTextureOpacity2 = 1.0f,
                     *                          TextFunc = () => (Hud.Game.Me.Stats.MoveSpeedBonus + 100).ToString("F1", CultureInfo.InvariantCulture) + "%",
                     *                          HintFunc = () => "Move Speed Bonus",
                     * }, */
                }
            });

            // defense 2
            LabelList.LabelDecorators.Add(new TopLabelDecorator(Hud)
            {
                TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 255, 255, 255, true, false, true),
                ExpandedHintFont            = expandedHintFont,
                ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                BackgroundTexture1          = Hud.Texture.ButtonTextureGray,
                BackgroundTexture2          = Hud.Texture.BackgroundTextureGreen,
                BackgroundTextureOpacity2   = 0.70f,
                TextFunc                    = () => ValueToString(Hud.Game.Me.Defense.EhpCur, ValueFormat.ShortNumber),
                HintFunc                    = () => "EHP Current",
                ExpandUpLabels              = new List <TopLabelDecorator>()
                {
                    new TopLabelDecorator(Hud)
                    {
                        TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 255, 255, 255, true, false, true),
                        ExpandedHintFont            = expandedHintFont,
                        ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                        BackgroundTexture1          = Hud.Texture.ButtonTextureGray,
                        BackgroundTexture2          = Hud.Texture.BackgroundTextureGreen,
                        BackgroundTextureOpacity2   = 1.0f,
                        TextFunc                    = () => ValueToString(Hud.Game.Me.Defense.EhpMax, ValueFormat.ShortNumber),
                        HintFunc                    = () => "EHP Max",
                    },
                    new TopLabelDecorator(Hud)
                    {
                        TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 255, 255, 255, true, false, true),
                        ExpandedHintFont            = expandedHintFont,
                        ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                        BackgroundTexture1          = Hud.Texture.ButtonTextureGray,
                        BackgroundTexture2          = Hud.Texture.BackgroundTextureGreen,
                        BackgroundTextureOpacity2   = 1.0f,
                        TextFunc                    = () => Hud.Game.Me.Defense.ResAverage.ToString("#,0", CultureInfo.InvariantCulture),
                        HintFunc                    = () => "Average Resist",
                    },
                    new TopLabelDecorator(Hud)
                    {
                        TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 255, 255, 255, true, false, true),
                        ExpandedHintFont            = expandedHintFont,
                        ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                        BackgroundTexture1          = Hud.Texture.ButtonTextureGray,
                        BackgroundTexture2          = Hud.Texture.BackgroundTextureGreen,
                        BackgroundTextureOpacity2   = 1.0f,
                        TextFunc                    = () => Hud.Game.Me.Defense.Armor.ToString("#,0", CultureInfo.InvariantCulture),
                        HintFunc                    = () => "Armor",
                    },
                    new TopLabelDecorator(Hud)
                    {
                        TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 255, 255, 255, true, false, true),
                        ExpandedHintFont            = expandedHintFont,
                        ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                        BackgroundTexture1          = Hud.Texture.ButtonTextureGray,
                        BackgroundTexture2          = Hud.Texture.BackgroundTextureGreen,
                        BackgroundTextureOpacity2   = 1.0f,
                        TextFunc                    = () => (Hud.Game.Me.Defense.drCombined * 100).ToString("F1", CultureInfo.InvariantCulture),
                        HintFunc                    = () => "Damage Reduction",
                    },
                }
            });

            // ias 3
            LabelList.LabelDecorators.Add(new TopLabelDecorator(Hud)
            {
                TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 255, 255, 255, true, false, true),
                ExpandedHintFont            = expandedHintFont,
                ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                BackgroundTexture1          = Hud.Texture.ButtonTextureOrange,
                BackgroundTexture2          = Hud.Texture.BackgroundTextureYellow,
                BackgroundTextureOpacity2   = 0.3f,
                // TextFunc = () => Hud.Game.Me.Offense.AttackSpeed.ToString("F2", CultureInfo.InvariantCulture) + "/s",
                //jack's edit to include Flying Dragon staff buff
                TextFunc = () =>
                {
                    var aps = Hud.Game.Me.Offense.AttackSpeed * (Hud.Game.Me.Powers.BuffIsActive(246562, 1) ? 2 : 1);
                    return(aps.ToString("F2", System.Globalization.CultureInfo.InvariantCulture) + "/s");
                },
                HintFunc       = () => "Attack Speed Per Sec",
                ExpandUpLabels = new List <TopLabelDecorator>()
                {
                    new TopLabelDecorator(Hud)
                    {
                        TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 255, 255, 255, true, false, true),
                        ExpandedHintFont            = expandedHintFont,
                        ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                        BackgroundTexture1          = Hud.Texture.ButtonTextureOrange,
                        BackgroundTexture2          = Hud.Texture.BackgroundTextureOrange,
                        BackgroundTextureOpacity2   = 0.75f,
                        // TextFunc = () => ValueToString(Hud.Game.Me.Offense.SheetDps, ValueFormat.ShortNumber),
                        //jack's edit to include Flying Dragon staff buff
                        TextFunc = () =>
                        {
                            var dps = Hud.Game.Me.Offense.SheetDps * (Hud.Game.Me.Powers.BuffIsActive(246562, 1) ? 2 : 1);
                            return(BasePlugin.ValueToString(dps, ValueFormat.ShortNumber));
                        },
                        HintFunc = () => "Sheet DPS",
                    },
                    new TopLabelDecorator(Hud)
                    {
                        TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 255, 255, 255, true, false, true),
                        ExpandedHintFont            = expandedHintFont,
                        ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                        BackgroundTexture1          = Hud.Texture.ButtonTextureOrange,
                        BackgroundTexture2          = Hud.Texture.BackgroundTextureOrange,
                        BackgroundTextureOpacity2   = 0.75f,
                        TextFunc                    = () => ValueToString(Hud.Game.Me.Offense.MainHandIsActive ? Hud.Game.Me.Offense.WeaponDamageMainHand : Hud.Game.Me.Offense.WeaponDamageSecondHand, ValueFormat.ShortNumber),
                        HintFunc                    = () => "Weapon Damage",
                    },
                    new TopLabelDecorator(Hud)
                    {
                        TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 255, 255, 255, true, false, true),
                        ExpandedHintFont            = expandedHintFont,
                        ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                        BackgroundTexture1          = Hud.Texture.ButtonTextureOrange,
                        BackgroundTexture2          = Hud.Texture.BackgroundTextureYellow,
                        BackgroundTextureOpacity2   = 0.75f,
                        TextFunc                    = () => Hud.Game.Me.Offense.AttackSpeedPets.ToString("F2", CultureInfo.InvariantCulture) + "/s",
                        HintFunc                    = () => "Pet Attack Speed Per Sec",
                    }
                }
            });

            // chc 4
            LabelList.LabelDecorators.Add(new TopLabelDecorator(Hud)
            {
                TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 255, 255, 255, true, false, true),
                ExpandedHintFont            = expandedHintFont,
                ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                BackgroundTexture1          = Hud.Texture.ButtonTextureOrange,
                BackgroundTexture2          = Hud.Texture.BackgroundTextureGreen,
                BackgroundTextureOpacity2   = 0.3f,
                TextFunc                    = () => Hud.Game.Me.Offense.CriticalHitChance.ToString("F1", CultureInfo.InvariantCulture) + "%",
                HintFunc                    = () => "Crit Hit Chance",
                ExpandUpLabels              = new List <TopLabelDecorator>()
                {
                    new TopLabelDecorator(Hud)
                    {
                        TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 255, 255, 255, true, false, true),
                        ExpandedHintFont            = expandedHintFont,
                        ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                        BackgroundTexture1          = Hud.Texture.ButtonTextureOrange,
                        BackgroundTexture2          = Hud.Texture.BackgroundTextureGreen,
                        BackgroundTextureOpacity2   = 0.75f,
                        TextFunc                    = () => Hud.Game.Me.Offense.CritDamage.ToString("F0", CultureInfo.InvariantCulture) + "%",
                        HintFunc                    = () => "Crit Hit Damage",
                    },
                    new TopLabelDecorator(Hud)
                    {
                        TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 200, 200, 255, true, false, true),
                        ExpandedHintFont            = expandedHintFont,
                        ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                        BackgroundTexture1          = Hud.Texture.ButtonTextureOrange,
                        BackgroundTexture2          = Hud.Texture.BackgroundTextureBlue,
                        BackgroundTextureOpacity2   = 0.75f,
                        TextFunc                    = () => Hud.Game.Me.Offense.AreaDamageBonus.ToString("F0", CultureInfo.InvariantCulture) + "%",
                        HintFunc                    = () => "Area Damage Bonus",
                    }
                }
            });

            //////////////////////

            // dps 5
            LabelList.LabelDecorators.Add(new TopLabelDecorator(Hud)
            {
                TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 255, 255, 255, true, false, true),
                ExpandedHintFont            = expandedHintFont,
                ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                BackgroundTexture1          = Hud.Texture.ButtonTextureBlue,
                BackgroundTexture2          = Hud.Texture.BackgroundTextureBlue,
                BackgroundTextureOpacity2   = 0.75f,
                TextFunc                    = () => ValueToString(Hud.Game.Me.Damage.CurrentDps, ValueFormat.LongNumber),
                HintFunc                    = () => "Current DPS",
                ExpandUpLabels              = new List <TopLabelDecorator>()
                {
                    new TopLabelDecorator(Hud)
                    {
                        TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 255, 200, 200, true, false, true),
                        ExpandedHintFont            = expandedHintFont,
                        ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                        BackgroundTexture1          = Hud.Texture.ButtonTextureBlue,
                        BackgroundTexture2          = Hud.Texture.BackgroundTextureBlue,
                        BackgroundTextureOpacity2   = 0.75f,
                        TextFunc                    = () => ValueToString(Hud.Game.Me.Damage.MaximumDps, ValueFormat.LongNumber),
                        HintFunc                    = () => "Maximum DPS",
                    },
                    new TopLabelDecorator(Hud)
                    {
                        TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 255, 200, 200, true, false, true),
                        ExpandedHintFont            = expandedHintFont,
                        ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                        BackgroundTexture1          = Hud.Texture.ButtonTextureBlue,
                        BackgroundTexture2          = Hud.Texture.BackgroundTextureBlue,
                        BackgroundTextureOpacity2   = 0.75f,
                        TextFunc                    = () => ValueToString(Hud.Game.Me.Damage.TotalDamage, ValueFormat.ShortNumber),
                        HintFunc                    = () => "Total Damage",
                    },
                }
            });

            // dps 6
            LabelList.LabelDecorators.Add(new TopLabelDecorator(Hud)
            {
                TextFont                  = Hud.Render.CreateFont("tahoma", 7, 230, 255, 255, 255, true, false, true),
                BackgroundTexture1        = Hud.Texture.ButtonTextureGray,
                BackgroundTexture2        = Hud.Texture.BackgroundTextureBlue,
                BackgroundTextureOpacity2 = 0.7f,
                TextFunc                  = () => ValueToString(Hud.Game.Me.Damage.RunDps, ValueFormat.LongNumber),
                HintFunc                  = () => "Average DPS",
            });

            //////////////////////

            // cdr 7
            LabelList.LabelDecorators.Add(new TopLabelDecorator(Hud)
            {
                TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 200, 200, 255, true, false, true),
                ExpandedHintFont            = expandedHintFont,
                ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                BackgroundTexture1          = Hud.Texture.ButtonTextureBlue,
                BackgroundTexture2          = Hud.Texture.BackgroundTextureBlue,
                BackgroundTextureOpacity2   = 0.75f,
                TextFunc                    = () => (Hud.Game.Me.Stats.CooldownReduction * 100).ToString("F1", CultureInfo.InvariantCulture) + "%",
                HintFunc                    = () => "Cooldown Reduction",
                ExpandUpLabels              = new List <TopLabelDecorator>()
                {
                    new TopLabelDecorator(Hud)
                    {
                        TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 255, 200, 200, true, false, true),
                        ExpandedHintFont            = expandedHintFont,
                        ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                        BackgroundTexture1          = Hud.Texture.ButtonTextureBlue,
                        BackgroundTexture2          = Hud.Texture.BackgroundTextureBlue,
                        BackgroundTextureOpacity2   = 0.75f,
                        TextFunc                    = () => (Hud.Game.Me.Stats.ResourceCostReduction * 100).ToString("F1", CultureInfo.InvariantCulture) + "%",
                        HintFunc                    = () => "Resource Cost Reduction",
                    },
                }
            });

            // rcr 8
            LabelList.LabelDecorators.Add(new TopLabelDecorator(Hud)
            {
                TextFont                  = Hud.Render.CreateFont("tahoma", 7, 230, 255, 200, 200, true, false, true),
                BackgroundTexture1        = Hud.Texture.ButtonTextureBlue,
                BackgroundTexture2        = Hud.Texture.BackgroundTextureBlue,
                BackgroundTextureOpacity2 = 0.75f,
                TextFunc                  = () => (Hud.Game.Me.Stats.ResourceCostReduction * 100).ToString("F1", CultureInfo.InvariantCulture) + "%",
                HintFunc                  = () => "Resource Cost Reduction",
            });

            // misc 9
            LabelList.LabelDecorators.Add(new TopLabelDecorator(Hud)
            {
                TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 255, 200, 200, true, false, true),
                ExpandedHintFont            = expandedHintFont,
                ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                BackgroundTexture1          = Hud.Texture.ButtonTextureGray,
                BackgroundTexture2          = Hud.Texture.BackgroundTextureGreen,
                BackgroundTextureOpacity2   = 0.75f,
                TextFunc                    = () => Hud.Game.Me.Stats.PickupRange.ToString("F0", CultureInfo.InvariantCulture),
                HintFunc                    = () => "Pickup Range",
                ExpandUpLabels              = new List <TopLabelDecorator>()
                {
                    new TopLabelDecorator(Hud)
                    {
                        TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 255, 200, 200, false, false, true),
                        ExpandedHintFont            = expandedHintFont,
                        ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                        BackgroundTexture1          = Hud.Texture.ButtonTextureGray,
                        BackgroundTexture2          = Hud.Texture.BackgroundTextureGreen,
                        BackgroundTextureOpacity2   = 0.75f,
                        TextFunc                    = () => (Hud.Game.Me.Stats.GoldFind).ToString("#,0", CultureInfo.InvariantCulture) + "%",
                        HintFunc                    = () => "Gold Find",
                    },
                    new TopLabelDecorator(Hud)
                    {
                        TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 255, 200, 200, true, false, true),
                        ExpandedHintFont            = expandedHintFont,
                        ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                        BackgroundTexture1          = Hud.Texture.ButtonTextureGray,
                        BackgroundTexture2          = Hud.Texture.BackgroundTextureGreen,
                        BackgroundTextureOpacity2   = 0.75f,
                        TextFunc                    = () => (Hud.Game.Me.Stats.MagicFind).ToString("F0", CultureInfo.InvariantCulture) + "%",
                        HintFunc                    = () => "Magic Find",
                    },
                }
            });

            // exp 10
            LabelList.LabelDecorators.Add(new TopLabelDecorator(Hud)
            {
                TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 255, 200, 200, false, false, true),
                ExpandedHintFont            = expandedHintFont,
                ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                BackgroundTexture1          = Hud.Texture.ButtonTextureOrange,
                BackgroundTexture2          = Hud.Texture.BackgroundTextureGreen,
                BackgroundTextureOpacity2   = 0.75f,
                TextFunc                    = () => ValueToString(Hud.Game.ExperiencePerHourToday, ValueFormat.ShortNumber) + "/h",
                HintFunc                    = () => "Exp Per Hour Today",
                ExpandUpLabels              = new List <TopLabelDecorator>()
                {
                    new TopLabelDecorator(Hud)
                    {
                        TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 255, 200, 200, true, false, true),
                        ExpandedHintFont            = expandedHintFont,
                        ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                        BackgroundTexture1          = Hud.Texture.ButtonTextureOrange,
                        BackgroundTexture2          = Hud.Texture.BackgroundTextureGreen,
                        BackgroundTextureOpacity2   = 0.75f,
                        TextFunc                    = () => (Hud.Game.Me.Stats.ExperiencePercentBonus * 100).ToString("F0", CultureInfo.InvariantCulture) + "%",
                        HintFunc                    = () => "Bonus Exp",
                    },
                    new TopLabelDecorator(Hud)
                    {
                        TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 255, 200, 200, true, false, true),
                        ExpandedHintFont            = expandedHintFont,
                        ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                        BackgroundTexture1          = Hud.Texture.ButtonTextureOrange,
                        BackgroundTexture2          = Hud.Texture.BackgroundTextureGreen,
                        BackgroundTextureOpacity2   = 0.75f,
                        TextFunc                    = () => Hud.Game.Me.Stats.ExpOnKill.ToString("F0", CultureInfo.InvariantCulture),
                        HintFunc                    = () => "Exp On Kill",
                    },
                    new TopLabelDecorator(Hud)
                    {
                        TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 255, 200, 200, true, false, true),
                        ExpandedHintFont            = expandedHintFont,
                        ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                        BackgroundTexture1          = Hud.Texture.ButtonTextureOrange,
                        BackgroundTexture2          = Hud.Texture.BackgroundTextureGreen,
                        BackgroundTextureOpacity2   = 0.75f,
                        TextFunc                    = () => Hud.Game.Me.Stats.ExperienceOnKillBonus.ToString("F0", CultureInfo.InvariantCulture),
                        HintFunc                    = () => "Exp On Kill (Bonus)",
                    },
                    new TopLabelDecorator(Hud)
                    {
                        TextFont                    = Hud.Render.CreateFont("tahoma", 7, 230, 255, 200, 200, true, false, true),
                        ExpandedHintFont            = expandedHintFont,
                        ExpandedHintWidthMultiplier = expandedHintWidthMultiplier,
                        BackgroundTexture1          = Hud.Texture.ButtonTextureOrange,
                        BackgroundTexture2          = Hud.Texture.BackgroundTextureGreen,
                        BackgroundTextureOpacity2   = 0.75f,
                        TextFunc                    = () => Hud.Game.Me.Stats.ExpOnKillNoPenalty.ToString("F0", CultureInfo.InvariantCulture),
                        HintFunc                    = () => "Exp On Kill (No Penalty)",
                    },
                }
            });
        }
        public bool SwitchToTab(int tabIndex, FullRareSetManagerSettings Settings)
        {
            var latency = (int)GameController.Game.IngameState.CurLatency;
            // We don't want to Switch to a tab that we are already on
            var openLeftPanel = GameController.Game.IngameState.IngameUi.OpenLeftPanel;

            try
            {
                var stashTabToGoTo =
                    GameController.Game.IngameState.ServerData.StashPanel.GetStashInventoryByIndex(tabIndex)
                    .InventoryUiElement;

                if (stashTabToGoTo.IsVisible)
                {
                    return(true);
                }
            }
            catch
            {
                // Nothing to see here officer.
            }

            var _clickWindowOffset = GameController.Window.GetWindowRectangle().TopLeft;
            // We want to maximum wait 20 times the Current Latency before giving up in our while loops.
            var maxNumberOfTries = latency * 20 > 2000 ? latency * 20 / WHILE_DELAY : 2000 / WHILE_DELAY;

            if (tabIndex > 30)
            {
                return(SwitchToTabViaArrowKeys(tabIndex));
            }

            var stashPanel = GameController.Game.IngameState.ServerData.StashPanel;

            try
            {
                var viewAllTabsButton = GameController.Game.IngameState.ServerData.StashPanel.ViewAllStashButton;

                if (stashPanel.IsVisible && !viewAllTabsButton.IsVisible)
                {
                    // The user doesn't have a view all tabs button, eg. 4 tabs.
                    return(SwitchToTabViaArrowKeys(tabIndex));
                }

                var dropDownTabElements = GameController.Game.IngameState.ServerData.StashPanel.ViewAllStashPanel;

                if (!dropDownTabElements.IsVisible)
                {
                    var pos = viewAllTabsButton.GetClientRect();
                    Mouse.SetCursorPosAndLeftClick(pos.Center + _clickWindowOffset, Settings.ExtraDelay);
                    //Thread.Sleep(200);
                    Thread.Sleep(latency + Settings.ExtraDelay);
                    var brCounter = 0;

                    while (1 == 2 && !dropDownTabElements.IsVisible)
                    {
                        Thread.Sleep(WHILE_DELAY);

                        if (brCounter++ <= maxNumberOfTries)
                        {
                            continue;
                        }
                        BasePlugin.LogMessage($"1. Error in SwitchToTab: {tabIndex}.", 5);
                        return(false);
                    }

                    if (GameController.Game.IngameState.ServerData.StashPanel.TotalStashes > 30)
                    {
                        // TODO:Zafaar implemented something that allows us to get in contact with the ScrollBar.
                        Mouse.VerticalScroll(true, 5);
                        Thread.Sleep(latency + Settings.ExtraDelay);
                    }
                }


                // Dropdown menu have the following children: 0, 1, 2.
                // Where:
                // 0 is the icon (fx. chaos orb).
                // 1 is the name of the tab.
                // 2 is the slider.
                var        totalStashes = GameController.Game.IngameState.ServerData.StashPanel.TotalStashes;
                var        slider       = dropDownTabElements.Children[1].ChildCount == totalStashes;
                var        noSlider     = dropDownTabElements.Children[2].ChildCount == totalStashes;
                RectangleF tabPos;
                if (slider)
                {
                    tabPos = dropDownTabElements.GetChildAtIndex(1).GetChildAtIndex(tabIndex).GetClientRect();
                }
                else if (noSlider)
                {
                    tabPos = dropDownTabElements.GetChildAtIndex(2).GetChildAtIndex(tabIndex).GetClientRect();
                }
                else
                {
                    BasePlugin.LogError("Couldn't detect slider/non-slider, contact Preaches [Stashie]", 3);
                    return(false);
                }

                Mouse.SetCursorPosAndLeftClick(tabPos.Center + _clickWindowOffset, Settings.ExtraDelay);
                Thread.Sleep(latency + Settings.ExtraDelay);
            }
            catch (Exception e)
            {
                BasePlugin.LogError($"Error in GoToTab {tabIndex}: {e.Message}", 5);
                return(false);
            }

            Inventory stash;

            var counter = 0;

            do
            {
                Thread.Sleep(WHILE_DELAY);
                stash = stashPanel.VisibleStash;

                if (counter++ <= maxNumberOfTries)
                {
                    continue;
                }
                BasePlugin.LogMessage("2. Error opening stash: " + tabIndex, 5);
                return(true);
            } while (stash?.VisibleInventoryItems == null);
            return(true);
        }
Пример #21
0
        private void GolemMain()
        {
            if (isTown)
            {
                return;
            }

            if (GameController == null || GameController.Window == null || GameController.Game.IngameState.Data.LocalPlayer == null || GameController.Game.IngameState.Data.LocalPlayer.Address == 0x00)
            {
                return;
            }

            if (!GameController.Window.IsForeground())
            {
                return;
            }

            if (!GameController.Game.IngameState.Data.LocalPlayer.IsValid)
            {
                return;
            }

            var playerLife = GameController.Game.IngameState.Data.LocalPlayer.GetComponent <Life>();

            if (playerLife == null)
            {
                return;
            }

            try
            {
                List <int> golems = GameController.Game.IngameState.Data.LocalPlayer.GetComponent <Actor>().Minions;

                // Don't cast if number of golems is superior or equal to the targetNumber
                if (golems.Count >= targetNumber)
                {
                    return;
                }

                if (Settings.DontCastOnNearbyMonster.Value)
                {
                    Vector3 positionPlayer = GameController.Game.IngameState.Data.LocalPlayer.GetComponent <Render>().Pos;

                    foreach (EntityWrapper monster in nearbyMonsters)
                    {
                        if (monster.IsValid && monster.IsAlive)
                        {
                            Render positionMonster = monster.GetComponent <Render>();
                            int    distance        = (int)Math.Sqrt(Math.Pow((double)(positionPlayer.X - positionMonster.X), 2.0) + Math.Pow((double)(positionPlayer.Y - positionMonster.Y), 2.0));
                            if (distance <= Settings.NearbyMonsterRange.Value)
                            {
                                return;  //don't cast if monsters are nearby
                            }
                        }
                    }
                }

                IngameUIElements ingameUiElements = GameController.Game.IngameState.IngameUi;
                int countChaosGolem     = 0;
                int countFireGolem      = 0;
                int countIceGolem       = 0;
                int countLightningGolem = 0;
                int countStoneGolem     = 0;

                foreach (var golemId in golems)
                {
                    if (GameController.Game.IngameState.Data.EntityList.EntitiesAsDictionary.ContainsKey(golemId))
                    {
                        var golemPathString = GameController.Game.IngameState.Data.EntityList.EntitiesAsDictionary[golemId].Path;

                        if (golemPathString.Contains("ChaosElemental"))
                        {
                            countChaosGolem++;
                        }
                        if (golemPathString.Contains("FireElemental"))
                        {
                            countFireGolem++;
                        }
                        if (golemPathString.Contains("IceElemental"))
                        {
                            countIceGolem++;
                        }
                        if (golemPathString.Contains("LightningGolem"))
                        {
                            countLightningGolem++;
                        }
                        if (golemPathString.Contains("RockGolem"))
                        {
                            countStoneGolem++;
                        }
                    }
                }

                if (Settings.ChaosGolem.Value && countChaosGolem < Settings.ChaosGolemMax.Value && ingameUiElements.SkillBar[Settings.ChaosGolemConnectedSkill.Value - 1].SkillIconPath.Contains("ChaosElementalSummon"))
                {
                    keyboard.KeyPressRelease(Settings.ChaosGolemKeyPressed.Value);
                }
                if (Settings.FireGolem.Value && countFireGolem < Settings.FireGolemMax.Value && ingameUiElements.SkillBar[Settings.FireGolemConnectedSkill.Value - 1].SkillIconPath.Contains("FireElementalSummon"))
                {
                    keyboard.KeyPressRelease(Settings.FireGolemKeyPressed.Value);
                }
                if (Settings.IceGolem.Value && countIceGolem < Settings.IceGolemMax.Value && ingameUiElements.SkillBar[Settings.IceGolemConnectedSkill.Value - 1].SkillIconPath.Contains("IceElementalSummon"))
                {
                    keyboard.KeyPressRelease(Settings.IceGolemKeyPressed.Value);
                }
                if (Settings.LightningGolem.Value && countLightningGolem < Settings.LightningGolemMax.Value && ingameUiElements.SkillBar[Settings.LightningGolemConnectedSkill.Value - 1].SkillIconPath.Contains("LightningGolem"))
                {
                    keyboard.KeyPressRelease(Settings.LightningGolemKeyPressed.Value);
                }
                if (Settings.StoneGolem.Value && countStoneGolem < Settings.StoneGolemMax.Value && ingameUiElements.SkillBar[Settings.StoneGolemConnectedSkill.Value - 1].SkillIconPath.Contains("RockGolemSummon"))
                {
                    keyboard.KeyPressRelease(Settings.StoneGolemKeyPressed.Value);
                }
            }
            catch (Exception err)
            {
                BasePlugin.LogError(err, 5);
            }
        }
Пример #22
0
 /// <summary>
 /// Enables a plugin.
 /// </summary>
 /// <param name="name">Plugin name</param>
 /// <returns>Returns true on plugin successfully Enabling</returns>
 public static bool DisablePlugin(BasePlugin plugin)
 {
     return(plugin.Disable());
 }
Пример #23
0
 public void Register(BasePlugin plugin)
 {
     OptionsManager.AddCustomOption(plugin, this);
 }
Пример #24
0
 public StopListeningChannelPage(BasePlugin program)
     : base("Stop listening to command in a channel", program)
 {
 }
Пример #25
0
        public async void UpdatePlugin()
        {
            if (FilesToDownload.Count == 0)
            {
                BasePlugin.LogMessage(
                    "Plugin don't have download information (changed files or release zip is not found)", 10);
                return;
            }

            var updateDirectory = Path.Combine(PluginDirectory, PoeHUD_PluginsUpdater.UpdateTempDir);

            if (Directory.Exists(updateDirectory))
            {
                Directory.Delete(updateDirectory, true);
            }

            Directory.CreateDirectory(updateDirectory);

            if (UpdateVariant == ePluginSourceOfUpdate.Release)
            {
                #region Release

                InstallProgress = "Preparing to download...";

                try
                {
                    using (var webClient = new WebClient())
                    {
                        webClient.DownloadProgressChanged +=
                            (s, e) => { InstallProgress = "Downloading: " + e.ProgressPercentage + "%"; };

                        var downloadFile = FilesToDownload[0];

                        var filename = downloadFile.Path;
                        await webClient.DownloadFileTaskAsync(downloadFile.Url, downloadFile.Path);

                        InstallProgress = "Extracting zip...";
                        ZipFile.ExtractToDirectory(filename, updateDirectory);
                        InstallProgress = "Extracting: Ok";

                        File.Delete(filename);


                        var dirInfo      = new DirectoryInfo(updateDirectory);
                        var dirInfoDirs  = dirInfo.GetDirectories();
                        var dirInfoFiles = dirInfo.GetFiles();

                        if (dirInfoDirs.Length == 1 && dirInfoFiles.Length == 0)
                        {
                            InstallProgress = "Fixing files hierarchy..";
                            var subDir = dirInfoDirs[0];

                            foreach (var file in subDir.GetFiles())
                            {
                                var destFile = Path.Combine(updateDirectory, file.Name);
                                File.Move(file.FullName, destFile);
                            }
                            foreach (var directory in subDir.GetDirectories())
                            {
                                var destDir = Path.Combine(updateDirectory, directory.Name);
                                Directory.Move(directory.FullName, destDir);
                            }
                            Directory.Delete(subDir.FullName);
                        }


                        foreach (var ignoreFile in IgnoredEntities)
                        {
                            var ignorePath = Path.Combine(updateDirectory, ignoreFile);

                            if (File.Exists(ignorePath))
                            {
                                File.Delete(ignorePath);
                                BasePlugin.LogMessage("Ignore File: " + ignorePath, 5);
                            }
                            else if (Directory.Exists(ignorePath))
                            {
                                Directory.Delete(ignorePath, true);
                                BasePlugin.LogMessage("Ignore Directory: " + ignorePath, 5);
                            }
                        }

                        InstallProgress = "";

                        var versionFilePath = Path.Combine(updateDirectory, PoeHUD_PluginsUpdater.VersionFileName);
                        File.WriteAllText(versionFilePath, RemoteVersion + Environment.NewLine + RemoteTag);

                        UpdateState = ePluginUpdateState.ReadyToInstal;
                    }
                }
                catch (Exception ex)
                {
                    InstallProgress = "Error updating";
                    BasePlugin.LogError(
                        "Plugins Updater: Error while updating plugin: " + PluginName + ", Error: " + ex.Message, 10);
                }
                DoAfterUpdate(this);
                #endregion
            }
            else if (UpdateVariant == ePluginSourceOfUpdate.RepoBranch)
            {
                InstallProgress = "Preparing to download...";

                try
                {
                    var downloadCount   = FilesToDownload.Count;
                    var downloadedCount = 0;

                    using (var webClient = new WebClient())
                    {
                        webClient.DownloadProgressChanged +=
                            (s, e) =>
                        {
                            InstallProgress = "Downloading: " + downloadedCount + "/" + downloadCount + " (" +
                                              e.ProgressPercentage + "%)";
                        };

                        foreach (var downloadFile in FilesToDownload)
                        {
                            var downloadDir = Path.GetDirectoryName(downloadFile.Path);
                            if (!Directory.Exists(downloadDir))
                            {
                                Directory.CreateDirectory(downloadDir);
                            }

                            await webClient.DownloadFileTaskAsync(downloadFile.Url, downloadFile.Path);

                            InstallProgress = "Downloading: " + downloadedCount + "/" + downloadCount;
                            downloadedCount++;
                        }

                        InstallProgress = "";

                        UpdateState = ePluginUpdateState.ReadyToInstal;
                    }
                }
                catch (Exception ex)
                {
                    InstallProgress = "Error updating";
                    BasePlugin.LogError(
                        "Plugins Updater: Error while updating plugin: " + PluginName + ", Error: " + ex.Message, 10);
                }
                DoAfterUpdate(this);
            }
            else
            {
                BasePlugin.LogMessage("Update type is not supported in code: " + UpdateVariant, 5);
            }
        }
        public static List <CustomFilter> Parse(string[] filtersLines)
        {
            var allFilters = new List <CustomFilter>();

            for (var i = 0; i < filtersLines.Length; ++i)
            {
                var filterLine = filtersLines[i];

                filterLine = filterLine.Replace("\t", "");

                if (filterLine.StartsWith(COMMENTSYMBOL))
                {
                    continue;
                }

                if (filterLine.StartsWith(COMMENTSYMBOLALT))
                {
                    continue;
                }

                if (filterLine.Replace(" ", "").Length == 0)
                {
                    continue;
                }

                var nameIndex = filterLine.IndexOf(SYMBOL_NAMEDIVIDE);
                if (nameIndex == -1)
                {
                    BasePlugin.LogMessage("Filter parser: Can't find filter name in line: " + (i + 1), 5);
                    continue;
                }

                var newFilter = new CustomFilter {
                    Name = filterLine.Substring(0, nameIndex)
                };
                TrimName(ref newFilter.Name);

                var filterCommandsLine = filterLine.Substring(nameIndex + 1);

                var submenuIndex = filterCommandsLine.IndexOf(SYMBOL_SUBMENUNAME);
                if (submenuIndex != -1)
                {
                    newFilter.SubmenuName = filterCommandsLine.Substring(submenuIndex + 1);
                    filterCommandsLine    = filterCommandsLine.Substring(0, submenuIndex);
                }

                var filterCommands = filterCommandsLine.Split(SYMBOL_COMMANDSDIVIDE);

                var filterErrorParse = false;

                foreach (var command in filterCommands)
                {
                    if (string.IsNullOrEmpty(command.Replace(" ", "")))
                    {
                        continue;
                    }

                    if (command.Contains(SYMBOL_COMMAND_FILTER_OR))
                    {
                        var orFilterCommands = command.Split(SYMBOL_COMMAND_FILTER_OR);
                        var newOrFilter      = new BaseFilter {
                            BAny = true
                        };
                        newFilter.Filters.Add(newOrFilter);

                        foreach (var t in orFilterCommands)
                        {
                            if (ProcessCommand(newOrFilter, t))
                            {
                                continue;
                            }

                            filterErrorParse = true;
                            break;
                        }

                        if (filterErrorParse)
                        {
                            break;
                        }
                    }
                    else
                    {
                        if (ProcessCommand(newFilter, command))
                        {
                            continue;
                        }

                        filterErrorParse = true;
                        break;
                    }
                }

                if (!filterErrorParse)
                {
                    allFilters.Add(newFilter);
                }
            }

            return(allFilters);
        }
Пример #27
0
 public TestRoleWon(BasePlugin plugin) : base(plugin)
 {
 }
 public BroadcastMessagePage(BasePlugin program)
     : base("Broadcast a message", program)
 {
 }
Пример #29
0
 public CmdPageSetup(IAppContext context, BasePlugin plugin)
 {
     OnCreate(context);
     _plugin = plugin as PrintingPlugin;
 }
Пример #30
0
 public SheriffRole(BasePlugin plugin) : base(plugin)
 {
 }
Пример #31
0
        public ExpressionsPlugin()
        {
            Enabled = true;
            list    = new Dictionary <string, Func <string> >();

            list["*bloodshards-total"]     = (() => BasePlugin.ValueToString(Me.Materials.BloodShard, ValueFormat.LongNumber));
            list["*monsters-in-20"]        = (() => BasePlugin.ValueToString(Hud.GetPlugin <UtilityCollection>().monsterDensityAroundPlayer(20), ValueFormat.NormalNumber));
            list["*cursor-monsters-in-20"] = (() => BasePlugin.ValueToString(Hud.GetPlugin <UtilityCollection>().monsterDensityAroundCursor(20), ValueFormat.NormalNumber));
            list["*shield"]            = (() => Def.CurShield > 0 ? BasePlugin.ValueToString(Def.CurShield, ValueFormat.LongNumber) : null);
            list["*shield-nok"]        = (() => Def.CurShield > 0 ? BasePlugin.ValueToString(Def.CurShield, ValueFormat.NormalNumberNoDecimal) : null);
            list["*gold-in-stash"]     = (() => BasePlugin.ValueToString(Me.Materials.Gold, ValueFormat.LongNumber));
            list["*gold-in-stash-nok"] = (() => BasePlugin.ValueToString(Me.Materials.Gold, ValueFormat.NormalNumberNoDecimal));
            list["*hp-cur"]            = (() => BasePlugin.ValueToString(Def.HealthCur, ValueFormat.LongNumber));
            list["*hp-cur-nok"]        = (() => BasePlugin.ValueToString(Def.HealthCur, ValueFormat.NormalNumberNoDecimal));
            list["*hp-cur-pct"]        = (() => Def.HealthPct.ToString("F0", CultureInfo.InvariantCulture) + "%");
            list["*hp-max"]            = (() => Def.HealthMax.ToString("F0", CultureInfo.InvariantCulture));
            list["*ehp-max"]           = (() => BasePlugin.ValueToString(Def.EhpMax, ValueFormat.LongNumber));
            list["*ehp-max-nok"]       = (() => BasePlugin.ValueToString(Def.EhpMax, ValueFormat.NormalNumberNoDecimal));
            list["*ehp-cur"]           = (() => BasePlugin.ValueToString(Def.EhpCur, ValueFormat.NormalNumberNoDecimal));
            list["*ehp-cur-nok"]       = (() => BasePlugin.ValueToString(Def.EhpCur, ValueFormat.NormalNumberNoDecimal));
            list["*resource-cur-pri"]  = (() => Stats.ResourceCurPri.ToString("F0", CultureInfo.InvariantCulture));
            list["*resource-cur-sec"]  = (() => Stats.ResourceCurSec.ToString("F0", CultureInfo.InvariantCulture));
            list["*resource-max-pri"]  = (() => Stats.ResourceMaxPri.ToString("F0", CultureInfo.InvariantCulture));
            list["*resource-max-sec"]  = (() => Stats.ResourceMaxSec.ToString("F0", CultureInfo.InvariantCulture));
            list["*resource-pct-pri"]  = (() => Stats.ResourcePctPri.ToString("F0", CultureInfo.InvariantCulture) + "%");
            list["*resource-pct-sec"]  = (() => Stats.ResourcePctSec.ToString("F0", CultureInfo.InvariantCulture) + "%");
            list["*resource-reg-pri"]  = (() => Stats.ResourceRegPri.ToString("F0", CultureInfo.InvariantCulture));
            list["*resource-reg-sec"]  = (() => Stats.ResourceRegSec.ToString("F0", CultureInfo.InvariantCulture));
            list["*critchance"]        = (() => Dmg.CriticalHitChance.ToString("F1", CultureInfo.InvariantCulture) + "%");
            list["*attackspeed"]       = (() => Dmg.AttackSpeed.ToString("F2", CultureInfo.InvariantCulture) + "/s");
            list["*dps-sheet"]         = (() => BasePlugin.ValueToString(Dmg.SheetDps, ValueFormat.LongNumber));


            list["*dps-cur"]   = (() => BasePlugin.ValueToString(Me.Damage.CurrentDps, ValueFormat.LongNumber));
            list["*dps-run"]   = (() => BasePlugin.ValueToString(Me.Damage.RunDps, ValueFormat.LongNumber));
            list["*magicfind"] = (() => Stats.MagicFind.ToString("F0", CultureInfo.InvariantCulture) + "%");
            list["*goldfind"]  = (() => Stats.GoldFind.ToString("F0", CultureInfo.InvariantCulture) + "%");
            list["*expbonus"]  = (() => (Stats.ExperiencePercentBonus).ToString("F0", CultureInfo.InvariantCulture) + "%");
            list["*exponkill"] = (() => BasePlugin.ValueToString(Stats.ExperienceOnKillBonus, ValueFormat.LongNumber));
            list["*ingame-latency-average"]  = (() => BasePlugin.ValueToString(Hud.Game.AverageLatency, ValueFormat.NormalNumberNoDecimal));
            list["*ingame-latency-current"]  = (() => BasePlugin.ValueToString(Hud.Game.CurrentLatency, ValueFormat.NormalNumberNoDecimal));
            list["*ingame-latency-combined"] = (() => BasePlugin.ValueToString(Hud.Game.AverageLatency, ValueFormat.NormalNumberNoDecimal) + " / " + BasePlugin.ValueToString(Hud.Game.CurrentLatency, ValueFormat.NormalNumberNoDecimal));
            list["*ingame-ip"]             = (() => Hud.Game.ServerIpAddress);
            list["*current-time"]          = (() => new TimeSpan(Hud.Game.CurrentRealTimeMilliseconds * 10000).ToString(@"hh\:mm\:ss"));
            list["*game-duration"]         = (() => new TimeSpan(Convert.ToInt64(Def.CurrentEffectiveHealingPercent / 60.0f * 10000000)).ToString(@"hh\:mm\:ss"));
            list["*net-healing"]           = (() => BasePlugin.ValueToString(Def.CurrentEffectiveHealingPercent, ValueFormat.LongNumber) + "%");
            list["*net-healing-nok"]       = (() => BasePlugin.ValueToString(Def.CurrentEffectiveHealingPercent, ValueFormat.NormalNumber) + "%");
            list["*hps-cur"]               = (() => Def.CurrentHealingPerSecond > 0 ? BasePlugin.ValueToString(Def.CurrentHealingPerSecond, ValueFormat.LongNumber) : "");
            list["*hps-cur-nok"]           = (() => Def.CurrentHealingPerSecond > 0 ? BasePlugin.ValueToString(Def.CurrentHealingPerSecond, ValueFormat.NormalNumberNoDecimal) : "");
            list["*hps-cur-plus"]          = (() => Def.CurrentHealingPerSecond > 0 ? "+" + BasePlugin.ValueToString(Def.CurrentHealingPerSecond, ValueFormat.LongNumber) : "");
            list["*hps-cur-plus-nok"]      = (() => Def.CurrentHealingPerSecond > 0 ? "+" + BasePlugin.ValueToString(Def.CurrentHealingPerSecond, ValueFormat.NormalNumberNoDecimal) : "");
            list["*dtps-cur"]              = (() => Def.CurrentDamageTakenPerSecond > 0 ? BasePlugin.ValueToString(Def.CurrentDamageTakenPerSecond, ValueFormat.LongNumber) : "");
            list["*dtps-cur-nok"]          = (() => Def.CurrentDamageTakenPerSecond > 0 ? BasePlugin.ValueToString(Def.CurrentDamageTakenPerSecond, ValueFormat.NormalNumberNoDecimal) : "");
            list["*dtps-cur-minus"]        = (() => Def.CurrentDamageTakenPerSecond > 0 ? "-" + BasePlugin.ValueToString(Def.CurrentDamageTakenPerSecond, ValueFormat.LongNumber) : "");
            list["*dtps-cur-minus-nok"]    = (() => Def.CurrentDamageTakenPerSecond > 0 ? "-" + BasePlugin.ValueToString(Def.CurrentDamageTakenPerSecond, ValueFormat.NormalNumberNoDecimal) : "");
            list["*dmg-dealt-bonus-ph"]    = (() => Dmg.BonusToPhysical == 0 ? "" : (Dmg.BonusToPhysical * 100).ToString("F0", CultureInfo.InvariantCulture));
            list["*dmg-dealt-bonus-f"]     = (() => Dmg.BonusToFire == 0 ? "" : (Dmg.BonusToFire * 100).ToString("F0", CultureInfo.InvariantCulture));
            list["*dmg-dealt-bonus-l"]     = (() => Dmg.BonusToLightning == 0 ? "" : (Dmg.BonusToLightning * 100).ToString("F0", CultureInfo.InvariantCulture));
            list["*dmg-dealt-bonus-c"]     = (() => Dmg.BonusToCold == 0 ? "" : (Dmg.BonusToCold * 100).ToString("F0", CultureInfo.InvariantCulture));
            list["*dmg-dealt-bonus-p"]     = (() => Dmg.BonusToPoison == 0 ? "" : (Dmg.BonusToPoison * 100).ToString("F0", CultureInfo.InvariantCulture));
            list["*dmg-dealt-bonus-a"]     = (() => Dmg.BonusToArcane == 0 ? "" : (Dmg.BonusToArcane * 100).ToString("F0", CultureInfo.InvariantCulture));
            list["*dmg-dealt-bonus-h"]     = (() => Dmg.BonusToHoly == 0 ? "" : (Dmg.BonusToHoly * 100).ToString("F0", CultureInfo.InvariantCulture));
            list["*dmg-dealt-bonus-elite"] = (() => Dmg.BonusToElites == 0 ? "" : (Dmg.BonusToElites * 100).ToString("F0", CultureInfo.InvariantCulture));
            list["*inventory-free-space"]  = (() => BasePlugin.ValueToString(Me.InventorySpaceTotal - Hud.Game.InventorySpaceUsed, ValueFormat.NormalNumber));
            list["*cdr"]                             = (() => BasePlugin.ValueToString(Stats.CooldownReduction * 100, ValueFormat.NormalNumberNoDecimal) + "%");
            list["*pickup"]                          = (() => Stats.PickupRange.ToString("F0", CultureInfo.InvariantCulture));
            list["*exp-level-cur"]                   = (() => (Me.CurrentLevelNormal < Me.CurrentLevelNormalCap) ? Me.CurrentLevelNormal.ToString("0") : "p" + Me.CurrentLevelParagonFloat.ToString("0.##", CultureInfo.InvariantCulture));
            list["*exp-to-next-level"]               = (() => BasePlugin.ValueToString(Me.ParagonExpToNextLevel, ValueFormat.LongNumber));
            list["*exp-to-next-level-nok"]           = (() => BasePlugin.ValueToString(Me.ParagonExpToNextLevel, ValueFormat.NormalNumberNoDecimal));
            list["*exp-in-this-level"]               = (() => BasePlugin.ValueToString(Me.ParagonExpInThisLevel, ValueFormat.LongNumber));
            list["*exp-in-this-level-nok"]           = (() => BasePlugin.ValueToString(Me.ParagonExpInThisLevel, ValueFormat.NormalNumberNoDecimal));
            list["*exp-remaining-to-next-level"]     = (() => BasePlugin.ValueToString(Me.ParagonExpToNextLevel - Me.ParagonExpInThisLevel, ValueFormat.LongNumber));
            list["*exp-remaining-to-next-level-nok"] = (() => BasePlugin.ValueToString(Me.ParagonExpToNextLevel - Me.ParagonExpInThisLevel, ValueFormat.NormalNumberNoDecimal));
            list["*exp-bonus-pool-percent"]          = (() => BasePlugin.ValueToString(Me.BonusPoolPercent * 100, ValueFormat.NormalNumber) + "%");
            list["*exp-bonus-pool-remaining"]        = (() => BasePlugin.ValueToString(Me.BonusPoolRemaining, ValueFormat.LongNumber));
            list["*exp-bonus-pool-remaining-nok"]    = (() => BasePlugin.ValueToString(Me.BonusPoolRemaining, ValueFormat.NormalNumberNoDecimal));
            list["*rift-info-pct"]                   = (() => Hud.Game.RiftPercentage.ToString("F1", CultureInfo.InvariantCulture) + "%");
            list["*rift-info-pct-remaining"]         = (() => (100.0 - Hud.Game.RiftPercentage).ToString("F1", CultureInfo.InvariantCulture) + "%");
            list["*perf-rendertime"]                 = (() => Hud.Stat.RenderPerfCounter.LastValue.ToString("F0") + " (" + Hud.Stat.RenderPerfCounter.LastCount.ToString("F0") + " FPS)");


            list["*damred"]              = (() => Def.DamageReduction.ToString("F1", CultureInfo.InvariantCulture) + "%");
            list["*damred-elite"]        = (() => Def.DRElite.ToString("F1", CultureInfo.InvariantCulture) + "%");
            list["*damred-melee"]        = (() => Def.DRMelee.ToString("F1", CultureInfo.InvariantCulture) + "%");
            list["*damred-ranged"]       = (() => Def.DRRanged.ToString("F1", CultureInfo.InvariantCulture) + "%");
            list["*damred-avr-fromtype"] = (() => Def.AverageDamageReductionFromType.ToString("F1", CultureInfo.InvariantCulture) + "%");

            list["*resist-physical"]  = (() => Def.ResPhysical.ToString("F0", CultureInfo.InvariantCulture));
            list["*resist-cold"]      = (() => Def.ResCold.ToString("F0", CultureInfo.InvariantCulture));
            list["*resist-fire"]      = (() => Def.ResFire.ToString("F0", CultureInfo.InvariantCulture));
            list["*resist-lightning"] = (() => Def.ResLightning.ToString("F0", CultureInfo.InvariantCulture));
            list["*resist-poison"]    = (() => Def.ResPoison.ToString("F0", CultureInfo.InvariantCulture));
            list["*resist-arcane"]    = (() => Def.ResArcane.ToString("F0", CultureInfo.InvariantCulture));
            list["*resist-lowest"]    = (() => Def.ResLowest.ToString("F0", CultureInfo.InvariantCulture));
            list["*armor"]            = (() => Def.Armor.ToString("F0", CultureInfo.InvariantCulture));


            //expressions.Add("*perf-memory-usage-gc", (GC.GetTotalMemory(false) / 1024.0 / 1024.0).ToString("F0") + " MB");
            //expressions.Add("*dmg-weapon", BasePlugin.ValueToString(Me.DWHandLeft ? Me.WeaponDMGmh : Me.WeaponDMGoh, ValueFormat.LongNumber));
            //expressions.Add("*exp-all", BasePlugin.ValueToString(Me.ParagonTotalExp, ValueFormat.LongNumber));
            //expressions.Add("*elemental-dps", BasePlugin.ValueToString(Me.SheetDPS * (1 + Me.HighestElementalDamageBonus), ValueFormat.LongNumber));
            //expressions.Add("*elite-dps", BasePlugin.ValueToString(Me.SheetDPS * (1 + Me.HighestElementalDamageBonus) * (1 + Me.BonusToElites), ValueFormat.LongNumber));
            //expressions.Add("*movespeed", Me.MoveSpeed.ToString("F0", CultureInfo.InvariantCulture));
            //expressions.Add("*movespeed-bonus", Me.MoveSpeedBonus.ToString("F0", CultureInfo.InvariantCulture));
            //list["*life-per-second"] = (() => BasePlugin.ValueToString(Hud.Collections.CurHealingPerSecond, ValueFormat.LongNumber));
            //list["*life-per-second-nok"] = (() => BasePlugin.ValueToString(Hud.Collections.CurHealingPerSecond, ValueFormat.NormalNumber));
            //expressions.Add("*attackspeed-pets", Me.AttackSpeedPets.ToString("F2", CultureInfo.InvariantCulture) + "/s");
            //expressions.Add("*healing-sheet", BasePlugin.ValueToString(Me.SheetHealing, ValueFormat.LongNumber));
            //expressions.Add("*healing-sheet-nok", BasePlugin.ValueToString(Me.SheetHealing, ValueFormat.NormalNumberNoDecimal));
            //expressions.Add("*healing-sheet-plus", "+" + BasePlugin.ValueToString(Me.SheetHealing, ValueFormat.LongNumber));
            //expressions.Add("*healing-sheet-plus-nok", "+" + BasePlugin.ValueToString(Me.SheetHealing, ValueFormat.NormalNumberNoDecimal));

            /*
             * expressions.Add("*exp-level-time-to-next1", Engine.TimeToParagonLevel(Me.CurrentLevelParagon + 1, true));
             * expressions.Add("*exp-level-time-to-next2", Engine.TimeToParagonLevel(Me.CurrentLevelParagon + 2, true));
             * expressions.Add("*exp-level-time-to-next3", Engine.TimeToParagonLevel(Me.CurrentLevelParagon + 3, true));
             * expressions.Add("*exp-level-time-to-next10", Engine.TimeToParagonLevel(Me.CurrentLevelParagon + 10, true));
             * expressions.Add("*exp-level-time-to-next20", Engine.TimeToParagonLevel(Me.CurrentLevelParagon + 20, true));
             * expressions.Add("*exp-level-time-to-next50", Engine.TimeToParagonLevel(Me.CurrentLevelParagon + 50, true));
             * expressions.Add("*exp-level-time-to-next100", Engine.TimeToParagonLevel(Me.CurrentLevelParagon + 100, true));
             * expressions.Add("*exp-level-time-to-next1-value", Engine.TimeToParagonLevel(Me.CurrentLevelParagon + 1, false));
             * expressions.Add("*exp-level-time-to-next2-value", Engine.TimeToParagonLevel(Me.CurrentLevelParagon + 2, false));
             * expressions.Add("*exp-level-time-to-next3-value", Engine.TimeToParagonLevel(Me.CurrentLevelParagon + 3, false));
             * expressions.Add("*exp-level-time-to-next10-value", Engine.TimeToParagonLevel(Me.CurrentLevelParagon + 10, false));
             * expressions.Add("*exp-level-time-to-next20-value", Engine.TimeToParagonLevel(Me.CurrentLevelParagon + 20, false));
             * expressions.Add("*exp-level-time-to-next50-value", Engine.TimeToParagonLevel(Me.CurrentLevelParagon + 50, false));
             * expressions.Add("*exp-level-time-to-next100-value", Engine.TimeToParagonLevel(Me.CurrentLevelParagon + 100, false));
             * expressions.Add("*exp-level-exp-to-next1", Engine.ExpToParagonLevel(Me.CurrentLevelParagon + 1));
             * expressions.Add("*exp-level-exp-to-next2", Engine.ExpToParagonLevel(Me.CurrentLevelParagon + 2));
             * expressions.Add("*exp-level-exp-to-next3", Engine.ExpToParagonLevel(Me.CurrentLevelParagon + 3));
             * expressions.Add("*exp-level-exp-to-next10", Engine.ExpToParagonLevel(Me.CurrentLevelParagon + 10));
             * expressions.Add("*exp-level-exp-to-next20", Engine.ExpToParagonLevel(Me.CurrentLevelParagon + 20));
             * expressions.Add("*exp-level-exp-to-next50", Engine.ExpToParagonLevel(Me.CurrentLevelParagon + 50));
             * expressions.Add("*exp-level-exp-to-next100", Engine.ExpToParagonLevel(Me.CurrentLevelParagon + 100));
             * expressions.Add("*life-on-hit", BasePlugin.ValueToString(Me.LifeOnHit, ValueFormat.LongNumber));
             * expressions.Add("*life-on-hit-nok", BasePlugin.ValueToString(Me.LifeOnHit, ValueFormat.NormalNumber));
             * expressions.Add("*life-on-kill", BasePlugin.ValueToString(Me.LifeOnKill, ValueFormat.LongNumber));
             * expressions.Add("*life-on-kill-nok", BasePlugin.ValueToString(Me.LifeOnKill, ValueFormat.NormalNumber));
             * expressions.Add("*hp-globe-bonus", BasePlugin.ValueToString(Me.GlobeBonus, ValueFormat.LongNumber));
             * expressions.Add("*hp-globe-bonus-nok", BasePlugin.ValueToString(Me.GlobeBonus, ValueFormat.NormalNumber));
             * expressions.Add("*dps-cur-party": { long t = 0); for (int i = 0) ; i < Collect.Players.Length); i++) t += (Collect.Players[i].ActorKnown() ? Collect.Players[i].CurDPS : 0)); S = BasePlugin.ValueToString(t, ValueFormat.LongNumber)); }
             * expressions.Add("*dps-run-party": { long t = 0); for (int i = 0) ; i < Collect.Players.Length); i++) t += Collect.Players[i].RunDPS()); S = BasePlugin.ValueToString(t, ValueFormat.LongNumber)); }
             * expressions.Add("*monster-damage", BasePlugin.ValueToString(Collect.Actors.MonsterHitpointDecreaseCounter.LastValue, ValueFormat.LongNumber));
             * expressions.Add("*dmg-total", BasePlugin.ValueToString(Me.TotalDMG, ValueFormat.LongNumber));
             * expressions.Add("*dmg-total-party": { double t = 0); for (int i = 0) ; i < Collect.Players.Length); i++) t += Collect.Players[i].TotalDMG); S = BasePlugin.ValueToString(t, ValueFormat.LongNumber)); }
             *
             */
        }
Пример #32
0
 public CmdEditorStart(IAppContext context, BasePlugin plugin)
 {
     OnCreate(context);
     _plugin = plugin as EditorPlugin;
 }
Пример #33
0
 public static Hook Subscribe(string hookname, BasePlugin plugin)
 {
     return(new Hook(hookname, args => plugin.Invoke(hookname, args)));
 }
 protected internal abstract void HookBase(BasePlugin plugin, Delegate callback, HookOrder order = HookOrder.NORMAL);
Пример #35
0
 public static void On_PluginLoaded(BasePlugin plugin)
 {
     OnNext("On_PluginLoaded", plugin);
 }
 protected internal abstract void Unhook(BasePlugin plugin);
Пример #37
0
 public ConsoleCommands(BasePlugin pl)
 {
     plugin = pl;
 }
Пример #38
0
 public JesterRole(BasePlugin plugin) : base(plugin)
 {
 }
        public void PluginManage(ISender sender, ArgumentList args)
        {
            /*
             * Commands:
             *      list    - shows all plugins
             *      info    - shows a plugin's author & description etc
             *      disable - disables a plugin
             *      enable  - enables a plugin
             *      reload
             *      unload
             *      status
             *      load
             */

            if (args.Count == 0)
                throw new CommandError("Subcommand expected.");

            string command = args[0];
            args.RemoveAt(0); //Allow the commands to use any additional arguments without also getting the command

            lock (PluginManager._plugins)
                switch (command)
                {
                    case "-l":
                    case "ls":
                    case "list":
                        {
                            if (PluginManager.PluginCount == 0)
                            {
                                sender.Message(255, "No plugins loaded.");
                                return;
                            }

                            var msg = new StringBuilder();
                            msg.Append("Plugins: ");

                            int i = 0;
                            foreach (var plugin in PluginManager.EnumeratePlugins)
                            {
                                if (i > 0)
                                    msg.Append(", ");
                                msg.Append(plugin.Name);

                                if (!String.IsNullOrEmpty(plugin.Version))
                                {
                                    msg.Append(" (");
                                    msg.Append(plugin.Version);
                                    msg.Append(")");
                                }

                                if (!plugin.IsEnabled)
                                    msg.Append("[OFF]");
                                i++;
                            }
                            msg.Append(".");

                            sender.Message(255, Color.DodgerBlue, msg.ToString());

                            break;
                        }

                    case "-s":
                    case "stat":
                    case "status":
                        {
                            if (PluginManager.PluginCount == 0)
                            {
                                sender.Message(255, "No plugins loaded.");
                                return;
                            }

                            var msg = new StringBuilder();

                            foreach (var plugin in PluginManager.EnumeratePlugins)
                            {
                                msg.Clear();
                                msg.Append(plugin.IsDisposed ? "[DISPOSED] " : (plugin.IsEnabled ? "[ON]  " : "[OFF] "));
                                msg.Append(plugin.Name);
                                msg.Append(" ");
                                msg.Append(plugin.Version);
                                if (plugin.Status != null && plugin.Status.Length > 0)
                                {
                                    msg.Append(" : ");
                                    msg.Append(plugin.Status);
                                }
                                sender.Message(255, Color.DodgerBlue, msg.ToString());
                            }

                            break;
                        }

                    case "-i":
                    case "info":
                        {
                            string name;
                            args.ParseOne(out name);

                            var fplugin = PluginManager.GetPlugin(name);
                            if (fplugin != null)
                            {
                                var path = Path.GetFileName(fplugin.FilePath);
                                sender.Message(255, Color.DodgerBlue, fplugin.Name);
                                sender.Message(255, Color.DodgerBlue, "Filename: " + path);
                                sender.Message(255, Color.DodgerBlue, "Version:  " + fplugin.Version);
                                sender.Message(255, Color.DodgerBlue, "Author:   " + fplugin.Author);
                                if (fplugin.Description != null && fplugin.Description.Length > 0)
                                    sender.Message(255, Color.DodgerBlue, fplugin.Description);
                                sender.Message(255, Color.DodgerBlue, "Status:   " + (fplugin.IsEnabled ? "[ON] " : "[OFF] ") + fplugin.Status);
                            }
                            else
                            {
                                sender.SendMessage("The plugin \"" + args[1] + "\" was not found.");
                            }

                            break;
                        }

                    case "-d":
                    case "disable":
                        {
                            string name;
                            args.ParseOne(out name);

                            var fplugin = PluginManager.GetPlugin(name);
                            if (fplugin != null)
                            {
                                if (fplugin.Disable())
                                    sender.Message(255, Color.DodgerBlue, fplugin.Name + " was disabled.");
                                else
                                    sender.Message(255, Color.DodgerBlue, fplugin.Name + " was disabled, errors occured during the process.");
                            }
                            else
                                sender.Message(255, "The plugin \"" + name + "\" could not be found.");

                            break;
                        }

                    case "-e":
                    case "enable":
                        {
                            string name;
                            args.ParseOne(out name);

                            var fplugin = PluginManager.GetPlugin(name);
                            if (fplugin != null)
                            {
                                if (fplugin.Enable())
                                    sender.Message(255, Color.DodgerBlue, fplugin.Name + " was enabled.");
                                else
                                    sender.Message(255, Color.DodgerBlue, fplugin.Name + " was enabled, errors occured during the process.");
                            }
                            else
                                sender.Message(255, "The plugin \"" + name + "\" could not be found.");

                            break;
                        }

                    case "-u":
                    case "-ua":
                    case "unload":
                        {
                            string name;

                            if (command == "-ua" || command == "-uca")
                                name = "all";
                            else
                                args.ParseOne(out name);

                            BasePlugin[] plugs;
                            if (name == "all" || name == "-a")
                            {
                                plugs = PluginManager._plugins.Values.ToArray();
                            }
                            else
                            {
                                var splugin = PluginManager.GetPlugin(name);

                                if (splugin == null)
                                {
                                    sender.Message(255, "The plugin \"" + name + "\" could not be found.");
                                    return;
                                }

                                plugs = new BasePlugin[] { splugin };
                            }

                            foreach (var fplugin in plugs)
                            {
                                if (PluginManager.UnloadPlugin(fplugin))
                                    sender.Message(255, Color.DodgerBlue, fplugin.Name + " was unloaded.");
                                else
                                    sender.Message(255, Color.DodgerBlue, fplugin.Name + " was unloaded, errors occured during the process.");
                            }

                            break;
                        }

                    case "-r":
                    case "-rc":
                    case "-ra":
                    case "-rca":
                    case "reload":
                        {
                            bool save = true;
                            if (command == "-rc" || command == "-rca" || args.TryPop("-c") || args.TryPop("-clean"))
                                save = false;

                            string name;

                            if (command == "-ra" || command == "-rca")
                                name = "all";
                            else
                                args.ParseOne(out name);

                            BasePlugin[] plugs;
                            if (name == "all" || name == "-a")
                            {
                                plugs = PluginManager._plugins.Values.ToArray();
                            }
                            else
                            {
                                var splugin = PluginManager.GetPlugin(name);

                                if (splugin == null)
                                {
                                    sender.Message(255, "The plugin \"" + name + "\" could not be found.");
                                    return;
                                }

                                plugs = new BasePlugin[] { splugin };
                            }

                            foreach (var fplugin in plugs)
                            {
                                var nplugin = PluginManager.ReloadPlugin(fplugin, save);
                                if (nplugin == fplugin)
                                {
                                    sender.Message(255, Color.DodgerBlue, "Errors occured while reloading plugin " + fplugin.Name + ", old instance kept.");
                                }
                                else if (nplugin == null)
                                {
                                    sender.Message(255, Color.DodgerBlue, "Errors occured while reloading plugin " + fplugin.Name + ", it has been unloaded.");
                                }
                            }

                            break;
                        }

                    case "-L":
                    case "-LR":
                    case "load":
                        {
                            bool replace = command == "-LR" || args.TryPop("-R") || args.TryPop("-replace");
                            bool save = command != "-LRc" && !args.TryPop("-c") && !args.TryPop("-clean");

                            var fname = string.Join(" ", args);
                            string path;

                            if (fname == "")
                                throw new CommandError("File name expected");

                            if (Path.IsPathRooted(fname))
                                path = Path.GetFullPath(fname);
                            else
                                path = Path.Combine(Globals.PluginPath, fname);

                            var fi = new FileInfo(path);

                            if (!fi.Exists)
                            {
                                sender.Message(255, "Specified file doesn't exist.");
                                return;
                            }

                            var newPlugin = PluginManager.LoadPluginFromPath(path);

                            if (newPlugin == null)
                            {
                                sender.Message(255, "Unable to load plugin.");
                                return;
                            }

                            var oldPlugin = PluginManager.GetPlugin(newPlugin.Name);
                            if (oldPlugin != null)
                            {
                                if (!replace)
                                {
                                    sender.Message(255, "A plugin named {0} is already loaded, use -replace to replace it.", oldPlugin.Name);
                                    return;
                                }

                                if (PluginManager.ReplacePlugin(oldPlugin, newPlugin, save))
                                {
                                    sender.Message(255, Color.DodgerBlue, "Plugin {0} has been replaced.", oldPlugin.Name);
                                }
                                else if (oldPlugin.IsDisposed)
                                {
                                    sender.Message(255, Color.DodgerBlue, "Replacement of plugin {0} failed, it has been unloaded.", oldPlugin.Name);
                                }
                                else
                                {
                                    sender.Message(255, Color.DodgerBlue, "Replacement of plugin {0} failed, old instance kept.", oldPlugin.Name);
                                }

                                return;
                            }

                            if (!newPlugin.InitializeAndHookUp())
                            {
                                sender.Message(255, Color.DodgerBlue, "Failed to initialize new plugin instance.");
                            }

                            PluginManager._plugins.Add(newPlugin.Name.ToLower().Trim(), newPlugin);

                            if (!newPlugin.Enable())
                            {
                                sender.Message(255, Color.DodgerBlue, "Failed to enable new plugin instance.");
                            }

                            sender.Message(255, Color.DodgerBlue, "New plugin instance loaded.");
                            break;
                        }

                    default:
                        {
                            throw new CommandError("Subcommand not recognized.");
                        }
                }
        }