Skip to content

Commit

Permalink
Update For LabAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
XLittleLeft committed Feb 11, 2025
1 parent d59b476 commit a80435e
Show file tree
Hide file tree
Showing 34 changed files with 833 additions and 963 deletions.
5 changes: 3 additions & 2 deletions HelpSense/API/API.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using HelpSense.API.Serialization;
using HelpSense.API.Events;
using HelpSense.API.Serialization;
using LiteDB;
using System.Collections.Generic;

Expand All @@ -15,7 +16,7 @@ public static bool TryGetLog(string id, out PlayerLog log)
{
return true;
}
using LiteDatabase database = new(Plugin.Instance.Config.SavePath);
using LiteDatabase database = new(CustomEventHandler.Config.SavePath);
log = database.GetCollection<PlayerLog>("Players")?.FindById(id);
if (log != null)
{
Expand Down
728 changes: 418 additions & 310 deletions HelpSense/Plugin.cs → HelpSense/API/Events/CustomEventHandler.cs

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions HelpSense/API/InfoExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ namespace HelpSense.API
using HelpSense.Helper;
using LiteDB;
using MEC;
using PluginAPI.Core;
using LabApi.Features.Wrappers;
using System;
using HelpSense.API.Events;

public static class InfoExtension
{
Expand All @@ -30,7 +31,7 @@ public static PlayerLog GetLog(this Player ply)
RolePlayed = 0,
PlayerShot = 0,
};
using LiteDatabase database = new(Plugin.Instance.Config.SavePath);
using LiteDatabase database = new(CustomEventHandler.Config.SavePath);
database.GetCollection<PlayerLog>("Players").Insert(toInsert);
}

Expand Down Expand Up @@ -59,7 +60,7 @@ public static PlayerLog GetLog(this ReferenceHub ply)
RolePlayed = 0,
PlayerShot = 0,
};
using LiteDatabase database = new(Plugin.Instance.Config.SavePath);
using LiteDatabase database = new(CustomEventHandler.Config.SavePath);
database.GetCollection<PlayerLog>("Players").Insert(toInsert);
}

Expand All @@ -70,7 +71,7 @@ public static PlayerLog GetLog(this ReferenceHub ply)

public static void UpdateLog(this PlayerLog log)
{
using LiteDatabase database = new(Plugin.Instance.Config.SavePath);
using LiteDatabase database = new(CustomEventHandler.Config.SavePath);
database.GetCollection<PlayerLog>("Players").Update(log);
}

Expand Down
9 changes: 6 additions & 3 deletions HelpSense/Commands/ChatCommand/AcCommand.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using CommandSystem;
using HelpSense.Helper.Chat;
using HelpSense.ConfigSystem;
using PluginAPI.Core;
using LabApi.Features.Wrappers;
using System;

using Log = LabApi.Features.Console.Logger;
using HelpSense.API.Events;

namespace HelpSense.Commands.ChatCommand
{
[CommandHandler(typeof(ClientCommandHandler))]
Expand All @@ -17,7 +20,7 @@ public class AcCommand : ICommand

public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
CommandTranslateConfig CommandTranslateConfig = Plugin.Instance.CommandTranslateConfig;
CommandTranslateConfig CommandTranslateConfig = CustomEventHandler.CommandTranslateConfig;
Player player;

if (sender is null || (player = Player.Get(sender)) is null)
Expand All @@ -26,7 +29,7 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
return false;
}

