Иконка ресурса

FREE SimplePVE : 1.2.6 1.2.6

Нет прав для скачивания
C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6

/*
*  <----- End-User License Agreement ----->
*  Copyright © 2024 Iftebinjan
*  Devoloper: Iftebinjan (Contact: https://discord.gg/HFaGs8YwsH)
*  
*  You may not copy, modify, merge, publish, distribute, sublicense, or sell copies of This Software without the Developer’s consent
*  
*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
*  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
*  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
*  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
*  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
using Oxide.Core.Plugins;
using Newtonsoft.Json;
using Oxide.Game.Rust.Cui;
using UnityEngine;
using Newtonsoft.Json.Linq;
using Oxide.Core;
using System.Collections.Generic;
using System.Linq;
using Network;
using System;
using Oxide.Core.Libraries.Covalence;
using System.Globalization;
using System.IO;
using Oxide.Core.Configuration;
using Steamworks.ServerList;
using Rust;
using ProtoBuf;
using ConVar;
using Oxide.Core.Libraries;
using CompanionServer.Handlers;
using System.Runtime;
using Facepunch;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Reflection;
using System.Collections;
using Oxide.Game.Rust.Libraries;
using Facepunch.Math;
using Oxide.Plugins.SimplePVEExtensionMethods;
using Rust.Ai.Gen2;
namespace Oxide.Plugins {
    [Info("SimplePVE", "Ifte", "1.2.6")]
    [Description("An easy simple PVE plugin for your server to modify or change PVE rules.")]
    public class SimplePVE : RustPlugin {
        /*------------------------------------
         *
         *          SimplePVE by Ifte
         *     Support: https://discord.gg/cCWadjcapr
         *     Fiverr: https://www.fiverr.com/s/e2pkYY
         *           Eror404 not found
         *
         ------------------------------------*/
        /*------------------------------------
        * 
        *   UPDATES
        * --------------
        * 1.2.0 - Latest with NewUI, Added new schedule system with weekdays support.Added config for Commands to execute when pvp purge starts and ends(Only from schedules)
        * 1.2.1 - Fixed ZombieHorde plugin, Fixed Tugboat vehicle damage, Added support for Backpack(Backpack no longer be pickup or open by other players)
        * 1.2.2 - Added new configuration, all rules configurations moved to Oxide/Data/SimplePVE/, Config values changed, Fixed DropBox & Mail not opening(More entitys option in the config)
        * 1.2.3 - Updated for latest force wipe, Added New Status UI for PVE status Zone Status Schedule Stats, New Configuration added, Fixed a bug where backpack cant be pickup after death by entity, Fixed few Zone Bugs, More bug added.* 1.2.4 - Updated for New Forced Update, Added support for FClan, Added support for codelock raid, Fixed Shark not damageing players
        * 1.2.5 - Fixed Status UI, Fixed APIs Not Calling, Working APIs(IsServerPVE, GetPVPStartTimeRemaining, GetPVPEndTimeRemaining, AddToExcludeZone, RemoveFromExcludeZone, IsStatusEnabled_API), 
        * 1.2.6 - Update for recent force wipe, Fixed for new wolf ai and wolf damage
        * 
        *   BUGS
        * ---------
        * Updates coming in
        * 
        ------------------------------------*/
#region Varriables
        [PluginReference]
        Plugin ZoneManager, ImageLibrary, Clans, Friends, RaidableBases, Convoy, HeliSignals, AbandonedBases, FClan;
        private static SimplePVE ins;
        private Configuration config;
        private ScheduleSave savedSch;
        private bool update = true;
        private bool PVPRun = false;
        private bool ChangedConfig = false;
        private bool DiscordMessageSent = false;
        private bool UsingStatusUI = false;
        private Dictionary<ulong, PVPDelay> pvp_delays = new Dictionary<ulong, PVPDelay>();
        enum PVERules {
            GRules, PRules, NRules, ERules, LRules, ZRules
        }
        private class PVPDelay {
            public string ZoneID;
            public Timer DelayTimer;
        }
        //permissions
        private const string PvEAdminPerms = "simplepve.admin";
        private const string PvEAdminLootPerms = "simplepve.adminloot";
        private const string PvEAdminDamagePerms = "simplepve.admindamage";
#endregion
#region Configs
        private class Configuration {
            [JsonProperty(PropertyName = "PVE Enabled")]
            public bool pveEnabledConfig {
                get;
                set;
            }
            public class PVPDelayNotify {
                [JsonProperty("PVP delay time in seconds(If enabled from ZoneRules)")]
                public int pvpdelaytime {
                    get;
                    set;
                }
                [JsonProperty("Show PVP Delay Message")]
                public bool pvpDelayMsgEnabled {
                    get;
                    set;
                }
                [JsonProperty("PVP Delay Message")]
                public string pvpDelayMessage {
                    get;
                    set;
                }
            }
            [JsonProperty(PropertyName = "Notifications")]
            public DisplayNotify displayNotify {
                get;
                set;
            }
            public class DisplayNotify {
                [JsonProperty("Prefix")]
                public string prefix {
                    get;
                    set;
                }
                [JsonProperty("Chat Avatar")]
                public ulong chatAvatar {
                    get;
                    set;
                }
                [JsonProperty("Show PVE Icon Overlay")]
                public bool showPvEOverlay {
                    get;
                    set;
                }
                [JsonProperty("Show PVE Warning Messages")]
                public bool showDamageM {
                    get;
                    set;
                }
                [JsonProperty("PVE Warning Type(Chat/UI/Both)")]
                public string showDamageMType {
                    get;
                    set;
                }
                [JsonProperty("PVE Warning Chat Message")]
                public string showDamageMTypeMessage {
                    get;
                    set;
                }
                [JsonProperty("PVE Warning UI Settings")]
                public WarningUI warningUI {
                    get;
                    set;
                }
                public class WarningUI {
                    [JsonProperty("Anchor Min")]
                    public string WarningAMin {
                        get;
                        set;
                    }
                    [JsonProperty("Anchor Max")]
                    public string WarningAMax {
                        get;
                        set;
                    }
                    [JsonProperty("Warning Image URL")]
                    public string WarningImgUrl {
                        get;
                        set;
                    }
                }
                [JsonProperty("Show Loot Protection Messages")]
                public bool LPMessagesOn {
                    get;
                    set;
                }
                [JsonProperty("Loot Protection Type(Chat/UI/Both)")]
                public string LPType {
                    get;
                    set;
                }
                [JsonProperty("Loot Protection Chat Message")]
                public string LPChatMessage {
                    get;
                    set;
                }
                [JsonProperty("Loot Protection UI Settings")]
                public LPUISetting lPUISetting {
                    get;
                    set;
                }
                public class LPUISetting {
                    [JsonProperty("Anchor Min")]
                    public string WarningAMin {
                        get;
                        set;
                    }
                    [JsonProperty("Anchor Max")]
                    public string WarningAMax {
                        get;
                        set;
                    }
                    [JsonProperty("Warning Loot UI Image URL")]
                    public string WarningImgUrl {
                        get;
                        set;
                    }
                }
                [JsonProperty("PVE/PVP Icon UI Settings")]
                public PEPUISetting pUISetting {
                    get;
                    set;
                }
                public class PEPUISetting {
                    [JsonProperty("Anchor Min")]
                    public string pepAMin {
                        get;
                        set;
                    }
                    [JsonProperty("Anchor Max")]
                    public string pepAMax {
                        get;
                        set;
                    }
                    [JsonProperty("Offset Min")]
                    public string pepOMin {
                        get;
                        set;
                    }
                    [JsonProperty("Offset Max")]
                    public string pepOMax {
                        get;
                        set;
                    }
                }
            }
            [JsonProperty(PropertyName = "Loot Protection Excluded Entitys", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public List<string> excludedEntitys {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Schedules Setting")]
            public Sche sche {
                get;
                set;
            }
            public class Sche {
                [JsonProperty("UTC Time Difference")]
                public int utcTimeDif {
                    get;
                    set;
                }
                [JsonProperty("Enable Weekly Schedule Only")]
                public bool enableweeklysch {
                    get;
                    set;
                }
                [JsonProperty("PVP On Notify Message")]
                public string pvpOnMessage {
                    get;
                    set;
                }
                [JsonProperty("PVE On Notify Message")]
                public string pveOnMessage {
                    get;
                    set;
                }
                [JsonProperty("PVP Purge Start Before Message")]
                public string pvppurgeStartMsg {
                    get;
                    set;
                }
                [JsonProperty("PVP Purge Ending Before Message")]
                public string pvppurgeEndingMsg {
                    get;
                    set;
                }
            }
            [JsonProperty(PropertyName = "PVP Delay Setting")]
            public PVPDelayNotify delaySetting {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Discord Setting")]
            public DiscordSetting discordSetting {
                get;
                set;
            }
            public class DiscordSetting {
                [JsonProperty("Enable Discord Notification")]
                public bool enableDiscordNotify {
                    get;
                    set;
                }
                [JsonProperty("Discord Webhook URL")]
                public string discordWebhookURL {
                    get;
                    set;
                }
                [JsonProperty("Enable Message Before PVP Time Start")]
                public bool messageBeforeStart {
                    get;
                    set;
                }
                [JsonProperty("Before PVP Time Start Minutes")]
                public int messageBeforeStartMinutes {
                    get;
                    set;
                }
                [JsonProperty("PVP Message Embed Color(Hexa)")]
                public string pvpmessageEmbed {
                    get;
                    set;
                }
                [JsonProperty("Before PVP Time Start Message Content")]
                public string[] pvpTimeMessage {
                    get;
                    set;
                }
                [JsonProperty("Enable Message Before PVE Time Start")]
                public bool messageBeforeStartPVE {
                    get;
                    set;
                }
                [JsonProperty("Before PVE Time Start Minutes")]
                public int messageBeforeStartMinutesPVE {
                    get;
                    set;
                }
                [JsonProperty("PVE Message Embed Color")]
                public string pvemessageEmbed {
                    get;
                    set;
                }
                [JsonProperty("Before PVE Time Start Message Content")]
                public string[] pveTimeMessage {
                    get;
                    set;
                }
            }
            [JsonProperty(PropertyName = "Commands when PVP Purge Starts")]
            public List<string> commandsExefrompvpstart {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Commands when PVP Purge Ends")]
            public List<string> commandsExefrompvpends {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Exclude Zone IDs From Rules")]
            public List<string> excludedZoneIDs {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Status UI")]
            public StatusUI statusUI {
                get;
                set;
            }
            public class StatusUI {
                [JsonProperty(PropertyName = "Enable Status")]
                public bool status {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Interval Time In Seconds")]
                public int interval {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "PVE/PVP Status")]
                public PVPorPVEStatus peStatus {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Zone Status")]
                public ZoneStatus zoneStatus {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Purge Schedule Status")]
                public PurgeStatus purgeStatus {
                    get;
                    set;
                }
            }
            public class PVPorPVEStatus {
                [JsonProperty(PropertyName = "Status Enable")]
                public bool status {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "PVE Status")]
                public Setting PVEStatus {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "PVP Status")]
                public Setting PVPStatus {
                    get;
                    set;
                }
            }
            public class ZoneStatus {
                [JsonProperty(PropertyName = "Status Enable")]
                public bool status {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "In PVP Area Status")]
                public Setting pvparea {
                    get;
                    set;
                }
            }
            public class PurgeStatus {
                [JsonProperty(PropertyName = "Status Enable")]
                public bool status {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Purge PVP Status")]
                public Setting purgepvpStatus {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Purge PVE Status")]
                public Setting purgepveStatus {
                    get;
                    set;
                }
            }
            public class Setting {
                [JsonProperty(PropertyName = "Enable Status")]
                public bool status {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Text List")]
                public string[] strings {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Text Color")]
                public string textColor {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Icon Image Url")]
                public string icon {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Icon Image Color")]
                public string iconColor {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Status Color")]
                public string statusColor {
                    get;
                    set;
                }
            }
            [JsonProperty(PropertyName = "Config Version (Don't Edit This)")]
            public string version {
                get;
                set;
            }
            public static Configuration CreateConfig() {
                return new Configuration {
                    pveEnabledConfig = true, displayNotify = new DisplayNotify {
                        showDamageM = true, prefix = "<color=#00ffff>[SimplePVE]</color>: ", chatAvatar = 0, showDamageMType = "Both", showDamageMTypeMessage = "PVE enabled on this server, blocking damage.", warningUI = new DisplayNotify.WarningUI {
                            WarningAMin = "0.786 0.722", WarningAMax = "0.99 0.815", WarningImgUrl = "https://i.postimg.cc/0jZNDr9x/Add-a-subheading-2.png"
                        }
                        , showPvEOverlay = true, LPMessagesOn = true, LPType = "Both", LPChatMessage = "This entity is protected!", lPUISetting = new DisplayNotify.LPUISetting {
                            WarningAMin = "0.786 0.722", WarningAMax = "0.99 0.815", WarningImgUrl = "https://i.postimg.cc/SxSsS67s/Add-a-subheading-1.png"
                        }
                        , pUISetting = new DisplayNotify.PEPUISetting {
                            pepAMin = "0.5 0", pepAMax = "0.5 0", pepOMin = "190 30", pepOMax = "250 60"
                        }
                    }
                    , statusUI = new StatusUI() {
                        status = true, interval = 1, peStatus = new PVPorPVEStatus() {
                            status = true, PVEStatus = new Setting() {
                                status = true, strings = new string[] {
                                    "PVE ENABLED", "RAID IS DISABLED", "PVP IS DISABLED",
                                }
                                , textColor = "#FFFFFF", icon = "https://i.postimg.cc/4ymwFnSC/quality.png", iconColor = "#A4FE0A", statusColor = "#718D48"
                            }
                            , PVPStatus = new Setting() {
                                status = true, strings = new string[] {
                                    "PVP ENABLED", "RAID IS ENABLED", "PVE IS DISABLED", "PVP IS ENABLED",
                                }
                                , textColor = "#FFFFFF", icon = "https://i.postimg.cc/50YVChxW/human-skull-with-crossed-bones-silhouette.png", iconColor = "#FFFFFF", statusColor = "#B22222"
                            }
                        }
                        , zoneStatus = new ZoneStatus() {
                            status = true, pvparea = new Setting() {
                                status = true, strings = new string[] {
                                    "YOU'RE IN THE PVP ZONE"
                                }
                                , textColor = "#FFFFFF", icon = "https://i.postimg.cc/qRGxrMBR/fighting-game.png", iconColor = "#FFFFFF", statusColor = "#A30000"
                            }
                        }
                        , purgeStatus = new PurgeStatus() {
                            status = true, purgepvpStatus = new Setting() {
                                status = true, strings = new string[] {
                                    "PVP ENABLEING IN {TIMER}", "RAID ENABLEING IN {TIMER}", "PVP PURGING IN {TIMER}"
                                }
                                , textColor = "#FFFFFF", icon = "https://i.postimg.cc/0j2n3rzp/time.png", iconColor = "#FFFFFF", statusColor = "#A30000"
                            }
                            , purgepveStatus = new Setting() {
                                status = true, strings = new string[] {
                                    "PVE ENABLING IN {TIMER}", "RAID DISABLEING IN {TIMER}", "PVE PURGING IN {TIMER}"
                                }
                                , textColor = "#FFFFFF", icon = "https://i.postimg.cc/rydRF7cc/time.png", iconColor = "#FFFFFF", statusColor = "#718D48"
                            }
                        }
                    }
                    , excludedEntitys = new List<string>() {
                        "mailbox.deployed", "dropbox.deployed"
                    }
                    , sche = new Sche {
                        utcTimeDif = 360, enableweeklysch = true, pvpOnMessage = "<#990000>PVP enabled on the server.Now you can raid others bases and fight!</color>", pveOnMessage = "<#008000>PVE enabled.Raid and fight is now prohibited!</color>", pvppurgeStartMsg = "PVP time is approaching! {TIMELEFT} minutes left.", pvppurgeEndingMsg = "PVP time is ending! {TIMELEFT} minutes left.",
                    }
                    , delaySetting = new PVPDelayNotify {
                        pvpdelaytime = 10, pvpDelayMsgEnabled = true, pvpDelayMessage = "You will be removed from PVP state in <color=#DC143C>{delay}</color> seconds.",
                    }
                    , discordSetting = new DiscordSetting {
                        enableDiscordNotify = false, discordWebhookURL = string.Empty, messageBeforeStart = false, messageBeforeStartMinutes = 30, pvpmessageEmbed = "#990000", pvpTimeMessage = new string[] {
                            "🔔 **Attention Rust Survivors!**", "", "PVP purge approaching!", "In {Minutes} Minutes🕒", "", "Prepare yourselves for intense battles! ⚔️",
                        }
                        , messageBeforeStartPVE = false, messageBeforeStartMinutesPVE = 30, pvemessageEmbed = "#32CD32", pveTimeMessage = new string[] {
                            "🔔 **Attention Rust Survivors!**", "", "PVP purge ending soon!", "In {Minutes} Minutes🕒", "", "Make your final moves wisely!", "Collect your victories and gear up for the next day!"
                        }
                    }
                    , commandsExefrompvpstart = new List<string> {
                    }
                    , commandsExefrompvpends = new List<string> {
                    }
                    , excludedZoneIDs = new List<string> {
                        "999", "6969"
                    }
                    , version = "1.2.5",
                }
                ;
            }
        }
        protected override void LoadConfig() {
            base.LoadConfig();
            config = Config.ReadObject<Configuration>();
            string currentVersion = "1.2.6";
            // Update this to your current plugin version
            if (config.version != currentVersion) {
                // Backup old configuration
                Puts("Config version updated.Backing up old config.");
                BackupOldConfig();
                // Load default config for the new version
                //config = Configuration.CreateConfig();
                config.version = currentVersion;
                SaveConfig();
            }
        }
        protected override void LoadDefaultConfig() {
            config = Configuration.CreateConfig();
        }
        protected override void SaveConfig() {
            Config.WriteObject(config, true);
        }
        private void BackupOldConfig() {
            string backupFileName = $"{Name}_config_backup_ver{config.version}_{Time:yyyy-MM-dd_HH-mm-ss}.json";
            string backupFilePath = Path.Combine(Interface.Oxide.ConfigDirectory, backupFileName);
            Config.WriteObject(config, false, backupFilePath);
        }
#endregion
#region Data files
        private RulesData rulesData;
        private void LoadRulesData() {
            rulesData = Interface.Oxide.DataFileSystem.ReadObject<RulesData>($"{Name}/RulesData");
            // If rulesData is null or empty, populate it with default rules
            if (rulesData == null || rulesData.IsRulesDataEmpty(rulesData)) {
                rulesData = RulesData.CreateDefaultRules();
                SaveRulesData();
            }
        }
        private void SaveRulesData() {
            Interface.Oxide.DataFileSystem.WriteObject($"{Name}/RulesData", rulesData);
        }
        private class RulesData {
            [JsonProperty(PropertyName = "General Rules")]
            public GRules gRules {
                get;
                set;
            }
            public class GRules {
                [JsonProperty("Allow Friendly Fire")]
                public bool aFriendlyFire {
                    get;
                    set;
                }
                [JsonProperty("Allow Suicide")]
                public bool allowSuicide {
                    get;
                    set;
                }
                [JsonProperty("Kill Sleepers")]
                public bool killSleepers {
                    get;
                    set;
                }
                [JsonProperty("Player Radiation Damage")]
                public bool pRadiation {
                    get;
                    set;
                }
                [JsonProperty("Allow Codelock Raid")]
                public bool aCodelockRaid {
                    get;
                    set;
                }
            }
            [JsonProperty(PropertyName = "Player Rules")]
            public PlayerRules playerRules {
                get;
                set;
            }
            public class PlayerRules {
                [JsonProperty("Player Can Hurt Players")]
                public bool pCanHurtp {
                    get;
                    set;
                }
                [JsonProperty("Player Can Hurt Animals")]
                public bool pCanHurta {
                    get;
                    set;
                }
                [JsonProperty("Player Can Hurt NPC")]
                public bool pCanHurtn {
                    get;
                    set;
                }
                [JsonProperty("Player Can Damage(Helicopters, Vehicles)")]
                public bool pCanDamEntitys {
                    get;
                    set;
                }
                [JsonProperty("Player Can Damage Other Player Buildings")]
                public bool pCanDamOtherpBuildings {
                    get;
                    set;
                }
                [JsonProperty("Player Can Damage Own Buildings")]
                public bool pCanDamageOwnBuildings {
                    get;
                    set;
                }
                [JsonProperty("Player Can Damage Own Teammates Building")]
                public bool pCanDamOwnTeamamtesBuilding {
                    get;
                    set;
                }
                [JsonProperty("Player Can Damage Other Player Twigs")]
                public bool PallowTwigDamage {
                    get;
                    set;
                }
            }
            [JsonProperty(PropertyName = "Npc Rules")]
            public NpcRules npcRules {
                get;
                set;
            }
            public class NpcRules {
                [JsonProperty("Npc Can Hurt Players")]
                public bool NpcHurtP {
                    get;
                    set;
                }
                [JsonProperty("Animal Can Hurt Players")]
                public bool AnimalCanHurtP {
                    get;
                    set;
                }
                [JsonProperty("Patrol Heli Can Hurt Player")]
                public bool PatrolHurtP {
                    get;
                    set;
                }
                [JsonProperty("Patrol Heli Can Hurt Buildings")]
                public bool PatrolHurtB {
                    get;
                    set;
                }
                [JsonProperty("Player SamSite Ignore Players")]
                public bool PSamigP {
                    get;
                    set;
                }
                [JsonProperty("Npc SamSite Ignore Players")]
                public bool NSamigP {
                    get;
                    set;
                }
                [JsonProperty("Bradley Can Hurt Players")]
                public bool bradleyHurtP {
                    get;
                    set;
                }
            }
            [JsonProperty(PropertyName = "Entity Rules")]
            public EntityRules entityRules {
                get;
                set;
            }
            public class EntityRules {
                [JsonProperty("Walls Entitys Can Hurt Players(Example: High External Wall)")]
                public bool WallHurtP {
                    get;
                    set;
                }
                [JsonProperty("Barricade Entitys Can Hurt Players(Example: Wooden Barricade)")]
                public bool BarrHurtP {
                    get;
                    set;
                }
                [JsonProperty("MLRS Rocket Can Damage Players or Buildings")]
                public bool MlrsHurtPB {
                    get;
                    set;
                }
                [JsonProperty("Vehicle Entitys Can Hurt Players(Example: Cars, Mini, ScrapHeli)")]
                public bool VehicleHurtP {
                    get;
                    set;
                }
                [JsonProperty("Disable Traps(BearTrap, LandMine, GunTrap, FlameTurret, AutoTurret)")]
                public bool trapD {
                    get;
                    set;
                }
                [JsonProperty("Enable Vehicle Collsion Damage")]
                public bool enableVehicleCollsionD {
                    get;
                    set;
                }
            }
            [JsonProperty(PropertyName = "Loot Rules")]
            public LootRules lootRules {
                get;
                set;
            }
            public class LootRules {
                [JsonProperty("Use Loot Protection")]
                public bool useLP {
                    get;
                    set;
                }
                [JsonProperty("Admin Can Loot All")]
                public bool adminCanLootAll {
                    get;
                    set;
                }
                [JsonProperty("Teams Can Access Loot")]
                public bool teamsAccessLoot {
                    get;
                    set;
                }
                [JsonProperty("Player can loot other player in PVP Zones")]
                public bool pclpvpzones {
                    get;
                    set;
                }
                [JsonProperty("Anyone can open Player called SupplyDrops")]
                public bool anyoneOpenSupplyDrop {
                    get;
                    set;
                }
            }
            [JsonProperty(PropertyName = "Zone Rules")]
            public ZoneRules zoneRules {
                get;
                set;
            }
            public class ZoneRules {
                [JsonProperty("Use ZoneManager")]
                public bool zoneManager {
                    get;
                    set;
                }
                [JsonProperty("Disable PVE Rules In Zones")]
                public bool disableRulesZone {
                    get;
                    set;
                }
                [JsonProperty("Enable PVP Delay from ZoneManager")]
                public bool enablePVPDelay {
                    get;
                    set;
                }
            }
            public static RulesData CreateDefaultRules() {
                return new RulesData {
                    zoneRules = new ZoneRules {
                        zoneManager = true, disableRulesZone = true, enablePVPDelay = true,
                    }
                    , gRules = new GRules {
                        aFriendlyFire = true, allowSuicide = true, killSleepers = false, pRadiation = true, aCodelockRaid = false,
                    }
                    , playerRules = new PlayerRules {
                        pCanHurtp = false, pCanHurta = true, pCanHurtn = true, pCanDamEntitys = true, pCanDamOtherpBuildings = false, pCanDamageOwnBuildings = true, pCanDamOwnTeamamtesBuilding = true, PallowTwigDamage = true,
                    }
                    , npcRules = new NpcRules {
                        NpcHurtP = true, AnimalCanHurtP = true, PatrolHurtP = true, PatrolHurtB = true, PSamigP = true, NSamigP = true, bradleyHurtP = true
                    }
                    , entityRules = new EntityRules {
                        WallHurtP = true, BarrHurtP = true, MlrsHurtPB = false, VehicleHurtP = false, trapD = true, enableVehicleCollsionD = true,
                    }
                    , lootRules = new LootRules {
                        useLP = true, adminCanLootAll = true, teamsAccessLoot = true, pclpvpzones = false, anyoneOpenSupplyDrop = false
                    }
                    ,
                }
                ;
            }
            public bool IsRulesDataEmpty(RulesData data) {
                return data.gRules == null && data.playerRules == null && data.npcRules == null && data.entityRules == null && data.lootRules == null && data.zoneRules == null;
            }
        }
#endregion
#region Commands Pack
        [Command("simplepve")]
        private void CommandEnable(IPlayer p, string cmd, string[] args) {
            if (!p.HasPermission(PvEAdminPerms)) {
                p.Message("You don't have permission to use this command.");
                return;
            }
            if (args.Length == 0) {
                p.Message("Usage: /simplepve <on|off>");
                return;
            }
            bool enablePVE = false;
            switch (args[0].ToLower()) {
                case "on" : enablePVE = true;
                break;
                case "off" : enablePVE = false;
                break;
                default : p.Message("Invalid argument.Usage: /simplepve <on|off>");
                return;
            }
            if (config.pveEnabledConfig == enablePVE) {
                p.Message($"SimplePVE is already {(enablePVE ? "enabled" : "disabled")}.");
                return;
            }
            config.pveEnabledConfig = enablePVE;
            SaveConfig();
            string message = config.pveEnabledConfig ? "SimplePVE enabled" : "SimplePVE disabled";
            p.Message(message);
            if (config.pveEnabledConfig) {
                Subscribe();
            }
            else {
                NotSubscribe();
            }
            foreach (var player in BasePlayer.activePlayerList) {
                RemovePVPPanel(player);
                RemovePVEPanel(player);
                if (config.pveEnabledConfig) {
                    ShowPVEUI(player);
                }
                else {
                    ShowPVPUi(player);
                }
            }
        }
        [Command("rsp")]
        private void ReloadPlugin(IPlayer player, string cmd, string[] args) {
            if (!player.HasPermission(PvEAdminPerms)) {
                player.Message("You don't have permission to use this command.");
                return;
            }
            player.Command("oxide.reload SimplePVE");
            player.Message("SimplePVE reloaded.");
        }
        [ChatCommand("sprules")]
        private void SimplePVEGui(BasePlayer player, string cmd, string[] args) {
            if (!permission.UserHasPermission(player.UserIDString, PvEAdminPerms)) {
                player.ChatMessage("You don't have permission to use this command.");
                return;
            }
            SimplePVEMainGui(player);
            PVERulesUI(player, PVERules.GRules);
        }
        [ChatCommand("notest")]
        private void SimplePVEGuiClose(BasePlayer player, string cmd, string[] args) {
            //StatusUI(player);
        }
        [ConsoleCommand("spvecui")]
        private void SPVECUICMD(ConsoleSystem.Arg args) {
            var player = args?.Player();
            string command = args.Args[0];
            switch (command) {
                case "pverules" : PVERulesUI(player, PVERules.GRules);
                break;
                case "pveschedules" : var time = DateTime.Now;
                PVESchedules(player);
                break;
                case "grules" : PVERulesUI(player, PVERules.GRules);
                break;
                case "prules" : PVERulesUI(player, PVERules.PRules);
                break;
                case "nrules" : PVERulesUI(player, PVERules.NRules);
                break;
                case "erules" : PVERulesUI(player, PVERules.ERules);
                break;
                case "lrules" : PVERulesUI(player, PVERules.LRules);
                break;
                case "zrules" : PVERulesUI(player, PVERules.ZRules);
                break;
                case "closeall" : CuiHelper.DestroyUi(player, "SimplePVECUI");
                /*if (ChangedConfig == true)
                    {
                        Server.Command($"o.reload {Name}");
                        ChangedConfig = false;
                    }      */
                break;
            }
        }
        [ConsoleCommand("grulesSetting")]
        private void GrulesCcmd(ConsoleSystem.Arg args) {
            var player = args?.Player();
            string propertyName = args.Args[0];
            SetProperty(propertyName);
            PVERulesUI(player, PVERules.GRules);
        }
        [ConsoleCommand("prulesSetting")]
        private void PrulesCcmd(ConsoleSystem.Arg args) {
            var player = args?.Player();
            string propertyName = args.Args[0];
            SetProperty(propertyName);
            PVERulesUI(player, PVERules.PRules);
        }
        [ConsoleCommand("nrulesSetting")]
        private void NrulesCcmd(ConsoleSystem.Arg args) {
            var player = args?.Player();
            string propertyName = args.Args[0];
            SetProperty(propertyName);
            PVERulesUI(player, PVERules.NRules);
        }
        [ConsoleCommand("erulesSetting")]
        private void ErulesCcmd(ConsoleSystem.Arg args) {
            var player = args?.Player();
            string propertyName = args.Args[0];
            SetProperty(propertyName);
            PVERulesUI(player, PVERules.ERules);
        }
        [ConsoleCommand("lrulesSetting")]
        private void LrulesCcmd(ConsoleSystem.Arg args) {
            var player = args?.Player();
            string propertyName = args.Args[0];
            SetProperty(propertyName);
            PVERulesUI(player, PVERules.LRules);
        }
        [ConsoleCommand("zrulesSetting")]
        private void ZrulesCcmd(ConsoleSystem.Arg args) {
            var player = args?.Player();
            string propertyName = args.Args[0];
            SetProperty(propertyName);
            PVERulesUI(player, PVERules.ZRules);
        }
        private void SetProperty(string propertyName) {
            if (config == null) return;
            PropertyInfo gRulesProperty = typeof(RulesData.GRules).GetProperty(propertyName);
            PropertyInfo pRulesProperty = typeof(RulesData.PlayerRules).GetProperty(propertyName);
            PropertyInfo nRulesProperty = typeof(RulesData.NpcRules).GetProperty(propertyName);
            PropertyInfo eRulesProperty = typeof(RulesData.EntityRules).GetProperty(propertyName);
            PropertyInfo lRulesProperty = typeof(RulesData.LootRules).GetProperty(propertyName);
            PropertyInfo zRulesProperty = typeof(RulesData.ZoneRules).GetProperty(propertyName);
            ChangedConfig = true;
            if (gRulesProperty != null) {
                bool currentValue = (bool)gRulesProperty.GetValue(rulesData.gRules);
                bool newValue = !currentValue;
                gRulesProperty.SetValue(rulesData.gRules, newValue);
            }
            else if (pRulesProperty != null) {
                bool currentValue = (bool)pRulesProperty.GetValue(rulesData.playerRules);
                bool newValue = !currentValue;
                pRulesProperty.SetValue(rulesData.playerRules, newValue);
            }
            else if (nRulesProperty != null) {
                bool currentValue = (bool)nRulesProperty.GetValue(rulesData.npcRules);
                bool newValue = !currentValue;
                nRulesProperty.SetValue(rulesData.npcRules, newValue);
            }
            else if (eRulesProperty != null) {
                bool currentValue = (bool)eRulesProperty.GetValue(rulesData.entityRules);
                bool newValue = !currentValue;
                eRulesProperty.SetValue(rulesData.entityRules, newValue);
            }
            else if (lRulesProperty != null) {
                bool currentValue = (bool)lRulesProperty.GetValue(rulesData.lootRules);
                bool newValue = !currentValue;
                lRulesProperty.SetValue(rulesData.lootRules, newValue);
            }
            else if (zRulesProperty != null) {
                bool currentValue = (bool)zRulesProperty.GetValue(rulesData.zoneRules);
                bool newValue = !currentValue;
                zRulesProperty.SetValue(rulesData.zoneRules, newValue);
            }
        }
#endregion
#region Plugin Loads
        void Init() {
            Puts("Cleaning up...");
            Puts("Initializing rules.....");
            //permission
            permission.RegisterPermission(PvEAdminPerms, this);
            permission.RegisterPermission(PvEAdminLootPerms, this);
            permission.RegisterPermission(PvEAdminDamagePerms, this);
            //Commands
            AddCovalenceCommand("simplepve", "CommandEnable");
            AddCovalenceCommand("rsp", "ReloadPlugin");
            NotSubscribe();
        }
        private void OnServerInitialized() {
            ins = this;
            if (config.pveEnabledConfig) {
                Subscribe();
            }
            else {
                NotSubscribe();
            }
            foreach (var player in BasePlayer.activePlayerList) {
                OnPlayerConnected(player);
            }
            //Images load from ImageLibrary
            LoadImages();
            UsingStatusUI = config.statusUI.status;
            timer.In(1f, OnServerInitializedLate);
        }
        private void OnServerInitializedLate() {
            //Start Schedules
            ServerMgr.Instance.StartCoroutine(Schedules());
        }
        private void Loaded() {
            LoadSchTime();
            LoadRulesData();
        }
        private void OnServerSave() {
            SaveRulesData();
            SaveSchTime();
        }
        private void Unload() {
            SaveRulesData();
            SaveSchTime();
            DestroyStatsUIServer();
            NotSubscribe();
            foreach (var player in BasePlayer.activePlayerList) {
                RemovePVEPanel(player);
                RemovePVPPanel(player);
                RemoveUIWarning(player);
                RemoveWarningLoot(player);
                CuiHelper.DestroyUi(player, "SimplePVECUI");
                OnPlayerDisconnected(player);
            }
            update = false;
            ChangedConfig = false;
            DiscordMessageSent = false;
        }
        private void Subscribe() {
            Subscribe(nameof(OnEntitySpawned));
            Subscribe(nameof(OnEntityTakeDamage));
            if (rulesData.lootRules.useLP) {
                Subscribe(nameof(CanLootEntity));
                Subscribe(nameof(CanLootPlayer));
                Subscribe(nameof(CanAdministerVending));
                Subscribe(nameof(OnOvenToggle));
                Subscribe(nameof(CanBuild));
                Subscribe(nameof(OnRackedWeaponMount));
                Subscribe(nameof(OnRackedWeaponSwap));
                Subscribe(nameof(OnRackedWeaponTake));
                Subscribe(nameof(OnRackedWeaponUnload));
                Subscribe(nameof(OnRackedWeaponLoad));
                //new
                Subscribe(nameof(OnItemDropped));
                Subscribe(nameof(OnLootEntity));
            }
            if (rulesData.entityRules.trapD) {
                Subscribe(nameof(OnTrapTrigger));
                Subscribe(nameof(CanBeTargeted));
            }
            if (rulesData.npcRules.NSamigP || rulesData.npcRules.PSamigP) {
                Subscribe(nameof(OnSamSiteTarget));
            }
        }
        private void NotSubscribe() {
            Unsubscribe(nameof(OnEntityTakeDamage));
            Unsubscribe(nameof(CanLootEntity));
            Unsubscribe(nameof(CanLootPlayer));
            Unsubscribe(nameof(CanAdministerVending));
            Unsubscribe(nameof(OnOvenToggle));
            Unsubscribe(nameof(OnTrapTrigger));
            Unsubscribe(nameof(CanBeTargeted));
            Unsubscribe(nameof(OnSamSiteTarget));
            Unsubscribe(nameof(OnEntitySpawned));
            Unsubscribe(nameof(CanBuild));
            //Racked
            Unsubscribe(nameof(OnRackedWeaponMount));
            Unsubscribe(nameof(OnRackedWeaponSwap));
            Unsubscribe(nameof(OnRackedWeaponTake));
            Unsubscribe(nameof(On
// ... [Code preview truncated due to length. Full source in attached file] ...

Автор
15FPS
Скачиваний
0
Просмотры
1
Первый выпуск
Обновление
Оценка
0.00 звёзд 0 оценок
Сверху