C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Facepunch;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using Oxide.Core;
using Oxide.Core.Configuration;
using Oxide.Core.Plugins;
using Oxide.Game.Rust;
using Rust;
using UnityEngine;
namespace Oxide.Plugins {
[Info("NTeleportation", "Nogrod", "1.0.25", ResourceId = 1832)]
class NTeleportation : RustPlugin {
private const string NewLine = "\n";
private const string ConfigDefaultPermVip = "nteleportation.vip";
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 PermTp = "nteleportation.tp";
private const string PermTpB = "nteleportation.tpb";
private const string PermTpConsole = "nteleportation.tpconsole";
private const string PermTpHome = "nteleportation.tphome";
private const string PermTpTown = "nteleportation.tptown";
private const string PermTpN = "nteleportation.tpn";
private const string PermTpL = "nteleportation.tpl";
private const string PermTpRemove = "nteleportation.tpremove";
private const string PermTpSave = "nteleportation.tpsave";
private const string PermWipeHomes = "nteleportation.wipehomes";
private const string PermCraftHome = "nteleportation.crafthome";
private const string PermCraftTown = "nteleportation.crafttown";
private const string PermCraftTpR = "nteleportation.crafttpr";
private DynamicConfigFile dataAdmin;
private DynamicConfigFile dataHome;
private DynamicConfigFile dataTPR;
private DynamicConfigFile dataTown;
private Dictionary<ulong, AdminData> Admin;
private Dictionary<ulong, HomeData> Home;
private Dictionary<ulong, TeleportData> TPR;
private Dictionary<ulong, TeleportData> Town;
private bool changedAdmin;
private bool changedHome;
private bool changedTPR;
private bool changedTown;
private ConfigData configData;
private float boundary;
private readonly int triggerLayer = LayerMask.GetMask("Trigger");
private readonly int groundLayer = LayerMask.GetMask("Terrain", "World");
private readonly int buildingLayer = LayerMask.GetMask("Terrain", "World", "Construction", "Deployed");
private readonly int blockLayer = LayerMask.GetMask("Construction");
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 HashSet<ulong> teleporting = new HashSet<ulong>();
[PluginReference]
private Plugin Economics;
[PluginReference]
private Plugin Friends;
[PluginReference]
private Plugin RustIO;
[PluginReference]
private Plugin Clans;
class ConfigData {
public SettingsData Settings {
get;
set;
}
public AdminSettingsData Admin {
get;
set;
}
public HomesSettingsData Home {
get;
set;
}
public TPRData TPR {
get;
set;
}
public TownData Town {
get;
set;
}
public VersionNumber Version {
get;
set;
}
}
class SettingsData {
public string ChatName {
get;
set;
}
public bool HomesEnabled {
get;
set;
}
public bool TPREnabled {
get;
set;
}
public bool TownEnabled {
get;
set;
}
public bool InterruptTPOnHurt {
get;
set;
}
public Dictionary<string, string> BlockedItems {
get;
set;
}
= new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
}
class AdminSettingsData {
public bool AnnounceTeleportToTarget {
get;
set;
}
public bool UseableByModerators {
get;
set;
}
public int LocationRadius {
get;
set;
}
public int TeleportNearDefaultDistance {
get;
set;
}
}
class HomesSettingsData {
public int HomesLimit {
get;
set;
}
public Dictionary<string, int> VIPHomesLimits {
get;
set;
}
public int Cooldown {
get;
set;
}
public int Countdown {
get;
set;
}
public int DailyLimit {
get;
set;
}
public Dictionary<string, int> VIPDailyLimits {
get;
set;
}
public Dictionary<string, int> VIPCooldowns {
get;
set;
}
public Dictionary<string, int> VIPCountdowns {
get;
set;
}
public int LocationRadius {
get;
set;
}
public bool ForceOnTopOfFoundation {
get;
set;
}
public bool CheckFoundationForOwner {
get;
set;
}
public bool UseFriends {
get;
set;
}
public bool UsableOutOfBuildingBlocked {
get;
set;
}
public bool UsableIntoBuildingBlocked {
get;
set;
}
public bool CupOwnerAllowOnBuildingBlocked {
get;
set;
}
public bool AllowIceberg {
get;
set;
}
public bool AllowCave {
get;
set;
}
public bool AllowCraft {
get;
set;
}
public bool AllowAboveFoundation {
get;
set;
}
public bool CheckValidOnList {
get;
set;
}
public int Pay {
get;
set;
}
}
class TPRData {
public int Cooldown {
get;
set;
}
public int Countdown {
get;
set;
}
public int DailyLimit {
get;
set;
}
public Dictionary<string, int> VIPDailyLimits {
get;
set;
}
public Dictionary<string, int> VIPCooldowns {
get;
set;
}
public Dictionary<string, int> VIPCountdowns {
get;
set;
}
public int RequestDuration {
get;
set;
}
public bool BlockTPAOnCeiling {
get;
set;
}
public bool UsableOutOfBuildingBlocked {
get;
set;
}
public bool UsableIntoBuildingBlocked {
get;
set;
}
public bool CupOwnerAllowOnBuildingBlocked {
get;
set;
}
public bool AllowCraft {
get;
set;
}
public int Pay {
get;
set;
}
}
class TownData {
public int Cooldown {
get;
set;
}
public int Countdown {
get;
set;
}
public int DailyLimit {
get;
set;
}
public Dictionary<string, int> VIPDailyLimits {
get;
set;
}
public Dictionary<string, int> VIPCooldowns {
get;
set;
}
public Dictionary<string, int> VIPCountdowns {
get;
set;
}
public Vector3 Location {
get;
set;
}
public bool UsableOutOfBuildingBlocked {
get;
set;
}
public bool AllowCraft {
get;
set;
}
public int Pay {
get;
set;
}
}
class AdminData {
[JsonProperty("pl")]
public Vector3 PreviousLocation {
get;
set;
}
[JsonProperty("l")]
public Dictionary<string, Vector3> Locations {
get;
set;
}
= new Dictionary<string, Vector3>(StringComparer.OrdinalIgnoreCase);
}
class HomeData {
[JsonProperty("l")]
public Dictionary<string, Vector3> Locations {
get;
set;
}
= new Dictionary<string, Vector3>(StringComparer.OrdinalIgnoreCase);
[JsonProperty("t")]
public TeleportData Teleports {
get;
set;
}
= new TeleportData();
}
class TeleportData {
[JsonProperty("a")]
public int Amount {
get;
set;
}
[JsonProperty("d")]
public string Date {
get;
set;
}
[JsonProperty("t")]
public int Timestamp {
get;
set;
}
}
class TeleportTimer {
public Timer Timer {
get;
set;
}
public BasePlayer OriginPlayer {
get;
set;
}
public BasePlayer TargetPlayer {
get;
set;
}
}
protected override void LoadDefaultConfig() {
Config.Settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
Config.Settings.Converters = new JsonConverter[] {
new UnityVector3Converter()
}
;
Config.WriteObject(new ConfigData {
Settings = new SettingsData {
ChatName = "<color=red>Teleportation</color>: ", HomesEnabled = true, TPREnabled = true, TownEnabled = true, InterruptTPOnHurt = true
}
, Admin = new AdminSettingsData {
AnnounceTeleportToTarget = false, UseableByModerators = true, LocationRadius = 25, TeleportNearDefaultDistance = 30
}
, Home = new HomesSettingsData {
HomesLimit = 2, VIPHomesLimits = new Dictionary<string, int> {
{
ConfigDefaultPermVip, 5
}
}
, Cooldown = 600, Countdown = 15, DailyLimit = 5, VIPDailyLimits = new Dictionary<string, int> {
{
ConfigDefaultPermVip, 5
}
}
, VIPCooldowns = new Dictionary<string, int> {
{
ConfigDefaultPermVip, 5
}
}
, VIPCountdowns = new Dictionary<string, int> {
{
ConfigDefaultPermVip, 5
}
}
, LocationRadius = 25, ForceOnTopOfFoundation = true, CheckFoundationForOwner = true, UseFriends = true, AllowAboveFoundation = true, CheckValidOnList = false, CupOwnerAllowOnBuildingBlocked = true
}
, TPR = new TPRData {
Cooldown = 600, Countdown = 15, DailyLimit = 5, VIPDailyLimits = new Dictionary<string, int> {
{
ConfigDefaultPermVip, 5
}
}
, VIPCooldowns = new Dictionary<string, int> {
{
ConfigDefaultPermVip, 5
}
}
, VIPCountdowns = new Dictionary<string, int> {
{
ConfigDefaultPermVip, 5
}
}
, RequestDuration = 30, BlockTPAOnCeiling = true, CupOwnerAllowOnBuildingBlocked = true
}
, Town = new TownData {
Cooldown = 600, Countdown = 15, DailyLimit = 5, VIPDailyLimits = new Dictionary<string, int> {
{
ConfigDefaultPermVip, 5
}
}
, VIPCooldowns = new Dictionary<string, int> {
{
ConfigDefaultPermVip, 5
}
}
, VIPCountdowns = new Dictionary<string, int> {
{
ConfigDefaultPermVip, 5
}
}
}
, Version = Version
}
, true);
}
private void Init() {
lang.RegisterMessages(new Dictionary<string, string> {
{
"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 to teleport to a set of coordinates outside the map boundaries!"
}
, {
"AdminTPBoundaries", "X and Z values need to be between -{0} and {0} while the Y value needs to be between -100 and 2000!"
}
, {
"AdminTPLocation", "You teleported to {0}!"
}
, {
"AdminTPLocationSave", "You have saved the current location!"
}
, {
"AdminTPLocationRemove", "You have removed the location {0}!"
}
, {
"AdminLocationList", "The following locations are available:"
}
, {
"AdminLocationListEmpty", "You haven't saved any locations!"
}
, {
"AdminTPBack", "You've teleported back to your previous location!"
}
, {
"AdminTPBackSave", "Your previous location has been saved, use /tpb to teleport back!"
}
, {
"AdminTPTargetCoordinatesTarget", "{0} teleported you to {1}!"
}
, {
"AdminTPConsoleTP", "You were teleported to {0}"
}
, {
"AdminTPConsoleTPPlayer", "You were teleported to {0}"
}
, {
"AdminTPConsoleTPPlayerTarget", "{0} was teleported to you!"
}
, {
"HomeTP", "You teleported to your home '{0}'!"
}
, {
"HomeAdminTP", "You teleported to {0}'s home '{1}'!"
}
, {
"HomeSave", "You have saved the current location as your home!"
}
, {
"HomeNoFoundation", "You can only use a home location on a foundation!"
}
, {
"HomeFoundationNotOwned", "You can't use home on someone else's house."
}
, {
"HomeFoundationUnderneathFoundation", "You can't use home on a foundation that is underneath another foundation."
}
, {
"HomeFoundationNotFriendsOwned", "You or a friend need to own the house to use home!"
}
, {
"HomeRemovedInvalid", "Your home '{0}' was removed because not on a foundation or not owned!"
}
, {
"HomeRemovedInsideBlock", "Your home '{0}' was removed because inside a foundation!"
}
, {
"HomeRemove", "You have removed your home {0}!"
}
, {
"HomeDelete", "You have removed {0}'s home '{1}'!"
}
, {
"HomeList", "The following homes are available:"
}
, {
"HomeListEmpty", "You haven't saved any homes!"
}
, {
"HomeMaxLocations", "Unable to set your home here, you have reached the maximum of {0} homes!"
}
, {
"HomeQuota", "You have set {0} of the maximum {1} homes!"
}
, {
"HomeTPStarted", "Teleporting to your home {0} in {1} seconds!"
}
, {
"HomeTPCooldown", "Your teleport is currently on cooldown.You'll have to wait {0} for your next teleport."
}
, {
"HomeTPLimitReached", "You have reached the daily limit of {0} teleports today!"
}
, {
"HomeTPAmount", "You have {0} home teleports left today!"
}
, {
"HomesListWiped", "You have wiped all the saved home locations!"
}
, {
"HomeTPBuildingBlocked", "You can't set your home if you are not allowed to build in this zone!"
}
, {
"HomeTPSwimming", "You can't set your home while swimming!"
}
, {
"HomeTPCrafting", "You can't set your home while crafting!"
}
, {
"Request", "You've requested a teleport to {0}!"
}
, {
"RequestTarget", "{0} requested to be teleported to you! Use '/tpa' to accept!"
}
, {
"PendingRequest", "You already have a request pending, cancel that request or wait until it gets accepted or times out!"
}
, {
"PendingRequestTarget", "The player you wish to teleport to already has a pending request, try again later!"
}
, {
"NoPendingRequest", "You have no pending teleport request!"
}
, {
"AcceptOnRoof", "You can't accept a teleport while you're on a ceiling, get to ground level!"
}
, {
"Accept", "{0} has accepted your teleport request! Teleporting in {1} seconds!"
}
, {
"AcceptTarget", "You've accepted the teleport request of {0}!"
}
, {
"NotAllowed", "You are not allowed to use this command!"
}
, {
"Success", "You teleported to {0}!"
}
, {
"SuccessTarget", "{0} teleported to you!"
}
, {
"Cancelled", "Your teleport request to {0} was cancelled!"
}
, {
"CancelledTarget", "{0} teleport request was cancelled!"
}
, {
"TPCancelled", "Your teleport was cancelled!"
}
, {
"TPCancelledTarget", "{0} cancelled teleport!"
}
, {
"TPYouCancelledTarget", "You cancelled {0} teleport!"
}
, {
"TimedOut", "{0} did not answer your request in time!"
}
, {
"TimedOutTarget", "You did not answer {0}'s teleport request in time!"
}
, {
"TargetDisconnected", "{0} has disconnected, your teleport was cancelled!"
}
, {
"TPRCooldown", "Your teleport requests are currently on cooldown.You'll have to wait {0} to send your next teleport request."
}
, {
"TPRLimitReached", "You have reached the daily limit of {0} teleport requests today!"
}
, {
"TPRAmount", "You have {0} teleport requests left today!"
}
, {
"TPRTarget", "Your target is currently not available!"
}
, {
"TPDead", "You can't teleport while being dead!"
}
, {
"TPWounded", "You can't teleport while being wounded!"
}
, {
"TPBuildingBlocked", "You can't teleport while in a building blocked zone!"
}
, {
"TPTargetBuildingBlocked", "You can't teleport in a building blocked zone!"
}
, {
"TPTargetInsideBlock", "You can't teleport into a foundation!"
}
, {
"TPSwimming", "You can't teleport while swimming!"
}
, {
"TPCrafting", "You can't teleport while crafting!"
}
, {
"TPBlockedItem", "You can't teleport while carrying: {0}!"
}
, {
"TownTP", "You teleported to town!"
}
, {
"TownTPNotSet", "Town is currently not set!"
}
, {
"TownTPLocation", "You have set the town location set to {0}!"
}
, {
"TownTPStarted", "Teleporting to town in {0} seconds!"
}
, {
"TownTPCooldown", "Your teleport is currently on cooldown.You'll have to wait {0} for your next teleport."
}
, {
"TownTPLimitReached", "You have reached the daily limit of {0} teleports today!"
}
, {
"TownTPAmount", "You have {0} town teleports left today!"
}
, {
"Interrupted", "Your teleport was interrupted!"
}
, {
"InterruptedTarget", "{0}'s teleport was interrupted!"
}
, {
"Unlimited", "Unlimited"
}
, {
"TPInfoGeneral", string.Join(NewLine, new[] {
"Please specify the module you want to view the info of.", "The available modules are: ",
}
)
}
, {
"TPHelpGeneral", string.Join(NewLine, new[] {
"/tpinfo - Shows limits and cooldowns.", "Please specify the module you want to view the help of.", "The available modules are: ",
}
)
}
, {
"TPHelpadmintp", string.Join(NewLine, new[] {
"As an admin you have access to the following commands:", "/tp \"targetplayer\" - Teleports yourself to the target player.", "/tp \"player\" \"targetplayer\" - Teleports the player to the target player.", "/tp x y z - Teleports you to the set of coordinates.", "/tpl - Shows a list of saved locations.", "/tpl \"location name\" - Teleports you to a saved location.", "/tpsave \"location name\" - Saves your current position as the location name.", "/tpremove \"location name\" - Removes the location from your saved list.", "/tpb - Teleports you back to the place where you were before teleporting.", "/home radius \"radius\" - Find all homes in radius.", "/home delete \"player name|id\" \"home name\" - Remove a home from a player.", "/home tp \"player name|id\" \"name\" - Teleports you to the home location with the name 'name' from the player.", "/home homes \"player name|id\" - Shows you a list of all homes from the player."
}
)
}
, {
"TPHelphome", string.Join(NewLine, new[] {
"With the following commands you can set your home location to teleport back to:", "/home add \"name\" - Saves your current position as the location name.", "/home list - Shows you a list of all the locations you have saved.", "/home remove \"name\" - Removes the location of your saved homes.", "/home \"name\" - Teleports you to the home location."
}
)
}
, {
"TPHelptpr", string.Join(NewLine, new[] {
"With these commands you can request to be teleported to a player or accept someone else's request:", "/tpr \"player name\" - Sends a teleport request to the player.", "/tpa - Accepts an incoming teleport request.", "/tpc - Cancel teleport or request."
}
)
}
, {
"TPSettingsGeneral", string.Join(NewLine, new[] {
"Please specify the module you want to view the settings of.", "The available modules are:",
}
)
}
, {
"TPSettingshome", string.Join(NewLine, new[] {
"Home System has the current settings enabled:", "Time between teleports: {0}", "Daily amount of teleports: {1}", "Amount of saved Home locations: {2}"
}
)
}
, {
"TPSettingstpr", string.Join(NewLine, new[] {
"TPR System has the current settings enabled:", "Time between teleports: {0}", "Daily amount of teleports: {1}"
}
)
}
, {
"TPSettingstown", string.Join(NewLine, new[] {
"Town System has the current settings enabled:", "Time between teleports: {0}", "Daily amount of teleports: {1}"
}
)
}
, {
"PlayerNotFound", "The specified player couldn't be found please try again!"
}
, {
"MultiplePlayers", "Found multiple players: {0}"
}
, {
"CantTeleportToSelf", "You can't teleport to yourself!"
}
, {
"CantTeleportPlayerToSelf", "You can't teleport a player to himself!"
}
, {
"TeleportPending", "You can't initiate another teleport while you have a teleport pending!"
}
, {
"TeleportPendingTarget", "You can't request a teleport to someone who's about to teleport!"
}
, {
"LocationExists", "A location with this name already exists at {0}!"
}
, {
"LocationExistsNearby", "A location with the name {0} already exists near this position!"
}
, {
"LocationNotFound", "Couldn't find a location with that name!"
}
, {
"NoPreviousLocationSaved", "No previous location saved!"
}
, {
"HomeExists", "You have already saved a home location by this name!"
}
, {
"HomeExistsNearby", "A home location with the name {0} already exists near this position!"
}
, {
"HomeNotFound", "Couldn't find your home with that name!"
}
, {
"InvalidCoordinates", "The coordinates you've entered are invalid!"
}
, {
"InvalidHelpModule", "Invalid module supplied!"
}
, {
"InvalidCharacter", "You have used an invalid character, please limit yourself to the letters a to z and numbers."
}
, {
"SyntaxCommandTP", string.Join(NewLine, new[] {
"A Syntax Error Occurred!", "You can only use the /tp command as follows:", "/tp \"targetplayer\" - Teleports yourself to the target player.", "/tp \"player\" \"targetplayer\" - Teleports the player to the target player.", "/tp x y z - Teleports you to the set of coordinates.", "/tp \"player\" x y z - Teleports the player to the set of coordinates."
}
)
}
, {
"SyntaxCommandTPL", string.Join(NewLine, new[] {
"A Syntax Error Occurred!", "You can only use the /tpl command as follows:", "/tpl - Shows a list of saved locations.", "/tpl \"location name\" - Teleports you to a saved location."
}
)
}
, {
"SyntaxCommandTPSave", string.Join(NewLine, new[] {
"A Syntax Error Occurred!", "You can only use the /tpsave command as follows:", "/tpsave \"location name\" - Saves your current position as 'location name'."
}
)
}
, {
"SyntaxCommandTPRemove", string.Join(NewLine, new[] {
"A Syntax Error Occurred!", "You can only use the /tpremove command as follows:", "/tpremove \"location name\" - Removes the location with the name 'location name'."
}
)
}
, {
"SyntaxCommandTPN", string.Join(NewLine, new[] {
"A Syntax Error Occurred!", "You can only use the /tpn command as follows:", "/tpn \"targetplayer\" - Teleports yourself the default distance behind the target player.", "/tpn \"targetplayer\" \"distance\" - Teleports you the specified distance behind the target player."
}
)
}
, {
"SyntaxCommandSetHome", string.Join(NewLine, new[] {
"A Syntax Error Occurred!", "You can only use the /home add command as follows:", "/home add \"name\" - Saves the current location as your home with the name 'name'."
}
)
}
, {
"SyntaxCommandRemoveHome", string.Join(NewLine, new[] {
"A Syntax Error Occurred!", "You can only use the /home remove command as follows:", "/home remove \"name\" - Removes the home location with the name 'name'."
}
)
}
, {
"SyntaxCommandHome", string.Join(NewLine, new[] {
"A Syntax Error Occurred!", "You can only use the /home command as follows:", "/home \"name\" - Teleports yourself to your home with the name 'name'.", "/home add \"name\" - Saves the current location as your home with the name 'name'.", "/home list - Shows you a list of all your saved home locations.", "/home remove \"name\" - Removes the home location with the name 'name'."
}
)
}
, {
"SyntaxCommandHomeAdmin", string.Join(NewLine, new[] {
"/home radius \"radius\" - Shows you a list of all homes in radius(10).", "/home delete \"player name|id\" \"name\" - Removes the home location with the name 'name' from the player.", "/home tp \"player name|id\" \"name\" - Teleports you to the home location with the name 'name' from the player.", "/home homes \"player name|id\" - Shows you a list of all homes from the player."
}
)
}
, {
"SyntaxCommandTown", string.Join(NewLine, new[] {
"A Syntax Error Occurred!", "You can only use the /town command as follows:", "/town - Teleports yourself to town."
}
)
}
, {
"SyntaxCommandTownAdmin", string.Join(NewLine, new[] {
"/town set - Saves the current location as town.",
}
)
}
, {
"SyntaxCommandHomeDelete", string.Join(NewLine, new[] {
"A Syntax Error Occurred!", "You can only use the /home delete command as follows:", "/home delete \"player name|id\" \"name\" - Removes the home location with the name 'name' from the player."
}
)
}
, {
"SyntaxCommandHomeAdminTP", string.Join(NewLine, new[] {
"A Syntax Error Occurred!", "You can only use the /home tp command as follows:", "/home tp \"player name|id\" \"name\" - Teleports you to the home location with the name 'name' from the player."
}
)
}
, {
"SyntaxCommandHomeHomes", string.Join(NewLine, new[] {
"A Syntax Error Occurred!", "You can only use the /home homes command as follows:", "/home homes \"player name|id\" - Shows you a list of all homes from the player."
}
)
}
, {
"SyntaxCommandListHomes", string.Join(NewLine, new[] {
"A Syntax Error Occurred!", "You can only use the /home list command as follows:", "/home list - Shows you a list of all your saved home locations."
}
)
}
, {
"SyntaxCommandTPR", string.Join(NewLine, new[] {
"A Syntax Error Occurred!", "You can only use the /tpr command as follows:", "/tpr \"player name\" - Sends out a teleport request to 'player name'."
}
)
}
, {
"SyntaxCommandTPA", string.Join(NewLine, new[] {
"A Syntax Error Occurred!", "You can only use the /tpa command as follows:", "/tpa - Accepts an incoming teleport request."
}
)
}
, {
"SyntaxCommandTPC", string.Join(NewLine, new[] {
"A Syntax Error Occurred!", "You can only use the /tpc command as follows:", "/tpc - Cancels an teleport request."
}
)
}
, {
"SyntaxConsoleCommandToPos", string.Join(NewLine, new[] {
"A Syntax Error Occurred!", "You can only use the teleport.topos console command as follows:", " > teleport.topos \"player\" x y z"
}
)
}
, {
"SyntaxConsoleCommandToPlayer", string.Join(NewLine, new[] {
"A Syntax Error Occurred!", "You can only use the teleport.toplayer console command as follows:", " > teleport.toplayer \"player\" \"target player\""
}
)
}
, {
"LogTeleport", "{0} teleported to {1}."
}
, {
"LogTeleportPlayer", "{0} teleported {1} to {2}."
}
, {
"LogTeleportBack", "{0} teleported back to previous location."
}
}
, this);
Config.Settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
Config.Settings.Converters = new JsonConverter[] {
new UnityVector3Converter()
}
;
try {
configData = Config.ReadObject<ConfigData>();
}
catch (Exception) {
Puts("Corrupt config, loading default...");
LoadDefaultConfig();
}
if (!(configData.Version == Version)) {
if (configData.Home.VIPHomesLimits == null) {
configData.Home.VIPHomesLimits = new Dictionary<string, int> {
{
ConfigDefaultPermVip, 5
}
}
;
configData.Home.VIPDailyLimits = new Dictionary<string, int> {
{
ConfigDefaultPermVip, 5
}
}
;
configData.Home.VIPCooldowns = new Dictionary<string, int> {
{
ConfigDefaultPermVip, 5
}
}
;
configData.TPR.VIPDailyLimits = new Dictionary<string, int> {
{
ConfigDefaultPermVip, 5
}
}
;
configData.TPR.VIPCooldowns = new Dictionary<string, int> {
{
ConfigDefaultPermVip, 5
}
}
;
configData.Town.VIPDailyLimits = new Dictionary<string, int> {
{
ConfigDefaultPermVip, 5
}
}
;
configData.Town.VIPCooldowns = new Dictionary<string, int> {
{
ConfigDefaultPermVip, 5
}
}
;
}
if (configData.Home.VIPCountdowns == null) {
configData.Home.VIPCountdowns = new Dictionary<string, int> {
{
ConfigDefaultPermVip, 5
}
}
;
configData.TPR.VIPCountdowns = new Dictionary<string, int> {
{
ConfigDefaultPermVip, 5
}
}
;
configData.Town.VIPCountdowns = new Dictionary<string, int> {
{
ConfigDefaultPermVip, 5
}
}
;
}
if (configData.Version <= new VersionNumber(1, 0, 4)) configData.Home.AllowAboveFoundation = true;
if (configData.Version < new VersionNumber(1, 0, 14)) {
configData.Home.UsableIntoBuildingBlocked = true;
configData.TPR.UsableIntoBuildingBlocked = true;
}
configData.Version = Version;
Config.WriteObject(configData, true);
}
dataAdmin = GetFile(nameof(NTeleportation) + "Admin");
Admin = dataAdmin.ReadObject<Dictionary<ulong, AdminData>>();
dataHome = GetFile(nameof(NTeleportation) + "Home");
Home = dataHome.ReadObject<Dictionary<ulong, HomeData>>();
dataTPR = GetFile(nameof(NTeleportation) + "TPR");
TPR = dataTPR.ReadObject<Dictionary<ulong, TeleportData>>();
dataTown = GetFile(nameof(NTeleportation) + "Town");
Town = dataTown.ReadObject<Dictionary<ulong, TeleportData>>();
cmd.AddConsoleCommand("teleport.toplayer", this, ccmdTeleport);
cmd.AddConsoleCommand("teleport.topos", this, ccmdTeleport);
permission.RegisterPermission(PermDeleteHome, this);
permission.RegisterPermission(PermHomeHomes, this);
permission.RegisterPermission(PermImportHomes, this);
permission.RegisterPermission(PermRadiusHome, this);
permission.RegisterPermission(PermTp, this);
permission.RegisterPermission(PermTpB, this);
permission.RegisterPermission(PermTpConsole, this);
permission.RegisterPermission(PermTpHome, this);
permission.RegisterPermission(PermTpTown, this);
permission.RegisterPermission(PermTpN, this);
permission.RegisterPermission(PermTpL, this);
permission.RegisterPermission(PermTpRemove, this);
permission.RegisterPermission(PermTpSave, this);
permission.RegisterPermission(PermWipeHomes, this);
permission.RegisterPermission(PermCraftHome, this);
permission.RegisterPermission(PermCraftTown, this);
permission.RegisterPermission(PermCraftTpR, this);
foreach (var key in configData.Home.VIPCooldowns.Keys) if (!permission.PermissionExists(key, this)) permission.RegisterPermission(key, this);
foreach (var key in configData.Home.VIPCountdowns.Keys) if (!permission.PermissionExists(key, this)) permission.RegisterPermission(key, this);
foreach (var key in configData.Home.VIPDailyLimits.Keys) if (!permission.PermissionExists(key, this)) permission.RegisterPermission(key, this);
foreach (var key in configData.Home.VIPHomesLimits.Keys) if (!permission.PermissionExists(key, this)) permission.RegisterPermission(key, this);
foreach (var key in configData.TPR.VIPCooldowns.Keys) if (!permission.PermissionExists(key, this)) permission.RegisterPermission(key, this);
foreach (var key in configData.TPR.VIPCountdowns.Keys) if (!permission.PermissionExists(key, this)) permission.RegisterPermission(key, this);
foreach (var key in configData.TPR.VIPDailyLimits.Keys) if (!permission.PermissionExists(key, this)) permission.RegisterPermission(key, this);
foreach (var key in configData.Town.VIPCooldowns.Keys) if (!permission.PermissionExists(key, this)) permission.RegisterPermission(key, this);
foreach (var key in configData.Town.VIPCountdowns.Keys) if (!permission.PermissionExists(key, this)) permission.RegisterPermission(key, this);
foreach (var key in configData.Town.VIPDailyLimits.Keys) if (!permission.PermissionExists(key, this)) permission.RegisterPermission(key, this);
}
private DynamicConfigFile GetFile(string name) {
var file = Interface.Oxide.DataFileSystem.GetFile(name);
file.Settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
file.Settings.Converters = new JsonConverter[] {
new UnityVector3Converter(), new CustomComparerDictionaryCreationConverter<string>(StringComparer.OrdinalIgnoreCase)
}
;
return file;
}
void OnServerInitialized() {
boundary = TerrainMeta.Size.x / 2;
CheckPerms(configData.Home.VIPHomesLimits);
CheckPerms(configData.Home.VIPDailyLimits);
CheckPerms(configData.Home.VIPCooldowns);
CheckPerms(configData.TPR.VIPDailyLimits);
CheckPerms(configData.TPR.VIPCooldowns);
CheckPerms(configData.Town.VIPDailyLimits);
CheckPerms(configData.Town.VIPCooldowns);
foreach (var item in configData.Settings.BlockedItems) {
var definition = ItemManager.FindItemDefinition(item.Key);
if (definition == null) {
Puts("Blocked item not found: {0}", item.Key);
continue;
}
ReverseBlockedItems[definition.itemid] = item.Value;
// ... [Code preview truncated due to length. Full source in attached file] ...