Hello and welcome back to cardo gao tom this is part two of the how to make a minecraft plugin series so in this video we’re going to be looking at how you can make your own minecraft commands so if you don’t know what a command is Then basically things you can run on um using the chat window and stuff like slash kill and that will actually kill you and there’s many other commands you can actually run like flash heal and that will heal you to full health and stuff like that and in this video we’re going to be Learning how you can make your own commands which people can execute and you can make the commands do anything you want and if you haven’t watched the part one yet the link is in the description make sure to watch that because you need to know how you can make a Simple plug-in before we can move on to commands so make sure to watch that link’s in the description anyways let’s get started So this is the simple plugin that we made in the last video all it does is that when the plugin is enabled it will log a message and when the plugin is disabled it will log a different message so to make commands all we have to do is first of all Let’s make a package to put all the commands in so right click on the main package and click on new and click on package new package and and basically let’s call this commands and in this package is where we will put all the command files so now we can make Our first command so all the first command is going to do is just send a message to the players will land the command so to do that first of all let’s make our command file so click on new and click on java class and let’s call the class hello command So basically all the command is going to do and so if we type in slash hello um it’s going to send hello and then the player’s name so first of all do implements command executor and this will allow us to get the command and stuff so here at override None here we can make our method that calls when the when the command is slammed so the public boolean on command and this will be learned when the command is executed so inside here we can get some basic data about the command so first of all we can get the Center of the command basically who sent the command next we can get the actual command itself then you get the label of the command and then you can get the arguments of the command so right now all of these are not important and for this video all you will really Need is just the sender variable so we need to actually make the command send the message to the planner sentence so you can see that we have this sender variable here and if we look here there’s actually a method in the central variable called not send message and we can use it to Send a message to the plans or sent it so we can do sender dot send message and do hello plus and then here we want the sender’s name so you can actually use the sunder.getname method and what this will do is just return the string of the player’s Username so yeah so this is just how you can make a simple command and then here we have to do it return to and what this will do is just make sure that it tells the server that the the command has run successfully and if we do it false i’m pretty sure it Will say the command wasn’t found so um we don’t want that we want the server to find the command so we’ll just do it return to so next we actually want the server to actually run this code when the command is gotten so we actually need to modify this um On enable function here so what we need to do is actually make sure that this hello command gets called when the children detect this command so get command and then here new here knew the name of the command so other case hello and then not set executed and what this will do is Just tap the executa method of the command so you can do new hello command and um we can the hello command will get called when the the command gets executed so that’s good so the last thing we need to do is actually like register the command so To do that um we can actually go into the plugin.yml file and here we can add a command entry and in this command essentially we can put a command name so for our case hello then in here we can type in the description of the command says a message and then The new segment command so how we use it and for other kids just squash command so command will automatically get replaced with hello and alliances and in our case we don’t have any alliances so just leave it blank and basically what an alliance is is basically um there’s gonna be different names for The command like hi so if you type in slash hi it will be the same thing as flash flow so now that all of this is done we can actually go ahead and test our command so click on build and click on build all the facts and click on build and this will Actually build our plugin to a single um file and in this we have our plugin just file which we can now test so let’s open up our folder and here and just drag in our newfoundlessplugin.com and um we have to replace it and now we have a new file so Go back to main folder and open up a terminal And then you can see leader then we can run a start.shapefile and this will actually cut a server and once it’s done i will show you the command And our server is downloading and um as you can see it is actually the first plugin which is enabled and then we can actually now test our server and we’re finally in and um we can try out the command so do slash and then here you can actually see that auto complete Slash hello and in that click on enter and then there you go we get our message which we said in the code and they actually got it twice because i read it twice and as you can see here you can actually um send the message which we set in the code So yeah so next i’m going to teach you about command arguments command arguments are basically text after a command which is passed back to the command um program which and the program will be able to use that text to do something so we’re gonna make an Add command and what it will do is just add two numbers and we’re gonna be able to specify which numbers to add so you type it like squash add one and one that will say the answer is two or something like that so first of all you can actually make Our files click on new click on java class and let’s call it add command and then here i’m just gonna copy i’m gonna old command because i’m not gonna type all of that again and command and then so you’ll actually see that we have an orange variable and Audience is just short for arguments so for example we type in add one one and if when this is typed all given today will be like this like one like that and um we can actually use this to advantage and we can use this array to um add these two numbers so Let’s get um the two integers that we need to add so let’s make a new it’s called integer on one equals zero and this will actually be a string and we need it to be an integer so we need to convert it to an integer To use to do that we can use integer dot value of and then here we can put our alex you can just copy that and then you can paste it and you can change everything so it’s on the second instagram and the reason we’re starting from zero is actually Because computers count from zero and not one so now we can um add these two numbers so make another variable and this is gonna be int one plus into two and now now we can actually display this to um the player who sent it you can do sender dot send message The answer is and then we can do added and this will get send a message to the player so we can also have to do the term true and then we can go to here and we can add this command here so it executes and then i’m going to plug in that yml And then just to it and here you can do on num1 two and so people can see um the numbers that will be added and um we’re just gonna leave the elias’s blank so now let’s actually go ahead and test this out so i’m gonna click on build build artifacts Build it then it’s done so i’m gonna open up this folder and drag it in and then yeah so now i’m going to start the server and um i’ll show you the plug-in when it’s done starting okay so it’s done so i’m going to try to lock in the server reconnect And it is done so let me just let’s try to command and and then see if we can add two numbers and there we go we have the answer is two and we can do this to any integer 10 10 any number and yeah so that’s our ad command with command arguments So there’s actually a lot of possibility with this command system and you can make any command you want and i’m actually going to make like 12 videos which um explain how you can make like specific commands like slash vanish which will actually hide the player And a lot more stuff like that so stay tuned for those videos and uh if you want me to make any command you have idea for um please tell me in the comments and i’ll make a video on how to make that command and so yeah this is the end of this video If you guys liked it make sure to leave a like and subscribe to the channel and uh in the next video i’m gonna be showing you guys how you can use events events are basically um called whenever a player does something like there’s a player drawing event There’s a play on this connective end there’s like a plan block blank event and there’s like a lot of events and you can like listen to those events and do something when the event is called so you’ll be able to like welcome plans you’ll be able to like Change the item drops of the block and stuff so yeah so stay tuned for that video and make sure to join the discord center if you have any questions like you can ask people there and if you want to ask me anything you can always email me Or ask in the comments and i’ll see you in the next video and goodbye You Video Information
This video, titled ‘Making a 1.17+ Minecraft Plugin with IntelliJ (Part 2 – Commands) | Spigot/Paper’, was uploaded by Coder Gautam on 2021-03-15 03:24:10. It has garnered 2690 views and 85 likes. The duration of the video is 00:15:11 or 911 seconds.
Hello, and welcome to part 2 of our How to Make a Minecraft Plugin Series! Today I’m gonna show you how you can make custom Minecraft commands! We will be using IntelliJ IDEA to edit our code. This tutorial should work on Spigot, Paper, and even CraftBukkit servers! Commands are basically text you can type in the chatbox and it usually does something. Commands are usually followed by a forward-slash(/). Some commands are /kill, /heal, /tp and much more. In this video, you will learn how to make your own commands using java! We will also learn about command arguments and how you can use them to get input from the player about the command! Thanks for watching, and stay tuned for part 3 in which we will learn about Minecraft Events and Listeners.
PART 3 IS OUT 😀 https://youtu.be/-9JzZmX5Qss WATCH PART ONE: https://youtu.be/WCJuP1klCU8
If you have any questions or problems, pls comment💬 below or contact me on my discord server(http://bit.ly/CoderGautamDiscordServer)
Be part of a Growing Coding & Tech Community http://www.bit.ly/Sub2CoderGautam — Music🎵: Vexento – Oh Look, Aliens! https://youtu.be/j2zMJ-Q650w
Vexento – Wild https://youtu.be/PLrVdrW4DIs
Vexento – Cloud 9 https://youtu.be/ILe2yxO-TPI
INTERCOM – The Upside Down https://youtu.be/8A8ACux8bRE — Chapters:
0:00- Intro 1:17- Making commands package 1:56- Setting up HelloCommand 3:30- Coding HelloCommand 4:36- Setting command executor in the Main class 5:35- Registering command in plugin.yml 6:34- Building jar and starting server to test HelloCommand 7:48- Testing HelloCommand 8:32- Command Arguments intro 9:05- Making AddCommand 11:31- Setting executor and registering AddCommand 12:08- just building and getting things ready to test 12:44- Testing AddCommand 13:16- Talking about short command vids(coming soon) 13:54- Outro — Want more Coder Gautam? Check these links! Discord: https://bit.ly/CoderGautamDiscordServer Website: http://bit.ly/CoderGautamSite
If you guys enjoyed the video, make sure to like👍 and subscribe🔴 to the Coder Gautam channel. ▶️
Also, comment💬 down below what my next video should be. Make sure it’s related to tech💻 or coding👨💻.