Skip to content

Commit ad16b5c

Browse files
author
Valandur
committed
Merge branch 'release/v4.6.3'
2 parents 4e40c0d + 22dbbae commit ad16b5c

35 files changed

+893
-133
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ dependencies {
5454
compileOnly files("lib/MMCTickets-1.4.0-API-5.2-7.X.jar")
5555
compileOnly files("lib/Nations-2.8-S6.1-MC1.11.2.jar")
5656
compileOnly files("lib/Nucleus-1.1.3-LTS-api.jar")
57+
compileOnly files("lib/RedProtect-Sponge-6.1.0-7.2.0-b137.jar")
5758
}
5859

5960
shadowJar {

docs/ADMIN_PANEL.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Web-API AdminPanel
2+
3+
The admin panel provides an access point for server admins and moderators to easily manage their
4+
server without having to be online/in minceraft or connected to the server through ssh.
5+
6+
7+
## Table of Contents
8+
1. [Creating users](#creating-users)
9+
1. [Modifying users](#modifying-users)
10+
11+
12+
<a name="creating-users"></a>
13+
## Creating users
14+
15+
To create a new user for the admin panel enter `/webapi users create [name]` in your server console.
16+
This will create a new user with the `[name]` specified and a random password. The password will
17+
be shown in the server console. If you want to specify the password for the user you can use the
18+
command `/webapi users create [name] [password]`.
19+
20+
> The permission required to create new users in Web-API is `webapi.users.add`
21+
22+
23+
<a name="modifying-users"></a>
24+
## Modifying users (changing passwords, etc.)
25+
26+
To change the password use the `/webapi users pw [name] [newpassword]` command.
27+
To change the permissions for a user you need to edit the `/config/webapi/user.conf` config file.
28+
You can also delete a user from this file to remove them.

docs/COMMANDS.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Web-API Commands
2+
3+
All commands begin with `/webapi`
4+
<> denotes **required** parameters
5+
[] denotes *optional* parameters
6+
[...] denotes *multiple optional* parameters
7+
8+
9+
## Table of Contents
10+
1. [AdminPanel users](#adminpanel)
11+
1. [Whitelist](#whitelist)
12+
1. [Blacklist](#blacklist)
13+
1. [Block Operations](#blockops)
14+
1. [Notify commands/WebHooks](#notify)
15+
16+
17+
<a name="adminpanel"></a>
18+
## AdminPanel Users
19+
20+
| Command | Permission | Description |
21+
|---------|------------|-------------|
22+
| users list | webapi.user.list | Lists all the users of the [AdminPanel](ADMIN_PANEL.md) |
23+
| users add \<user> [password] | webapi.user.add | Adds a new [AdminPanel](ADMIN_PANEL.md) user |
24+
| users pw \<user> <password> | webapi.user.changepw | Changes the password of an [AdminPanel](ADMIN_PANEL.md) user |
25+
26+
27+
<a name="whitelist"></a>
28+
## Whitelist
29+
30+
| Command | Permission | Description |
31+
|---------|------------|-------------|
32+
| whitelist add \<ip> | webapi.whitelist.add | Adds the specified IP to the whitelist |
33+
| whitelist remove \<ip> | webapi.whitelist.remove | Removes the specified IP from the whitelist |
34+
| whitelist enable | webapi.whitelist.enable | Enables the whitelist for Web-API |
35+
| whitelist disable | webapi.whitelist.disable | Disables the whitelist for Web-API |
36+
37+
38+
<a name="blacklist"></a>
39+
## Blacklist
40+
41+
| Command | Permission | Description |
42+
|---------|------------|-------------|
43+
| blacklist add \<ip> | webapi.blacklist.add | Adds the specified IP to the blacklist |
44+
| blacklist remove \<ip> | webapi.blacklist.remove | Removes the specified IP from the blacklist |
45+
| blacklist enable | webapi.blacklist.enable | Enables the blacklist for Web-API |
46+
| blacklist disable | webapi.blacklist.disable | Disables the blacklist for Web-API |
47+
48+
49+
<a name="blockops"></a>
50+
## Block Operations
51+
52+
| Command | Permission | Description |
53+
|---------|------------|-------------|
54+
| ops list | webapi.op.list | List all running block operations |
55+
| ops pause \<uuid> | webapi.op.pause | Pause/Resume the specified block operation |
56+
| ops stop \<uuid> | webapi.op.stop | Stops the specified block operation |
57+
58+
59+
<a name="notify"></a>
60+
## Notify commands / WebHooks
61+
62+
| Command | Permission | Description |
63+
|---------|------------|-------------|
64+
| notify \<name> [params...] | webapi.notify.\<name> | Triggers the \<name> [WebHook](WEBHOOKS.md) |

docs/INDEX.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,27 @@
22

33
This is a collection of various documentations and tutorials for various sections of the Web-API.
44

5+
1. [AdminPanel](ADMIN_PANEL.md)
6+
Short description of the AdminPanel and how to set it up.
7+
8+
1. [Commands (**and their permissions**)](COMMANDS.md)
9+
Lists the various commands the Web-API provides, including their required player **permissions**.
10+
511
1. [Consumer Tutorial](CONSUME.md)
612
This tutorial shows some basic examples of how to use/consume the Web-API. This will be helpfull
713
if you're building an app that relies on the data from the Web-API
814

915
1. [General config](CONFIG.md)
1016
This sections describes the basic configuration options of the Web-API.
1117

12-
1. [Permissions](PERMISSIONS.md)
18+
1. [Permissions (for API endpoints, **not** commands)](PERMISSIONS.md)
1319
This documentation talks about the `permissions.conf` file and the various settings you can use
1420
to adjust the Web-API to your needs, specifically the permissions that restrict access and data.
1521

22+
1. [Messages](MESSAGE.md)
23+
Read this guide to find out how to send messages with interactive options to players and
24+
process their responses.
25+
1626
1. [WebHooks](WEBHOOKS.md)
1727
This documentation explains how to use WebHooks to have your own app stay informed about stuff
1828
that happens on the minecraft server, without constantly requesting data.

docs/MESSAGE.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Web-API Messages
2+
3+
Message are pieces of text that can be sent to players, if required with clickable options for
4+
the player to interact with.
5+
6+
7+
## Table of Contents
8+
1. [Format](#format)
9+
1. [Responses](#responses)
10+
11+
12+
<a name="format"></a>
13+
## Format
14+
15+
You must send a `POST` request to the `/message` endpoint.
16+
The body of the request must have the following format:
17+
18+
```json
19+
{
20+
"id": "unique-id",
21+
"target": "player-uuid",
22+
"targets": [ "player-1-uuid", "player-2-uuid"],
23+
"message": "Hello world! Testing the Web-API messages :D",
24+
"once": true,
25+
"options": [{
26+
"key": "option1",
27+
"value": "Option 1"
28+
}, {
29+
"key": "other_opt",
30+
"value": "[Other Option]"
31+
}]
32+
}
33+
```
34+
35+
The `id` is a unique identifier that the Web-API will send back to your server. You can use
36+
this to identify different messages. You can put anything you like here, or leave it blank
37+
in case you don't need it.
38+
39+
The `target` is the UUID of the player you wish to send the message to. Sending messages
40+
to offline players is not possible. If you want to send a message to multiple players use
41+
the `targets` array, which is an array of UUIDs. You must specify either `target` or `targets`.
42+
43+
`message` is the content of your message - the actual text sent to the player in chat.
44+
You can use the [Ampersand formatting](https://docs.spongepowered.org/stable/en-GB/plugin/text/representations/formatting-code-legacy.html#ampersand-formatting)
45+
to apply text formatting to the message. Your message must have a message...
46+
47+
If the `once` option is set to true then the player will only be able to reply to the message
48+
once (assuming it has clickable options). Otherwise, if missing or set to false, the player will
49+
be able to click the provided options multiple times.
50+
51+
The `options` array contains all the clickable options the player can choose from.
52+
Each option has a `key` and a `value`. The `key` is used internally, and sent back to your
53+
server if the player clicks that option. The `value` is what is displayed to the player
54+
in the text.
55+
56+
57+
<a name="responses"></a>
58+
## Responses
59+
60+
To receive the responses (when players click one of the provided options) you must add a
61+
[WebHook](WEBHOOKS.md) for **CUSTOM_MESSAGE**.
62+
63+
The response will look similar to the following:
64+
```json
65+
{
66+
"id": "your_id",
67+
"source": "The UUID of the player that selected this response",
68+
"choice": "The key of the option that the player selected"
69+
}
70+
```
71+
72+
The `id` is the id that you specified when sending the message as described above.
73+
74+
The `source` is the UUID of the player that clicked on the option.
75+
76+
The `choice` is the **key** of the option that the player clicked on.

docs/WEBHOOKS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ as to when that event is triggered.
137137
| Event / Hook name | Description |
138138
| ------------------- | ----------- |
139139
| ALL | Fired for all events listed below
140+
| CUSTOM_MESSAGE | Use this hook to capture the response from [Messages](MESSAGE.md)
140141
| ACHIEVEMENT | Fired when a player earns a new achievement
141142
| BLOCK_UPDATE_STATUS | Fired when a Web-API BlockUpdate changes status
142143
| CHAT | Fired when a chat message is sent (by players)

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
version=4.6.2
1+
version=4.6.3
22
minecraftVersion=1.11.2
33
spongeVersion=6.1
292 KB
Binary file not shown.

src/main/java/valandur/webapi/WebAPI.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
import valandur.webapi.integration.mmctickets.MMCTicketsServlet;
7979
import valandur.webapi.integration.nations.NationsServlet;
8080
import valandur.webapi.integration.nucleus.NucleusServlet;
81+
import valandur.webapi.integration.redprotect.RedProtectServlet;
8182
import valandur.webapi.integration.webbhooks.WebBookServlet;
8283
import valandur.webapi.json.JsonService;
8384
import valandur.webapi.message.MessageService;
@@ -359,6 +360,12 @@ public void onInitialization(GameInitializationEvent event) {
359360
servletService.registerServlet(WebBookServlet.class);
360361
} catch (ClassNotFoundException ignored) { }
361362

363+
try {
364+
Class.forName("br.net.fabiozumbi12.redprotect.RedProtect");
365+
logger.info(" Integrating with RedProtect...");
366+
servletService.registerServlet(RedProtectServlet.class);
367+
} catch (ClassNotFoundException ignored) { }
368+
362369
// Main init function, that is also called when reloading the plugin
363370
init(null);
364371

src/main/java/valandur/webapi/command/CommandRegistry.java

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,29 @@ public static void init() {
4646
// Whitelist
4747
CommandSpec specWhitelistAdd = CommandSpec.builder()
4848
.description(Text.of("Add an IP to the whitelist"))
49-
.permission("webapi.command.whitelist.add")
49+
.permission("webapi.whitelist.add")
5050
.arguments(new CmdIpElement(Text.of("ip")))
5151
.executor(new CmdAuthListAdd(true))
5252
.build();
5353
CommandSpec specWhitelistRemove = CommandSpec.builder()
5454
.description(Text.of("Remove an IP from the whitelist"))
55-
.permission("webapi.command.whitelist.remove")
55+
.permission("webapi.whitelist.remove")
5656
.arguments(new CmdIpElement(Text.of("ip")))
5757
.executor(new CmdAuthListRemove(true))
5858
.build();
5959
CommandSpec specWhitelistEnable = CommandSpec.builder()
6060
.description(Text.of("Enable the whitelist"))
61-
.permission("webapi.command.whitelist.enable")
61+
.permission("webapi.whitelist.enable")
6262
.executor(new CmdAuthListEnable(true))
6363
.build();
6464
CommandSpec specWhitelistDisable = CommandSpec.builder()
6565
.description(Text.of("Disable the whitelist"))
66-
.permission("webapi.command.whitelist.disable")
66+
.permission("webapi.whitelist.disable")
6767
.executor(new CmdAuthListDisable(true))
6868
.build();
6969
CommandSpec specWhitelist = CommandSpec.builder()
7070
.description(Text.of("Manage the whitelist"))
71-
.permission("webapi.command.whitelist")
71+
.permission("webapi.whitelist")
7272
.child(specWhitelistAdd, "add")
7373
.child(specWhitelistRemove, "remove")
7474
.child(specWhitelistEnable, "enable")
@@ -78,64 +78,64 @@ public static void init() {
7878
// Blacklist
7979
CommandSpec specBlacklistAdd = CommandSpec.builder()
8080
.description(Text.of("Add an IP to the blacklist"))
81-
.permission("webapi.command.blacklist.add")
81+
.permission("webapi.blacklist.add")
8282
.arguments(GenericArguments.string(Text.of("ip")))
8383
.executor(new CmdAuthListAdd(false))
8484
.build();
8585
CommandSpec specBlaclistRemove = CommandSpec.builder()
8686
.description(Text.of("Remove an IP from the blacklist"))
87-
.permission("webapi.command.blacklist.remove")
87+
.permission("webapi.blacklist.remove")
8888
.arguments(GenericArguments.string(Text.of("ip")))
8989
.executor(new CmdAuthListRemove(false))
9090
.build();
9191
CommandSpec specBlacklistEnable = CommandSpec.builder()
9292
.description(Text.of("Enable the blacklist"))
93-
.permission("webapi.command.blacklist.enable")
93+
.permission("webapi.blacklist.enable")
9494
.executor(new CmdAuthListEnable(false))
9595
.build();
9696
CommandSpec specBlacklistDisable = CommandSpec.builder()
9797
.description(Text.of("Disable the blacklist"))
98-
.permission("webapi.command.blacklist.disable")
98+
.permission("webapi.blacklist.disable")
9999
.executor(new CmdAuthListDisable(false))
100100
.build();
101101
CommandSpec specBlacklist = CommandSpec.builder()
102102
.description(Text.of("Manage the blacklist"))
103-
.permission("webapi.command.blacklist")
103+
.permission("webapi.blacklist")
104104
.child(specBlacklistAdd, "add")
105105
.child(specBlaclistRemove, "remove")
106106
.child(specBlacklistEnable, "enable")
107107
.child(specBlacklistDisable, "disable")
108108
.build();
109109

110+
// Block operations
110111
final BlockService blockService = WebAPI.getBlockService();
111-
// Block updates
112-
CommandSpec specBlockUpdatesList = CommandSpec.builder()
113-
.description(Text.of("List all running block updates"))
114-
.permission("webapi.command.blocks.list")
112+
CommandSpec specBlockOpsList = CommandSpec.builder()
113+
.description(Text.of("List all running block operations"))
114+
.permission("webapi.op.list")
115115
.executor(new CmdBlockUpdatesList())
116116
.build();
117-
CommandSpec specBlockUpdatesPause = CommandSpec.builder()
118-
.description(Text.of("Pause/Resume running block updates"))
119-
.permission("webapi.command.blocks.pause")
117+
CommandSpec specBlockOpsPause = CommandSpec.builder()
118+
.description(Text.of("Pause/Resume running block operations"))
119+
.permission("webapi.op.pause")
120120
.arguments(GenericArguments.choices(Text.of("uuid"),
121121
() -> blockService.getBlockOperations().stream().map(u -> u.getUUID().toString()).collect(Collectors.toList()),
122122
uuid -> blockService.getBlockOperation(UUID.fromString(uuid))))
123123
.executor(new CmdBlockUpdatesList())
124124
.build();
125-
CommandSpec specBlockUpdatesStop = CommandSpec.builder()
126-
.description(Text.of("Stop a running block update"))
127-
.permission("webapi.command.blocks.stop")
125+
CommandSpec specBlockOpsStop = CommandSpec.builder()
126+
.description(Text.of("Stop a running block operation"))
127+
.permission("webapi.op.stop")
128128
.arguments(GenericArguments.choices(Text.of("uuid"),
129129
() -> blockService.getBlockOperations().stream().map(u -> u.getUUID().toString()).collect(Collectors.toList()),
130130
uuid -> Util.isValidUUID(uuid) ? blockService.getBlockOperation(UUID.fromString(uuid)) : null))
131131
.executor(new CmdBlockUpdatesList())
132132
.build();
133-
CommandSpec specBlockUpdates = CommandSpec.builder()
134-
.description(Text.of("Manage running block updates"))
135-
.permission("webapi.command.blocks")
136-
.child(specBlockUpdatesList, "list")
137-
.child(specBlockUpdatesPause, "pause")
138-
.child(specBlockUpdatesStop, "stop", "delete", "remove")
133+
CommandSpec specBlockOps = CommandSpec.builder()
134+
.description(Text.of("Manage running block operations"))
135+
.permission("webapi.op")
136+
.child(specBlockOpsList, "list")
137+
.child(specBlockOpsPause, "pause")
138+
.child(specBlockOpsStop, "stop", "delete", "remove")
139139
.build();
140140

141141
// Users
@@ -190,7 +190,7 @@ public static void init() {
190190

191191
CommandSpec hookCmd = CommandSpec.builder()
192192
.description(Text.of("Notify the " + name + " hook"))
193-
.permission("webapi.command.notify." + name)
193+
.permission("webapi.notify." + name)
194194
.arguments(args.toArray(new CommandElement[args.size()]))
195195
.executor(new CmdNotifyHook(hook))
196196
.build();
@@ -201,19 +201,19 @@ public static void init() {
201201
// Notify parent
202202
CommandSpec specNotifyHook = CommandSpec.builder()
203203
.description(Text.of("Notify a hook"))
204-
.permission("webapi.command.notify")
204+
.permission("webapi.notify")
205205
.children(hookSpecs)
206206
.build();
207207

208208
// Register main command
209209
CommandSpec spec = CommandSpec.builder()
210210
.description(Text.of("Manage Web-API settings"))
211-
.permission("webapi.command")
211+
.permission("webapi")
212212
.child(specWhitelist, "whitelist")
213213
.child(specBlacklist, "blacklist")
214214
.child(specNotifyHook, "notify")
215-
.child(specBlockUpdates, "blocks")
216-
.child(specUsers, "users")
215+
.child(specBlockOps, "ops", "op", "blockops")
216+
.child(specUsers, "users", "user")
217217
.build();
218218
manager.register(WebAPI.getInstance(), spec, "webapi").map(m -> mappings.add(m));
219219

0 commit comments

Comments
 (0)