Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AutoPluginManager/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void AutoCheckUpdate(EventArgs args)
if (updates.Any())
{
TShock.Log.ConsoleInfo("[以下插件有新的版本更新]\n" + string.Join("\n", updates.Select(i => $"[{i.Name}] V{i.OldVersion} >>> V{i.NewVersion}")));
TShock.Log.ConsoleInfo("你可以使用命令/uplugin更新插件哦~");
TShock.Log.ConsoleInfo("你可以使用命令/apm -u 更新插件哦~");
}

}
Expand Down
10 changes: 9 additions & 1 deletion BedSet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,12 @@

## 文件位置
> tshock/Bed.json

```json
{
"重生点": {}
}
```
## 反馈
- 优先发issued -> 共同维护的插件库:https://github.com/Controllerdestiny/TShockPlugin
- 次优先:TShock官方群:816771079
- 大概率看不到但是也可以:国内社区trhub.cn ,bbstr.net , tr.monika.love
9 changes: 7 additions & 2 deletions Chameleon/Chameleon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class Chameleon : TerrariaPlugin

public override string Description => "账户系统交互替换方案";

public override Version Version => new Version(1, 0, 0);
public override Version Version => new Version(1, 0, 1);

private readonly string _clientWasBooted;

Expand Down Expand Up @@ -327,7 +327,12 @@ public static void Kick(TSPlayer player, string msg, string custom)
private static void LoadConfig()
{
Config = Configuration.Read(Configuration.FilePath);
Config.Write(Configuration.FilePath);

if (Config == null)
{
Config = new Configuration();
Config.Write(Configuration.FilePath);
}

if (Config.AwaitBufferSize != Size)
{
Expand Down
81 changes: 43 additions & 38 deletions Chameleon/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,50 +31,55 @@ internal class Configuration
" 1. 在\"服务器密码\"中输入自己的密码, 以后加服时输入这个密码即可",
" 1. 阅读完毕后请重新加入"
};
[JsonProperty("同步注册服务器")]
public List<RESTser> SyncServerReg = new List<RESTser>
{
new RESTser
{
Name ="测试服务器",
IPAddress = "http://127.0.0.1:7878/",
Token="TOKENTEST"
}
};
[JsonProperty("同步注册服务器")]
public List<RESTser> SyncServerReg { get; set; }

public class RESTser
{
public class RESTser
{
[JsonProperty("名称")]
public string Name { get; set; }
[JsonProperty("地址")]
public string IPAddress { get; set; }
public string Token { get; set; }
}
}

public void Write(string path)
{
using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Write))
{
var str = JsonConvert.SerializeObject(this, Formatting.Indented);
using (var sw = new StreamWriter(fs))
{
sw.Write(str);
}
}
}
public Configuration()
{
SyncServerReg = new List<RESTser>
{
new RESTser
{
Name ="测试服务器",
IPAddress = "http://127.0.0.1:7878/",
Token="TOKENTEST"
}
};
}

public static Configuration Read(string path)
{
if (!File.Exists(path))
return new Configuration();
using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
{
using (var sr = new StreamReader(fs))
{
var cf = JsonConvert.DeserializeObject<Configuration>(sr.ReadToEnd());
return cf;
}
}
}
}
public void Write(string path)
{
using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Write))
{
var str = JsonConvert.SerializeObject(this, Formatting.Indented);
using (var sw = new StreamWriter(fs))
{
sw.Write(str);
}
}
}

public static Configuration Read(string path)
{
if (!File.Exists(path))
return null;
using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
{
using (var sr = new StreamReader(fs))
{
var cf = JsonConvert.DeserializeObject<Configuration>(sr.ReadToEnd());
return cf;
}
}
}
}
}
3 changes: 2 additions & 1 deletion Chameleon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
## 更新日志

```
暂无
v1.0.1
修复了reload后同步注册服务器反复写入的问题
```

## 指令
Expand Down
196 changes: 87 additions & 109 deletions ChestRestore/MainPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,113 +9,91 @@

