Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Converters;
- using UnityEngine;
- using Oxide.Core;
- namespace Oxide.Plugins
- {
- [Info("LootModifier", "Jojolepro & Mr. Blue/AltCom.io", "1.3.0")]
- class LootModifier : HurtworldPlugin{
- bool gen = false;
- Dictionary<string, Dictionary<string, object>> s;
- void OnServerInitialized()
- {
- timer.Once (1f, () => {
- if(!gen)
- Apply();
- else
- GenData();
- });
- }
- void Loaded()
- {
- s = Interface.Oxide.DataFileSystem.ReadObject<Dictionary<string, Dictionary<string, object>>>("LootModifier");
- if(s == null || s.Count == 0) gen = true;
- }
- void GenData(){
- Dictionary<string, Dictionary<string, object>> o = new Dictionary<string, Dictionary<string, object>>();
- foreach(var l in RuntimeHurtDB.Instance.GetAll<LootTree>()){
- l.OnBeforeSerialize();
- Dictionary<string, object> json = JsonConvert.DeserializeObject<Dictionary<string, object>>(l.TreeJsonData.JsonText);
- o.Add(RuntimeHurtDB.Instance.GetGuid(l), json);
- }
- Interface.Oxide.DataFileSystem.WriteObject("LootModifier",o);
- }
- void Apply(){
- foreach(var e in s){
- var l = RuntimeHurtDB.Instance.GetObjectByGuid<LootTree>(e.Key);
- l.OnBeforeSerialize();
- l.TreeJsonData.JsonText = JsonConvert.SerializeObject(e.Value);
- l.OnAfterDeserialize();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement