public static bool checkOwner(DeployableObject obj, Controllable controllable) { bool flag; Fougerite.Player pl = Fougerite.Server.Cache[controllable.playerClient.userID]; if (obj.ownerID == pl.UID) { flag = true; } else if (obj is SleepingBag) { flag = false; } else { ShareCommand command = ChatCommand.GetCommand("share") as ShareCommand; ArrayList list = (ArrayList)command.GetSharedDoors()[obj.ownerID]; if (list == null) { flag = false; } if (list.Contains(pl.UID)) { flag = true; } flag = false; } return(flag); }
void DoorUse(Fougerite.Player p, DoorEvent de) { if (Core.IsEnabled() && !de.Open) { ShareCommand command = ChatCommand.GetCommand("share") as ShareCommand; ArrayList list = (ArrayList)command.GetSharedDoors()[de.Entity.OwnerID]; if (list == null) { de.Open = false; } else if (list.Contains(p.PlayerClient.userID)) { de.Open = true; } else { de.Open = false; } } }
public static bool checkOwner(DeployableObject obj, Controllable controllable) { bool flag; if (obj.ownerID == controllable.playerClient.userID) { return(true); } try { SleepingBag bag1 = (SleepingBag)obj; flag = false; } catch { try { ShareCommand command = ChatCommand.GetCommand("share") as ShareCommand; ArrayList list = (ArrayList)command.GetSharedDoors()[obj.ownerID]; if (list == null) { return(false); } if (list.Contains(controllable.playerClient.userID)) { return(true); } flag = false; } catch (Exception) { flag = false; } } return(flag); }
public static void CreateSaves() { try { ShareCommand command = (ShareCommand)ChatCommand.GetCommand("share"); FriendsCommand command2 = (FriendsCommand)ChatCommand.GetCommand("friends"); if (command.GetSharedDoors().Count != 0) { ObjectToFile <Hashtable>(command.GetSharedDoors(), RustPPModule.GetAbsoluteFilePath("doorsSave.rpp")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp")); } if (command2.GetFriendsLists().Count != 0) { ObjectToFile <Hashtable>(command2.GetFriendsLists(), RustPPModule.GetAbsoluteFilePath("friendsSave.rpp")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp")); } if (Administrator.AdminList.Count != 0) { ObjectToXML <List <Administrator> >(Administrator.AdminList, RustPPModule.GetAbsoluteFilePath("admins.xml")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("admins.xml"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("admins.xml")); } if (Core.userCache.Count != 0) { ObjectToFile <Dictionary <ulong, string> >(Core.userCache, RustPPModule.GetAbsoluteFilePath("cache.rpp")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("cache.rpp"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("cache.rpp")); } if (Core.whiteList.Count != 0) { ObjectToXML <List <PList.Player> >(Core.whiteList.PlayerList, RustPPModule.GetAbsoluteFilePath("whitelist.xml")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("whitelist.xml"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("whitelist.xml")); } if (Core.blackList.Count != 0) { ObjectToXML <List <PList.Player> >(Core.blackList.PlayerList, RustPPModule.GetAbsoluteFilePath("bans.xml")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("bans.xml"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("bans.xml")); } } catch (Exception ex) { Fougerite.Logger.LogException(ex); throw; } }
public static void CreateSaves() { Logger.Log("Guardando clanes"); RustPP.Data.Globals.GuardarClanes(); Logger.Log("Guardando cuentas"); RustPP.Data.Globals.GuardarCuentas(); ShareCommand command = (ShareCommand)ChatCommand.GetCommand("share"); FriendsCommand command2 = (FriendsCommand)ChatCommand.GetCommand("amigos"); if (command.GetSharedDoors().Count != 0) { Logger.Log("Guardando puertas"); ObjectToFile <Hashtable>(command.GetSharedDoors(), RustPPModule.GetAbsoluteFilePath("doorsSave.rpp")); SerializableDictionary <ulong, List <ulong> > doorsSave = new SerializableDictionary <ulong, List <ulong> >(); foreach (DictionaryEntry entry in command.GetSharedDoors()) { ulong key = (ulong)entry.Key; ArrayList value = (ArrayList)entry.Value; List <ulong> list = new List <ulong>(value.OfType <ulong>()); doorsSave.Add(key, list); } ObjectToXML <SerializableDictionary <ulong, List <ulong> > >(doorsSave, RustPPModule.GetAbsoluteFilePath("doorsSave.xml")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp")); } if (command2.GetFriendsLists().Count != 0) { Logger.Log("Saving friends lists."); ObjectToFile <Hashtable>(command2.GetFriendsLists(), RustPPModule.GetAbsoluteFilePath("friendsSave.rpp")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp")); } if (Administrator.AdminList.Count != 0) { Logger.Log("Saving administrator list."); ObjectToXML <List <Administrator> >(Administrator.AdminList, RustPPModule.GetAbsoluteFilePath("admins.xml")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("admins.xml"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("admins.xml")); } if (Core.userCache.Count != 0) { Logger.Log("Saving user cache."); ObjectToXML <SerializableDictionary <ulong, string> >(new SerializableDictionary <ulong, string>(Core.userCache), RustPPModule.GetAbsoluteFilePath("userCache.xml")); ObjectToFile <Dictionary <ulong, string> >(Core.userCache, RustPPModule.GetAbsoluteFilePath("cache.rpp")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("cache.rpp"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("cache.rpp")); } if (Core.structureCache.Count != 0) { Logger.Log("Saving structure cache."); ObjectToXML <SerializableDictionary <int, string> >(new SerializableDictionary <int, string>(Core.structureCache), RustPPModule.GetAbsoluteFilePath("structureCache.xml")); ObjectToFile <Dictionary <int, string> >(Core.structureCache, RustPPModule.GetAbsoluteFilePath("structureCache.rpp")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("structureCache.rpp"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("structureCache.rpp")); } if (Core.userLang.Count != 0) { Logger.Log("Guardando preferencias de lenguaje."); ObjectToXML <SerializableDictionary <ulong, string> >(new SerializableDictionary <ulong, string>(Core.userLang), RustPPModule.GetAbsoluteFilePath("userLang.xml")); ObjectToFile <Dictionary <ulong, string> >(Core.userLang, RustPPModule.GetAbsoluteFilePath("userLang.rpp")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("userLang.rpp"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("userLang.rpp")); } if (Core.whiteList.Count != 0) { Logger.Log("Saving whitelist."); ObjectToXML <List <PList.Player> >(Core.whiteList.PlayerList, RustPPModule.GetAbsoluteFilePath("whitelist.xml")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("whitelist.xml"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("whitelist.xml")); } if (Core.muteList.Count != 0) { Logger.Log("Saving mutelist."); ObjectToXML <List <PList.Player> >(Core.muteList.PlayerList, RustPPModule.GetAbsoluteFilePath("mutelist.xml")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("mutelist.xml"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("mutelist.xml")); } if (Core.blackList.Count != 0) { Logger.Log("Saving blacklist."); ObjectToXML <List <PList.Player> >(Core.blackList.PlayerList, RustPPModule.GetAbsoluteFilePath("bans.xml")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("bans.xml"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("bans.xml")); } }
public static void Init() { InitializeCommands(); ShareCommand command = ChatCommand.GetCommand("share") as ShareCommand; FriendsCommand command2 = ChatCommand.GetCommand("friends") as FriendsCommand; bool success = false; if (File.Exists(RustPPModule.GetAbsoluteFilePath("doorsSave.xml"))) { SerializableDictionary <ulong, List <ulong> > doorsDict; doorsDict = Helper.ObjectFromXML <SerializableDictionary <ulong, List <ulong> > >(RustPPModule.GetAbsoluteFilePath("doorsSave.xml")); Hashtable doorsSave = new Hashtable(); foreach (KeyValuePair <ulong, List <ulong> > kvp in doorsDict) { ArrayList arr = new ArrayList(kvp.Value); doorsSave.Add(kvp.Key, arr); } command.SetSharedDoors(doorsSave); success = true; } if (File.Exists(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp")) && !success) { command.SetSharedDoors(Helper.ObjectFromFile <Hashtable>(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp"))); } if (!File.Exists(RustPPModule.GetAbsoluteFilePath("doorsSave.xml"))) { SerializableDictionary <ulong, List <ulong> > doorsSave = new SerializableDictionary <ulong, List <ulong> >(); foreach (DictionaryEntry entry in command.GetSharedDoors()) { ulong key = (ulong)entry.Key; ArrayList value = (ArrayList)entry.Value; List <ulong> list = new List <ulong>(value.OfType <ulong>()); doorsSave.Add(key, list); } Helper.ObjectToXML <SerializableDictionary <ulong, List <ulong> > >(doorsSave, RustPPModule.GetAbsoluteFilePath("doorsSave.xml")); } if (File.Exists(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp"))) { command2.SetFriendsLists(Helper.ObjectFromFile <Hashtable>(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp"))); } if (File.Exists(RustPPModule.GetAbsoluteFilePath("admins.xml"))) { Administrator.AdminList = Helper.ObjectFromXML <List <Administrator> >(RustPPModule.GetAbsoluteFilePath("admins.xml")); } success = false; if (File.Exists(RustPPModule.GetAbsoluteFilePath("userCache.xml"))) { FileInfo fi = new FileInfo(RustPPModule.GetAbsoluteFilePath("userCache.xml")); float mega = (fi.Length / 1024f) / 1024f; if (mega > 0.70) { Logger.LogWarning("Rust++ Cache.xml and Cache.rpp are getting big. Deletion is suggested."); } SerializableDictionary <ulong, string> userDict = Helper.ObjectFromXML <SerializableDictionary <ulong, string> >(RustPPModule.GetAbsoluteFilePath("userCache.xml")); userCache = new Dictionary <ulong, string>(userDict); success = true; } if (File.Exists(RustPPModule.GetAbsoluteFilePath("cache.rpp")) && !success) { userCache = Helper.ObjectFromFile <Dictionary <ulong, string> >(RustPPModule.GetAbsoluteFilePath("cache.rpp")); if (!File.Exists(RustPPModule.GetAbsoluteFilePath("userCache.xml"))) { Helper.ObjectToXML <SerializableDictionary <ulong, string> >(new SerializableDictionary <ulong, string>(userCache), RustPPModule.GetAbsoluteFilePath("userCache.xml")); } } else if (!success) { userCache = new Dictionary <ulong, string>(); } if (File.Exists(RustPPModule.GetAbsoluteFilePath("whitelist.xml"))) { whiteList = new PList(Helper.ObjectFromXML <List <PList.Player> >(RustPPModule.GetAbsoluteFilePath("whitelist.xml"))); } else { whiteList = new PList(); } if (File.Exists(RustPPModule.GetAbsoluteFilePath("mutelist.xml"))) { muteList = new PList(Helper.ObjectFromXML <List <PList.Player> >(RustPPModule.GetAbsoluteFilePath("mutelist.xml"))); } else { muteList = new PList(); } if (File.Exists(RustPPModule.GetAbsoluteFilePath("bans.xml"))) { blackList = new PList(Helper.ObjectFromXML <List <PList.Player> >(RustPPModule.GetAbsoluteFilePath("bans.xml"))); } else { blackList = new PList(); } }
public static void Init() { InitializeCommands(); ShareCommand command = ChatCommand.GetCommand("share") as ShareCommand; FriendsCommand command2 = ChatCommand.GetCommand("friends") as FriendsCommand; bool success = false; if (File.Exists(RustPPModule.GetAbsoluteFilePath("doorsSave.xml"))) { SerializableDictionary <ulong, List <ulong> > doorsDict; doorsDict = Helper.ObjectFromXML <SerializableDictionary <ulong, List <ulong> > >(RustPPModule.GetAbsoluteFilePath("doorsSave.xml")); Hashtable doorsSave = new Hashtable(); foreach (KeyValuePair <ulong, List <ulong> > kvp in doorsDict) { ArrayList arr = new ArrayList(kvp.Value); doorsSave.Add(kvp.Key, arr); } command.SetSharedDoors(doorsSave); success = true; } if (File.Exists(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp")) && !success) { command.SetSharedDoors(Helper.ObjectFromFile <Hashtable>(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp"))); } if (!File.Exists(RustPPModule.GetAbsoluteFilePath("doorsSave.xml"))) { SerializableDictionary <ulong, List <ulong> > doorsSave = new SerializableDictionary <ulong, List <ulong> >(); foreach (DictionaryEntry entry in command.GetSharedDoors()) { ulong key = (ulong)entry.Key; ArrayList value = (ArrayList)entry.Value; List <ulong> list = new List <ulong>(value.OfType <ulong>()); doorsSave.Add(key, list); } Helper.ObjectToXML <SerializableDictionary <ulong, List <ulong> > >(doorsSave, RustPPModule.GetAbsoluteFilePath("doorsSave.xml")); } if (File.Exists(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp"))) { command2.SetFriendsLists(Helper.ObjectFromFile <Hashtable>(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp"))); } if (File.Exists(RustPPModule.GetAbsoluteFilePath("admins.xml"))) { Administrator.AdminList = Helper.ObjectFromXML <List <Administrator> >(RustPPModule.GetAbsoluteFilePath("admins.xml")); } success = false; bool clearer = false; if (File.Exists(RustPPModule.GetAbsoluteFilePath("userCache.xml"))) { FileInfo fi = new FileInfo(RustPPModule.GetAbsoluteFilePath("userCache.xml")); float mega = (fi.Length / 1024f) / 1024f; if (mega > 0.65) { try { //string n = Path.Combine(RustPPModule.ConfigsFolder, "userCache-OLD-" + DateTime.Now.ToShortDateString() + ".xml"); System.IO.File.Move(RustPPModule.GetAbsoluteFilePath("userCache.xml"), Path.Combine(RustPPModule.ConfigsFolder, "userCache-OLD-" + DateTime.Now.ToShortDateString() + ".xml")); clearer = true; } catch (Exception ex) { Logger.LogError("Rust++ failed to copy the usercache file."); } } else { SerializableDictionary <ulong, string> userDict = Helper.ObjectFromXML <SerializableDictionary <ulong, string> >(RustPPModule.GetAbsoluteFilePath("userCache.xml")); userCache = new Dictionary <ulong, string>(userDict); success = true; } } if (File.Exists(RustPPModule.GetAbsoluteFilePath("cache.rpp")) && !success) { if (clearer) { File.WriteAllText(RustPPModule.GetAbsoluteFilePath("cache.rpp"), string.Empty); } userCache = Helper.ObjectFromFile <Dictionary <ulong, string> >(RustPPModule.GetAbsoluteFilePath("cache.rpp")); if (!File.Exists(RustPPModule.GetAbsoluteFilePath("userCache.xml"))) { Helper.ObjectToXML <SerializableDictionary <ulong, string> >(new SerializableDictionary <ulong, string>(userCache), RustPPModule.GetAbsoluteFilePath("userCache.xml")); } } else if (!success) { userCache = new Dictionary <ulong, string>(); } if (File.Exists(RustPPModule.GetAbsoluteFilePath("whitelist.xml"))) { whiteList = new PList(Helper.ObjectFromXML <List <PList.Player> >(RustPPModule.GetAbsoluteFilePath("whitelist.xml"))); } else { whiteList = new PList(); } if (File.Exists(RustPPModule.GetAbsoluteFilePath("mutelist.xml"))) { muteList = new PList(Helper.ObjectFromXML <List <PList.Player> >(RustPPModule.GetAbsoluteFilePath("mutelist.xml"))); } else { muteList = new PList(); } if (File.Exists(RustPPModule.GetAbsoluteFilePath("bans.xml"))) { blackList = new PList(Helper.ObjectFromXML <List <PList.Player> >(RustPPModule.GetAbsoluteFilePath("bans.xml"))); } else { blackList = new PList(); } }