diff --git a/.vitepress/config.mts b/.vitepress/config.mts index e8b0c20..bf468a6 100644 --- a/.vitepress/config.mts +++ b/.vitepress/config.mts @@ -3,158 +3,192 @@ import { tabsMarkdownPlugin } from "vitepress-plugin-tabs"; // https://vitepress.dev/reference/site-config export default defineConfig({ - title: "Minestom", - description: - "A multithreaded, open-source library for developing high-performance Minecraft servers.", - markdown: { - config(md) { - md.use(tabsMarkdownPlugin); - }, - }, - head: [ - ["link", { rel: "icon", href: "/favicon.ico" }], - ["meta", { name: "theme-color", content: "#ff6c32" }], - ], - cleanUrls: true, - themeConfig: { - // https://vitepress.dev/reference/default-theme-config - search: { - provider: "local" + title: "Minestom", + description: + "A multithreaded, open-source library for developing high-performance Minecraft servers.", + markdown: { + config(md) { + md.use(tabsMarkdownPlugin); + }, }, - logo: "/minestom-logo.png", - nav: [ - { text: "Libraries", link: "/libraries" }, - // { text: "Showcase", link: "/showcase/introduction" }, - { text: "Wiki", link: "/docs/introduction" }, - { text: "Javadoc", link: "https://javadoc.minestom.net" }, + head: [ + ["link", { rel: "icon", href: "/favicon.ico" }], + ["meta", { name: "theme-color", content: "#ff6c32" }], ], - - sidebar: { - // "/showcase": [ - // { - // text: "Introduction", - // link: "/showcase/introduction", - // }, - // - // // Showcase example - // { - // text: "Showcase", - // items: [{ text: "Example Server", link: "/showcase/example" }], - // }, - // ], - "/docs/": [ - { - text: "Introduction", - link: "/docs/introduction", + cleanUrls: true, + themeConfig: { + // https://vitepress.dev/reference/default-theme-config + search: { + provider: "local", }, - { - text: "Setup", - items: [ - { text: "Dependencies", link: "/docs/setup/dependencies" }, - { - text: "Your First Server", - link: "/docs/setup/your-first-server", - }, - ], - }, - { - text: "Thread Architecture", - items: [ - { - text: "Thread Safety in the JVM", - link: "/docs/thread-architecture/thread-safety", - }, - { - text: "Acquirable API", - link: "/docs/thread-architecture/acquirable-api", - items: [ + logo: "/minestom-logo.png", + nav: [ + { text: "Libraries", link: "/libraries" }, + // { text: "Showcase", link: "/showcase/introduction" }, + { text: "Wiki", link: "/docs/introduction" }, + { text: "Javadoc", link: "https://javadoc.minestom.net" }, + ], + + sidebar: { + // "/showcase": [ + // { + // text: "Introduction", + // link: "/showcase/introduction", + // }, + // + // // Showcase example + // { + // text: "Showcase", + // items: [{ text: "Example Server", link: "/showcase/example" }], + // }, + // ], + "/docs/": [ { - text: "The Inside", - link: "/docs/thread-architecture/acquirable-api/inside-the-api", + text: "Introduction", + link: "/docs/introduction", }, - ], - }, - ], - }, - { - text: "World", - items: [ - { text: "Instances", link: "/docs/world/instances" }, - { - text: "Chunk Management", - link: "/docs/world/chunk-management", - items: [ - { text: "Anvil Loader", link: "/docs/world/anvilloader" }, - { text: "Lighting", link: "/docs/world/lightloader" }, - ], - }, - { text: "Blocks", link: "/docs/world/blocks" }, - { text: "Coordinates", link: "/docs/world/coordinates" }, - { text: "Generation", link: "/docs/world/generation" }, - { text: "Batch", link: "/docs/world/batch" }, - ], - }, - { - text: "Feature", - items: [ - { text: "Adventure", link: "/docs/feature/adventure" }, - { - text: "Player Capabilities", - link: "/docs/feature/player-capabilities", - }, - { - text: "Events", - link: "/docs/feature/events", - items: [ { - text: "Implementation", - link: "/docs/feature/events/implementation", + text: "Setup", + items: [ + { + text: "Dependencies", + link: "/docs/setup/dependencies", + }, + { + text: "Your First Server", + link: "/docs/setup/your-first-server", + }, + ], }, { - text: "Server List Ping", - link: "/docs/feature/events/server-list-ping", + text: "Thread Architecture", + items: [ + { + text: "Thread Safety in the JVM", + link: "/docs/thread-architecture/thread-safety", + }, + { + text: "Acquirable API", + link: "/docs/thread-architecture/acquirable-api", + items: [ + { + text: "The Inside", + link: "/docs/thread-architecture/acquirable-api/inside-the-api", + }, + ], + }, + ], }, - ], - }, - { text: "Items", link: "/docs/feature/items" }, + { + text: "World", + items: [ + { text: "Instances", link: "/docs/world/instances" }, + { + text: "Chunk Management", + link: "/docs/world/chunk-management", + items: [ + { + text: "Anvil Loader", + link: "/docs/world/anvilloader", + }, + { + text: "Lighting", + link: "/docs/world/lightloader", + }, + ], + }, + { text: "Blocks", link: "/docs/world/blocks" }, + { + text: "Coordinates", + link: "/docs/world/coordinates", + }, + { text: "Generation", link: "/docs/world/generation" }, + { text: "Batch", link: "/docs/world/batch" }, + ], + }, + { + text: "Feature", + items: [ + { text: "Adventure", link: "/docs/feature/adventure" }, + { + text: "Player Capabilities", + link: "/docs/feature/player-capabilities", + }, + { + text: "Events", + link: "/docs/feature/events", + items: [ + { + text: "Implementation", + link: "/docs/feature/events/implementation", + }, + { + text: "Server List Ping", + link: "/docs/feature/events/server-list-ping", + }, + ], + }, + { text: "Items", link: "/docs/feature/items" }, + { + text: "Entities", + link: "/docs/feature/entities", + items: [ + { + text: "AI", + link: "/docs/feature/entities/ai", + }, + ], + }, + { text: "Tags", link: "/docs/feature/tags" }, + { + text: "Schedulers", + link: "/docs/feature/schedulers", + }, + { text: "Commands", link: "/docs/feature/commands" }, + { + text: "Inventories", + link: "/docs/feature/inventories", + }, + { + text: "Player UUID", + link: "/docs/feature/player-uuid", + }, + { + text: "Player Skin", + link: "/docs/feature/player-skin", + }, + { + text: "Advancements", + link: "/docs/feature/advancements", + }, + { + text: "Map Rendering", + link: "/docs/feature/map-rendering", + items: [ + { + text: "GLFW Map Rendering", + link: "/docs/feature/map-rendering/glfwmaprendering", + }, + ], + }, + { text: "Query System", link: "/docs/feature/query" }, + { + text: "Open to LAN", + link: "/docs/feature/open-to-lan", + }, + ], + }, + ], + }, + socialLinks: [ { - text: "Entities", - link: "/docs/feature/entities", - items: [{ text: "AI", link: "/docs/feature/entities/ai" }], + icon: "github", + link: "https://github.com/minestom/Minestom", }, - { text: "Tags", link: "/docs/feature/tags" }, - { text: "Schedulers", link: "/docs/feature/schedulers" }, - { text: "Commands", link: "/docs/feature/commands" }, - { text: "Inventories", link: "/docs/feature/inventories" }, - { text: "Player UUID", link: "/docs/feature/player-uuid" }, - { text: "Player Skin", link: "/docs/feature/player-skin" }, - { text: "Permissions", link: "/docs/feature/permissions" }, - { text: "Advancements", link: "/docs/feature/advancements" }, { - text: "Map Rendering", - link: "/docs/feature/map-rendering", - items: [ - { - text: "GLFW Map Rendering", - link: "/docs/feature/map-rendering/glfwmaprendering", - }, - ], + icon: "discord", + link: "https://discord.gg/pkFRvqB", }, - { text: "Query System", link: "/docs/feature/query" }, - { text: "Open to LAN", link: "/docs/feature/open-to-lan" }, - ], - }, - ], + ], }, - socialLinks: [ - { - icon: "github", - link: "https://github.com/minestom/Minestom", - }, - { - icon: "discord", - link: "https://discord.gg/pkFRvqB", - }, - ], - }, }); diff --git a/docs/feature/permissions.md b/docs/feature/permissions.md deleted file mode 100644 index 593ac2a..0000000 --- a/docs/feature/permissions.md +++ /dev/null @@ -1,67 +0,0 @@ -# Permissions - -Permissions are the feature allowing you to determine if a player is able to perform an action or not. - -[`Permission`](https://minestom.github.io/Minestom/net/minestom/server/permission/Permission.html) is an immutable class that can be added to any [`PermissionHandler`](https://minestom.github.io/Minestom/net/minestom/server/permission/PermissionHandler.html). - -A permission contains 2 things, a unique name (same as with Bukkit if you are familiar with it), and an optional `NBTCompound` which can be used to add additional data to the permission (no more "my.permission.X" where X represents a number). - -## Handling permission access - -In order to add a permission to a PermissionHandler you should use `PermissionHandler#addPermission(Permission)`. - -To remove a permission, `PermissionHandler#removePermission(Permission)` and `PermissionHandler#removePermission(String)` are available. - -## Checking permissions - -To verify if a PermissionHandler has a permission, you have the choice between simply checking if the handler has a permission with the same name, or verifying that the handler has both the permission name and the right data associated with it. - -To check if the handler has a permission with a specific name, `PermissionHandler#hasPermission(String)` should be used. If you want to verify that the handler has the right NBT data `PermissionHandler#hasPermission(String, PermissionVerifier)` is the right choice. - -A [`PermissionVerifier`](https://minestom.github.io/Minestom/net/minestom/server/permission/PermissionVerifier.html) is a simple functional interface used to check if the given `NBTCompound` is valid. - -Alternatively, `PermissionHandler#hasPermission(Permission)` can be used. It does require both the permission name and the data to be equal. - -## Adding permissions to players and checking them - -In order to add a permission to a player, you will have to call the `Player#addPermission(Permission)` function, an example of proper usage would be - -```java -player.addPermission(new Permission("operator")); -``` - -If you want to check, if a player has a permission, you can use the `Player#hasPermission(Permission)` function, here is an example of checking a permission from a command: - -```java -public class StopCommand extends Command { - public StopCommand() { - super("stop"); - setCondition((sender, commandString) -> sender.hasPermission(new Permission("operator"))); - setDefaultExecutor((sender, context) -> MinecraftServer.stopCleanly()); - } -} -``` - -## Permission wildcard matching - -Minestom supports wildcard matching for permissions. -This means that if a player has a permission like `admin.*`, this will satisfy any checks for permissions that have the same format, with differing contents for the wildcard. e.g. `admin.tp` will return true. - -Example: -```java -player.addPermission(new Permission("command.*")); // Gives the player every permission with the 'command.' prefix - -player.hasPermission(new Permission("command.gamemode")); // This returns true - -// Same thing goes for -player.addPermission(new Permission("*")); // Gives the player every permission - -player.hasPermission(new Permission("user.chat")); // returns true -player.hasPermission(new Permission("3i359cvjm.sdfk239c")); // returns true -``` - -## Permission serialisation - -Nothing is automatically saved persistently in Minestom, permissions are not an exception. - -Permissions must be serialized and deserialized back manually if you want such a feature. You are lucky since the `Permission` class can easily be interpreted as 2 strings, one being the permission name, and the second representing the optional data using `NBTCompound#toSNBT()` (and deserialized with `SNBTParser#parse()`). diff --git a/docs/feature/player-capabilities.md b/docs/feature/player-capabilities.md index baa4b73..c93f932 100644 --- a/docs/feature/player-capabilities.md +++ b/docs/feature/player-capabilities.md @@ -69,11 +69,11 @@ Notification notification = new Notification( ); ``` -To send the notification, use one of the static methods on `NotificationCenter`: +To send the notification, use Player#sendNotification or PacketGroupingAudience#sendNotification ```java -NotificationCenter.send(Notification, Player); -NotificationCenter.send(Notification, Collection); +Player.sendNotification(Notification); +PacketGroupingAudience.sendNotification(Notification); ``` The example renders as the following: