Skip to content

Commit

Permalink
Merge pull request #34 from UncomplicatedCustomServer/dev-main
Browse files Browse the repository at this point in the history
Version v3.0.0 - Candidate I
  • Loading branch information
FoxWorn3365 authored Jul 13, 2024
2 parents 2447e99 + b344e2d commit 7f88b2d
Show file tree
Hide file tree
Showing 30 changed files with 914 additions and 407 deletions.
3 changes: 2 additions & 1 deletion Localization/README-FR.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
<br><br>
</div>

**EXILED** >= `v8.9.4`
**EXILED** >= `v8.9.6`
<br><br>

## README Traduis
- [**Original** (Anglais)](https://github.com/UncomplicatedCustomServer/UncomplicatedCustomRoles/blob/main/README.md)
- [Italien](https://github.com/UncomplicatedCustomServer/UncomplicatedCustomRoles/blob/main/Localization/README-IT.md)
- [Russie](https://github.com/UncomplicatedCustomServer/UncomplicatedCustomRoles/blob/main/Localization/README-RU.md)

## Qu'est ce que c'est UncomplicatedCustomRoles ?
**UncomplicatedCustomRoles** ou **UCR** est un plugin pour [EXILED](https://github.com/Exiled-Team/EXILED) qui vous permet de créer des rôles personnalisé complètement customisable et configurable avec du YAML.\
Expand Down
3 changes: 2 additions & 1 deletion Localization/README-IT.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
<br><br>
</div>

**EXILED** >= `v8.9.4`
**EXILED** >= `v8.9.6`
<br><br>

## README tradotti
- [**Principale** (Inglese)](https://github.com/UncomplicatedCustomServer/UncomplicatedCustomRoles)
- [Francese](https://github.com/UncomplicatedCustomServer/UncomplicatedCustomRoles/blob/main/Localization/README-FR.md)
- [Russo](https://github.com/UncomplicatedCustomServer/UncomplicatedCustomRoles/blob/main/Localization/README-RU.md)

## Cosa è UncomplicatedCustomRoles?
**UncomplicatedCustomRoles** o **UCR** è un plugin per [EXILED](https://github.com/Exiled-Team/EXILED) che permette ai server owner la creazione di ruoli custom completamente personalizzabili.\
Expand Down
58 changes: 58 additions & 0 deletions Localization/README-RU.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<div align="center"><a href="https://github.com/UncomplicatedCustomServer/UncomplicatedCustomRoles/releases/latest"><img src="https://img.shields.io/github/v/release/UncomplicatedCustomServer/UncomplicatedCustomRoles"></a> <a href="https://github.com/UncomplicatedCustomServer/UncomplicatedCustomRoles/releases/latest"><img src="https://img.shields.io/github/downloads/UncomplicatedCustomServer/UncomplicatedCustomRoles/total"></a> <a href="https://github.com/UncomplicatedCustomServer/UncomplicatedCustomRoles/pulls"><img src="https://img.shields.io/github/issues-pr/UncomplicatedCustomServer/UncomplicatedCustomRoles"></a> <a href="https://github.com/UncomplicatedCustomServer/UncomplicatedCustomRoles/pulls"><img src="https://img.shields.io/github/issues-pr-closed/UncomplicatedCustomServer/UncomplicatedCustomRoles"></a> <a href="https://github.com/UncomplicatedCustomServer/UncomplicatedCustomRoles/commits/main/"><img src="https://badgen.net/github/commits/UncomplicatedCustomServer/UncomplicatedCustomRoles/main"></a> <img src="https://img.shields.io/badge/Verified_Exiled_Plugin-ss">

<h1>UncomplicatedCustomRoles</h1>
<i>Простые, полностью конфигурируемые и настраиваемые пользовательские роли для вашего сервера SCP:SL!</i>

<br><br>
<img src="https://ucs.fcosma.it/api/v2/ucr/graph/black">
<br><br>
<a href='https://discord.gg/5StRGu8EJV'><img src='https://www.allkpop.com/upload/2021/01/content/262046/1611711962-discord-button.png' height="100"></a>
<br><br>
</div>

**EXILED** >= `v8.9.6`
<br><br>

## Локализованные README
- [Оригинальное (Английское)](https://github.com/UncomplicatedCustomServer/UncomplicatedCustomRoles)
- [Французское](https://github.com/UncomplicatedCustomServer/UncomplicatedCustomRoles/blob/main/Localization/README-FR.md)
- [Итальянское](https://github.com/UncomplicatedCustomServer/UncomplicatedCustomRoles/blob/main/Localization/README-IT.md)

## Что такое UncomplicatedCustomRoles
**UncomplicatedCustomRoles** или **UCR** - это плагин для [EXILED](https://github.com/Exiled-Team/EXILED), который позволяет создавать полностью конфигурируемые и настраиваемые пользовательские роли с помощью YAML.\
Вы сможете настроить <ins>роль</ins>, <ins>здоровье</ins>, <ins>роль после побега</ins> и многое другое.

## Особенности
**UCR** имеет множество возможностей, таких как:
- Неограниченное количество пользовательских ролей
- Конфиги находятся в отдельном файле, а не в файле EXILED по умолчанию
- Исчерпывающая [вики](https://github.com/UncomplicatedCustomServer/UncomplicatedCustomRoles/wiki)
- Не требуется никаких зависимостей
- Активное сообщество в **Discord**
- __Особые привилегии и предварительный просмотр__ для проверенных владельцев серверов
- Внутриигровые команды для работы с плагином и ролями

## Установка
Скачайте `UncomplicatedCustomRoles.dll` с [последних релизов](https://github.com/UncomplicatedCustomServer/UncomplicatedCustomRoles/releases/latest) и поместите его в папку `EXILED/Plugins`.

## Разработчики
UncomplicatedCustomRoles имеет простую и быструю систему API для разработчиков, чтобы они могли использовать наш плагин.
Мы сделали множество примеров в [вики для разработчиков](https://github.com/UncomplicatedCustomServer/UncomplicatedCustomRoles/wiki/Developers-World)!

## Есть проблемы с пониманием?
Прочитайте [ВИКИ](https://github.com/UncomplicatedCustomServer/UncomplicatedCustomRoles/wiki) и если вы все еще не можете решить проблему, вы можете спросить у сообщества на нашем [Discord сервере](https://discord.gg/5StRGu8EJV)!

## Контакты
### UncomplicatedCustomRoles
**Discord:** [https://discord.gg/5StRGu8EJV](https://discord.gg/5StRGu8EJV)

### FoxWorn3365
**Discord:** `@foxworn`\
**Email:** `[email protected]`
### Dr.Agenda
**Discord:** `dr.agenda`

## Перевод на другие языки
**Французский:** `@robocnop`\
**Итальянский:** `@foxworn` \
**Русский:** `@naxefir`
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
<br><br>
</div>

**EXILED** >= `v8.9.4`
**EXILED** >= `v8.9.6`
<br><br>

## Localized READMEs
- [Français](https://github.com/UncomplicatedCustomServer/UncomplicatedCustomRoles/blob/main/Localization/README-FR.md)
- [Italiano](https://github.com/UncomplicatedCustomServer/UncomplicatedCustomRoles/blob/main/Localization/README-IT.md)
- [Russian](https://github.com/UncomplicatedCustomServer/UncomplicatedCustomRoles/blob/main/Localization/README-RU.md)

## What's UncomplicatedCustomRoles
**UncomplicatedCustomRoles** or **UCR** is a plugin for [EXILED](https://github.com/Exiled-Team/EXILED) that allow you to create fully configurable and customizable custom role with YAML.\
Expand Down Expand Up @@ -53,4 +54,5 @@ Read the [WIKI](https://github.com/UncomplicatedCustomServer/UncomplicatedCustom

## Translation Credits
**French:** `@robocnop`\
**Italian:** `@foxworn`
**Italian:** `@foxworn`\
**Russian:** `@naxefir`
25 changes: 25 additions & 0 deletions UncomplicatedCustomRoles/API/Features/Behaviour/AhpBehaviour.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Exiled.API.Features;

namespace UncomplicatedCustomRoles.API.Features.Behaviour
{
public class AhpBehaviour
{
public float Amount { get; set; } = 0;

public float Limit { get; set; } = 75;

public float Decay { get; set; } = 1.2f;

public float Efficacy { get; set; } = 0.7f;

public float Sustain { get; set; } = 0f;

public bool Persistant { get; set; } = false;

public void Apply(Player player)
{
if (Amount > 0)
player.AddAhp(Amount, Limit, Decay, Efficacy, Sustain, Persistant);
}
}
}
22 changes: 22 additions & 0 deletions UncomplicatedCustomRoles/API/Features/Behaviour/HealthBehaviour.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Exiled.API.Features;

namespace UncomplicatedCustomRoles.API.Features.Behaviour
{
public class HealthBehaviour
{
public float Amount { get; set; } = 100;

public float Maximum { get; set; } = 100;

public float HumeShield { get; set; } = 0;

public void Apply(Player player)
{
player.Health = Amount;
player.MaxHealth = Maximum;

if (HumeShield > 0)
player.HumeShield = HumeShield;
}
}
}
48 changes: 48 additions & 0 deletions UncomplicatedCustomRoles/API/Features/Behaviour/SpawnBehaviour.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Exiled.API.Enums;
using PlayerRoles;
using System.Collections.Generic;
using UnityEngine;

namespace UncomplicatedCustomRoles.API.Features.Behaviour
{
#nullable enable
public class SpawnBehaviour
{
// Spawn Behaviour for the plugin (global)
public static bool DoHandleWave { get; internal set; } = true;

// Spawn Behaviour for the roles (role-based)
public List<RoleTypeId> CanReplaceRoles { get; set; } = new()
{
RoleTypeId.ClassD
};

public int MaxPlayers { get; set; } = 10;

public int MinPlayers { get; set; } = 1;

public int SpawnChance { get; set; } = 60;

public SpawnLocationType Spawn { get; set; } = SpawnLocationType.RoomsSpawn;

public List<ZoneType> SpawnZones { get; set; } = new();

public List<RoomType> SpawnRooms { get; set; } = new()
{
RoomType.LczClassDSpawn
};

public Vector3 SpawnPosition { get; set; } = new();

public Vector3 SpawnOffset { get; set; } = new();

public string? RequiredPermission { get; set; } = string.Empty;

// You can use this class to handle the RespawnWave like to disable it
public static void DisableSpawnWave()
{
DoHandleWave = false;
Plugin.RoleSpawnQueue.Clear();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Exiled.API.Features;
using Exiled.API.Features.Roles;

namespace UncomplicatedCustomRoles.API.Features.Behaviour
{
public class StaminaBehaviour
{
public float RegenMultiplier { get; set; } = 1;

public float UsageMultiplier { get; set; } = 1;

public bool Infinite { get; set; } = false;

public void Apply(Player player)
{
if (player.Role is FpcRole Fpc)
{
Fpc.StaminaRegenMultiplier = RegenMultiplier;
Fpc.StaminaUsageMultiplier = UsageMultiplier;
}

player.IsUsingStamina = !Infinite;
}
}
}
107 changes: 102 additions & 5 deletions UncomplicatedCustomRoles/API/Features/CustomRole.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using UncomplicatedCustomRoles.Interfaces;
using UncomplicatedCustomRoles.Manager;
using UnityEngine;

namespace UncomplicatedCustomRoles.API.Features
{
#pragma warning disable CS0618 // Il tipo o il membro è obsoleto
public class CustomRole
{
/// <summary>
/// Get a list of every <see cref="ICustomRole"/> registered.
/// </summary>
public static List<ICustomRole> List { get; } = Plugin.CustomRoles.Values.ToList();
public static List<ICustomRole> List { get; } = new(Plugin.CustomRoles.Values);

/// <summary>
/// Get a list of every alive player with a custom role and the custom role Id
/// Handle the Respawn Queue for waves handled by UCR.
/// </summary>
public List<int> RespawnQueue = Plugin.RoleSpawnQueue;

/// <summary>
/// Get a list of every alive player with a custom role and the custom role Id.
/// </summary>
public static Dictionary<int, int> Alive { get; } = Plugin.PlayerRegistry;

Expand Down Expand Up @@ -55,9 +63,98 @@ public static ICustomRole Get(int id)
/// Required only if you want the custom role to be evaluated from UCR.
/// </summary>
/// <param name="customRole"></param>
public static void Register(ICustomRole customRole)
public static void Register(ICustomRole Role, bool notLoadIfLoaded = false)
{
SpawnManager.RegisterCustomSubclass(customRole);
if (!Validate(Role))
{
LogManager.Warn($"Failed to register the UCR role with the ID {Role.Id} due to the validator check!");

return;
}

LogManager.Debug($"Proposed new role {Role.Id} to register with {Role.MaxScp330Candies} ccds");

if (!Plugin.CustomRoles.ContainsKey(Role.Id))
{
Plugin.CustomRoles.Add(Role.Id, Role);

if (Plugin.Instance.Config.EnableBasicLogs)
{
LogManager.Info($"Successfully registered the UCR role with the ID {Role.Id} and {Role.Name} as name!");
}

return;
}

if (notLoadIfLoaded)
{
LogManager.Debug($"Can't load role {Role.Id} {Role.Name} due to plugin settings!\nPlease reach UCS support for UCR!");
return;
}

LogManager.Warn($"Failed to register the UCR role with the ID {Role.Id}: The problem can be the following: ERR_ID_ALREADY_HERE!\nTrying to assign a new one...");

int NewId = GetFirstFreeID(Role.Id);

LogManager.Info($"Custom Role {Role.Name} with the old Id {Role.Id} will be registered with the following Id: {NewId}");

Role.Id = NewId;

Register(Role, true);
}

/// <summary>
/// Validate a <see cref="ICustomRole"/>
/// </summary>
/// <param name="Role"></param>
/// <returns></returns>
[Obsolete("This method should not be used as was intended for the first versions of UCR and now the plugin can handle also things that are reported as errors here!", false)]
public static bool Validate(ICustomRole Role)
{
if (Role is null)
return false;

if (Role.SpawnSettings is null)
{
LogManager.Warn($"Is kinda useless registering a role with no spawn_settings.\nFound (or not found) in role: {Role.Name} ({Role.Id})");
return false;
}

if (Role.SpawnSettings.Spawn == SpawnLocationType.ZoneSpawn && Role.SpawnSettings.SpawnZones.Count() < 1)
{
LogManager.Warn($"The UCR custom role with the ID {Role.Id} failed the check: if you select the ZoneSpawn as SpawnType the List SpawnZones can't be empty!");
return false;
}
else if (Role.SpawnSettings.Spawn == SpawnLocationType.RoomsSpawn && Role.SpawnSettings.SpawnRooms.Count() < 1)
{
LogManager.Warn($"The UCR custom role with the ID {Role.Id} failed the check: if you select the RoomSpawn as SpawnType the List SpawnRooms can't be empty!");
return false;
}
else if (Role.SpawnSettings.Spawn == SpawnLocationType.PositionSpawn && Role.SpawnSettings.SpawnPosition == new Vector3(0, 0, 0))
{
LogManager.Warn($"The UCR custom role with the ID {Role.Id} failed the check: if you select the PositionSpawn as SpawnType the Vector3 SpawnPosition can't be empty!");
return false;
}
else if (Role.SpawnSettings.MinPlayers == 0)
{
LogManager.Warn($"The UCR custom role with the ID {Role.Id} failed the check: the value of MinPlayers field must be greater than or equals to 1!");
return false;
}

return true;
}

/// <summary>
/// Get the first free id to register a new custom role
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public static int GetFirstFreeID(int Id)
{
while (Plugin.CustomRoles.ContainsKey(Id))
Id++;

return Id;
}

/// <summary>
Expand Down
10 changes: 5 additions & 5 deletions UncomplicatedCustomRoles/Commands/CommandParent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ internal class CommandParent : ParentCommand

public override void LoadGeneratedCommands()
{
RegisteredCommands.Add(new UCRList());
RegisteredCommands.Add(new UCROwner());
RegisteredCommands.Add(new UCRRole());
RegisteredCommands.Add(new UCRSpawn());
RegisteredCommands.Add(new UCRReload());
RegisteredCommands.Add(new List());
RegisteredCommands.Add(new Owner());
RegisteredCommands.Add(new Role());
RegisteredCommands.Add(new Spawn());
RegisteredCommands.Add(new Reload());
}

public List<IUCRCommand> RegisteredCommands { get; } = new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace UncomplicatedCustomRoles.Commands
{
public class UCRList : IUCRCommand
public class List : IUCRCommand
{
public string Name { get; } = "list";

Expand Down
Loading

0 comments on commit 7f88b2d

Please sign in to comment.