Skip to content

Commit

Permalink
屎一般的更新
Browse files Browse the repository at this point in the history
添加游戏控制台API
  • Loading branch information
Carl-Frellett authored Aug 20, 2024
1 parent becc707 commit 67b5e0b
Show file tree
Hide file tree
Showing 9 changed files with 231 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static void PosHint(this Player 玩家, float 位置, string 文本, bool
});
if (是否启用日志 == true)
{
LogAPI.日志($"JBAPI.Hint调用");
ServerConsoleMessage.日志($"JBAPI.Hint调用");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static void RuelHint(this Player 玩家, float 位置, string 文本, boo
});
if (是否启用日志 == true)
{
LogAPI.日志($"JBAPI.Htnt调用");
ServerConsoleMessage.日志($"JBAPI.Htnt调用");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Exiled.API.Features;
using static JBAPI.Log.Level;

namespace JBAPI.Log
{
public static class GameConsoleMessage
{
public static void 控制台消息(this Player 玩家, string 消息, ConsoleLevel 级别)
{
string 前缀 = _级别(级别);
string 颜色 = _颜色(级别);

玩家.SendConsoleMessage($"<color={颜色}>{前缀}</color>{消息}", 颜色);
}

private static string _级别(ConsoleLevel 级别)
{
switch (级别)
{
case ConsoleLevel.消息:
return "[消息] ";
case ConsoleLevel.警告:
return "[警告] ";
case ConsoleLevel.错误:
return "[错误] ";
case ConsoleLevel.自定义:
return "";
default:
return "";
}
}

private static string _颜色(ConsoleLevel 级别)
{
switch (级别)
{
case ConsoleLevel.消息:
return "#a2a2a2";
case ConsoleLevel.警告:
return "yellow";
case ConsoleLevel.错误:
return "red";
default:
return "";
}
}
}
}
13 changes: 13 additions & 0 deletions 宇宙无敌超级神威霸王龙SL的实用API/Log/Game/Level.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace JBAPI.Log
{
public class Level
{
public enum ConsoleLevel
{
消息,
警告,
错误,
自定义
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace JBPI.Log
{
public static class ServerConsoleMessage
{
// 默认情况下的日志
public static void 日志(string 消息)
=> ServerConsole.AddLog(消息, System.ConsoleColor.Cyan);

// 警告日志
public static void 警告(string 消息)
=> ServerConsole.AddLog(消息, System.ConsoleColor.DarkYellow);

// 调式日志 Debug
public static void 调试(string 消息)
=> ServerConsole.AddLog($"[调试] {消息}", System.ConsoleColor.Gray);

// 发生错误时的日志
public static void 错误(string 消息)
=> ServerConsole.AddLog($"[错误] {消息}", System.ConsoleColor.Red);

// 其他日志
public static void 其他(string 消息)
=> ServerConsole.AddLog(消息, System.ConsoleColor.Green);

// 自定义消息
public static void 自定义(string 消息, System.ConsoleColor 颜色)
=> ServerConsole.AddLog(消息, 颜色);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static void ORTag(this Player 玩家, string 文本, string 颜色)
{
玩家.RankName = 文本;
玩家.RankColor = 颜色;
LogAPI.日志($"JBAPI.OnlyColor调用 玩家 {玩家.Nickname} ({玩家.UserId})");
ServerConsoleMessage.日志($"JBAPI.OnlyColor调用 玩家 {玩家.Nickname} ({玩家.UserId})");
});
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using Exiled.API.Features;
using UnityEngine;
using JBAPI.UnityScript;
using JBPI.Log;
using MEC;
using JBAPI.Log;

namespace JBAPI.Tag
{
public static class somecolor
{
private static readonly string[] 颜色 = new[]
{
"pink", "red", "brown", "silver",
"light_green", "crimson", "cyan",
"aqua","deep_pink","tomato",
"yellow","magenta","blue_green",
"orange","lime","green",
"emerald","carmine","nickel",
"mint","army_green","pumpkin"
};

public static void RTag(this Player 玩家, string 文本, bool 是否启用)
{
Timing.CallContinuously(2f, () =>
{
玩家.RankName = 文本;
if (!是否启用)
{
var 神威 = 玩家.GameObject.GetComponent<TagController>();
if (神威 != null)
{
Object.Destroy(神威);
}
玩家.RankColor = "red";
return;
}

var 霸王龙 = 玩家.GameObject.GetComponent<TagController>();

ServerConsoleMessage.日志($"JBAPI.somecolor调用 玩家 {玩家.Nickname} ({玩家.UserId})");


if (霸王龙 == null)
{
霸王龙 = 玩家.GameObject.AddComponent<TagController>();
霸王龙.Colors = 颜色;
霸王龙.Interval = 0.5f;//孩子,时间越快服务器越容易崩,如果你改了,服务器爆炸概不负责
}

});
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using System.Collections;
using UnityEngine;
using Exiled.API.Features;
using System;

namespace JBAPI.UnityScript
{
public class TagController : MonoBehaviour
{
private Player player;
private int positionIndex = 0;
private string[] colors = Array.Empty<string>();
private float timer = 0f;

public string[] Colors
{
get => colors;
set
{
colors = value ?? Array.Empty<string>();
positionIndex = 0;
}
}

public float Interval { get; set; }

void Awake()
{
player = Player.Get(gameObject);

if (player == null)
{
Destroy(this);
return;
}

StartCoroutine(InitializeColorChange());
}

IEnumerator InitializeColorChange()
{
yield return new WaitForSeconds(0.5f);

SetNextColor();
}

void Update()
{
timer += Time.deltaTime;

if (timer >= Interval)
{
SetNextColor();
timer %= Interval;
}
}

void SetNextColor()
{
var nextColor = RollNext();
if (!string.IsNullOrEmpty(nextColor))
player.RankColor = nextColor;
}

public string RollNext()
{
if (colors.Length == 0)
return string.Empty;

positionIndex++;
if (positionIndex >= colors.Length) positionIndex = 0;

return colors[positionIndex];
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,13 @@
<ItemGroup>
<Compile Include="Hint\PosHint.cs" />
<Compile Include="Hint\RuelHint.cs" />
<Compile Include="Log\Level.cs" />
<Compile Include="Log\LogAPI.cs" />
<Compile Include="Log\Game\GameConsoleMessage.cs" />
<Compile Include="Log\Game\Level.cs" />
<Compile Include="Log\ServerConsoleMessage.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Tag\Onlycolor\API.cs" />
<Compile Include="Tag\somecolor\API.cs" />
<Compile Include="Tag\somecolor\TagController.cs" />
<Compile Include="Tag\Somecolor\API.cs" />
<Compile Include="Tag\Somecolor\TagController.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
Expand Down

0 comments on commit 67b5e0b

Please sign in to comment.