mirror of
https://github.com/MikuLeaks/KianaBH3.git
synced 2025-12-12 13:04:33 +01:00
feat: add giveall command
This commit is contained in:
@@ -40,7 +40,7 @@ public class WordTextEN
|
|||||||
public string Material => "Material";
|
public string Material => "Material";
|
||||||
public string Pet => "Pet";
|
public string Pet => "Pet";
|
||||||
public string Relic => "Relic";
|
public string Relic => "Relic";
|
||||||
public string Equipment => "Light Cone";
|
public string Weapon => "Weapon";
|
||||||
public string Talent => "Talent";
|
public string Talent => "Talent";
|
||||||
public string Banner => "Gacha";
|
public string Banner => "Gacha";
|
||||||
public string Activity => "Activity";
|
public string Activity => "Activity";
|
||||||
@@ -120,6 +120,7 @@ public class CommandTextEN
|
|||||||
public NoticeTextEN Notice { get; } = new();
|
public NoticeTextEN Notice { get; } = new();
|
||||||
public HelpTextEN Help { get; } = new();
|
public HelpTextEN Help { get; } = new();
|
||||||
public ValkTextEN Valk { get; } = new();
|
public ValkTextEN Valk { get; } = new();
|
||||||
|
public GiveAllTextEN GiveAll { get; } = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -238,6 +239,19 @@ public class ValkTextEN
|
|||||||
public string ValkSetSkillLevel => "Set character {0}'s skill levels to max!";
|
public string ValkSetSkillLevel => "Set character {0}'s skill levels to max!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// path: Game.Command.GiveAll
|
||||||
|
/// </summary>
|
||||||
|
public class GiveAllTextEN
|
||||||
|
{
|
||||||
|
public string Desc => "Give all items of specified type\n" +
|
||||||
|
"weapon: weapons";
|
||||||
|
|
||||||
|
public string Usage =>
|
||||||
|
"Usage: /giveall weapon";
|
||||||
|
|
||||||
|
public string GiveAllItems => "Granted all {0}";
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
22
GameServer/Command/Commands/CommandGiveAll.cs
Normal file
22
GameServer/Command/Commands/CommandGiveAll.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using KianaBH.Data;
|
||||||
|
using KianaBH.Enums.Item;
|
||||||
|
using KianaBH.Enums.Player;
|
||||||
|
using KianaBH.Internationalization;
|
||||||
|
|
||||||
|
namespace KianaBH.GameServer.Command.Commands;
|
||||||
|
|
||||||
|
[CommandInfo("giveall", "Game.Command.GiveAll.Desc", "Game.Command.GiveAll.Usage", ["ga"], [PermEnum.Admin, PermEnum.Support])]
|
||||||
|
public class CommandGiveall : ICommands
|
||||||
|
{
|
||||||
|
[CommandMethod("weapon")]
|
||||||
|
public async ValueTask GiveWeapon(CommandArg arg)
|
||||||
|
{
|
||||||
|
if (!await arg.CheckOnlineTarget()) return;
|
||||||
|
foreach (var conf in GameData.WeaponData.Values.Where(weapon => weapon.Rarity == weapon.MaxRarity))
|
||||||
|
{
|
||||||
|
var item = await arg.Target!.Player!.InventoryManager!.AddItem(conf.ID, 1, ItemMainTypeEnum.Weapon, conf.MaxLv, sync:false);
|
||||||
|
}
|
||||||
|
await arg.Target!.Player!.SyncWeapon();
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.GiveAllItems", I18NManager.Translate("Word.Weapon")));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -111,6 +111,11 @@ public class PlayerInstance(PlayerData data)
|
|||||||
return Data.ToProto();
|
return Data.ToProto();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async ValueTask SyncWeapon()
|
||||||
|
{
|
||||||
|
await SendPacket(new PacketGetEquipmentDataRsp(this));
|
||||||
|
}
|
||||||
|
|
||||||
public async ValueTask SyncValk()
|
public async ValueTask SyncValk()
|
||||||
{
|
{
|
||||||
await SendPacket(new PacketGetAvatarDataRsp(AvatarManager!.AvatarData!.Avatars!.ToList(), true));
|
await SendPacket(new PacketGetAvatarDataRsp(AvatarManager!.AvatarData!.Avatars!.ToList(), true));
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using KianaBH.Internationalization;
|
|||||||
using KianaBH.Util;
|
using KianaBH.Util;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace KianaBH.KianaBH.Tool;
|
namespace KianaBH.KianaBH.Tool;
|
||||||
|
|
||||||
@@ -40,8 +41,7 @@ public static class HandbookGenerator
|
|||||||
public static void Generate(string lang)
|
public static void Generate(string lang)
|
||||||
{
|
{
|
||||||
var textMapPath = ConfigManager.Config.Path.ResourcePath + "/TextMap/TextMap" + lang + ".json";
|
var textMapPath = ConfigManager.Config.Path.ResourcePath + "/TextMap/TextMap" + lang + ".json";
|
||||||
var fallbackTextMapPath = ConfigManager.Config.Path.ResourcePath + "/TextMap/TextMap" +
|
|
||||||
ConfigManager.Config.ServerOption.FallbackLanguage + ".json";
|
|
||||||
if (!File.Exists(textMapPath))
|
if (!File.Exists(textMapPath))
|
||||||
{
|
{
|
||||||
Logger.GetByClassName().Error(I18NManager.Translate("Server.ServerInfo.FailedToReadItem", textMapPath,
|
Logger.GetByClassName().Error(I18NManager.Translate("Server.ServerInfo.FailedToReadItem", textMapPath,
|
||||||
@@ -49,18 +49,9 @@ public static class HandbookGenerator
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!File.Exists(fallbackTextMapPath))
|
List<TextMapEntry> textMap = JsonConvert.DeserializeObject<List<TextMapEntry>>(File.ReadAllText(textMapPath))!;
|
||||||
{
|
|
||||||
Logger.GetByClassName().Error(I18NManager.Translate("Server.ServerInfo.FailedToReadItem", textMapPath,
|
|
||||||
I18NManager.Translate("Word.NotFound")));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var textMap = JsonConvert.DeserializeObject<Dictionary<long, string>>(File.ReadAllText(textMapPath));
|
if (textMap == null)
|
||||||
var fallbackTextMap =
|
|
||||||
JsonConvert.DeserializeObject<Dictionary<long, string>>(File.ReadAllText(fallbackTextMapPath));
|
|
||||||
|
|
||||||
if (textMap == null || fallbackTextMap == null)
|
|
||||||
{
|
{
|
||||||
Logger.GetByClassName().Error(I18NManager.Translate("Server.ServerInfo.FailedToReadItem", textMapPath,
|
Logger.GetByClassName().Error(I18NManager.Translate("Server.ServerInfo.FailedToReadItem", textMapPath,
|
||||||
I18NManager.Translate("Word.Error")));
|
I18NManager.Translate("Word.Error")));
|
||||||
@@ -92,4 +83,15 @@ public static class HandbookGenerator
|
|||||||
{
|
{
|
||||||
File.WriteAllText($"{ConfigManager.Config.Path.HandbookPath}/Handbook{lang}.txt", content);
|
File.WriteAllText($"{ConfigManager.Config.Path.HandbookPath}/Handbook{lang}.txt", content);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TextMapEntry
|
||||||
|
{
|
||||||
|
[JsonPropertyName("value")] public ValueEntry? Value { get; set; }
|
||||||
|
[JsonPropertyName("text")] public string? Text { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ValueEntry
|
||||||
|
{
|
||||||
|
[JsonPropertyName("hash")] public int Hash { get; set; }
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user