Пример #1
0
 public void Execute(IRocketPlayer caller, string[] command)
 {
     //Requires PlayerInfoLib to work, if not loaded time won't be tracked
     if (RocketPlugin.IsDependencyLoaded("PlayerInfoLib"))
     {
         int    totalSeconds = PlayerInfoLib.Database.QueryById(UnturnedPlayer.FromName(caller.DisplayName).CSteamID, true).TotalPlayime;
         string str          = "";
         if (totalSeconds >= 86400)
         {
             int num = totalSeconds / 86400;
             str = string.Concat(num.ToString(), "d ");
         }
         if (totalSeconds >= 3600)
         {
             int num1 = totalSeconds / 3600 % 24;
             str = string.Concat(str, num1.ToString(), "h ");
         }
         if (totalSeconds >= 60)
         {
             int num2 = totalSeconds / 60 % 60;
             str = string.Concat(str, num2.ToString(), "m ");
         }
         int num3 = totalSeconds % 60;
         str = string.Concat(str, num3.ToString(), "s");
         TranslationList translationLists = UTools.Instance.Translations.Instance;
         object[]        objArray         = new object[] { str };
         UnturnedChat.Say(caller, translationLists.Translate("total_playtime", objArray), Color.yellow);
     }
     else
     {
         UnturnedChat.Say(caller, "Playtime is not being tracked!", Color.yellow);
     }
 }
Пример #2
0
        /// <summary>
        /// Logs that a plugin was unloaded.
        /// </summary>
        /// <param name="plugin">The instance of the plugin that was unloaded.</param>
        public static void PluginUnloaded(RocketPlugin plugin)
        {
            var pluginVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(plugin.Assembly.Location)
                                .ProductVersion;
            var pluginIdentity = $"{plugin.Name} v{pluginVersion}";

            Write(pluginIdentity, $"{pluginIdentity}, by Pustalorc, has been unloaded.");
        }
Пример #3
0
 public void Execute(IRocketPlayer caller, string[] command)
 {
     try
     {
         var player = (UnturnedPlayer)caller;
         if (Plugin.NoQuestion)
         {
             var noQuestion = Plugin.Inst.Translate("mathquiz_no_question");
             ChatManager.serverSendMessage(noQuestion, UnturnedChat.GetColorFromName(Plugin.Conf.UnfavorableMessageColor, Color.red), null, ((UnturnedPlayer)caller).SteamPlayer(), EChatMode.SAY, Plugin.Conf.AnnouncerImageUrl, true);
         }
         else
         {
             if (command.Length >= 1)
             {
                 if (command[0] == Plugin.Result.ToString() && !Plugin.NoQuestion)
                 {
                     Plugin.NoQuestion = true;
                     if (Plugin.Inst.CurrentQuizModel.RewardType == ERewardType.Uconomy)
                     {
                         RocketPlugin.ExecuteDependencyCode("Uconomy", (IRocketPlugin plugin) =>
                         {
                             var uconomy = (Uconomy)plugin;
                             uconomy.Database.IncreaseBalance(player.CSteamID.ToString(), Plugin.Inst.CurrentQuizModel.RewardAmount);
                             var rightanswer = Plugin.Inst.Translate("mathquiz_true_answer", Plugin.Inst.CurrentQuizModel.RewardAmount.ToString(), uconomy.Configuration.Instance.MoneyName, uconomy.Database.GetBalance(player.CSteamID.ToString()));
                             ChatManager.serverSendMessage(rightanswer, UnturnedChat.GetColorFromName(Plugin.Conf.MessageColor, Color.yellow), null, player.SteamPlayer(), EChatMode.SAY, Plugin.Conf.AnnouncerImageUrl, true);
                             var winner = Plugin.Inst.Translate("mathquiz_broadcast_winner", caller.DisplayName, Plugin.Result.ToString(), Plugin.Inst.CurrentQuizModel.RewardAmount.ToString(), uconomy.Configuration.Instance.MoneyName);
                             ChatManager.serverSendMessage(winner, UnturnedChat.GetColorFromName(Plugin.Conf.MessageColor, Color.yellow), null, null, EChatMode.GLOBAL, Plugin.Conf.AnnouncerImageUrl, true);
                         });
                     }
                     else
                     {
                         player.Experience += Plugin.Inst.CurrentQuizModel.RewardAmount;
                         var correctAnswer = Plugin.Inst.Translate("mathquiz_true_answer", Plugin.Inst.CurrentQuizModel.RewardAmount.ToString(), "Experience", player.Experience);
                         ChatManager.serverSendMessage(correctAnswer, UnturnedChat.GetColorFromName(Plugin.Conf.MessageColor, Color.yellow), null, player.SteamPlayer(), EChatMode.SAY, Plugin.Conf.AnnouncerImageUrl, true);
                         var winner = Plugin.Inst.Translate("mathquiz_broadcast_winner", caller.DisplayName, Plugin.Result.ToString(), Plugin.Inst.CurrentQuizModel.RewardAmount.ToString(), "Experience");
                         ChatManager.serverSendMessage(winner, UnturnedChat.GetColorFromName(Plugin.Conf.MessageColor, Color.yellow), null, null, EChatMode.GLOBAL, Plugin.Conf.AnnouncerImageUrl, true);
                     }
                 }
                 if (command[0] != Plugin.Result.ToString() && !Plugin.NoQuestion)
                 {
                     ChatManager.serverSendMessage(Plugin.Inst.Translate("mathquiz_wrong_answer"), UnturnedChat.GetColorFromName(Plugin.Conf.UnfavorableMessageColor, Color.red), null,
                                                   ((UnturnedPlayer)caller).SteamPlayer(), EChatMode.SAY, Plugin.Conf.AnnouncerImageUrl, true);
                 }
             }
             else
             {
                 ChatManager.serverSendMessage(Plugin.Inst.Translate("mathquiz_invalid_parameter"), UnturnedChat.GetColorFromName(Plugin.Conf.MessageColor, Color.yellow), null,
                                               ((UnturnedPlayer)caller).SteamPlayer(), EChatMode.SAY, Plugin.Conf.AnnouncerImageUrl, true);
             }
         }
     }
     catch (Exception err)
     {
         Logger.LogError("[RFMathQuiz] Error: " + err);
     }
 }
        private void ExecuteFeatures(RocketPlayer player, Package features, string itemName, bool wasAlready)
        {
            if (features.Commands != null && features.Commands.Length > 0)
            {
                foreach (var command in features.Commands)
                {
                    R.Commands.Execute(new ConsolePlayer(), command.Replace("{steamid}", player.Id).Replace("{steamname}", player.DisplayName));
                }
            }

            if (features.AddGroups != null && features.AddGroups.Length > 0)
            {
                foreach (var group in features.AddGroups)
                {
                    R.Permissions.AddPlayerToGroup(group, player);
                }
            }

            if (features.RemoveGroups != null && features.RemoveGroups.Length > 0)
            {
                foreach (var group in features.RemoveGroups)
                {
                    R.Permissions.RemovePlayerFromGroup(group, player);
                }
            }

            if (features.UconomyMoney > 0)
            {
                if (pluginInstance.Configuration.Instance.PayUconomyMoneyOnce && wasAlready)
                {
                    Logger.LogWarning("Uconomy money was already paid, skipping.");
                }
                else
                {
                    if (RocketPlugin.IsDependencyLoaded("Uconomy"))
                    {
                        // using helper to avoid depdency error message in case uconomy not installed
                        UconomyHelper.PayMoney(player.Id, features.UconomyMoney);
                    }
                    else
                    {
                        Logger.LogWarning($"Failed to pay {features.UconomyMoney} money to {player.DisplayName} {player.Id}, because Uconomy is not installed");
                    }
                }
            }

            if (!features.DisableBroadcast && player.DisplayName != null)
            {
                UnturnedChat.Say(pluginInstance.Translate("PurchaseBroadcast", player.DisplayName, itemName), pluginInstance.MessageColor);
            }
        }
 internal MultiLangTranslator(RocketPlugin plugin) : this(plugin.Directory, plugin.Name)
 {
 }
