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
36 changes: 22 additions & 14 deletions src/ItemDecoration/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Terraria.ID;
using TerrariaApi.Server;
using TShockAPI;
using TShockAPI.Hooks;

namespace ItemDecoration;

Expand All @@ -21,7 +22,7 @@ public class Plugin : LazyPlugin
public override string Description => GetString("Show Item Decoration and More!!!");

public override string Name => Assembly.GetExecutingAssembly().GetName().Name!;
public override Version Version => new Version(3, 0, 1);
public override Version Version => new Version(3, 0, 2);

public Plugin(Main game) : base(game)
{
Expand All @@ -30,23 +31,30 @@ public Plugin(Main game) : base(game)

public override void Initialize()
{
ServerApi.Hooks.ServerChat.Register(this, this.OnServerChat);
PlayerHooks.PlayerChat += this.OnPlayerChat;
Hooks.MessageBuffer.InvokeGetData += this.MessageBuffer_InvokeGetData;
}
Comment thread
sourcery-ai[bot] marked this conversation as resolved.


private void OnServerChat(ServerChatEventArgs args)
protected override void Dispose(bool disposing)
{
var player = TShock.Players[args.Who];
if (args.Handled || player == null
|| args.Text.StartsWith(TShock.Config.Settings.CommandSilentSpecifier)
|| args.Text.StartsWith(TShock.Config.Settings.CommandSpecifier)
|| string.IsNullOrWhiteSpace(args.Text)) // Verificar si el texto está vacío o es solo espacios en blanco.
if (disposing)
{
PlayerHooks.PlayerChat -= this.OnPlayerChat;
Hooks.MessageBuffer.InvokeGetData -= this.MessageBuffer_InvokeGetData;
}
base.Dispose(disposing);
}


private void OnPlayerChat(PlayerChatEventArgs args)
{
var player = args.Player;
if (args.Handled || player == null || string.IsNullOrWhiteSpace(args.RawText))
{
return;
}
var msg = ReplacePlaceholderWithItem(player, args.Text);
if (!string.IsNullOrWhiteSpace(msg)) // Verificar que el mensaje procesado no esté vacío.
var msg = ReplacePlaceholderWithItem(player, args.RawText);
if (!string.IsNullOrWhiteSpace(msg))
{
TShock.Utils.Broadcast(string.Format(
TShock.Config.Settings.ChatFormat,
Expand Down Expand Up @@ -116,8 +124,8 @@ private bool MessageBuffer_InvokeGetData(Hooks.MessageBuffer.orig_InvokeGetData
{
return orig(instance, ref packetId, ref readOffset, ref start, ref length, ref messageType, maxPackets);
}


if (!this._lastSelectedItem.ContainsKey(player.Index) || this._lastSelectedItem[player.Index] != newSelectItem.type)
{
this._lastSelectedItem[player.Index] = newSelectItem.type;
Expand Down Expand Up @@ -165,7 +173,7 @@ private static string ReplacePlaceholderWithItem(TSPlayer player, string message
{
stringBuilder.Append(' ');
}

stringBuilder.Append($"[c/{damageColorHex}:{selectedItem.damage}]");
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/ItemDecoration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@
```
## 更新日志

### v3.0.2
- 修复 `/help 2` 等带数字的指令会被误拦截的问题(ServerChat → PlayerChat)
### v1.0.0.1
- 完成西班牙语的i18n config配置,修复聊天不显示名字的问题
### v1.0.0.0
Expand Down
14 changes: 12 additions & 2 deletions src/WorldEdit/WorldEdit/WorldEdit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class WorldEdit : TerrariaPlugin

public override string Name => System.Reflection.Assembly.GetExecutingAssembly().GetName().Name!;

public override Version Version => new Version(2026, 07, 20);
public override Version Version => new Version(2026, 07, 21);

static WorldEdit()
{
Expand Down Expand Up @@ -407,6 +407,8 @@ private void OnInitialize(EventArgs e)
{
HelpText = "Sets actuators in the worldedit selection."
});
try
{
string text = TShock.Config.Settings.StorageType.ToLowerInvariant();
string storageType = text;
if (storageType != "mysql")
Expand All @@ -430,7 +432,10 @@ private void OnInitialize(EventArgs e)
}
if (!File.Exists(path))
{
Database.Query("DROP TABLE WorldEdit");
if (Database != null)
{
Database.Query("DROP TABLE IF EXISTS WorldEdit");
}
foreach (string item in Directory.EnumerateFiles("worldedit", "undo-*.dat"))
{
File.Delete(item);
Expand Down Expand Up @@ -478,6 +483,11 @@ private void OnInitialize(EventArgs e)
Colors.Add(itemNameById.Substring(0, itemNameById.Length - 6).ToLowerInvariant(), paintItem.paint);
}
}
}
catch (Exception ex)
{
TShock.Log.ConsoleError($"WorldEdit initialization error (database/biomes/colors): {ex}");
}
Selections.Add("altcheckers", (int i, int j, TSPlayer plr) => ((i + j) & 1) == 0);
Selections.Add("checkers", (int i, int j, TSPlayer plr) => ((i + j) & 1) == 1);
Selections.Add("ellipse", delegate (int i, int j, TSPlayer plr)
Expand Down
Loading