### Setting System Properties in a Batch File Source: https://docs.papermc.io/paper/reference/system-properties Demonstrates how to set system properties when starting a Paper server using a .bat or .sh file. This example shows how to agree to the EULA. ```bash java -Dcom.mojang.eula.agree=true -jar paper.jar ``` -------------------------------- ### SpongeAPI Plugin Setup Source: https://docs.papermc.io/adventure/platform/spongeapi Example of setting up a SpongeAPI plugin with SpongeAudiences for message handling. ```java @Plugin(/* [...] */) public class MyPlugin { private final SpongeAudiences adventure; @Inject MyPlugin(final SpongeAudiences adventure) { this.adventure = adventure; } @NonNull public SpongeAudiences adventure() { return this.adventure; } } ``` -------------------------------- ### Install Prerequisites on Ubuntu/Debian Source: https://docs.papermc.io/misc/java-install Ensures your system has the necessary tools for Java installation on Debian-based systems. ```bash sudo apt-get update sudo apt-get install ca-certificates apt-transport-https gnupg wget ``` -------------------------------- ### Basic plugin.yml Example Source: https://docs.papermc.io/paper/dev/plugin-yml A fundamental example of a plugin.yml file, showcasing essential metadata for a PaperMC plugin. ```yaml name: ExamplePlugin version: 1.0.0 main: io.papermc.testplugin.ExamplePlugin description: An example plugin author: PaperMC website: https://papermc.io api-version: '26.1.2' ``` -------------------------------- ### YAML Configuration Example Source: https://docs.papermc.io/paper/dev/plugin-configurations Illustrates the basic key-value pair structure of a YAML configuration file. ```yaml root: one-key: 10 another-key: David ``` -------------------------------- ### Starting Server with No GUI Source: https://docs.papermc.io/paper/reference/cli-arguments Use the --nogui flag to start the server without its graphical user interface. This is a common way to run Paper servers, especially on headless systems. ```bash java -jar server.jar --nogui ``` -------------------------------- ### Valid User-Agent Examples Source: https://docs.papermc.io/misc/downloads-service Examples of correctly formatted User-Agent headers for the Downloads Service. Ensure your User-Agent clearly identifies your software and includes contact information. ```text mc-image-helper/1.39.11 (https://github.com/itzg/docker-minecraft-server) nodecraft/packifier/1.0.0 (staff@nodecraft.com) ``` -------------------------------- ### Start Spark Profiler Source: https://docs.papermc.io/paper/profiling Use this command to start the Spark profiler on your server. It will automatically stop after the specified timeout and generate a report URL. ```command /spark profiler start --timeout 600 ``` -------------------------------- ### Example Command Structure Source: https://docs.papermc.io/paper/dev/command-api/basics/command-tree Illustrates a basic command structure with a root and several subcommands. ```plaintext /customplugin reload /customplugin tphere /customplugin killall ``` -------------------------------- ### Expected Java Installation Output Source: https://docs.papermc.io/misc/java-install This is the expected output when Java 25 is successfully installed. Pay attention to the 'openjdk 25' and '64-Bit' indicators. ```text openjdk version "25" 2025-09-16 OpenJDK Runtime Environment (build 25+36-3489) OpenJDK 64-Bit Server VM (build 25+36-3489, mixed mode, sharing) ``` -------------------------------- ### Key Argument Example Source: https://docs.papermc.io/paper/dev/command-api/arguments/adventure Shows how to use the key argument to accept and validate namespaced keys. ```java public static LiteralCommandNode keyArgument() { return Commands.literal("key") .then(Commands.argument("key_input", ArgumentTypes.key()) .executes(ctx -> { final Key key = ctx.getArgument("key_input", Key.class); ctx.getSource().getSender().sendRichMessage("You put in !", Placeholder.unparsed("key", key.asString()) ); return Command.SINGLE_SUCCESS; })) .build(); } ``` -------------------------------- ### Example Syncloadinfo Output Source: https://docs.papermc.io/paper/reference/commands This is the expected output for the /paper syncloadinfo command when the required JVM flag is set. ```json { "worlds": [] } ``` -------------------------------- ### Java Plugin Bootstrap Implementation Source: https://docs.papermc.io/paper/dev/getting-started/paper-plugins Example implementation of the `PluginBootstrap` interface for Paper plugins, demonstrating the `bootstrap` and `createPlugin` methods. ```java public class TestPluginBootstrap implements PluginBootstrap { @Override public void bootstrap(BootstrapContext context) { } @Override public JavaPlugin createPlugin(PluginProviderContext context) { return new TestPlugin("My custom parameter"); } } ``` -------------------------------- ### RegistryKey Interface Example Source: https://docs.papermc.io/paper/dev/command-api/arguments/registry Illustrates the definition of a RegistryKey for items within the RegistryKey interface. ```java public sealed interface RegistryKey extends Keyed permits RegistryKeyImpl { // ... RegistryKey ITEM = RegistryKeyImpl.create("item"); // ... } ``` -------------------------------- ### Shapeless Recipe Crafting Grid Examples Source: https://docs.papermc.io/paper/dev/recipes Examples of valid item arrangements for a shapeless recipe. Any combination of the specified ingredients will yield the result. ```plaintext DSS | SDS | S D D | D | D D | D | D S ``` -------------------------------- ### Paper NamespacedKey Argument Example Source: https://docs.papermc.io/paper/dev/command-api/arguments/paper Provides an example of a namespaced key argument, which is useful for handling custom keys in Bukkit API. It returns a NamespacedKey object. ```java public static LiteralCommandNode namespacedKeyArgument() { return Commands.literal("namespacedkey") .then(Commands.argument("key", ArgumentTypes.namespacedKey()) .executes(ctx -> { final NamespacedKey key = ctx.getArgument("key", NamespacedKey.class); ctx.getSource().getSender().sendRichMessage("You put in !", Placeholder.unparsed("key", key.toString()) ); return Command.SINGLE_SUCCESS; })) .build(); } ``` -------------------------------- ### Use Translatable Component Source: https://docs.papermc.io/paper/dev/component-api/i18n This example shows how to create a translatable component using a defined translation key and providing arguments. ```java Component.translatable("some.translation.key", Component.text("The Argument")) ``` -------------------------------- ### Install Java 25 using Zypper on RPM-based Linux Source: https://docs.papermc.io/misc/java-install Installs the Java 25 Development Kit on openSUSE, SLES, and related distributions using the Zypper package manager. ```bash sudo zypper addrepo https://yum.corretto.aws/corretto.repo sudo zypper refresh sudo zypper install java-25-amazon-corretto-devel ``` -------------------------------- ### BungeeCord Plugin Initialization Source: https://docs.papermc.io/adventure/platform/bungeecord Example of initializing and closing the BungeeAudiences provider in a BungeeCord plugin. ```java public class MyPlugin extends Plugin { private BungeeAudiences adventure; @NonNull public BungeeAudiences adventure() { if (this.adventure == null) { throw new IllegalStateException("Cannot retrieve audience provider while plugin is not enabled"); } return this.adventure; } @Override public void onEnable() { this.adventure = BungeeAudiences.create(this); } @Override public void onDisable() { if (this.adventure != null) { this.adventure.close(); this.adventure = null; } } } ``` -------------------------------- ### Component Argument Example Source: https://docs.papermc.io/paper/dev/command-api/arguments/adventure Demonstrates how to use the component argument to accept and display a JSON-formatted text component. ```java public static LiteralCommandNode componentArgument() { return Commands.literal("componentargument") .then(Commands.argument("arg", ArgumentTypes.component()) .executes(ctx -> { final Component component = ctx.getArgument("arg", Component.class); ctx.getSource().getSender().sendRichMessage( "Your message: ", Placeholder.component("input", component) ); return Command.SINGLE_SUCCESS; })) .build(); } ``` -------------------------------- ### Start Spark Profiler for 300 Seconds Source: https://docs.papermc.io/paper/basic-troubleshooting Use this command to start the Spark profiler for a specified duration to diagnose performance issues. The profiler will record data for the entire duration. ```bash /spark profiler start --timeout 300 ``` -------------------------------- ### Datapack Load Success Console Output Source: https://docs.papermc.io/paper/dev/lifecycle/datapacks Example console output indicating a datapack has loaded successfully. ```log [01:10:12 INFO]: [PaperDocsTestProject] Loading server plugin PaperDocsTestProject v1.0-DEV [01:10:12 INFO]: [PaperDocsTestProject] The datapack loaded successfully! ``` -------------------------------- ### Chaining 'then' for 'eat' Subcommand Source: https://docs.papermc.io/paper/dev/command-api/basics/command-tree Demonstrates chaining literal arguments for the 'eat' subcommand, similar to the 'killall' example. ```java eat .then(Commands.literal("ice-cream")) .then(Commands.literal("main-dish")); ``` -------------------------------- ### Build BrigadierCommand Node Source: https://docs.papermc.io/velocity/dev/command-api Example of building a BrigadierCommand node, returning Command.SINGLE_SUCCESS for success or BrigadierCommand.FORWARD to pass to the server. ```java return new BrigadierCommand(helloNode); } } ``` -------------------------------- ### Adventure Style Argument Example Source: https://docs.papermc.io/paper/dev/command-api/arguments/adventure Illustrates using the style argument to apply Adventure styles to text components. ```java public static LiteralCommandNode styleArgument() { return Commands.literal("style") .then(Commands.argument("style", ArgumentTypes.style()) .then(Commands.argument("message", StringArgumentType.greedyString()) .executes(ctx -> { final Style style = ctx.getArgument("style", Style.class); final String msg = StringArgumentType.getString(ctx, "message"); ctx.getSource().getSender().sendRichMessage("Your input: ", Placeholder.component("input", Component.text(message).style(style)) ); return Command.SINGLE_SUCCESS; }))) .build(); } ``` -------------------------------- ### Player Argument Example Source: https://docs.papermc.io/paper/dev/command-api/arguments/entity-player Demonstrates retrieving a specific player using the player argument and applying a velocity to them. Requires the 'minecraft.command.selector' permission. ```Java public static LiteralCommandNode playerArgument() { return Commands.literal("player") .then(Commands.argument("target", ArgumentTypes.player()) .executes(ctx -> { final PlayerSelectorArgumentResolver targetResolver = ctx.getArgument("target", PlayerSelectorArgumentResolver.class); final Player target = targetResolver.resolve(ctx.getSource()).getFirst(); target.setVelocity(new Vector(0, 100, 0)); target.sendRichMessage("Yeeeeeeeeeet"); ctx.getSource().getSender().sendRichMessage("Yeeted !", Placeholder.component("target", target.name()) ); return Command.SINGLE_SUCCESS; })) .build(); } ``` -------------------------------- ### Paper Plugin Dependency Example Source: https://docs.papermc.io/paper/dev/getting-started/paper-plugins Illustrates various dependency configurations in `paper-plugin.yml`, including load order, requirement status, and classpath access. ```yaml # Suppose we require ProtocolLib to be loaded for our plugin ProtocolLib: load: BEFORE required: true # Now, we are going to register some details for a shop plugin # So the shop plugin should load after our plugin SuperShopsXUnlimited: load: AFTER required: false # Now, we are going to need to access a plugins classpath # So that we can properly interact with it. SuperDuperTacoParty: required: true join-classpath: true ``` -------------------------------- ### Transition Text Examples Source: https://docs.papermc.io/adventure/minimessage/format Shows how to use the transition tag for text where all characters share the same color, with the phase parameter controlling the color. ```minemessage ||||||||| Hello world [phase] ``` -------------------------------- ### Send PlayerCount Plugin Message Source: https://docs.papermc.io/paper/dev/plugin-messaging Example of sending a 'PlayerCount' plugin message to a BungeeCord proxy to get the number of players on a specific server. The response is handled in `onPluginMessageReceived`. ```java public class MyPlugin extends JavaPlugin implements PluginMessageListener { @Override public void onEnable() { this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", this); Player player = ...; ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF("PlayerCount"); out.writeUTF("lobby"); player.sendPluginMessage(this, "BungeeCord", out.toByteArray()); // The response will be handled in onPluginMessageReceived } @Override public void onPluginMessageReceived(String channel, Player player, byte[] message) { if (!channel.equals("BungeeCord")) { return; } ByteArrayDataInput in = ByteStreams.newDataInput(message); String subchannel = in.readUTF(); if (subchannel.equals("PlayerCount")) { // This is our response to the PlayerCount request String server = in.readUTF(); int playerCount = in.readInt(); } } } ``` -------------------------------- ### Enabling Demo Mode Source: https://docs.papermc.io/paper/reference/cli-arguments Use the --demo flag to start the server in demo mode. This mode generates a fixed world and displays demo-specific messages. ```bash java -jar server.jar --demo ``` -------------------------------- ### Initializing Settings Only Source: https://docs.papermc.io/paper/reference/cli-arguments Use the --initSettings flag to create configuration files and then shut down the server without starting it. This is useful for pre-configuring settings. ```bash java -jar server.jar --initSettings ``` -------------------------------- ### Plugin Annotation Example Source: https://docs.papermc.io/velocity/dev/api-basics Example of the @Plugin annotation used to define plugin metadata. ```java @Plugin(id = "myfirstplugin", name = "My First Plugin", version = "0.1.0-SNAPSHOT", url = "awesome.org", description = "I did it!", authors = {"Me"}) public class VelocityTest { ``` -------------------------------- ### SQL Injection Example Input Source: https://docs.papermc.io/paper/dev/using-databases Example of malicious input that can be used to exploit SQL injection vulnerabilities. ```text ' OR 1=1; -- ``` -------------------------------- ### Check Plugin List Command Source: https://docs.papermc.io/paper/adding-plugins After installing a plugin, use this command in-game or in the console to verify it has loaded correctly. A green listed plugin indicates success. ```text /plugins ``` -------------------------------- ### Run Basic Waterfall Proxy Source: https://docs.papermc.io/waterfall/getting-started Start the Waterfall proxy with basic memory allocation. Replace 'waterfall-###.jar' with your actual JAR file name. ```bash java -Xms512M -Xmx512M -jar waterfall-###.jar ``` -------------------------------- ### Install Java 25 on Ubuntu/Debian Source: https://docs.papermc.io/misc/java-install Installs Java 25 Development Kit and essential graphical libraries on Debian-based systems. ```bash sudo apt-get update sudo apt-get install -y java-25-amazon-corretto-jdk libxi6 libxtst6 libxrender1 ``` -------------------------------- ### Install OpenJDK 25 on macOS using Homebrew Source: https://docs.papermc.io/misc/java-install Installs OpenJDK version 25 on macOS using the Homebrew package manager. ```bash brew install openjdk@25 ``` -------------------------------- ### Create and Open a Book Source: https://docs.papermc.io/adventure/book Demonstrates how to construct a book with a title, author, and pages, and then open it for a target audience. Ensure the necessary components and audience are available. ```java // Create and open a book about cats for the target audience public void openMyBook(final @NonNull Audience target) { Component bookTitle = Component.text("Encyclopedia of cats"); Component bookAuthor = Component.text("kashike"); Collection bookPages = Cats.getCatKnowledge(); Book myBook = Book.book(bookTitle, bookAuthor, bookPages); target.openBook(myBook); } ``` -------------------------------- ### Example Entity Listing Output Source: https://docs.papermc.io/paper/reference/commands This is an example of the output format for the /paper entity list command, showing ticking and non-ticking entity counts. ```plaintext Total Ticking: -78, Total Non-Ticking: 92 10 (3) : minecraft:pig 1 (0) : minecraft:piglin ``` -------------------------------- ### Displaying Help Message Source: https://docs.papermc.io/paper/reference/cli-arguments Use the -? or --help flags to display a help message listing all available CLI arguments. This action will not start the server. ```bash java -jar server.jar -?, --help ``` -------------------------------- ### Verify Java Installation Command Source: https://docs.papermc.io/misc/java-install Run this command in your terminal to check if Java 25 is installed correctly. Ensure your terminal session is active. ```bash java -version ``` -------------------------------- ### Run Paper Server Command Source: https://docs.papermc.io/paper/getting-started Use this command to start your Paper server from the terminal. Ensure you are in the server directory and replace 'paper.jar' with your downloaded JAR file name. Adjust RAM allocation using -Xms and -Xmx flags. --nogui disables the graphical user interface. ```bash java -Xms4G -Xmx4G -jar paper.jar --nogui ``` -------------------------------- ### Paper Watchdog Dump Example Source: https://docs.papermc.io/paper/basic-troubleshooting This is an example of a Paper Watchdog dump, which indicates severe lag. Examine the stack trace to identify the main thread's bottleneck. ```log [02:04:00] [Paper Watchdog Thread/ERROR]: --- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH - 1.21.3-66-afb5b13 (MC: 1.21.3) --- [02:04:00] [Paper Watchdog Thread/ERROR]: The server has not responded for 10 seconds! Creating thread dump [02:04:00] [Paper Watchdog Thread/ERROR]: ------------------------------ [02:04:00] [Paper Watchdog Thread/ERROR]: Server thread dump (Look for plugins here before reporting to Paper!): [02:04:00] [Paper Watchdog Thread/ERROR]: ------------------------------ [02:04:00] [Paper Watchdog Thread/ERROR]: Current Thread: Server thread [02:04:00] [Paper Watchdog Thread/ERROR]: PID: 129 | Suspended: false | Native: true | State: RUNNABLE [02:04:00] [Paper Watchdog Thread/ERROR]: Stack: [02:04:00] [Paper Watchdog Thread/ERROR]: java.base@21.0.5/sun.nio.ch.UnixFileDispatcherImpl.write0(Native Method) [02:04:00] [Paper Watchdog Thread/ERROR]: java.base@21.0.5/sun.nio.ch.UnixFileDispatcherImpl.write(UnixFileDispatcherImpl.java:65) [02:04:00] [Paper Watchdog Thread/ERROR]: java.base@21.0.5/sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:137) [02:04:00] [Paper Watchdog Thread/ERROR]: java.base@21.0.5/sun.nio.ch.IOUtil.write(IOUtil.java:102) [02:04:00] [Paper Watchdog Thread/ERROR]: java.base@21.0.5/sun.nio.ch.IOUtil.write(IOUtil.java:72) [02:04:00] [Paper Watchdog Thread/ERROR]: java.base@21.0.5/sun.nio.ch.FileChannelImpl.write(FileChannelImpl.java:300) [02:04:00] [Paper Watchdog Thread/ERROR]: java.base@21.0.5/sun.nio.ch.ChannelOutputStream.writeFully(ChannelOutputStream.java:68) [02:04:00] [Paper Watchdog Thread/ERROR]: java.base@21.0.5/sun.nio.ch.ChannelOutputStream.write(ChannelOutputStream.java:105) [02:04:00] [Paper Watchdog Thread/ERROR]: java.base@21.0.5/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:125) [02:04:00] [Paper Watchdog Thread/ERROR]: java.base@21.0.5/java.io.BufferedOutputStream.implFlush(BufferedOutputStream.java:252) [02:04:00] [Paper Watchdog Thread/ERROR]: java.base@21.0.5/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:240) [02:04:00] [Paper Watchdog Thread/ERROR]: java.base@21.0.5/java.io.FilterOutputStream.close(FilterOutputStream.java:184) ``` -------------------------------- ### Creating Subcommands with Chained Branches Source: https://docs.papermc.io/paper/dev/command-api/basics/command-tree This example shows how to create subcommand builders ('eat' and 'killall') with their branches already chained, and then register these subcommands to a root command. ```java LiteralArgumentBuilder eat = Commands.literal("eat") .then(Commands.literal("ice-cream")) .then(Commands.literal("main-dish")); LiteralArgumentBuilder killall = Commands.literal("killall") .then(Commands.literal("entities")) .then(Commands.literal("players")) .then(Commands.literal("zombies")); LiteralArgumentBuilder advancedCommandRoot = Commands.literal("advanced"); advancedCommandRoot.then(eat); advancedCommandRoot.then(killall); ``` -------------------------------- ### Install Java 25 using YUM on older RPM-based Linux Source: https://docs.papermc.io/misc/java-install Installs the Java 25 Development Kit on older CentOS/RHEL and Fedora releases using the YUM package manager. ```bash sudo rpm --import https://yum.corretto.aws/corretto.key sudo curl -Lo /etc/yum.repos.d/corretto.repo https://yum.corretto.aws/corretto.repo sudo yum -y install java-25-amazon-corretto-devel ``` -------------------------------- ### Install Java 25 using DNF on RPM-based Linux Source: https://docs.papermc.io/misc/java-install Installs the Java 25 Development Kit on Fedora, CentOS/RHEL 7+, and related distributions using the DNF package manager. ```bash sudo rpm --import https://yum.corretto.aws/corretto.key sudo curl -Lo /etc/yum.repos.d/corretto.repo https://yum.corretto.aws/corretto.repo sudo dnf -y install java-25-amazon-corretto-devel ``` -------------------------------- ### Create Custom Styling Placeholders Source: https://docs.papermc.io/adventure/minimessage/dynamic-replacements Demonstrates creating custom styling placeholders for color, hover events, and click events. ```java Placeholder.styling("fancy", TextColor.color(150, 200, 150)); // will replace the color between "" and "" Placeholder.styling("myhover", HoverEvent.showText(Component.text("test"))); // will display your custom text as hover Placeholder.styling("mycmd", ClickEvent.runCommand("/mycmd is cool")); // will create a clickable text which will run your specified command. ``` -------------------------------- ### Creating Components (Sub-optimal) Source: https://docs.papermc.io/paper/dev/component-api/introduction Demonstrates a less efficient way to build components where each modification creates a new instance. Use builders for optimal construction. ```java final Component component = Component.text("Hello") .color(TextColor.color(0x13f832)) .append(Component.text(" world!", NamedTextColor.GREEN)); ``` -------------------------------- ### Setting System Properties in PowerShell Source: https://docs.papermc.io/paper/reference/system-properties Illustrates the correct syntax for setting system properties with a '.' character in their name when using PowerShell. This example also shows how to agree to the EULA. ```powershell java "-Dcom.mojang.eula.agree=true" -jar paper.jar ``` -------------------------------- ### Per-World Configuration Example Source: https://docs.papermc.io/paper/reference/configuration Example of how to override a default configuration value for a specific world by editing the `paper-world.yml` file within that world's directory. This snippet shows enabling auto-replenish for lootables. ```yaml _version: 28 lootables: auto-replenish: true ``` -------------------------------- ### Registering a Simple BrigadierCommand Source: https://docs.papermc.io/velocity/dev/command-api This snippet shows how to register a basic BrigadierCommand that sends a 'Hello World' message to the executor. It includes permission checks and demonstrates basic command execution logic. ```java package com.example.velocityplugin; import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.Command; import com.mojang.brigadier.tree.LiteralCommandNode; import com.velocitypowered.api.command.BrigadierCommand; import com.velocitypowered.api.command.CommandSource; import com.velocitypowered.api.command.VelocityBrigadierMessage; import com.velocitypowered.api.proxy.ProxyServer; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; public final class TestBrigadierCommand { public static BrigadierCommand createBrigadierCommand(final ProxyServer proxy) { LiteralCommandNode helloNode = BrigadierCommand.literalArgumentBuilder("test") // Here you can filter the subjects that can execute the command. // This is the ideal place to do "hasPermission" checks .requires(source -> source.hasPermission("test.permission")) // Here you can add the logic that will be used in // the execution of the "/test" command without any argument .executes(context -> { // Here you get the subject that executed the command CommandSource source = context.getSource(); Component message = Component.text("Hello World", NamedTextColor.AQUA); source.sendMessage(message); // Returning Command.SINGLE_SUCCESS means that the execution was successful // Returning BrigadierCommand.FORWARD will send the command to the server return Command.SINGLE_SUCCESS; }) // Using the "then" method, you can add sub-arguments to the command. // For example, this subcommand will be executed when using the command "/test " // A RequiredArgumentBuilder is a type of argument in which you can enter some undefined data // of some kind. For example, this example uses a StringArgumentType.word() that requires // a single word to be entered, but you can also use different ArgumentTypes provided by Brigadier // that return data of type Boolean, Integer, Float, other String types, etc .then(BrigadierCommand.requiredArgumentBuilder("argument", StringArgumentType.word()) // Here you can define the hints to be provided in case the ArgumentType does not provide them. // In this example, the names of all connected players are provided .suggests((ctx, builder) -> { // Here we provide the names of the players along with a tooltip, // which can be used as an explanation of a specific argument or as a simple decoration proxy.getAllPlayers().forEach(player -> builder.suggest( player.getUsername(), // A VelocityBrigadierMessage takes a component. // In this case, the player's name is provided with a rainbow // gradient created using MiniMessage. VelocityBrigadierMessage.tooltip( MiniMessage.miniMessage().deserialize("" + player.getUsername()) ) )); // If you do not need to add a tooltip to the hint // or your command is intended only for versions lower than Minecraft 1.13, // you can omit adding the tooltip, since for older clients, // the tooltip will not be displayed. builder.suggest("all"); return builder.buildFuture(); }) // Here the logic of the command "/test " is executed .executes(context -> { // Here you get the argument that the CommandSource has entered. // You must enter exactly the name as you have named the argument // and you must provide the class of the argument you expect, in this case... a String String argumentProvided = context.getArgument("argument", String.class); // This method will check if the given string corresponds to a // player's name and if it does, it will send a message to that player proxy.getPlayer(argumentProvided).ifPresent(player -> player.sendMessage(Component.text("Hello!")) ); return Command.SINGLE_SUCCESS; })) .build(); return new BrigadierCommand(helloNode); } } ``` -------------------------------- ### Item Predicate Argument Example Source: https://docs.papermc.io/paper/dev/command-api/arguments/predicate Illustrates the use of the item predicate argument to filter items based on specific criteria. This example checks if a default wooden sword satisfies the given predicate. ```java public static LiteralCommandNode itemPredicateArgument() { return Commands.literal("itempredicate") .then(Commands.argument("predicate", ArgumentTypes.itemPredicate()) .executes(ctx -> { final ItemStackPredicate predicate = ctx.getArgument("predicate", ItemStackPredicate.class); final ItemStack defaultWoodenSword = ItemType.WOODEN_SWORD.createItemStack(); ctx.getSource().getSender().sendRichMessage("Does predicate include a default wooden sword? ", Placeholder.parsed("result", predicate.test(defaultWoodenSword) ? "true" : "false") ); return Command.SINGLE_SUCCESS; })) .build(); } ``` -------------------------------- ### Outdated Java Version Error Source: https://docs.papermc.io/paper/basic-troubleshooting This error indicates that the installed Java Runtime Environment is too old for the server version. Ensure you have the correct Java version installed and that it is accessible in your system's PATH. ```text Exception in thread "ServerMain" java.lang.UnsupportedClassVersionError: org/bukkit/craftbukkit/Main has been compiled by a more recent version of the Java Runtime (class file version 65.0), this version of the Java Runtime only recognizes class file versions up to 61.0 at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017) at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150) at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:524) at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:427) at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:421) at java.base/java.security.AccessController.doPrivileged(AccessController.java:712) at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:420) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:592) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525) at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Class.java:467) at io.papermc.paperclip.Paperclip.lambda$main$0(Paperclip.java:38) at java.base/java.lang.Thread.run(Thread.java:842) ``` -------------------------------- ### Creating Components (Optimal with Builder) Source: https://docs.papermc.io/paper/dev/component-api/introduction Shows the recommended, efficient method for constructing components using builders, which avoids creating new instances for each change. Static imports are suggested for brevity. ```java final Component component = text() .content("Hello").color(color(0x13f832)) .append(text(" world!", GREEN)) .build(); ``` -------------------------------- ### Update Velocity and Install CrossStitch for Fabric 1.16+ Source: https://docs.papermc.io/velocity/faq If you are running a modded server with Fabric 1.16+ and encounter the 'Argument type identifier unknown' error, update Velocity to at least 1.1.2 and install CrossStitch. ```text Argument type identifier : unknown. ``` -------------------------------- ### Start Spark Profiler for Lag Spikes Source: https://docs.papermc.io/paper/basic-troubleshooting This command starts the Spark profiler to specifically capture lag spikes exceeding 100 milliseconds over a 300-second timeout. It helps in identifying and analyzing brief performance drops. ```bash /spark profiler start --only-ticks-over 100 --timeout 300 ``` -------------------------------- ### Run Waterfall Proxy with Recommended Flags Source: https://docs.papermc.io/waterfall/getting-started Start the Waterfall proxy using Aikar's recommended JVM flags for optimal performance. Replace 'waterfall-###.jar' with your actual JAR file name. ```bash java -Xms512M -Xmx512M -XX:+UseG1GC -XX:G1HeapRegionSize=4M -XX:+UnlockExperimentalVMOptions -XX:+ParallelRefProcEnabled -XX:+AlwaysPreTouch -jar waterfall-###.jar ``` -------------------------------- ### Paper ItemStack Argument Example Source: https://docs.papermc.io/paper/dev/command-api/arguments/paper Shows how to implement an item stack argument for commands, allowing players to specify items with components. This mirrors the functionality of the vanilla /give command. ```java public static LiteralCommandNode itemStackArgument() { return Commands.literal("itemstack") .then(Commands.argument("stack", ArgumentTypes.itemStack()) .executes(ctx -> { final ItemStack itemStack = ctx.getArgument("stack", ItemStack.class); if (ctx.getSource().getExecutor() instanceof Player player) { player.getInventory().addItem(itemStack); ctx.getSource().getSender().sendRichMessage("Successfully gave a ", Placeholder.component("player", player.name()), Placeholder.component("item", Component.translatable(itemStack)) ); return Command.SINGLE_SUCCESS; } ctx.getSource().getSender().sendRichMessage("This argument requires a player!"); return Command.SINGLE_SUCCESS; })) .build(); } ``` -------------------------------- ### Startup Flag to Ignore World Version Source: https://docs.papermc.io/paper/basic-troubleshooting This flag can be used to attempt to load a world saved with a newer version, but it is highly not recommended and may corrupt your world. Always back up your world before using this. ```bash -DPaper.ignoreWorldDataVersion=true ``` -------------------------------- ### Configure Java Launcher for Dev Bundle Source: https://docs.papermc.io/paper/dev/userdev If encountering errors during paperweightUserdevSetup, specify a compatible Java launcher for the dev bundle. This example sets it for Minecraft 1.17.1. ```gradle paperweight { javaLauncher = javaToolchains.launcherFor { // Example scenario: // Paper 1.17.1 was originally built with JDK 16 and the bundle // has not been updated to work with 21+ (but we want to compile with a 25 toolchain) languageVersion = JavaLanguageVersion.of(17) } } ``` -------------------------------- ### Get and Cancel Plugin Tasks Source: https://docs.papermc.io/velocity/dev/scheduler-api Retrieve all tasks scheduled by a specific plugin and cancel them. ```java Collection tasks = server.getScheduler().tasksByPlugin(plugin); // then you can control them, for example, cancel all task scheduled by a plugin for (ScheduledTask task : tasks) { task.cancel(); } ``` -------------------------------- ### Get Audience UUID Source: https://docs.papermc.io/adventure/audiences Retrieves the UUID of an audience member. Returns an Optional. ```java audience.get(Identity.UUID); ``` -------------------------------- ### Registering a BasicCommand with Lambda Source: https://docs.papermc.io/paper/dev/command-api/misc/basic-command Demonstrates registering a command using a lambda expression for conciseness. This is functional but may reduce readability for complex commands. ```java @Override public void onEnable() { registerCommand( "quickcmd", (source, args) -> source.getSender().sendRichMessage("Hello!") ); } ``` -------------------------------- ### Velocity Initial Launch Output Source: https://docs.papermc.io/velocity/getting-started This is a sample console output after successfully launching the Velocity proxy for the first time. It indicates the proxy is booting up and listening on the default port. ```log [05:41:13 INFO]: Booting up Velocity 3.5.0-SNAPSHOT (git-74c932e5-b363)... [05:41:13 INFO]: Loading localizations... [05:41:13 INFO]: Connections will use epoll channels, libdeflate (Linux aarch64) compression, OpenSSL (Linux aarch64) ciphers [05:41:13 INFO]: Loading plugins... [05:41:13 INFO]: Loaded 0 plugins [05:41:13 INFO]: Listening on /[0:0:0:0:0:0:0:0%0]:25565 [05:41:13 INFO]: Done (0.36s)! ``` -------------------------------- ### Command Requiring Operator Status Source: https://docs.papermc.io/paper/dev/command-api/basics/requirements This example shows how to define a command that can only be executed by a server operator. ```java Commands.literal("testcmd") .requires(sender -> sender.getSender().isOp()) .executes(ctx -> { ctx.getSource().getSender().sendRichMessage("You are a server operator!"); return Command.SINGLE_SUCCESS; }); ``` -------------------------------- ### Using ArgumentTypes.resource with RegistryKey.ITEM Source: https://docs.papermc.io/paper/dev/command-api/arguments/registry Demonstrates how to use the `ArgumentTypes.resource` with `RegistryKey.ITEM` to directly retrieve an item and add it to the player's inventory. This method includes client-side error checking. ```java Commands.argument("item", ArgumentTypes.resource(RegistryKey.ITEM)) .executes(ctx -> { final ItemType item = ctx.getArgument("item", ItemType.class); if (ctx.getSource().getExecutor() instanceof Player player) { player.getInventory().addItem(item.createItemStack()); } return Command.SINGLE_SUCCESS; }); ``` -------------------------------- ### Get Lifecycle Manager in BootstrapContext Source: https://docs.papermc.io/paper/dev/lifecycle Obtain the LifecycleEventManager instance within a BootstrapContext during server startup. ```java @Override public void bootstrap(BootstrapContext context) { final LifecycleEventManager lifecycleManager = context.getLifecycleManager(); } ```