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

添加插件:MapTeleport #9

Merged
merged 2 commits into from
Apr 12, 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
53 changes: 53 additions & 0 deletions MapTp/MapTeleport.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Microsoft.Xna.Framework;
using System;
using System.IO;
using System.Reflection;
using Terraria;
using TerrariaApi.Server;
using TShockAPI;
using System.Timers;

namespace MapTeleport
{
[ApiVersion(2, 1)]
public class MapTeleport : TerrariaPlugin
{
public MapTeleport(Main game) : base(game)
{
Order = 1;
}
public override Version Version => Assembly.GetExecutingAssembly().GetName().Version;
public override string Author => "Nova4334,肝帝熙恩汉化适配1449";
public override string Name => "MapTeleport";
public override string Description => "允许玩家传送到地图上的选定位置.";

public override void Initialize()
{
GetDataHandlers.ReadNetModule.Register(teleport);
}

public const string ALLOWED = "maptp.noclip";

public const string ALLOWEDSOLIDS = "maptp";

private void teleport(object unused, GetDataHandlers.ReadNetModuleEventArgs args)
{
if (args.Player.HasPermission(ALLOWED) || args.Player.HasPermission(ALLOWEDSOLIDS))
{
if (args.ModuleType == GetDataHandlers.NetModuleType.Ping)
{
using (var reader = new BinaryReader(args.Data))
{
Vector2 pos = reader.ReadVector2();
if (!(pos.X == Tile.Type_Solid && pos.Y == Tile.Type_Solid) || args.Player.HasPermission(ALLOWEDSOLIDS))
{
args.Player.Teleport(pos.X * 16, pos.Y * 16); return;
}
else args.Player.SendErrorMessage("您正在尝试传送到实心方块中。请在地图上选择一个不包含实心方块的地方,然后重试.");
return;
}
}
}
}
}
}
5 changes: 5 additions & 0 deletions MapTp/MapTp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="..\template.targets" />

</Project>
28 changes: 28 additions & 0 deletions MapTp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Maptp 双击大地图传送

- 作者: Nova4334,肝帝熙恩
- 出处: github
- 有权限的玩家打开大地图后,双击去往所指定的位置
- 更近一步是否允许传送到实心方块

## 更新日志

```
暂无
```

## 指令

| 语法 | 权限 | 说明 |
| -------------- | :-----------------: | :------: |
| 无 | maptp.noclip | 允许双击传送(不包括实心方块)|
| 无 | maptp | 允许双击传送(包括实心方块)|

## 配置

```json
暂无
```
## 反馈
- 共同维护的插件库:https://github.com/THEXN/TShockPlugin/
- 国内社区trhub.cn 或 TShock官方群等
10 changes: 10 additions & 0 deletions Plugin.sln
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Back", "Back\Back.csproj",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BanNpc", "BanNpc\BanNpc.csproj", "{A0CD7941-8248-4DEE-B6C1-972995A9D511}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MapTp", "MapTp\MapTp.csproj", "{E3F0A3C7-2B10-48AB-B280-722F2039944C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -156,6 +158,14 @@ Global
{A0CD7941-8248-4DEE-B6C1-972995A9D511}.Release|Any CPU.Build.0 = Release|Any CPU
{A0CD7941-8248-4DEE-B6C1-972995A9D511}.Release|x64.ActiveCfg = Release|Any CPU
{A0CD7941-8248-4DEE-B6C1-972995A9D511}.Release|x64.Build.0 = Release|Any CPU
{E3F0A3C7-2B10-48AB-B280-722F2039944C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E3F0A3C7-2B10-48AB-B280-722F2039944C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E3F0A3C7-2B10-48AB-B280-722F2039944C}.Debug|x64.ActiveCfg = Debug|Any CPU
{E3F0A3C7-2B10-48AB-B280-722F2039944C}.Debug|x64.Build.0 = Debug|Any CPU
{E3F0A3C7-2B10-48AB-B280-722F2039944C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E3F0A3C7-2B10-48AB-B280-722F2039944C}.Release|Any CPU.Build.0 = Release|Any CPU
{E3F0A3C7-2B10-48AB-B280-722F2039944C}.Release|x64.ActiveCfg = Release|Any CPU
{E3F0A3C7-2B10-48AB-B280-722F2039944C}.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 @@ -39,3 +39,4 @@
| [DisableMonsCoin](https://github.com/Controllerdestiny/TShockPlugin/tree/master/DisableMonsCoin) | 怪物不掉钱 | 无 |
| [Back](https://github.com/Controllerdestiny/TShockPlugin/tree/master/Back) | 死亡回溯 | 无 |
| [BanNpc](https://github.com/Controllerdestiny/TShockPlugin/tree/master/BanNpc) | 阻止怪物生成 | 无 |
| [MapTeleport](https://github.com/Controllerdestiny/TShockPlugin/tree/master/MapTeleport) | 双击大地图传送 | 无 |
Loading