Skip to content

Commit 2316c92

Browse files
TomGrobbesir-lord-pizza
authored andcommitted
feat(routing-buckets): add support for routing bucket related features and plugin updates
1 parent 9b7907c commit 2316c92

18 files changed

Lines changed: 194 additions & 19 deletions

File tree

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,19 @@ Just like vMenu legacy, vMenu Enhanced will be using [MenuAPI (MAPI)](https://gi
7171

7272
vMenu Enhanced can be extended with **plugins**, which are separate FiveM resources that add their own menus inside vMenu. A plugin never patches vMenu, and vMenu does not need to know it exists beforehand. The two introduce themselves to each other while the server runs, in whatever order they happen to start.
7373

74+
### Official plugins
75+
76+
Made and kept up to date alongside vMenu itself. Each one is ready to install, and each is also worth reading as an example of how a plugin is put together.
77+
78+
| Plugin | What it does |
79+
| --- | --- |
80+
| [Routing Buckets](https://github.com/TomGrobbe/vMenu.RoutingBucketsPlugin) | Allows you to manage routing buckets on your server. |
81+
| [Theme Picker](https://github.com/TomGrobbe/vMenu.ThemePicker) | Let's each player choose a theme for vMenu themselves, rather than being forced to use the server theme. |
82+
| [Custom Themes](https://github.com/TomGrobbe/vMenu.CustomThemesPlugin) | Allows you to easily add new custom themes to vMenu. |
83+
| [Example Plugin](https://github.com/TomGrobbe/vMenu.ExamplePlugin) | Example plugin, do not use on public servers, use this as a tempalte if you want to make your own plugins. |
84+
85+
### Writing your own
86+
7487
Two NuGet packages are all you need to write one:
7588

7689
| Package | Used by |
@@ -85,7 +98,7 @@ Where to read more:
8598
- [What plugins are](https://docs.vespura.com/vmenu/enhanced/plugins/), if you have not met one yet
8699
- [Installing plugins](https://docs.vespura.com/vmenu/enhanced/plugins/installing/), for server owners
87100
- [Making a plugin](https://docs.vespura.com/vmenu/enhanced/plugins/developing/), for developers
88-
- [vMenu.ExamplePlugin](https://github.com/TomGrobbe/vMenu.ExamplePlugin), a complete working plugin to copy from
101+
- The [official plugins](#official-plugins) above, all of them complete working plugins to copy from
89102

90103
A plugin built on these packages is a work based on vMenu, so it carries the same license vMenu does. That means open sourcing it if you hand it to anybody else, free or paid. See [License](#license) below, and the [licensing section of the plugin docs](https://docs.vespura.com/vmenu/enhanced/plugins/developing/#license) for what it asks of you in practice.
91104

docs/src/content/docs/admin-menu.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Only the staff member who picked somebody up can put them down. If two of you re
2727

2828
"Closest" means the closest player your game actually knows about. On a busy server your game is only told about people near you, so this finds somebody standing in front of you, not somebody on the other side of the map. How far it reaches is set by `vMenu.Enhanced.Admin.ClosestPlayerRange`, which defaults to 5 metres and can go up to 15.
2929

30+
**Return To The Default World** puts you back in the main routing bucket, for when you teleported to someone who was in a different bucket.
31+
3032
**Show Players In NoClip** is the same option that used to live in Miscellaneous Settings. It keeps showing the blip and the name of anybody flying around in noclip, who everybody else has them hidden from.
3133

3234
### Vehicles
@@ -210,6 +212,7 @@ These go in your `configuration.cfg`. They are all listed in the `configuration.
210212
| `...Admin.Announce` | Sending an announcement to the whole server |
211213
| `...Admin.ManageAnnouncements` | Adding and removing scheduled announcements, which writes the config file |
212214
| `...Admin.RefreshPermissions` | Refreshing everybody's permissions at once |
215+
| `...Admin.ResetRoutingBucket` | Putting yourself back in the default world |
213216

214217
All of them start with `vMenu.Enhanced.Menus.`, and `...Admin.All` grants the lot. They are listed in the `config/permissions.cfg.example` file your server writes on every start.
215218

docs/src/content/docs/plugins/developing.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ A look at what a tiny JavaScript plugin could look like can be found in the cust
99
:::tip[Start from an example]
1010
[vMenu.ExamplePlugin](https://github.com/TomGrobbe/vMenu.ExamplePlugin) is a complete working plugin that uses every kind of row once. Copy from it.
1111

12+
[vMenu.RoutingBucketsPlugin](https://github.com/TomGrobbe/vMenu.RoutingBucketsPlugin) is a more advanced plugin. This plugin includes server and client side code, both sides talking to each other, server side permission checks on everything, live state pushed out to the menu (live menu updates), rows in [Online Players](#player-actions), and a saved config file of its own.
13+
1214
For theme related plugins, see [vMenu.ThemePicker](https://github.com/TomGrobbe/vMenu.ThemePicker),
1315
and [vMenu.CustomThemesPlugin](https://github.com/TomGrobbe/vMenu.CustomThemesPlugin), and read [registering themes](#adding-themes-of-your-own) to see how you can make your own themes for your server.
16+
17+
All four are listed on the [plugins page](/vmenu/enhanced/plugins/).
1418
:::
1519

1620
:::caution[Read the license section]

docs/src/content/docs/plugins/index.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@ Everything a plugin adds uses vMenu's own permissions system. A missing or locke
1818

1919
## Official plugins
2020

21-
These are made and kept up to date alongside vMenu itself. Each one is a real plugin you can install as it is, and each is also worth reading as an example of how a plugin is put together.
21+
These are made and kept up to date alongside vMenu itself. Each one is a real plugin you can install
22+
as it is, and each is also worth reading as an example of how a plugin is put together.
2223

2324
| Plugin | What it does |
2425
| --- | --- |
25-
| [Theme Picker](https://github.com/TomGrobbe/vMenu.ThemePicker) | Let your players pick their own theme. |
26-
| [Custom Themes](https://github.com/TomGrobbe/vMenu.CustomThemesPlugin) | Use this plugin to create and register your own themes inside vMenu. |
27-
| [Example Plugin](https://github.com/TomGrobbe/vMenu.ExamplePlugin) | An example plugin in C#. You shouldn't use this on your production server, but feel free to use it as a baseline for making your own C# plugin. |
26+
| [Routing Buckets](https://github.com/TomGrobbe/vMenu.RoutingBucketsPlugin) | Allows you to manage routing buckets on your server. |
27+
| [Theme Picker](https://github.com/TomGrobbe/vMenu.ThemePicker) | Let's each player choose a theme for vMenu themselves, rather than being forced to use the server theme. |
28+
| [Custom Themes](https://github.com/TomGrobbe/vMenu.CustomThemesPlugin) | Allows you to easily add new custom themes to vMenu. |
29+
| [Example Plugin](https://github.com/TomGrobbe/vMenu.ExamplePlugin) | Example plugin, do not use on public servers, use this as a tempalte if you want to make your own plugins. |
30+
31+
Every one of them is GPL-3.0-or-later, same as vMenu, and each publishes a ready to drop in zip on its
32+
own releases page.
2833

2934
## Where to go from here
3035

docs/src/content/docs/webhook-logging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Everything else a menu can do is deliberately not logged. Opening the about page
3737

3838
If you want something added to this list, open an issue. The list lives in the code, not in a setting.
3939

40-
**Staff**, what a player does to somebody else. Kicking, killing, summoning, messaging, wanted levels, freezing, carrying, lending noclip, deleting vehicles, clearing areas, announcing.
40+
**Staff**, what a player does to somebody else. Kicking, killing, summoning, messaging, wanted levels, freezing, carrying, lending noclip, deleting vehicles, clearing areas, announcing, and putting themselves back in the default world.
4141

4242
Staff alerts live here too. You get a line when somebody raises one, with their reason, and another when a staff member answers or dismisses it, naming both people. An alert nobody answers before it runs out is logged as well, so a missed call for help leaves a trace.
4343

src/Client/vMenu.Enhanced.MenuFramework/Localization/Languages/EnglishStrings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,10 @@ internal static class EnglishStrings
13621362
[Loc.Admin.RefreshPermissions] = "Refresh All Permissions",
13631363
[Loc.Admin.RefreshPermissionsDescription] = "Hand everybody on the server a fresh copy of what they are allowed to do. Use it once you have actually changed somebody's permissions on the server, so their menu catches up without them having to rejoin.",
13641364
[Loc.Admin.RefreshPermissionsDone] = "Refreshed permissions for ~g~{count}~s~ player(s).",
1365+
[Loc.Admin.ResetRoutingBucket] = "Return To The Default World",
1366+
[Loc.Admin.ResetRoutingBucketDescription] = "Put yourself back in the world everybody else is in. Teleporting to a player in a separate world takes you along with them, and this is the way back out again.",
1367+
[Loc.Admin.ResetRoutingBucketDone] = "Moved you out of world ~y~{bucket}~s~ and back into the default world.",
1368+
[Loc.Admin.ResetRoutingBucketAlready] = "You are already in the default world.",
13651369

13661370
[Loc.StaffAlerts.Title] = "Staff Alerts",
13671371
[Loc.StaffAlerts.Subtitle] = "{count} waiting",

src/Client/vMenu.Enhanced.MenuFramework/Localization/Loc.Admin.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,13 @@ public static class Admin
179179
public const string RefreshPermissionsDescription = "admin.refreshpermissions.desc";
180180

181181
public const string RefreshPermissionsDone = "admin.refreshpermissions.done";
182+
183+
public const string ResetRoutingBucket = "admin.resetroutingbucket";
184+
185+
public const string ResetRoutingBucketDescription = "admin.resetroutingbucket.desc";
186+
187+
public const string ResetRoutingBucketDone = "admin.resetroutingbucket.done";
188+
189+
public const string ResetRoutingBucketAlready = "admin.resetroutingbucket.already";
182190
}
183191
}

src/Client/vMenu.Enhanced.Menus/Admin/AdminPlayerActions.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ public static class AdminPlayerActions
1212
{
1313
private const string On = "1";
1414

15+
private const string DefaultRoutingBucket = "0";
16+
1517
private static int _carrying;
1618

1719
private static bool _busy;
@@ -124,6 +126,29 @@ public static async Task RefreshEveryonesPermissionsAsync()
124126
("count", MenuText.Literal(result.Data[0]))));
125127
}
126128

129+
public static async Task ResetRoutingBucketAsync()
130+
{
131+
var result = await ServerActions.InvokeAsync(ActionIds.Admin.ResetRoutingBucket);
132+
133+
if (result.Status != ActionStatus.Ok || result.Data.Length < 1)
134+
{
135+
AdminReport.Show(result);
136+
137+
return;
138+
}
139+
140+
if (result.Data[0] == DefaultRoutingBucket)
141+
{
142+
Notifications.Info(MenuText.Key(Loc.Admin.ResetRoutingBucketAlready));
143+
144+
return;
145+
}
146+
147+
Notifications.Success(MenuText.Key(
148+
Loc.Admin.ResetRoutingBucketDone,
149+
("bucket", MenuText.Literal(result.Data[0]))));
150+
}
151+
127152
private static RosteredPlayer? Closest()
128153
{
129154
var target = AdminTargeting.Closest();

src/Client/vMenu.Enhanced.Menus/AdminMenu.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ public sealed class AdminMenu : MenuDefinition
2222
private static MenuGate PlayersGate =>
2323
MenuGate.Permission(AdminPermissions.FreezePlayer)
2424
| AdminPermissions.GrabPlayer
25-
| AdminPermissions.SeeNoClipPlayers;
25+
| AdminPermissions.SeeNoClipPlayers
26+
| AdminPermissions.ResetRoutingBucket;
2627

2728
private static MenuGate VehiclesGate =>
2829
MenuGate.Permission(AdminPermissions.DeleteVehicle)
@@ -62,6 +63,14 @@ protected override void Build(MenuBuilder menu)
6263
OnSelectedAsync = _ => GrabAsync(menu),
6364
});
6465

66+
menu.Entries.Add(new ButtonEntry
67+
{
68+
Text = MenuText.Key(Loc.Admin.ResetRoutingBucket),
69+
Description = MenuText.Key(Loc.Admin.ResetRoutingBucketDescription),
70+
Gate = AdminPermissions.ResetRoutingBucket,
71+
OnSelectedAsync = _ => AdminPlayerActions.ResetRoutingBucketAsync(),
72+
});
73+
6574
menu.Entries.Add(new CheckboxEntry
6675
{
6776
Text = MenuText.Key(Loc.Admin.SeeNoClipPlayers),

src/Client/vMenu.Enhanced.Plugins/PluginHost.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,23 @@ private static void Register(string resource, string json)
262262
// that knows nothing of the menus the player may be standing in right now.
263263
CloseIfInsideAPluginMenu();
264264

265+
var firstRegistration = !Plugins.ContainsKey(resource);
266+
265267
Plugins[resource] = state;
266268
LastPayload[resource] = json;
267269

268270
RebuildRows();
269271

270272
RaiseChanged();
271273

272-
Log.Info($"[Plugins] Registered '{resource}' with {state.ItemsById.Count} item(s).");
274+
if (firstRegistration)
275+
{
276+
Log.Info($"[Plugins] Registered '{resource}'.");
277+
}
278+
else
279+
{
280+
Log.Debug($"[Plugins] '{resource}' re-registered with {state.ItemsById.Count} item(s).");
281+
}
273282

274283
Reply(resource, result);
275284

0 commit comments

Comments
 (0)