if (arguments.Count == 0 || player.IsMuted || !Plugin.Instance.Config.EnableAcSystem)
if (arguments.Count == 0 || player.IsMuted || !CustomEventHandler.Config.EnableAcSystem)
{
response = CommandTranslateConfig.ChatCommandFailed;
return false;
Expand Down
9 changes: 6 additions & 3 deletions HelpSense/Commands/ChatCommand/BcCommand.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using CommandSystem;
using HelpSense.Helper.Chat;
using HelpSense.ConfigSystem;
using PluginAPI.Core;
using LabApi.Features.Wrappers;
using System;

using Log = LabApi.Features.Console.Logger;
using HelpSense.API.Events;

namespace HelpSense.Commands.ChatCommand
{
[CommandHandler(typeof(ClientCommandHandler))]
Expand All @@ -17,7 +20,7 @@ public class BcCommand : ICommand

public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
CommandTranslateConfig CommandTranslateConfig = Plugin.Instance.CommandTranslateConfig;
CommandTranslateConfig CommandTranslateConfig = CustomEventHandler.CommandTranslateConfig;
Player player;

if (sender is null || (player = Player.Get(sender)) is null)
Expand All @@ -26,7 +29,7 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
return false;
}

if (arguments.Count == 0 || player.IsMuted || !Plugin.Instance.Config.EnableChatSystem)
if (arguments.Count == 0 || player.IsMuted || !CustomEventHandler.Config.EnableChatSystem)
{
response = CommandTranslateConfig.ChatCommandFailed;
return false;
Expand Down
9 changes: 6 additions & 3 deletions HelpSense/Commands/ChatCommand/CCommand.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using CommandSystem;
using HelpSense.Helper.Chat;
using HelpSense.ConfigSystem;
using PluginAPI.Core;
using LabApi.Features.Wrappers;
using System;

using Log = LabApi.Features.Console.Logger;
using HelpSense.API.Events;

namespace HelpSense.Commands.ChatCommand
{
[CommandHandler(typeof(ClientCommandHandler))]
Expand All @@ -17,7 +20,7 @@ public class CCommand : ICommand

public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
CommandTranslateConfig CommandTranslateConfig = Plugin.Instance.CommandTranslateConfig;
CommandTranslateConfig CommandTranslateConfig = CustomEventHandler.CommandTranslateConfig;
Player player;

if (sender is null || (player = Player.Get(sender)) is null)
Expand All @@ -26,7 +29,7 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
return false;
}

if (arguments.Count == 0 || player.IsMuted || !Plugin.Instance.Config.EnableChatSystem)
if (arguments.Count == 0 || player.IsMuted || !CustomEventHandler.Config.EnableChatSystem)
{
response = CommandTranslateConfig.ChatCommandFailed;
return false;
Expand Down
7 changes: 4 additions & 3 deletions HelpSense/Commands/InfoCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
using HelpSense.API.Serialization;
using HelpSense.ConfigSystem;
using PlayerRoles;
using PluginAPI.Core;
using LabApi.Features.Wrappers;
using System;
using HelpSense.API.Events;

namespace HelpSense.Commands
{
Expand All @@ -21,15 +22,15 @@ public class InfoCommand : ICommand
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
Player player;
CommandTranslateConfig CommandTranslateConfig = Plugin.Instance.CommandTranslateConfig;
CommandTranslateConfig CommandTranslateConfig = CustomEventHandler.CommandTranslateConfig;

if (sender is null || (player = Player.Get(sender)) is null)
{
response = CommandTranslateConfig.InfoCommandFailed;
return false;
}

if (player.DoNotTrack || !Plugin.Instance.Config.SavePlayersInfo)
if (player.DoNotTrack || !CustomEventHandler.Config.SavePlayersInfo)
{
response = CommandTranslateConfig.InfoCommandFailed;
return false;
Expand Down
7 changes: 5 additions & 2 deletions HelpSense/Commands/RescueCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
using HelpSense.ConfigSystem;
using HelpSense.Helper;
using MEC;
using PluginAPI.Core;
using LabApi.Features.Wrappers;
using RelativePositioning;
using System;

using Log = LabApi.Features.Console.Logger;
using HelpSense.API.Events;

namespace HelpSense.Commands
{
[CommandHandler(typeof(ClientCommandHandler))]
Expand All @@ -20,7 +23,7 @@ public class RescueCommand : ICommand
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
Player player;
CommandTranslateConfig CommandTranslateConfig = Plugin.Instance.CommandTranslateConfig;
CommandTranslateConfig CommandTranslateConfig = CustomEventHandler.CommandTranslateConfig;

if (sender is null || (player = Player.Get(sender)) is null)
{
Expand Down
13 changes: 7 additions & 6 deletions HelpSense/Commands/VersionCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CommandSystem;
using HelpSense.API.Events;
using HelpSense.API.Features.Pool;
using HelpSense.ConfigSystem;
using System;
Expand All @@ -16,14 +17,14 @@ public class VersionCommand : ICommand

public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
var config = Plugin.Instance.Config;
CommandTranslateConfig CommandTranslateConfig = Plugin.Instance.CommandTranslateConfig;
var config = CustomEventHandler.Config;
CommandTranslateConfig CommandTranslateConfig = CustomEventHandler.CommandTranslateConfig;
var sb = StringBuilderPool.Pool.Get();

//Version and update time
sb.AppendFormat(CommandTranslateConfig.VersionCommand["PluginVersion"], Plugin.PluginVersion).AppendLine();
sb.AppendFormat(CommandTranslateConfig.VersionCommand["LastUpdateTime"], Plugin.LastUpdateTime).AppendLine();
sb.AppendFormat(CommandTranslateConfig.VersionCommand["RequiredGameVersion"], Plugin.RequiredGameVersion).AppendLine();
sb.AppendFormat(CommandTranslateConfig.VersionCommand["PluginVersion"], Plugins.Instance.Version).AppendLine();
sb.AppendFormat(CommandTranslateConfig.VersionCommand["LastUpdateTime"], Plugins.LastUpdateTime).AppendLine();
sb.AppendFormat(CommandTranslateConfig.VersionCommand["RequiredGameVersion"], Plugins.RequiredGameVersion).AppendLine();

//Function list
sb.AppendLine(CommandTranslateConfig.VersionCommand["Text"]);
Expand All @@ -41,7 +42,7 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
sb.AppendFormat(CommandTranslateConfig.VersionCommand["SCP2936"], BoolTranslate(config.SCP2936)).AppendLine();
sb.AppendFormat(CommandTranslateConfig.VersionCommand["SCP1093"], BoolTranslate(config.SCP1093)).AppendLine();
sb.AppendFormat(CommandTranslateConfig.VersionCommand["InfiniteAmmo"], BoolTranslate(config.InfiniteAmmo)).AppendLine();
sb.AppendFormat(CommandTranslateConfig.VersionCommand["InfiniteAmmoType"], Plugin.Instance.Config.InfiniteAmmoType).AppendLine();
sb.AppendFormat(CommandTranslateConfig.VersionCommand["InfiniteAmmoType"], CustomEventHandler.Config.InfiniteAmmoType).AppendLine();

//Copyright
sb.AppendLine("-Made By X小左(XLittleLeft)-");
Expand Down
6 changes: 2 additions & 4 deletions HelpSense/ConfigSystem/Config.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using HelpSense.Helper.Lobby;
using PlayerRoles;
using PluginAPI.Helpers;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using LabApi.Loader.Features.Paths;

namespace HelpSense.ConfigSystem
{
Expand All @@ -15,7 +15,7 @@ public class Config
[Description("玩家信息储存")]
public bool SavePlayersInfo { get; set; } = true;
[Description("保存位置")]
public string SavePath { get; set; } = Path.Combine(Paths.Configs ?? Environment.CurrentDirectory, @"HelpSense_玩家信息储存.Database");
public string SavePath { get; set; } = Path.Combine(PathManager.Configs.FullName ?? Environment.CurrentDirectory, @"HelpSense_玩家信息储存.Database");
[Description("是否打开开局给D级人员一张卡")]
public bool EnableRoundSupplies { get; set; } = true;
[Description("给D级人员什么卡?")]
Expand Down Expand Up @@ -170,8 +170,6 @@ public class Config
public bool AdminLogShow { get; set; } = false;
[Description("记录管理日志地址")]
public string AdminLogPath { get; set; } = $"{Environment.GetFolderPath(Environment.SpecialFolder.Desktop)}\\管理记录.txt";
[Description("隐藏教程角色")]
public bool HideTutorials { get; set; } = false;
[Description("自救指令")]
public bool ZiJiuCommand { get; set; } = true;

Expand Down
8 changes: 4 additions & 4 deletions HelpSense/Handler/LobbyLocationHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using PluginAPI.Core.Zones;
using MapGeneration;
using System.Linq;
using UnityEngine;
using Random = UnityEngine.Random;
Expand All @@ -25,13 +25,13 @@ public static void TowerLocation()

public static void IntercomLocation()
{
var intercomRoom = EntranceZone.Rooms.FirstOrDefault(x => x.GameObject.name == "EZ_Intercom");
var intercomRoom = RoomIdentifier.AllRoomIdentifiers.FirstOrDefault(x => x.Name is RoomName.EzIntercom);

if (intercomRoom == null)
return;

LobbyPosition = intercomRoom.Transform.TransformPoint(new Vector3(-4.16f, -3.860f, -2.113f));
LobbyRotation = Quaternion.Euler(intercomRoom.Rotation.eulerAngles.x, intercomRoom.Rotation.eulerAngles.y + 180, intercomRoom.Rotation.eulerAngles.z);
LobbyPosition = intercomRoom.transform.TransformPoint(new Vector3(-4.16f, -3.860f, -2.113f));
LobbyRotation = Quaternion.Euler(intercomRoom.transform.rotation.eulerAngles.x, intercomRoom.transform.rotation.eulerAngles.y + 180, intercomRoom.transform.rotation.eulerAngles.z);
}

public static void MountainLocation()
Expand Down
Loading

0 comments on commit a80435e

Please sign in to comment.