Пример #6
0
        public static void GiveReward(UnturnedPlayer player, string serviceName)
        {
            int    sum             = Plugin.VoteRewardsPlugin.Instance.Configuration.Instance.Rewards.Sum(p => p.Chance);
            string selectedElement = null;
            string value           = null;

            System.Random r = new System.Random();

            int i = 0, diceRoll = r.Next(0, sum);

            foreach (var reward in Plugin.VoteRewardsPlugin.Instance.Configuration.Instance.Rewards)
            {
                if (diceRoll > i && diceRoll <= i + reward.Chance)
                {
                    selectedElement = reward.Type;
                    value           = reward.Value;
                    break;
                }
                i = i + reward.Chance;
            }

            if (selectedElement == null || value == null)
            {
                UnturnedChat.Say(player, "The admin hasn't setup rewards yet.", Color.red);
                return;
            }

            // Rewards
            if (selectedElement == "item" || selectedElement == "i")
            {
                List <string> items = value.Split(',').ToList();
                foreach (string item in items)
                {
                    ushort itemID = ushort.Parse(item);

                    player.Inventory.tryAddItem(new Item(itemID, true), true);
                }

                UnturnedChat.Say(player, Plugin.VoteRewardsPlugin.Instance.Translate("reward", "some items"));
            }
            else if (selectedElement == "xp" || selectedElement == "exp")
            {
                player.Experience += uint.Parse(value);

                UnturnedChat.Say(player, Plugin.VoteRewardsPlugin.Instance.Translate("reward", value + " xp"));
            }
            else if (selectedElement == "group" || selectedElement == "permission")
            {
                R.Permissions.AddPlayerToGroup(value, player);
                R.Permissions.Reload();

                UnturnedChat.Say(player, Plugin.VoteRewardsPlugin.Instance.Translate("reward", value + " Permission Group"));
            }
            else if (selectedElement == "uconomy" || selectedElement == "money")
            {
                if (Plugin.VoteRewardsPlugin.Uconomy)
                {
                    RocketPlugin.ExecuteDependencyCode("Uconomy", (IRocketPlugin plugin) =>
                    {
                        Uconomy.Instance.Database.IncreaseBalance(player.CSteamID.ToString(), decimal.Parse(value));

                        UnturnedChat.Say(player, Plugin.VoteRewardsPlugin.Instance.Translate("reward", value + " Uconomy " + Uconomy.Instance.Configuration.Instance.MoneyName + "s"));
                    });
                }
            }
            else if (selectedElement == "slot" || selectedElement.Contains("customkit"))
            {
                if (Plugin.VoteRewardsPlugin.CustomKits)
                {
                    RocketPlugin.ExecuteDependencyCode("CustomKits", (IRocketPlugin plugin) =>
                    {
                        SlotManager.AddSlot(player, 1, int.Parse(value));

                        UnturnedChat.Say(player, Plugin.VoteRewardsPlugin.Instance.Translate("reward", "a CustomKits slot with item limit of " + value));
                    });
                }
            }

            // Optional global announcement
            if (Plugin.VoteRewardsPlugin.Instance.Configuration.Instance.GlobalAnnouncement)
            {
                foreach (SteamPlayer sP in Provider.clients)
                {
                    var p = sP.playerID.steamID;
                    if (p != player.CSteamID)
                    {
                        ChatManager.say(p, Plugin.VoteRewardsPlugin.Instance.Translate("reward_announcement", player.CharacterName, serviceName), Color.green, EChatMode.GLOBAL);
                    }
                }
            }
        }
