Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加插件:UnseenInventory 允许服务器端生成“无法获取”的物品 #389

Merged
merged 2 commits into from
Aug 13, 2024
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
10 changes: 10 additions & 0 deletions Plugin.sln
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SmartRegions", "SmartRegion
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProxyProtocolSocket", "ProxyProtocolSocket\ProxyProtocolSocket.csproj", "{CBCF3F14-A506-435D-BC55-A06FFEB095B2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnseenInventory", "UnseenInventory\UnseenInventory.csproj", "{5ECADACA-6DD4-47CC-BC23-A1F2A81186DE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1106,6 +1108,14 @@ Global
{CBCF3F14-A506-435D-BC55-A06FFEB095B2}.Release|Any CPU.Build.0 = Release|Any CPU
{CBCF3F14-A506-435D-BC55-A06FFEB095B2}.Release|x64.ActiveCfg = Release|Any CPU
{CBCF3F14-A506-435D-BC55-A06FFEB095B2}.Release|x64.Build.0 = Release|Any CPU
{5ECADACA-6DD4-47CC-BC23-A1F2A81186DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5ECADACA-6DD4-47CC-BC23-A1F2A81186DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5ECADACA-6DD4-47CC-BC23-A1F2A81186DE}.Debug|x64.ActiveCfg = Debug|Any CPU
{5ECADACA-6DD4-47CC-BC23-A1F2A81186DE}.Debug|x64.Build.0 = Debug|Any CPU
{5ECADACA-6DD4-47CC-BC23-A1F2A81186DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5ECADACA-6DD4-47CC-BC23-A1F2A81186DE}.Release|Any CPU.Build.0 = Release|Any CPU
{5ECADACA-6DD4-47CC-BC23-A1F2A81186DE}.Release|x64.ActiveCfg = Release|Any CPU
{5ECADACA-6DD4-47CC-BC23-A1F2A81186DE}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
| [AutoReset](AutoReset/README.md) | 完全自动重置 | 无 |
| [SmartRegions](SmartRegions/README.md) | 智能区域 | 无 |
| [ProxyProtocolSocket](ProxyProtocolSocket/README.md) | 接受 proxy protocol 协议 | 无 |
| [UnseenInventory](UnseenInventory/README.md) | 允许服务器端生成“无法获取”的物品 | 无 |

</Details>

Expand Down
63 changes: 63 additions & 0 deletions UnseenInventory/Configuration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using Newtonsoft.Json;
using Terraria.ID;
using TShockAPI;

namespace UnseenInventory;

public class Configuration
{
public static readonly string FilePath = Path.Combine(TShock.SavePath, "允许无法获取的物品列表.json");

[JsonProperty("允许无法获取的物品id")]
public int[] AllowList = new int[] { 4722 };
[JsonProperty("参考列表")]
public Dictionary<int, string> Items = new Dictionary<int, string>
{
{ 2772, "星旋斧" },
{ 2773, "星旋链锯" },
{ 2775, "星旋锤" },
{ 2777, "星云斧" },
{ 2778, "星云链锯" },
{ 2780, "星云锤" },
{ 2782, "耀斑斧" },
{ 2783, "耀斑链锯" },
{ 2785, "耀斑锤" },
{ 2881, "相位扭曲弹射器" },
{ 3462, "星尘斧" },
{ 3463, "星尘链锯" },
{ 3465, "星尘镐" },
{ 3847, "食人魔面具" },
{ 3848, "哥布林面具" },
{ 3849, "哥布林炸弹帽" },
{ 3850, "埃特尼亚标枪" },
{ 3851, "小妖魔雷管背包" },
{ 3861, "食人魔宝藏袋" },
{ 3862, "黑暗魔法师宝藏袋" },
{ 3978, "仅颜色染料" },
{ 4010, "苹果派切片" },
{ 4058, "骷髅头弓" },
{ 4722, "第一分型" },
{ 5013, "入睡图标" },
};

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 new Configuration();
using var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
using var sr = new StreamReader(fs);
return JsonConvert.DeserializeObject<Configuration>(sr.ReadToEnd()) ?? new();
}
}
60 changes: 60 additions & 0 deletions UnseenInventory/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# UnseenInventory 允许服务器端生成“无法获取”的物品

- 作者: 肝帝熙恩
- 出处: 参考了[gitee](https://gitee.com/hufang360/TShockAllowFirstFractal)
- 允许服务器端生成“无法获取”的物品,比如/i 4722
- 但是客户端也有检测,需要配合特殊的客户端使用
- 特殊客户端,电脑版可b站搜:hufang360,手机版可b站搜:EternalFuture
- 或者https://niaoluo.top/wp-admin/post.php?post=232&action=edit内搜索“泰拉瑞亚,实用工具”

## 更新日志

```
暂无
```
## 指令

```
暂无
```

## 配置

```json
{
"允许无法获取的物品id": [
4722
],
"参考列表": {
"2772": "星旋斧",
"2773": "星旋链锯",
"2775": "星旋锤",
"2777": "星云斧",
"2778": "星云链锯",
"2780": "星云锤",
"2782": "耀斑斧",
"2783": "耀斑链锯",
"2785": "耀斑锤",
"2881": "相位扭曲弹射器",
"3462": "星尘斧",
"3463": "星尘链锯",
"3465": "星尘镐",
"3847": "食人魔面具",
"3848": "哥布林面具",
"3849": "哥布林炸弹帽",
"3850": "埃特尼亚标枪",
"3851": "小妖魔雷管背包",
"3861": "食人魔宝藏袋",
"3862": "黑暗魔法师宝藏袋",
"3978": "仅颜色染料",
"4010": "苹果派切片",
"4058": "骷髅头弓",
"4722": "第一分型",
"5013": "入睡图标"
}
}
```
## 反馈
- 优先发issued -> 共同维护的插件库:https://github.com/Controllerdestiny/TShockPlugin
- 次优先:TShock官方群:816771079
- 大概率看不到但是也可以:国内社区trhub.cn ,bbstr.net , tr.monika.love
65 changes: 65 additions & 0 deletions UnseenInventory/UnseenInventory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System;
using System.Reflection;
using Terraria;
using Terraria.ID;
using TerrariaApi.Server;
using TShockAPI;
using TShockAPI.Hooks;


namespace UnseenInventory
{
[ApiVersion(2, 1)]
public class UnseenInventory : TerrariaPlugin
{

public override string Author => "肝帝熙恩";
public override string Description => "允许服务器端生成“无法获取”的物品";
public override string Name => "UnseenInventory";
public override Version Version => new Version(1, 0, 0);
public static Configuration Config;

public UnseenInventory(Main game) : base(game)
{
LoadConfig();
}

private static void LoadConfig()
{
Config = Configuration.Read(Configuration.FilePath);
Config.Write(Configuration.FilePath);
}

private static void ReloadConfig(ReloadEventArgs args)
{
LoadConfig();
OnUpdate();
args.Player.SendSuccessMessage("[{0}] 重新加载配置完毕。", typeof(UnseenInventory).Name);
}

public override void Initialize()
{
GeneralHooks.ReloadEvent += ReloadConfig;
OnUpdate();
}

protected override void Dispose(bool disposing)
{
if (disposing)
{
GeneralHooks.ReloadEvent -= ReloadConfig;
}
base.Dispose(disposing);
}

private static void OnUpdate()
{

foreach (var item in Config.AllowList)
{
Array.Clear(ItemID.Sets.Deprecated, item, 1);
}
}

}
}
3 changes: 3 additions & 0 deletions UnseenInventory/UnseenInventory.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\template.targets"/>
</Project>
Loading