{"id":3723,"date":"2026-11-10T14:43:40","date_gmt":"2026-11-10T06:43:40","guid":{"rendered":"http:\/\/www.intacthair.com\/blog\/?p=3723"},"modified":"2026-11-10T14:43:40","modified_gmt":"2026-11-10T06:43:40","slug":"how-to-add-custom-commands-on-a-spigot-server-4799-c7a262","status":"publish","type":"post","link":"http:\/\/www.intacthair.com\/blog\/2026\/11\/10\/how-to-add-custom-commands-on-a-spigot-server-4799-c7a262\/","title":{"rendered":"How to add custom commands on a Spigot server?"},"content":{"rendered":"<p>If you\u2019ve ever run a Spigot server, you know that out-of-the-box commands like \/tp, \/gamemode, and \/kill get the job done\u2014but they rarely match the unique vibe you\u2019re building for your community. As a Spigot server provider, I\u2019ve helped dozens of small communities level up their gameplay by adding custom commands that fit their world, not the other way around. Over the last seven years, I\u2019ve tested everything from simple one-line commands to complex, permission-based systems that work without breaking a server\u2019s stability, and today I\u2019m breaking down the steps to do it right\u2014no jargon, no workarounds, just actionable advice. <a href=\"https:\/\/www.shunyecasting.com\/spigot\/\">Spigot<\/a><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.shunyecasting.com\/uploads\/47565\/small\/closed-radial-flow-pump-impellerf1ea4.jpg\"><\/p>\n<p>First, let\u2019s get one thing straight: adding custom commands isn\u2019t just about pasting a bit of code. It\u2019s about balancing fun, utility, and performance. A command that works for a 20-player survival server might crash a 200-player minigame server if it\u2019s not written with Spigot\u2019s API in mind. I\u2019ve seen this happen firsthand: a new server owner once added a \/firework command that fired a rocket every time a player typed it, and within an hour, his server\u2019s TPS dropped from 20 (full speed) to 5 because each rocket triggered 10+ entity spawn events. That\u2019s why the first rule is: know your server\u2019s needs before you write a line of code.<\/p>\n<p>Start with the basics: what do you want your custom command to do? Common use cases I see as a provider include a \/sethome and \/home system for a survival server, a \/vote command that links to your server\u2019s site, or a \/shop command that lets players sell items without a separate plugin. Simple commands like these are easy to build, and they give you a foundation to work with. More complex commands, like a custom quest line or a weather toggle that only works in specific areas, require a bit more work, but the steps to set them up are the same.<\/p>\n<p>Now, let\u2019s walk through the actual process. The first thing you\u2019ll need is a plugin development environment. You don\u2019t have to be a professional coder\u2014most of the code for simple custom commands is basic Java, and there are plenty of resources to help. I recommend using IntelliJ IDEA or Eclipse, both of which have free versions, and you\u2019ll need to add the Spigot API as a dependency. If you\u2019re not comfortable writing code from scratch, there are also plugins like CommandAPI that let you create custom commands with YAML files instead of Java, which is perfect for beginners.<\/p>\n<p>Once you have your environment set up, the next step is to create your plugin\u2019s main class. This is the file that Spigot will load when your plugin starts up, and it\u2019s where you\u2019ll register your commands. For a simple \/hello command that sends a welcome message to the player, the code looks something like this:<\/p>\n<p>package com.yourname.yourplugin;<\/p>\n<p>import org.bukkit.command.Command;<br \/>\nimport org.bukkit.command.CommandExecutor;<br \/>\nimport org.bukkit.command.CommandSender;<br \/>\nimport org.bukkit.entity.Player;<br \/>\nimport org.bukkit.plugin.java.JavaPlugin;<\/p>\n<p>public class YourPlugin extends JavaPlugin implements CommandExecutor {<\/p>\n<pre><code>@Override\npublic void onEnable() {\n    getLogger().info(&quot;YourPlugin has been enabled!&quot;);\n}\n\n@Override\npublic void onDisable() {\n    getLogger().info(&quot;YourPlugin has been disabled!&quot;);\n}\n\n@Override\npublic boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {\n    if (cmd.getName().equalsIgnoreCase(&quot;hello&quot;)) {\n        if (sender instanceof Player) {\n            Player player = (Player) sender;\n            player.sendMessage(&quot;Hello, &quot; + player.getName() + &quot;! Welcome to the server.&quot;);\n            return true;\n        } else {\n            sender.sendMessage(&quot;This command can only be used by a player.&quot;);\n            return true;\n        }\n    }\n    return false;\n}\n<\/code><\/pre>\n<p>}<\/p>\n<p>Wait a second\u2014you might be wondering why we check if the sender is a player. That\u2019s a mistake I see new server owners make all the time: writing a command that only works for players, but not accounting for console commands. If someone runs \/hello from the console, the code will throw an error if you don\u2019t add that check, which can break your plugin. That\u2019s why every custom command needs to handle both player and console senders, depending on what it does.<\/p>\n<p>Next, you\u2019ll need to register the command in your plugin\u2019s plugin.yml file. This is a simple text file that tells Spigot about your commands, permissions, and dependencies. For the \/hello command, the plugin.yml looks like this:<\/p>\n<p>name: YourPlugin<br \/>\nversion: 1.0<br \/>\nmain: com.yourname.yourplugin.YourPlugin<br \/>\napi-version: 1.20<\/p>\n<p>commands:<br \/>\nhello:<br \/>\ndescription: Sends a welcome message to the player<br \/>\nusage: \/<command><br \/>\npermission: yourplugin.hello<\/p>\n<p>Permissions are another key part of adding custom commands that I can\u2019t stress enough. If you let every player run every command, you\u2019ll end up with players abusing commands to grief or break the server. For example, you don\u2019t want a new player to run a \/teleport command that lets them warp to the end\u2019s dragon fight. By adding a permission node (yourplugin.hello in the example above), you can control who can use the command. You can assign permissions to groups\u2014like default for all players, moderator for staff, or admin for owners\u2014using a permissions plugin like LuckPerms, which is the standard for most Spigot servers.<\/p>\n<p>Let\u2019s take that a step further with a more useful command: a \/home and \/sethome system. This is one of the most popular custom commands for survival servers, and it\u2019s a great example of how to add persistence (meaning the data saves when the server restarts). To do this, you\u2019ll need to save each player\u2019s home location to a file, like a YAML configuration file. Here\u2019s a quick breakdown of how to adjust the onCommand method for \/sethome and \/home:<\/p>\n<p>@Override<br \/>\npublic boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {<br \/>\nif (sender instanceof Player) {<br \/>\nPlayer player = (Player) sender;<br \/>\nif (cmd.getName().equalsIgnoreCase(&quot;sethome&quot;)) {<br \/>\n\/\/ Save the player&#8217;s location to the config<br \/>\ngetConfig().set(&quot;homes.&quot; + player.getUniqueId() + &quot;.world&quot;, player.getWorld().getName());<br \/>\ngetConfig().set(&quot;homes.&quot; + player.getUniqueId() + &quot;.x&quot;, player.getLocation().getX());<br \/>\ngetConfig().set(&quot;homes.&quot; + player.getUniqueId() + &quot;.y&quot;, player.getLocation().getY());<br \/>\ngetConfig().set(&quot;homes.&quot; + player.getUniqueId() + &quot;.z&quot;, player.getLocation().getZ());<br \/>\nsaveConfig();<br \/>\nplayer.sendMessage(&quot;Your home has been set!&quot;);<br \/>\nreturn true;<br \/>\n} else if (cmd.getName().equalsIgnoreCase(&quot;home&quot;)) {<br \/>\n\/\/ Check if the player has a home set<br \/>\nif (getConfig().contains(&quot;homes.&quot; + player.getUniqueId())) {<br \/>\ndouble x = getConfig().getDouble(&quot;homes.&quot; + player.getUniqueId() + &quot;.x&quot;);<br \/>\ndouble y = getConfig().getDouble(&quot;homes.&quot; + player.getUniqueId() + &quot;.y&quot;);<br \/>\ndouble z = getConfig().getDouble(&quot;homes.&quot; + player.getUniqueId() + &quot;.z&quot;);<br \/>\nWorld world = Bukkit.getWorld(getConfig().getString(&quot;homes.&quot; + player.getUniqueId() + &quot;.world&quot;));<br \/>\nplayer.teleport(new Location(world, x, y, z));<br \/>\nplayer.sendMessage(&quot;Teleported to your home!&quot;);<br \/>\n} else {<br \/>\nplayer.sendMessage(&quot;You don&#8217;t have a home set! Use \/sethome first.&quot;);<br \/>\n}<br \/>\nreturn true;<br \/>\n}<br \/>\n} else {<br \/>\nsender.sendMessage(&quot;This command can only be used by a player.&quot;);<br \/>\nreturn true;<br \/>\n}<br \/>\nreturn false;<br \/>\n}<\/p>\n<p>This is a simplified version, but it works for most small servers. The key here is that we use the player\u2019s unique ID (player.getUniqueId()) to store their home, so even if a player changes their username, their home data stays intact. I\u2019ve had clients come to me with broken \/home systems because they used usernames instead of unique IDs, and players lost their homes when they changed names\u2014this is a small detail that makes a big difference.<\/p>\n<p>Now, what if you don\u2019t want to write Java code? As a server provider, I know not everyone has time to learn coding, so there are alternatives. The CommandAPI is a great tool that lets you create custom commands by writing JSON or YAML files, and it handles the registration and permission setup for you. For a \/vote command that links to your server\u2019s voting site, you could set it up in the CommandAPI without writing a single line of Java:<\/p>\n<p>command:<br \/>\nname: &quot;vote&quot;<br \/>\ndescription: &quot;Get the link to vote for the server&quot;<br \/>\nusage: &quot;\/vote&quot;<br \/>\nexecutor:<br \/>\ntype: &quot;player&quot;<br \/>\nactions:<br \/>\n&#8211; &quot;sendMessage: &amp;aVote here: https:\/\/yourserver.com\/vote&quot;<\/p>\n<p>It\u2019s not as flexible as writing your own code, but it\u2019s perfect for simple commands, and it\u2019s a quick way to add utility to your server without hiring a developer. I\u2019ve used this for dozens of small community servers I work with, and it\u2019s saved me hours of development time.<\/p>\n<p>Once you\u2019ve written your command, the next step is to test it. This is another area I see server owners skip, and it\u2019s a mistake. Before you add the command to your live server, test it in a local test server. Spigot lets you run a local instance on your computer, so you can spawn in a player and test the command without affecting your community. When testing, check for common issues: does the command work for players? Does it throw errors in the console? Does it cause TPS to drop (which is a sign the code is inefficient)? For the \/home command, test what happens if a player deletes the world file or moves their home. For the \/hello command, test running it from the console to make sure it doesn\u2019t crash.<\/p>\n<p>After testing, it\u2019s time to deploy. You\u2019ll need to package your plugin into a JAR file, which you can do from your development environment (IntelliJ has a built-in tool for this). Once you have the JAR file, upload it to your server\u2019s plugins folder, restart your server, and test the command live. As a provider, I always recommend adding a test group first\u2014let a few trusted staff members test the command for a day before releasing it to all players. This way, you can catch any last-minute bugs that didn\u2019t show up in your local test.<\/p>\n<p>Now, let\u2019s talk about common pitfalls to avoid. The first is overcomplicating commands. I once worked with a server owner who added a \/boss command that spawned a custom dragon with 10 different abilities, and within a week, his server\u2019s TPS was consistently below 10 because the dragon\u2019s AI was using too much processing power. If your command is causing performance issues, players will stop using it, and it\u2019ll hurt your server\u2019s overall stability. Keep commands as simple as possible, and test them with your server\u2019s player count. For a 50-player server, even a slightly inefficient command won\u2019t cause problems, but for a 500-player server, you need code that\u2019s optimized.<\/p>\n<p>Another pitfall is not handling edge cases. For example, what if a player tries to run \/home when they\u2019re in the nether, and their home is in the overworld? The code above will teleport them correctly, but what if the world no longer exists? You\u2019ll want to add a check to make sure the world is still loaded, so the command doesn\u2019t throw a \u201cworld not found\u201d error. Small things like this make your command feel polished and reliable.<\/p>\n<p>Finally, permissions. I\u2019ve seen servers where custom commands were available to everyone, and it led to players abusing commands to spawn items or teleport to other players. Always set permissions for your custom commands, and use a system like LuckPerms to assign them to groups. For example, give default players access to \/home and \/vote, give moderators access to \/kick and \/ban, and give admins access to \/sethome for other players. This way, you can control what each group can do, and prevent abuse.<\/p>\n<p>If you\u2019ve made it this far, you know that adding custom commands to a Spigot server is a mix of coding, testing, and attention to detail. For many server owners, though, it\u2019s more than that\u2014it\u2019s about making your server feel unique. I\u2019ve had clients come to me because they want a \/pet command that lets players tame custom wolves, or a \/discord command that sends a link to their Discord server, and those small commands are what make a server stand out from the hundreds of generic Spigot servers out there.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.shunyecasting.com\/uploads\/47565\/small\/super-duplex-stainless-steel-castingse4c4a.jpg\"><\/p>\n<p>If you\u2019re running a Spigot server and you want to add custom commands that fit your community, or if you need help troubleshooting a command that\u2019s not working right, I\u2019m here to help. As a Spigot server provider, I\u2019ve worked with all kinds of servers\u2014from small survival communities to large minigame networks\u2014and I can help you build commands that are fun, safe, and optimized for your server. Don\u2019t hesitate to reach out to discuss your needs, whether it\u2019s a simple utility command or a complex custom feature for your world.<\/p>\n<p><a href=\"https:\/\/www.shunyecasting.com\/impeller\/fan-impeller\/\">Fan Impeller<\/a> References:<\/p>\n<ol>\n<li>Spigot API Documentation<\/li>\n<li>CommandAPI Official Guide<\/li>\n<li>LuckPerms Permissions Setup<\/li>\n<li>Bukkit Plugin Development Basics<\/li>\n<\/ol>\n<hr>\n<p><a href=\"https:\/\/www.shunyecasting.com\/\">Shandong Shunye Stainless Steel Co., Ltd.<\/a><\/p>\n<p>Address: Shandong Province, Binzhou City, Wudi County, Liubao Town, Zhangdong Road, Duliucun Village<br \/>E-mail: sales@wdshunye.com<br \/>WebSite: <a href=\"https:\/\/www.shunyecasting.com\/\">https:\/\/www.shunyecasting.com\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you\u2019ve ever run a Spigot server, you know that out-of-the-box commands like \/tp, \/gamemode, and &hellip; <a title=\"How to add custom commands on a Spigot server?\" class=\"hm-read-more\" href=\"http:\/\/www.intacthair.com\/blog\/2026\/11\/10\/how-to-add-custom-commands-on-a-spigot-server-4799-c7a262\/\"><span class=\"screen-reader-text\">How to add custom commands on a Spigot server?<\/span>Read more<\/a><\/p>\n","protected":false},"author":970,"featured_media":3723,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3686],"class_list":["post-3723","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-industry","tag-spigot-4960-c85b84"],"_links":{"self":[{"href":"http:\/\/www.intacthair.com\/blog\/wp-json\/wp\/v2\/posts\/3723","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.intacthair.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.intacthair.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.intacthair.com\/blog\/wp-json\/wp\/v2\/users\/970"}],"replies":[{"embeddable":true,"href":"http:\/\/www.intacthair.com\/blog\/wp-json\/wp\/v2\/comments?post=3723"}],"version-history":[{"count":0,"href":"http:\/\/www.intacthair.com\/blog\/wp-json\/wp\/v2\/posts\/3723\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.intacthair.com\/blog\/wp-json\/wp\/v2\/posts\/3723"}],"wp:attachment":[{"href":"http:\/\/www.intacthair.com\/blog\/wp-json\/wp\/v2\/media?parent=3723"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.intacthair.com\/blog\/wp-json\/wp\/v2\/categories?post=3723"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.intacthair.com\/blog\/wp-json\/wp\/v2\/tags?post=3723"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}