Пример #7
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            if (command.Length == 0)
            {
                UnturnedChat.Say(caller, "Rocket v" + Assembly.GetExecutingAssembly().GetName().Version + " for Unturned v" + Provider.Version);
                UnturnedChat.Say(caller, "https://rocket.foundation - 2015");
                return;
            }

            if (command.Length == 1)
            {
                switch (command[0].ToLower())
                {
                case "plugins":
                    if (caller != null && !caller.HasPermission("rocket.plugins"))
                    {
                        return;
                    }
                    List <IRocketPlugin> plugins = R.Plugins.GetPlugins();
                    UnturnedChat.Say(caller, U.Translate("command_rocket_plugins_loaded", String.Join(", ", plugins.Where(p => p.State == PluginState.Loaded).Select(p => p.GetType().Assembly.GetName().Name).ToArray())));
                    UnturnedChat.Say(caller, U.Translate("command_rocket_plugins_unloaded", String.Join(", ", plugins.Where(p => p.State == PluginState.Unloaded).Select(p => p.GetType().Assembly.GetName().Name).ToArray())));
                    UnturnedChat.Say(caller, U.Translate("command_rocket_plugins_failure", String.Join(", ", plugins.Where(p => p.State == PluginState.Failure).Select(p => p.GetType().Assembly.GetName().Name).ToArray())));
                    UnturnedChat.Say(caller, U.Translate("command_rocket_plugins_cancelled", String.Join(", ", plugins.Where(p => p.State == PluginState.Cancelled).Select(p => p.GetType().Assembly.GetName().Name).ToArray())));
                    break;

                case "reload":
                    if (caller != null && !caller.HasPermission("rocket.reload"))
                    {
                        return;
                    }
                    UnturnedChat.Say(caller, U.Translate("command_rocket_reload"));
                    R.Reload();
                    break;
                }
            }

            if (command.Length == 2)
            {
                RocketPlugin p = (RocketPlugin)R.Plugins.GetPlugins().Where(pl => pl.Name.ToLower().Contains(command[1].ToLower())).FirstOrDefault();
                if (p != null)
                {
                    switch (command[0].ToLower())
                    {
                    case "reload":
                        if (caller != null && !caller.HasPermission("rocket.reloadplugin"))
                        {
                            return;
                        }
                        if (p.State == PluginState.Loaded)
                        {
                            UnturnedChat.Say(caller, U.Translate("command_rocket_reload_plugin", p.GetType().Assembly.GetName().Name));
                            p.ReloadPlugin();
                        }
                        else
                        {
                            UnturnedChat.Say(caller, U.Translate("command_rocket_not_loaded", p.GetType().Assembly.GetName().Name));
                        }
                        break;

                    case "unload":
                        if (caller != null && !caller.HasPermission("rocket.unloadplugin"))
                        {
                            return;
                        }
                        if (p.State == PluginState.Loaded)
                        {
                            UnturnedChat.Say(caller, U.Translate("command_rocket_unload_plugin", p.GetType().Assembly.GetName().Name));
                            p.UnloadPlugin();
                        }
                        else
                        {
                            UnturnedChat.Say(caller, U.Translate("command_rocket_not_loaded", p.GetType().Assembly.GetName().Name));
                        }
                        break;

                    case "load":
                        if (caller != null && !caller.HasPermission("rocket.loadplugin"))
                        {
                            return;
                        }
                        if (p.State != PluginState.Loaded)
                        {
                            UnturnedChat.Say(caller, U.Translate("command_rocket_load_plugin", p.GetType().Assembly.GetName().Name));
                            p.LoadPlugin();
                        }
                        else
                        {
                            UnturnedChat.Say(caller, U.Translate("command_rocket_already_loaded", p.GetType().Assembly.GetName().Name));
                        }
                        break;
                    }
                }
                else
                {
                    UnturnedChat.Say(caller, U.Translate("command_rocket_plugin_not_found", command[1]));
                }
            }
        }
Пример #8
0
 public FireworksPlugin()
 {
     Instance = (RocketPlugin)this;
 }