namespace ChestRestore
{
[ApiVersion(2, 1)]
public class MainPlugin : TerrariaPlugin
{
public MainPlugin(Main game) : base(game)
{
}
public override string Name
{
get
{
return "ChestRestore";
}
}
public override Version Version
{
get
{
return Assembly.GetExecutingAssembly().GetName().Version;
}
}
public override string Author
{
get
{
return "Cjx修改";
}
}
public override string Description
{
get
{
return "箱子自动补充资源";
}
}
public override void Initialize()
{
ServerApi.Hooks.NetGetData.Register(this, new HookHandler<GetDataEventArgs>(this.OnGetData));
GetDataHandlers.ChestOpen += new EventHandler<GetDataHandlers.ChestOpenEventArgs>(this.OnChestOpen);
}
private void OnChestOpen(object sender, GetDataHandlers.ChestOpenEventArgs args)
{
int num = Chest.FindChest(args.X, args.Y);
Chest chest = Main.chest[num];
if (chest != null)
{
bool flag = false;
for (int i = 0; i < chest.item.Length; i++)
{
if (chest.item[i].stack != 0)
{
flag = true;
}
}
if (flag)
{
List<NetItem> list = new List<NetItem>();
for (int j = 0; j < chest.item.Length; j++)
{
Item item = chest.item[j];
list.Add(new NetItem(item.netID, item.stack, item.prefix));
}
args.Player.SetData<string>("chestrestore", JsonConvert.SerializeObject(list));
args.Player.SetData<int>("chestx", args.X);
args.Player.SetData<int>("chesty", args.Y);
}
}
}
private void OnGetData(GetDataEventArgs args)
{
if (args.MsgID == PacketTypes.ChestOpen)
{
using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(args.Msg.readBuffer, args.Index, args.Length)))
{
TSPlayer tsplayer = TShock.Players[args.Msg.whoAmI];
int num = (int)binaryReader.ReadInt16();
int num2 = Chest.FindChest(tsplayer.GetData<int>("chestx"), tsplayer.GetData<int>("chesty"));
Chest chest = null;
if (num2 != -1)
{
chest = Main.chest[num2];
}
if (num == -1 && chest != null)
{
List<NetItem> list = JsonConvert.DeserializeObject<List<NetItem>>(tsplayer.GetData<string>("chestrestore"));
for (int i = 0; i < chest.item.Length; i++)
{
Item item = chest.item[i];
item.netDefaults(list[i].NetId);
item.stack = list[i].Stack;
item.prefix = list[i].PrefixId;
TSPlayer.All.SendData(PacketTypes.ChestItem, "", num2, (float)i, 0f, 0f, 0);
}
tsplayer.SetData<string>("chestrestore", "");
tsplayer.SetData<int>("chestx", 0);
tsplayer.SetData<int>("chesty", 0);
}
}
}
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
ServerApi.Hooks.NetGetData.Deregister(this, new HookHandler<GetDataEventArgs>(this.OnGetData));
GetDataHandlers.ChestOpen -= new EventHandler<GetDataHandlers.ChestOpenEventArgs>(this.OnChestOpen);
}
base.Dispose(disposing);
}
}
[ApiVersion(2, 1)]
public class MainPlugin : TerrariaPlugin
{
public MainPlugin(Main game) : base(game)
{
}
public override string Name => "ChestRestore";
public override Version Version => new Version(1, 0, 1);
public override string Author => "Cjx修改,肝帝熙恩简单修改";
public override string Description => "无限宝箱插件";

public override void Initialize()
{
ServerApi.Hooks.NetGetData.Register(this, OnGetData);
GetDataHandlers.ChestOpen += OnChestOpen;
}
private void OnChestOpen(object sender, GetDataHandlers.ChestOpenEventArgs args)
{
int num = Chest.FindChest(args.X, args.Y);
Chest chest = Main.chest[num];
if (chest != null)
{
bool hasItems = false;
foreach (Item item in chest.item)
{
if (item.stack != 0)
{
hasItems = true;
break;
}
}
if (hasItems)
{
List<NetItem> list = new List<NetItem>();
for (int j = 0; j < chest.item.Length; j++)
{
Item item = chest.item[j];
list.Add(new NetItem(item.netID, item.stack, item.prefix));
}
args.Player.SetData("chestrestore", JsonConvert.SerializeObject(list));
args.Player.SetData("chestx", args.X);
args.Player.SetData("chesty", args.Y);
}
}
}
private void OnGetData(GetDataEventArgs args)
{
if (args.MsgID == PacketTypes.ChestOpen)
{
using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(args.Msg.readBuffer, args.Index, args.Length)))
{
TSPlayer tsplayer = TShock.Players[args.Msg.whoAmI];
int num = binaryReader.ReadInt16();
int num2 = Chest.FindChest(tsplayer.GetData<int>("chestx"), tsplayer.GetData<int>("chesty"));
Chest chest = null;
if (num2 != -1)
{
chest = Main.chest[num2];
}
if (num == -1 && chest != null)
{
List<NetItem> list = JsonConvert.DeserializeObject<List<NetItem>>(tsplayer.GetData<string>("chestrestore"));
for (int i = 0; i < chest.item.Length; i++)
{
Item item = chest.item[i];
item.netDefaults(list[i].NetId);
item.stack = list[i].Stack;
item.prefix = list[i].PrefixId;
TSPlayer.All.SendData(PacketTypes.ChestItem, "", num2, (float)i, 0f, 0f, 0);
}
tsplayer.SetData("chestrestore", "");
tsplayer.SetData("chestx", 0);
tsplayer.SetData("chesty", 0);
}
}
}
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
ServerApi.Hooks.NetGetData.Deregister(this, OnGetData);
GetDataHandlers.ChestOpen -= OnChestOpen;
}
base.Dispose(disposing);
}
}
}
7 changes: 4 additions & 3 deletions ChestRestore/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# ChestRestore

- 作者: 未知(Cjx修改
- 资源无限插件
- 作者: 佚名,Cjx修改,肝帝熙恩简单修改
- 无限宝箱插件,装上后全局宝箱无限拿取且不可更改

## 更新日志

```
暂无
v1.0.1
优化简化部分代码
```

## 指令
Expand Down