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

FREE NTeleportation : 1.7.7 1.7.7

Нет прав для скачивания
C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
//#define DEBUG
using Facepunch;
using Network;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using Oxide.Core;
using Oxide.Core.Configuration;
using Oxide.Core.Libraries.Covalence;
using Oxide.Core.Plugins;
using Oxide.Game.Rust;
using Oxide.Game.Rust.Cui;
using Rust;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using UnityEngine;
namespace Oxide.Plugins {
    [Info("NTeleportation", "nivex", "1.7.7")]
    [Description("Multiple teleportation systems for admin and players")]
    class NTeleportation : RustPlugin {
        [PluginReference]
        private Plugin Clans, Economics, IQEconomic, ServerRewards, Friends, CompoundTeleport, ZoneManager, NoEscape, PopupNotifications, BlockUsers;
        private Dictionary<string, BasePlayer> _ids = new Dictionary<string, BasePlayer>();
        private Dictionary<BasePlayer, string> _players = new Dictionary<BasePlayer, string>();
        private bool newSave;
        private const string NewLine = "\n";
        private const string TPA = "tpa";
        private static readonly string[] nullArg = {
        }
        ;
        private const string PermAdmin = "nteleportation.admin";
        private const string PermRestrictions = "nteleportation.norestrictions";
        private const string ConfigDefaultPermVip = "nteleportation.vip";
        private const string PermHome = "nteleportation.home";
        private const string PermWipeHomes = "nteleportation.wipehomes";
        private const string PermCraftHome = "nteleportation.crafthome";
        private const string PermDeleteHome = "nteleportation.deletehome";
        private const string PermHomeHomes = "nteleportation.homehomes";
        private const string PermImportHomes = "nteleportation.importhomes";
        private const string PermRadiusHome = "nteleportation.radiushome";
        private const string PermCraftTpR = "nteleportation.crafttpr";
        private const string PermTpR = "nteleportation.tpr";
        private const string PermTp = "nteleportation.tp";
        private const string PermDisallowTpToMe = "nteleportation.disallowtptome";
        private const string PermTpT = "nteleportation.tpt";
        private const string PermTpB = "nteleportation.tpb";
        private const string PermTpN = "nteleportation.tpn";
        private const string PermTpL = "nteleportation.tpl";
        private const string PermTpConsole = "nteleportation.tpconsole";
        private const string PermTpRemove = "nteleportation.tpremove";
        private const string PermTpSave = "nteleportation.tpsave";
        private const string PermExempt = "nteleportation.exemptfrominterruptcountdown";
        private const string PermFoundationCheck = "nteleportation.bypassfoundationcheck";
        private const string PermTpMarker = "nteleportation.tpmarker";
        private DynamicConfigFile dataConvert;
        private DynamicConfigFile dataDisabled;
        private DynamicConfigFile dataAdmin;
        private DynamicConfigFile dataHome;
        private DynamicConfigFile dataTPR;
        private DynamicConfigFile dataTPT;
        private Dictionary<ulong, AdminData> _Admin;
        private Dictionary<ulong, HomeData> _Home;
        private Dictionary<ulong, TeleportData> _TPR;
        private Dictionary<string, List<string>> TPT = new Dictionary<string, List<string>>();
        private bool changedAdmin;
        private bool changedHome;
        private bool changedTPR;
        private bool changedTPT;
        private float boundary;
        private readonly Dictionary<ulong, float> TeleportCooldowns = new Dictionary<ulong, float>();
        private readonly Dictionary<ulong, TeleportTimer> TeleportTimers = new Dictionary<ulong, TeleportTimer>();
        private readonly Dictionary<ulong, Timer> PendingRequests = new Dictionary<ulong, Timer>();
        private readonly Dictionary<ulong, BasePlayer> PlayersRequests = new Dictionary<ulong, BasePlayer>();
        private readonly Dictionary<int, string> ReverseBlockedItems = new Dictionary<int, string>();
        private readonly Dictionary<ulong, Vector3> teleporting = new Dictionary<ulong, Vector3>();
        private SortedDictionary<string, Vector3> caves = new SortedDictionary<string, Vector3>();
        private List<MonumentInfoEx> monuments = new List<MonumentInfoEx>();
        private bool outpostEnabled;
        private bool banditEnabled;
        private class MonumentInfoEx {
            public MonumentInfo monument;
            public Vector3 position;
            public float radius;
            public string name;
            public string prefab;
            public MonumentInfoEx() {
            }
            public MonumentInfoEx(MonumentInfo monument, Vector3 position, float radius, string name, string prefab) {
                this.monument = monument;
                this.position = position;
                this.radius = radius;
                this.name = name;
                this.prefab = prefab;
            }
            public bool IsInBounds(Vector3 target) {
                return monument != null && monument.transform.position.y < 0f && TerrainMeta.HeightMap.GetHeight(target) < 0f && monument.IsInBounds(target);
            }
        }
#region Configuration
        private static Configuration config;
        public class InterruptSettings {
            [JsonProperty(PropertyName = "Interrupt Teleport At Specific Monuments", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public List<string> Monuments {
                get;
                set;
            }
            = new List<string>();
            [JsonProperty(PropertyName = "Above Water")]
            public bool AboveWater {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Under Water")]
            public bool UnderWater {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Balloon")]
            public bool Balloon {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Boats")]
            public bool Boats {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Cargo Ship")]
            public bool Cargo {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Cold")]
            public bool Cold {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Excavator")]
            public bool Excavator {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Hot")]
            public bool Hot {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Hostile")]
            public bool Hostile {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Hurt")]
            public bool Hurt {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Junkpiles")]
            public bool Junkpiles {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Lift")]
            public bool Lift {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Monument")]
            public bool Monument {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Ignore Monument Marker Prefab")]
            public bool BypassMonumentMarker {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Mounted")]
            public bool Mounted {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Oil Rig")]
            public bool Oilrig {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Safe Zone")]
            public bool Safe {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Swimming")]
            public bool Swimming {
                get;
                set;
            }
            = false;
        }
        private object OnPlayerRespawn(BasePlayer player) {
            if (player == null) return null;
            var settings = GetSettings("outpost");
            if (settings == null || settings.Location == Vector3.zero) return null;
            if (player.State.unHostileTimestamp > TimeEx.currentTimestamp) {
                player.State.unHostileTimestamp = TimeEx.currentTimestamp;
                player.DirtyPlayerState();
                player.ClientRPCPlayer(null, player, "SetHostileLength", 0f);
            }
            return new BasePlayer.SpawnPoint {
                pos = settings.Location, rot = Quaternion.identity
            }
            ;
        }
        public class PluginSettings {
            [JsonProperty(PropertyName = "Delay Saving Data On Server Save")]
            public double SaveDelay {
                get;
                set;
            }
            = 4.0;
            [JsonProperty("TPB")]
            public TPBSettings TPB = new TPBSettings();
            [JsonProperty(PropertyName = "Interrupt TP")]
            public InterruptSettings Interrupt {
                get;
                set;
            }
            = new InterruptSettings();
            [JsonProperty(PropertyName = "Auto Wake Up After Teleport")]
            public bool AutoWakeUp {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Respawn Players At Outpost")]
            public bool RespawnOutpost {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Block Teleport (NoEscape)")]
            public bool BlockNoEscape {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Block Teleport (ZoneManager)")]
            public bool BlockZoneFlag {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Chat Name")]
            public string ChatName {
                get;
                set;
            }
            = "<color=red>Teleportation</color> \n\n";
            [JsonProperty(PropertyName = "Chat Steam64ID")]
            public ulong ChatID {
                get;
                set;
            }
            = 76561199056025689;
            [JsonProperty(PropertyName = "Check Boundaries On Teleport X Y Z")]
            public bool CheckBoundaries {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Check Boundaries Min Height")]
            public float BoundaryMin {
                get;
                set;
            }
            = -100f;
            [JsonProperty(PropertyName = "Check Boundaries Max Height")]
            public float BoundaryMax {
                get;
                set;
            }
            = 2000f;
            [JsonProperty(PropertyName = "Check If Inside Rock")]
            public bool Rock {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Height To Prevent Teleporting To/From (0 = disabled)")]
            public float ForcedBoundary {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Data File Directory (Blank = Default)")]
            public string DataFileFolder {
                get;
                set;
            }
            = string.Empty;
            [JsonProperty(PropertyName = "Draw Sphere On Set Home")]
            public bool DrawHomeSphere {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Homes Enabled")]
            public bool HomesEnabled {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "TPR Enabled")]
            public bool TPREnabled {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Strict Foundation Check")]
            public bool StrictFoundationCheck {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Minimum Temp")]
            public float MinimumTemp {
                get;
                set;
            }
            = 0f;
            [JsonProperty(PropertyName = "Maximum Temp")]
            public float MaximumTemp {
                get;
                set;
            }
            = 40f;
            [JsonProperty(PropertyName = "Blocked Items", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<string, string> BlockedItems {
                get;
                set;
            }
            = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
            [JsonProperty(PropertyName = "Bypass CMD")]
            public string BypassCMD {
                get;
                set;
            }
            = "pay";
            [JsonProperty(PropertyName = "Use Economics")]
            public bool UseEconomics {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Use Server Rewards")]
            public bool UseServerRewards {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Wipe On Upgrade Or Change")]
            public bool WipeOnUpgradeOrChange {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Auto Generate Outpost Location")]
            public bool AutoGenOutpost {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Outpost Map Prefab", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public List<string> Outpost {
                get;
                set;
            }
            = new List<string> {
                "outpost", "compound"
            }
            ;
            [JsonProperty(PropertyName = "Auto Generate Bandit Location")]
            public bool AutoGenBandit {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Bandit Map Prefab", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public List<string> Bandit {
                get;
                set;
            }
            = new List<string> {
                "bandit_town"
            }
            ;
            [JsonProperty(PropertyName = "Show Time As Seconds Instead")]
            public bool UseSeconds {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Use Quick Teleport")]
            public bool Quick {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Chat Command Color")]
            public string ChatCommandColor = "#FFFF00";
            [JsonProperty(PropertyName = "Chat Command Argument Color")]
            public string ChatCommandArgumentColor = "#FFA500";
            [JsonProperty("Enable Popup Support")]
            public bool UsePopup = false;
            [JsonProperty("Send Messages To Player")]
            public bool SendMessages = true;
            [JsonProperty("Block All Teleporting From Inside Authorized Base")]
            public bool BlockAuthorizedTeleporting = false;
            [JsonProperty("Global Teleport Cooldown")]
            public float Global = 0f;
            [JsonProperty("Global VIP Teleport Cooldown")]
            public float GlobalVIP = 0f;
            [JsonProperty("Play Sounds Before Teleport")]
            public bool PlaySoundsBeforeTeleport = true;
            [JsonProperty("Sound Effects Before Teleport", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public List<string> DisappearEffects = new List<string> {
                "assets/prefabs/missions/portal/proceduraldungeon/effects/disappear.prefab"
            }
            ;
            [JsonProperty("Play Sounds After Teleport")]
            public bool PlaySoundsAfterTeleport = true;
            [JsonProperty("Sound Effects After Teleport", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public List<string> ReappearEffects = new List<string> {
                "assets/prefabs/missions/portal/proceduraldungeon/effects/appear.prefab"
            }
            ;
        }
        public class TPBSettings {
            [JsonProperty(PropertyName = "VIP Countdowns", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<string, int> Countdowns {
                get;
                set;
            }
            = new Dictionary<string, int> {
                {
                    ConfigDefaultPermVip, 0
                }
            }
            ;
            [JsonProperty("Countdown")]
            public int Countdown = 0;
            [JsonProperty("Available After X Seconds")]
            public int Time = 0;
        }
        public class AdminSettings {
            [JsonProperty(PropertyName = "Announce Teleport To Target")]
            public bool AnnounceTeleportToTarget {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Usable By Admins")]
            public bool UseableByAdmins {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Usable By Moderators")]
            public bool UseableByModerators {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Location Radius")]
            public int LocationRadius {
                get;
                set;
            }
            = 25;
            [JsonProperty(PropertyName = "Teleport Near Default Distance")]
            public int TeleportNearDefaultDistance {
                get;
                set;
            }
            = 30;
            [JsonProperty(PropertyName = "Extra Distance To Block Monument Teleporting")]
            public int ExtraMonumentDistance {
                get;
                set;
            }
        }
        public class HomesSettings {
            [JsonProperty(PropertyName = "Homes Limit")]
            public int HomesLimit {
                get;
                set;
            }
            = 2;
            [JsonProperty(PropertyName = "VIP Homes Limits", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<string, int> VIPHomesLimits {
                get;
                set;
            }
            = new Dictionary<string, int> {
                {
                    ConfigDefaultPermVip, 5
                }
            }
            ;
            [JsonProperty(PropertyName = "Allow Sethome At Specific Monuments", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public List<string> AllowedMonuments {
                get;
                set;
            }
            = new List<string> {
                "HQM Quarry", "Stone Quarry", "Sulfur Quarry", "Ice Lake", "Wild Swamp"
            }
            ;
            [JsonProperty(PropertyName = "Allow Sethome At All Monuments")]
            public bool AllowAtAllMonuments {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Allow Sethome On Tugboats")]
            public bool AllowTugboats {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Allow TPB")]
            public bool AllowTPB {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Cooldown")]
            public int Cooldown {
                get;
                set;
            }
            = 600;
            [JsonProperty(PropertyName = "Countdown")]
            public int Countdown {
                get;
                set;
            }
            = 15;
            [JsonProperty(PropertyName = "Daily Limit")]
            public int DailyLimit {
                get;
                set;
            }
            = 5;
            [JsonProperty(PropertyName = "VIP Daily Limits", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<string, int> VIPDailyLimits {
                get;
                set;
            }
            = new Dictionary<string, int> {
                {
                    ConfigDefaultPermVip, 5
                }
            }
            ;
            [JsonProperty(PropertyName = "VIP Cooldowns", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<string, int> VIPCooldowns {
                get;
                set;
            }
            = new Dictionary<string, int> {
                {
                    ConfigDefaultPermVip, 5
                }
            }
            ;
            [JsonProperty(PropertyName = "VIP Countdowns", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<string, int> VIPCountdowns {
                get;
                set;
            }
            = new Dictionary<string, int> {
                {
                    ConfigDefaultPermVip, 5
                }
            }
            ;
            [JsonProperty(PropertyName = "Location Radius")]
            public int LocationRadius {
                get;
                set;
            }
            = 25;
            [JsonProperty(PropertyName = "Force On Top Of Foundation")]
            public bool ForceOnTopOfFoundation {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Check Foundation For Owner")]
            public bool CheckFoundationForOwner {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Use Friends")]
            public bool UseFriends {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Use Clans")]
            public bool UseClans {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Use Teams")]
            public bool UseTeams {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Usable Out Of Building Blocked")]
            public bool UsableOutOfBuildingBlocked {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Usable Into Building Blocked")]
            public bool UsableIntoBuildingBlocked {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Usable From Safe Zone Only")]
            public bool UsableFromSafeZoneOnly {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Allow Cupboard Owner When Building Blocked")]
            public bool CupOwnerAllowOnBuildingBlocked {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Allow Iceberg")]
            public bool AllowIceberg {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Allow Cave")]
            public bool AllowCave {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Allow Crafting")]
            public bool AllowCraft {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Allow Above Foundation")]
            public bool AllowAboveFoundation {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Check If Home Is Valid On Listhomes")]
            public bool CheckValidOnList {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Pay")]
            public int Pay {
                get;
                set;
            }
            = 0;
            [JsonProperty(PropertyName = "Bypass")]
            public int Bypass {
                get;
                set;
            }
            = 0;
            [JsonProperty(PropertyName = "Hours Before Useable After Wipe")]
            public double Hours {
                get;
                set;
            }
            = 0;
        }
        public class TPTSettings {
            [JsonProperty(PropertyName = "Use Friends")]
            public bool UseFriends {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Use Clans")]
            public bool UseClans {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Use Teams")]
            public bool UseTeams {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Allow Cave")]
            public bool AllowCave {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Enabled Color")]
            public string EnabledColor {
                get;
                set;
            }
            = "green";
            [JsonProperty(PropertyName = "Disabled Color")]
            public string DisabledColor {
                get;
                set;
            }
            = "red";
        }
        // Added `TPR => Play Sounds To Request Target` (false)
        // Added `TPR => Play Sounds When Target Accepts` (false)
        public class TPRSettings {
            [JsonProperty("Play Sounds To Request Target")]
            public bool PlaySoundsToRequestTarget;
            [JsonProperty("Teleport Request Sound Effects", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public List<string> TeleportRequestEffects = new List<string> {
                "assets/prefabs/missions/portal/proceduraldungeon/effects/disappear.prefab"
            }
            ;
            [JsonProperty("Play Sounds When Target Accepts")]
            public bool PlaySoundsWhenTargetAccepts;
            [JsonProperty("Teleport Accept Sound Effects", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public List<string> TeleportAcceptEffects = new List<string> {
                "assets/prefabs/missions/portal/proceduraldungeon/effects/appear.prefab"
            }
            ;
            [JsonProperty(PropertyName = "Require Player To Be Friend, Clan Mate, Or Team Mate")]
            public bool UseClans_Friends_Teams {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Allow Cave")]
            public bool AllowCave {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Allow TPB")]
            public bool AllowTPB {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Use Blocked Users")]
            public bool UseBlockedUsers {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Cooldown")]
            public int Cooldown {
                get;
                set;
            }
            = 600;
            [JsonProperty(PropertyName = "Countdown")]
            public int Countdown {
                get;
                set;
            }
            = 15;
            [JsonProperty(PropertyName = "Daily Limit")]
            public int DailyLimit {
                get;
                set;
            }
            = 5;
            [JsonProperty(PropertyName = "VIP Daily Limits", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<string, int> VIPDailyLimits {
                get;
                set;
            }
            = new Dictionary<string, int> {
                {
                    ConfigDefaultPermVip, 5
                }
            }
            ;
            [JsonProperty(PropertyName = "VIP Cooldowns", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<string, int> VIPCooldowns {
                get;
                set;
            }
            = new Dictionary<string, int> {
                {
                    ConfigDefaultPermVip, 5
                }
            }
            ;
            [JsonProperty(PropertyName = "VIP Countdowns", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<string, int> VIPCountdowns {
                get;
                set;
            }
            = new Dictionary<string, int> {
                {
                    ConfigDefaultPermVip, 5
                }
            }
            ;
            [JsonProperty(PropertyName = "Enable Request UI")]
            public bool UI {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Request Duration")]
            public int RequestDuration {
                get;
                set;
            }
            = 30;
            [JsonProperty(PropertyName = "Block TPA On Ceiling")]
            public bool BlockTPAOnCeiling {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Usable Out Of Building Blocked")]
            public bool UsableOutOfBuildingBlocked {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Usable Into Building Blocked")]
            public bool UsableIntoBuildingBlocked {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Allow Cupboard Owner When Building Blocked")]
            public bool CupOwnerAllowOnBuildingBlocked {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Allow Crafting")]
            public bool AllowCraft {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Pay")]
            public int Pay {
                get;
                set;
            }
            = 0;
            [JsonProperty(PropertyName = "Bypass")]
            public int Bypass {
                get;
                set;
            }
            = 0;
            [JsonProperty(PropertyName = "Hours Before Useable After Wipe")]
            public double Hours {
                get;
                set;
            }
            = 0;
        }
        public class TownSettings {
            [JsonProperty(PropertyName = "Command Enabled")]
            public bool Enabled {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Set Position From Monument Marker Name")]
            public string MonumentMarkerName {
                get;
                set;
            }
            = "";
            [JsonProperty(PropertyName = "Set Position From Monument Marker Name Offset")]
            public string MonumentMarkerNameOffset {
                get;
                set;
            }
            = "0 0 0";
            [JsonProperty(PropertyName = "Allow TPB")]
            public bool AllowTPB {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Allow Cave")]
            public bool AllowCave {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Cooldown")]
            public int Cooldown {
                get;
                set;
            }
            = 600;
            [JsonProperty(PropertyName = "Countdown")]
            public int Countdown {
                get;
                set;
            }
            = 15;
            [JsonProperty(PropertyName = "Daily Limit")]
            public int DailyLimit {
                get;
                set;
            }
            = 5;
            [JsonProperty(PropertyName = "VIP Daily Limits", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<string, int> VIPDailyLimits {
                get;
                set;
            }
            = new Dictionary<string, int> {
                {
                    ConfigDefaultPermVip, 5
                }
            }
            ;
            [JsonProperty(PropertyName = "VIP Cooldowns", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<string, int> VIPCooldowns {
                get;
                set;
            }
            = new Dictionary<string, int> {
                {
                    ConfigDefaultPermVip, 5
                }
            }
            ;
            [JsonProperty(PropertyName = "VIP Countdowns", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<string, int> VIPCountdowns {
                get;
                set;
            }
            = new Dictionary<string, int> {
                {
                    ConfigDefaultPermVip, 5
                }
            }
            ;
            [JsonProperty(PropertyName = "Location")]
            public Vector3 Location {
                get;
                set;
            }
            = Vector3.zero;
            [JsonProperty(PropertyName = "Locations", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public List<Vector3> Locations {
                get;
                set;
            }
            = new List<Vector3>();
            [JsonProperty(PropertyName = "Teleport To Random Location")]
            public bool Random {
                get;
                set;
            }
            = true;
            [JsonProperty(PropertyName = "Usable Out Of Building Blocked")]
            public bool UsableOutOfBuildingBlocked {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Allow Crafting")]
            public bool AllowCraft {
                get;
                set;
            }
            = false;
            [JsonProperty(PropertyName = "Pay")]
            public int Pay {
                get;
                set;
            }
            = 0;
            [JsonProperty(PropertyName = "Bypass")]
            public int Bypass {
                get;
                set;
            }
            = 0;
            [JsonProperty(PropertyName = "Hours Before Useable After Wipe")]
            public double Hours {
                get;
                set;
            }
            = 0;
            public bool CanCraft(BasePlayer player, string command) {
                return AllowCraft || player.IPlayer.HasPermission($"nteleportation.craft{command}");
            }
            [JsonIgnore]
            public StoredData Teleports = new StoredData();
            [JsonIgnore]
            public string Command {
                get;
                set;
            }
        }
        private class Configuration {
            [JsonProperty(PropertyName = "Settings")]
            public PluginSettings Settings = new PluginSettings();
            [JsonProperty(PropertyName = "Admin")]
            public AdminSettings Admin = new AdminSettings();
            [JsonProperty(PropertyName = "Home")]
            public HomesSettings Home = new HomesSettings();
            [JsonProperty(PropertyName = "TPT")]
            public TPTSettings TPT = new TPTSettings();
            [JsonProperty(PropertyName = "TPR")]
            public TPRSettings TPR = new TPRSettings();
            [JsonProperty(PropertyName = "Dynamic Commands", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<string, TownSettings> DynamicCommands {
                get;
                set;
            }
            = DefaultCommands;
        }
        private static Dictionary<string, TownSettings> DefaultCommands = new Dictionary<string, TownSettings> {
            ["Town"]
            = new TownSettings() {
                Random = false
            }
            , ["Island"] = new TownSettings() {
                AllowTPB = false
            }
            , ["Outpost"] = new TownSettings(), ["Bandit"] = new TownSettings(),
        }
        ;
        public void InitializeDynamicCommands() {
            foreach (var entry in config.DynamicCommands) {
                if (!entry.Value.Enabled) {
                    continue;
                }
                else if (entry.Key.Equals("bandit", StringComparison.OrdinalIgnoreCase)) {
                    if (CompoundTeleport == null || Convert.ToBoolean(CompoundTeleport?.Call("umodversion"))) {
                        banditEnabled = true;
                    }
                    else continue;
                }
                else if (entry.Key.Equals("outpost", StringComparison.OrdinalIgnoreCase)) {
                    if (CompoundTeleport == null || Convert.ToBoolean(CompoundTeleport?.Call("umodversion"))) {
                        outpostEnabled = true;
                    }
                    else continue;
                }
                entry.Value.Command = entry.Key;
                RegisterCommand(entry.Key, nameof(CommandCustom));
            }
            RegisterCommand("ntp", nameof(CommandDynamic));
        }
        protected override void LoadConfig() {
            base.LoadConfig();
            try {
                Config.Settings.Converters = new JsonConverter[] {
                    new UnityVector3Converter()
                }
                ;
                config = Config.ReadObject<Configuration>();
                if (config == null) LoadDefaultConfig();
                SaveConfig();
            }
            catch (JsonException ex) {
                Debug.LogException(ex);
                LoadDefaultConfig();
            }
            config.Settings.ReappearEffects.Remove("");
            config.Settings.DisappearEffects.Remove("");
            config.TPR.TeleportRequestEffects.Remove("");
            config.TPR.TeleportAcceptEffects.Remove("");
        }
        protected override void SaveConfig() {
            Config.WriteObject(config);
        }
        protected override void LoadDefaultConfig() {
            config = new Configuration();
            Puts("Loaded default configuration.");
        }
#endregion
        private class DisabledData {
            [JsonProperty("List of disabled commands")]
            public List<string> DisabledCommands = new List<string>();
            public DisabledData() {
            }
        }
        DisabledData DisabledCommandData = new DisabledData();
        private class AdminData {
            [JsonProperty("pl")]
            public Vector3 PreviousLocation {
                get;
                set;
            }
            [JsonProperty("b")]
            public bool BuildingBlocked {
                get;
                set;
            }
            [JsonProperty("c")]
            public bool AllowCrafting {
                get;
                set;
            }
            [JsonProperty("l")]
            public Dictionary<string, Vector3> Locations {
                get;
                set;
            }
            = new Dictionary<string, Vector3>(StringComparer.OrdinalIgnoreCase);
        }
        private class HomeData {
            public class Entry {
                public Vector3 Position;
                public BaseNetworkable Entity;
                public bool isEntity => Entity.IsValid() && !Entity.IsDestroyed;
                public bool wasEntity;
                public Entry() {
                }
                public Entry(Vector3 Position) {
                    this.Position = Position;
                }
                public Vector3 Get() {
                    if (isEntity) {
                        return Entity.transform.position + Position;
                    }
                    return Position;
                }
            }
            public class Boat {
                public ulong Value;
                public Vector3 Offset;
                public Boat() {
                }
                public Boat(Entry entry) {
                    Offset = entry.Position;
                    Value = entry.Entity.net.ID.Value;
                }
            }
            [JsonProperty("l")]
            public Dictionary<string, Vector3> buildings {
                get;
                set;
            }
            = new Dictionary<string, Vector3>(StringComparer.OrdinalIgnoreCase);
            [JsonProperty("b")]
            public Dictionary<string, Boat> boats {
                get;
                set;
            }
            = new Dictionary<string, Boat>(StringComparer.OrdinalIgnoreCase);
            [JsonProperty("t")]
            public TeleportData Teleports {
                get;
                set;
            }
            = new TeleportData();
            [JsonIgnore]
            private Dictionary<string, Entry> Cache = new Dictionary<string, Entry>();
            [JsonIgnore]
            public Dictionary<string, Entry> Locations {
                get {
                    if (Cache.Count == 0) {
                        InitializeBuildings();
                        InitializeBoats();
                    }
                    return Cache;
                }
            }
            private void InitializeBuildings() {
                foreach (var pair in buildings) {
                    Cache[pair.Key] = new Entry(pair.Value);
                }
            }
            private void InitializeBoats() {
                foreach (var pair in boats.ToList()) {
                    var entity = BaseNetworkable.serverEntities.Find(new NetworkableId(pair.Value.Value));
                    if (!entity.IsValid() || entity.IsDestroyed) continue;
                    Cache[pair.Key] = new Entry {
                        Position = pair.Value.Offset, wasEntity = true, Entity = entity
                    }
                    ;
                }
            }
            public bool TryGetValue(string key, out Entry homeEntry) {
                return Locations.TryGetValue(key, out homeEntry);
            }
            public void Set(string key, Entry homeEntry) {
                Locations[key] = homeEntry;
                if (homeEntry.isEntity) {
                    boats[key] = new Boat(homeEntry);
                }
                else buildings[key] = homeEntry.Get();
            }
            public bool Remove(string key) {
                bool removed = boats.Remove(key) || buildings.Remove(key);
                return Locations.Remove(key) || removed;
            }
        }
        public class TeleportData {
            [JsonProperty("a")]
            public int Amount {
                get;
                set;
            }
            [JsonProperty("d")]
            public string Date {
                get;
                set;
            }
            [JsonProperty("t")]
            public int Timestamp {
                get;
                set;
            }
        }
        private class TeleportTimer {
            public Timer Timer {
                get;
                set;
            }
            public BasePlayer OriginPlayer {
                get;
                set;
            }
            public BasePlayer TargetPlayer {
                get;
                set;
            }
        }
        private List<string> GetMonumentMessages() {
            return new List<string> {
                "Abandoned Cabins", "Abandoned Supermarket", "Abandoned Military Base", "Airfield", "Arctic Research Base", "Bandit Camp", "Barn", "Crow's Nest", "Ferry Terminal", "Fishing Village", "Gas Station", "Giant Excavator Pit", "Harbor", "HQM Quarry", "Ice Lake", "Junkyard", "Large Barn", "Large Fishing Village", "Launch Site", "Lighthouse", "Military Tunnel", "Mining Outpost", "Missile Silo", "Mountain", "Oil Rig", "Large Oil Rig", "Outpost", "Oxum's Gas Station", "Power Plant", "Ranch", "Radtown", "Satellite Dish", "Sewer Branch", "Stone Quarry", "Substation", "Sulfur Quarry", "The Supermarket", "The Dome", "Train Tunnel", "Train Yard", "Underwater Lab", "Water Treatment Plant", "Water Well", "Wild Swamp",
            }
            ;
        }
        protected override void LoadDefaultMessages() {
            if (!_cmcCompleted) {
                timer.Once(1f, LoadDefaultMessages);
                return;
            }
            var monumentMessages = GetMonumentMessages();
            var en = new Dictionary<string, string> {
                {
                    "ErrorTPR", "Teleporting to {0} is blocked ({1})"
                }
                , {
                    "AdminTP", "You teleported to {0}!"
                }
                , {
                    "AdminTPTarget", "{0} teleported to you!"
                }
                , {
                    "AdminTPPlayers", "You teleported {0} to {1}!"
                }
                , {
                    "AdminTPPlayer", "{0} teleported you to {1}!"
                }
                , {
                    "AdminTPPlayerTarget", "{0} teleported {1} to you!"
                }
                , {
                    "AdminTPCoordinates", "You teleported to {0}!"
                }
                , {
                    "AdminTPTargetCoordinates", "You teleported {0} to {1}!"
                }
                , {
                    "AdminTPOutOfBounds", "You tried 
// ... [Code preview truncated due to length. Full source in attached file] ...

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