Пример #9
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            if (command.Length == 0)
            {
                UnturnedChat.Say(caller, "Rocket v" + Assembly.GetExecutingAssembly().GetName().Version + " for Unturned v" + Provider.APP_VERSION);
                UnturnedChat.Say(caller, "https://rocketmod.net - 2017");
                return;
            }

            if (command.Length == 1)
            {
                switch (command[0].ToLower())
                {
                case "plugins":
                    if (caller != null && !caller.HasPermission("rocket.plugins"))
                    {
                        return;
                    }
                    List <IRocketPlugin> plugins   = R.Plugins.GetPlugins();
                    List <string>        loaded    = new List <string>();
                    List <string>        unloaded  = new List <string>();
                    List <string>        failure   = new List <string>();
                    List <string>        cancelled = new List <string>();
                    foreach (var p in plugins)
                    {
                        var st = p.GetType().Assembly.GetName().Name;
                        switch (p.State)
                        {
                        case PluginState.Loaded:
                            loaded.Add(st);
                            break;

                        case PluginState.Unloaded:
                            unloaded.Add(st);
                            break;

                        case PluginState.Failure:
                            failure.Add(st);
                            break;

                        case PluginState.Cancelled:
                            cancelled.Add(st);
                            break;
                        }
                    }
                    UnturnedChat.Say(caller, U.Translate("command_rocket_plugins_loaded", string.Join(", ", loaded.ToArray())));
                    UnturnedChat.Say(caller, U.Translate("command_rocket_plugins_unloaded", string.Join(", ", unloaded.ToArray())));
                    UnturnedChat.Say(caller, U.Translate("command_rocket_plugins_failure", string.Join(", ", failure.ToArray())));
                    UnturnedChat.Say(caller, U.Translate("command_rocket_plugins_cancelled", string.Join(", ", cancelled.ToArray())));
                    break;

                case "reload":
                    if (caller != null && !caller.HasPermission("rocket.reload"))
                    {
                        return;
                    }
                    UnturnedChat.Say(caller, U.Translate("command_rocket_reload"));
                    R.Reload();
                    break;
                }
            }

            if (command.Length == 2)
            {
                foreach (var pl in R.Plugins.GetPlugins())
                {
                    if (pl.Name.IndexOf(command[1], StringComparison.OrdinalIgnoreCase) == -1)
                    {
                        continue;
                    }
                    RocketPlugin p    = (RocketPlugin)pl;
                    var          name = p.GetType().Assembly.GetName().Name;
                    switch (command[0].ToLower())
                    {
                    case "reload":
                        if (caller != null && !caller.HasPermission("rocket.reloadplugin"))
                        {
                            return;
                        }
                        if (p.State == PluginState.Loaded)
                        {
                            UnturnedChat.Say(caller, U.Translate("command_rocket_reload_plugin", name));
                            p.ReloadPlugin();
                        }
                        else
                        {
                            UnturnedChat.Say(caller, U.Translate("command_rocket_not_loaded", name));
                        }
                        break;

                    case "unload":
                        if (caller != null && !caller.HasPermission("rocket.unloadplugin"))
                        {
                            return;
                        }
                        if (p.State == PluginState.Loaded)
                        {
                            UnturnedChat.Say(caller, U.Translate("command_rocket_unload_plugin", name));
                            p.UnloadPlugin();
                        }
                        else
                        {
                            UnturnedChat.Say(caller, U.Translate("command_rocket_not_loaded", name));
                        }
                        break;

                    case "load":
                        if (caller != null && !caller.HasPermission("rocket.loadplugin"))
                        {
                            return;
                        }
                        if (p.State != PluginState.Loaded)
                        {
                            UnturnedChat.Say(caller, U.Translate("command_rocket_load_plugin", name));
                            p.LoadPlugin();
                        }
                        else
                        {
                            UnturnedChat.Say(caller, U.Translate("command_rocket_already_loaded", name));
                        }
                        break;
                    }
                    return;
                }
                UnturnedChat.Say(caller, U.Translate("command_rocket_plugin_not_found", command[1]));
            }
        }
Пример #10
0
 /// <summary>
 /// Creates new instance of <see cref="MultiLangTranslator" /> for <paramref name="plugin" /> <br/>
 /// You can use <see cref="MultiLangRocketPlugin" /> for easier integration
 /// </summary>
 /// <param name="plugin"></param>
 /// <returns>Default <see cref="MultiLangTranslator"/></returns>
 public static MultiLangTranslator RegisterTranslator(RocketPlugin plugin) => new MultiLangTranslator(plugin);
Пример #11
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            if (command.Length == 0)
            {
                UnturnedChat.Say(caller, "Rocket v" + Assembly.GetExecutingAssembly().GetName().Version + " for Unturned v" + Provider.APP_VERSION);
                UnturnedChat.Say(caller, "https://rocketmod.net - 2017");
                return;
            }

            if (command.Length == 1)
            {
                switch (command[0].ToLower())
                {
                case "plugins":
                    if (caller != null && !caller.HasPermission("rocket.plugins"))
                    {
                        return;
                    }
                    List <IRocketPlugin> plugins = R.Plugins.GetPlugins();
                    UnturnedChat.Say(caller, U.Translate("command_rocket_plugins_loaded", String.Join(", ", plugins.Where(p => p.State == PluginState.Loaded).Select(p => p.GetType().Assembly.GetName().Name).ToArray())));
                    UnturnedChat.Say(caller, U.Translate("command_rocket_plugins_unloaded", String.Join(", ", plugins.Where(p => p.State == PluginState.Unloaded).Select(p => p.GetType().Assembly.GetName().Name).ToArray())));
                    UnturnedChat.Say(caller, U.Translate("command_rocket_plugins_failure", String.Join(", ", plugins.Where(p => p.State == PluginState.Failure).Select(p => p.GetType().Assembly.GetName().Name).ToArray())));
                    UnturnedChat.Say(caller, U.Translate("command_rocket_plugins_cancelled", String.Join(", ", plugins.Where(p => p.State == PluginState.Cancelled).Select(p => p.GetType().Assembly.GetName().Name).ToArray())));
                    break;

                case "reload":
                    if (caller != null && !caller.HasPermission("rocket.reload"))
                    {
                        return;
                    }
                    // Many plugins do not support reloading properly, so this command which reloaded all plugins
                    // at once has been disabled by popular request. Reloading individual plugins is still enabled.
                    // https://github.com/SmartlyDressedGames/Unturned-3.x-Community/issues/1794
                    UnturnedChat.Say(caller, U.Translate("command_rocket_reload_disabled"));
                    break;
                }
            }

            if (command.Length == 2)
            {
                RocketPlugin p = (RocketPlugin)R.Plugins.GetPlugins().Where(pl => pl.Name.ToLower().Contains(command[1].ToLower())).FirstOrDefault();
                if (p != null)
                {
                    switch (command[0].ToLower())
                    {
                    case "reload":
                        if (caller != null && !caller.HasPermission("rocket.reloadplugin"))
                        {
                            return;
                        }
                        if (p.State == PluginState.Loaded)
                        {
                            UnturnedChat.Say(caller, U.Translate("command_rocket_reload_plugin", p.GetType().Assembly.GetName().Name));
                            p.ReloadPlugin();
                        }
                        else
                        {
                            UnturnedChat.Say(caller, U.Translate("command_rocket_not_loaded", p.GetType().Assembly.GetName().Name));
                        }
                        break;

                    case "unload":
                        if (caller != null && !caller.HasPermission("rocket.unloadplugin"))
                        {
                            return;
                        }
                        if (p.State == PluginState.Loaded)
                        {
                            UnturnedChat.Say(caller, U.Translate("command_rocket_unload_plugin", p.GetType().Assembly.GetName().Name));
                            p.UnloadPlugin();
                        }
                        else
                        {
                            UnturnedChat.Say(caller, U.Translate("command_rocket_not_loaded", p.GetType().Assembly.GetName().Name));
                        }
                        break;

                    case "load":
                        if (caller != null && !caller.HasPermission("rocket.loadplugin"))
                        {
                            return;
                        }
                        if (p.State != PluginState.Loaded)
                        {
                            UnturnedChat.Say(caller, U.Translate("command_rocket_load_plugin", p.GetType().Assembly.GetName().Name));
                            p.LoadPlugin();
                        }
                        else
                        {
                            UnturnedChat.Say(caller, U.Translate("command_rocket_already_loaded", p.GetType().Assembly.GetName().Name));
                        }
                        break;
                    }
                }
                else
                {
                    UnturnedChat.Say(caller, U.Translate("command_rocket_plugin_not_found", command[1]));
                }
            }
        }