Transcripts
1. Intro: What's going on, guys? My name is Trevor and in this series, I'm going to be teaching
you how to make Minecraft plugins. So
a little bit about me. I've been doing
minecraft servers for five years and I've encoding Minecraft plug-ins for three. I'm currently a
lead developer on an NFT server known
as world blocks. Now I know what you're thinking. What even is a
Minecraft plug-in? And I'm going to
start by showing you just some of the things
that they can do. In this series. Minecraft
plugins are gonna be written using the programming
language Java. Now, don't worry, you don't have any programming
experience whatsoever. This is totally
beginner friendly. My mission is to show
you how much you can do with just a little bit
of programming knowledge. You don't have to be a
wizard, do something awesome. And if any of this
sounds awesome to you, and this is definitely
the series for you.
2. JDK Download: Alright guys, so the first
thing we're gonna be doing is installing the Java JDK. So we're gonna go
to Google and type in Java JDK download. Click on the top link, make sure it's the
Oracle website. So I'm going to click Java 17. Alright, so I'm going to click
on the dot EXE right here. Alright, So when
that's done, just go ahead and click on it
and please keep in mind, this process might be
a little bit different if you're on a Mac or something, but mostly it's
gonna be the same. Alright, and that's
all there is to installing the Java JDK.
3. Local Environment: Alright, so now we're
gonna be setting up a Minecraft local environment. And all that means is
we're gonna be running a Minecraft server
on our own computer. So to make things easy, we're gonna be using
a desktop panel for that handles
everything for us. So I want you to
go ahead and look up visual spigot, spigot. And click on the top link, it'll be spigot MC, and
then click Download. All right, when that's
done, just click on it. If you see this
pop-up, don't worry, just click on More
Info and run anyways. Alright, so when
the app is finally installed, go ahead and open it. Here's my leg, a little
different from mine. I gotta theme on mine. Go to Google and
type in paper MC, click on the top link,
go to downloads, and then click onto
this right here. Here's will probably say
something different. Mindsets 40. When that's done downloading, go ahead and drag
it to your desktop. Click on an ad server again. Click on manual and
just drag it in there. Now all I have to
do is press Start. Now once the server
is fully started, you should be able to go over to Minecraft direct connection and type in local
host join server. I'm on the wrong version.
And click Join server. This is gonna be the
server you just booted. There you go. You now have a Minecraft Server. So first things first
you're probably going to want to opt yourself. So go back over to
Visual spigot on the console and type
up space your name. Minus could punish her 69. So now that I'm OPT, I can now type operator commands like put myself in Game Mode creative. So now mobs won't kill me
while I'm testing plugins. Also, if you hate nighttime
or you hate mobs, or you hate whether you
can set some game rules. So I'm gonna do game rule, do mob spawning,
balls, game role, do weather cycle, false, and game role do
daylights like false. Alright, so now
all this is done. I'm going to head over to
Visual spigot and click stop. Because now we're ready
to start making plug-ins.
4. Intellij Download: So now we're gonna be installing the IDE you're gonna
be programming in. This idea is called
intelligent way. We're gonna go ahead and type in intelligent download link on the top one makes sure
it says JetBrains. Now you'll see two
different versions, ultimate and community. We're gonna go out and do the community edition
because it's free. Make sure you select your correct operating system
and then click Download. Alright, so now I'm just
going to click on it. I'm going to create a
desktop shortcut just because I like
desktop shortcuts. Next, next. Alright, Now it's done.
I'm going to click finish. Alright, so now that
all that's done, you're gonna go
ahead and click on the intelligent
application and you should get a pop-up that
looks something like this. So we're going to create
our very first project. So go ahead and click
on New Project. Now because this plugin is gonna end up doing
a lot of things, I'm gonna go ahead and
call it hybrid plug-in. You can call it
whatever you want. Now, make sure the JDK is 18, which is the JDK that
you downloaded until j will probably automatically do this for you as it did for me. And click Create. And now we're ready to
start building something.
5. Hello World: Alright, so the first
thing we're gonna do is create what is considered the base package. You're going to click on SRC
right here, right-click it. Go to new package type mi dot, whatever your name is. My name is Trevor dot. The name of your plug-in. Mine is hybrid plug-in. And press Enter. Alright, so now we're
going to right-click that, go to New, and then
click on Java class. And we're going to call
this Main and press Enter. I want to increase my font size, so I'm going to click on
File Settings editor. And then I'm going
to click on Font. And I'm gonna increase mine to 25 so you guys can
see it more clearly. Apply. And Okay. Now before
we go any further, I'm gonna kinda try to explain what you're
looking at here. If you go to the top,
you'll notice that it says Package me dot Trevor
dot hybrid plug-in, which is the package
that we just created. And if you go below that, you'll see it says
public, class main. And then there's
two brackets here. So in Java, every
single file that you create that has code in it is always going to be
inside of a class. It's always gonna
be public class, whatever your class name is, all of the code in that file is going to live inside
these two brackets. Alright, so now you're
going to create your very first program, which is the infamous
program HelloWorld. Going to press Enter
and make sure you're typing inside of
these two brackets. And then type P, S, VM, Enter. Now, don't get too confused or breakdown of
what you're looking at here. You'll see that it
says public, static, void, main, string, args. And then there's
two more brackets. Now I don't really
want you to focus too much on the meaning of this. All you need to
understand is that every Java application has to run inside of this
specific statement. Public, static, void,
main, string, args. Every job application will
start up inside of this. So what that means is if
I had code way down here, but there was no
code inside of this, inside of public
static, void main, or I'm going to refer to
it as the main method, then nothing would happen when I ran this job application. Alright, so now we're ready
to write our helloworld code. I want you to type S, O, U, T, and Enter. And then you're gonna put
quotes just like this. So you should have something
it looks exactly like that. And then makes
sure at the end of the line, there's a semicolon. If there's no semicolon, it will not run at the end
of most lines in Java. You're gonna be
putting a semicolon. So just get used to it. It's something
you're going to have to get comfortable doing. So we're gonna put
our semicolon again. And inside here we're going
to write hello world. Now this is done.
We're going to click the green button to the left. Click Run main. And then as you can see here, the output is hello world.
6. Access Paper API: Okay, so now we're going to
be accessing the paper API. And all API stands for application
programming interface. This API is going to
allow us to interact with Minecraft and put plugins
onto our Minecraft Server. The first thing we're
gonna do is add Maven framework support
to our project. And if you don't know
what that means, don't worry, just
follow my steps. So go to the top where it says your plugin name,
right-click it. Go to the bottom and click
Add framework support. Check Maven, and press. Ok. Alright, so I moved
my face so you could see a little bit more clearly about everything
that's happening. What you're going to do is go to the top and you're going to see reload all maven projects. Click that. That's going to
fix your projects. Go to the top right
and click Minus. And we can even exit
out of this for now. I don't really want you to
worry about what that is. Head over to Google
and type in paper MC. Click on the top link. On the very top you'll
see documentation. Click on Maven and Gradle. Now I only want you to focus on the top two parts,
repository and dependency. So I want you to copy this. We're gonna go back
over to Intel J and go to where it
says palm dot xml. Click on that at
the bottom here, I want you to type repositories, press Enter, and then
paste in what you copied. Now we're gonna go back and copy this dependency back to Intel J. Go down and type independencies,
press Enter, paste. And now the top right, you're going to refresh Maven. Alright, now that that's done, we're going to exit
out of the palm. And we now actually have
access to the paper API.
7. Minecraft Main Class: Alright, so the first step of every plugin is creating
your main class. So we already have a main class. However, when it comes
to Minecraft plugins, you don't actually use
the main method in Java. We're going to go
ahead and delete this. And we're gonna go to the top. I want you to type extends
Java plugin, press Enter. And you'll see that at the top, it imported a new package. Anytime you're
importing something from a different
file or package, you're going to see this
import statement at the top. Now inside the main
class brackets, we're going to type public
void on Enable parentheses. And to the right of
that, we're going to put brackets and then open, and then on top of this, we're going to type at override. I know it's possible
none of this makes sense to you. In that case. Don't freak out. This is basically the main
method of Minecraft plugins. So everything that
your plug-in does needs to run inside of
the on Enable method. Now I want you to do the
same thing we did earlier. And we're gonna go
ahead and print a statement to the
console and Minecraft. Whenever this plugin
gets enabled, we're gonna do S
OUT, enter quotes. And instead of hello world,
we're going to say this is my new amazing Minecraft plugin.
8. Comments: So now I'm gonna be teaching
you about comments. A comment is
something developers put inside of their code to explain it to another
developer or themselves later, the comment has no effect
on the code whatsoever. So we're gonna write a very basic comment above
our logger statement, just explaining what it's doing. So a comment is two slashes and then you
can write your comment. So I'm gonna say this is my amazing comment describing my amazing logger statement. Now you can also write another type of
comment which you'll generally see above,
classes or methods. So above this on enabled method, I'm going to type slash asterisk two Asterix and I'm
going to press Enter, and then I can write
a comment here. This is the on Enable method for my super
amazing Minecraft plug-in. And then you can
even throw a comment above the main class. This is my main class. Now that you know how
to write a comment, I'm going to quickly describe to you how you should
be using them. Avoid what I just did here. What I did here was put comments everywhere and they're
useless comments. You don't want your comment
to distract from your code. And in fact, your comment
should really only be there if the code itself isn't
describing what's happening. So if you go to the
top, you'll see that I put this is my main class, but everyone knows that
this is your main class. So there's no point in
having this comment. If you go down here,
you'll see this is the on Enable method for my super
amazing Minecraft plug-in. Again, everybody knows what an ensemble method is if they're writing
Minecraft plugins. So we're gonna delete.
9. Plugin Yaml: Now we have to create
something known as the plug-in dot YAML. Know Minecraft plugin is
going to run without this, you're going to head
over to resources. And the top-left,
right-click it. Go New File and type
plug-in dot YAML. So in the plug-in dot YAML, we're gonna go ahead
and put the name of the plugin at the top. So we're going to type name, colon space, the
name of the plugin. So we're gonna do
hybrid plug-in. That's my plug-in name. Then I'm gonna do author, which is whatever your name is, I'm going to say
Trevor. Version colon. I'm gonna do 1, since it's
the very first version. And then I'm gonna
put main colon space. And then all this does is it follows the package structure all the way to your main class. In our case, we have me, That's Trevor dot hybrid
plug-in, dot main. So we're gonna do me Trevor
dot hybrid plug-in main. Then we can add a
plugin description. I'm going to say description. This plug-in does random stuff. And then we can even
put an API version. Since we're on 1.19,
I'm going to say 1.19. And then once you
have all of this, you're now done with the
plug-in and dot YAML file.
10. Compiling Plugin: Alright, so now all those
left to do to finish your first plug-in is actually put your
plug-in on your server. In order to do that, we need to compile the jar to your server plugin
directory path. Now, that sounds confusing, just follow my steps
and it'll make sense. Alright, so we're
gonna go to the top left and click File, and then click on
project structure. Then what you're gonna do
is on the left side menu, you're going to
click on artifacts. Then you should see this. Now we're going to click on
the Plus button right here. Jar, don't click on it. And then to the right go, click on modules
with dependencies. And then press, Okay. So this right here is the output directory of the
jar you're gonna be building. And we want to change this to build directly
onto our server. So we're gonna go
click on visual spigot and make sure you've selected
your correct server. I want you to type
dot pass, Enter. This is going to copy the path of your server to
your clipboard. Go here, paste that in.
11. Discord Command: Alright, so now for the moment you've all been waiting for, we're going to create
our very first command, and it's gonna be a
slash discord command. This is a very
common command you see on most Minecraft servers. So it actually is useful and
it's pretty simple to make. So we're going to head
over to the left, click on our base package. We're going to right-click
it new Java class, and we're going to call
it discord command. Now what you want to do
is type implements man, executer and press Enter. Now you're gonna see
it has a red line under it. Hover over that. And then click on
Implement Methods. Press. Okay, now I've made my
text a little bit smaller, and I'm gonna go ahead and
shorten some of these names just so you can see everything
a little bit better. Now if we take a step back and we look at what's
happening here, you'll see that this is its
own method called on command, and it has its own
pair of brackets, just like what
you've seen before. So that means all of
the code related to this command is going to run
inside of these brackets. Now you'll see right here, this is the sender. This is the person
executing the command. That could be a console
or it could be a player. Now, we're gonna do
something interesting. We're gonna go ahead and send a message to this
player or console. We're going to type sender
dot send message quotes, which is similar to what
you've seen before. And then we're gonna do,
this is an amazing message. Now there's two
things we have to do to make this command alive. We have to register it
and the main class, and we have to register it
and the plug-in dot YAML. So first we're gonna
go to the main class. I'm going to remove this. And I'm going to type
git commands quotes. And this is what you want
your command name to be. I want it to be discord. I'm gonna do dot set, executer. Then you're going
to type new space, whatever your command class
name is, Discord command. And you're going to see a
little highlight right here. Don't worry about it. If
it bothers you enough, you can click Replace with
objects that require non null. It's not gonna do anything if
you do that or don't do it. Now that we've registered
it in our main class, we're gonna go ahead and do
go to our plugin dot YML, go down and we're going
to type commands, colon, press Enter, and then type the command
that you want it to be. So in this case it's Discord. Then we can write a
description for the command. Let's say access the
servers discord. Alright, now we're gonna
do is click Build, build artifacts, and build. Now I have Minecraft and
the server open here. So I'm going to join the server. I'm gonna show you that it
works for console and players. I'm going to type slash discord. You're going to see this
is an amazing message. Then we're gonna
go to the console and I'm going to type discord. You're gonna see this
is an amazing message. Now we need to do
is actually send them a real discord link. I'm gonna go back
to my intelligence and back to the command class. This discord link can be any
discord link that you have. I'm just going to do one that I have for the server
that I work on. So I'm going to delete
this and I'm going to type HTTPS colon and then the
discord link roadblocks. I want this to be obvious, so I'm going to
say discord link. And then I'm going
to press Build, Build Artifacts, and build. So rather than restarting the server every single time
I make one little change. I want it to, I'm gonna go
ahead and type slash reload. Now it's going to say, are
you sure you want to reload? And I'm going to say
reload, confirm. Now it's trying to warn you that reloads or bad
and they are if you have a bunch of
players on your server or even too many plugins. But because we have one
plug-in that's really tiny, It's completely justified
to type slash reload. Now that we type such reload, I'm going to type
slash discord again and you'll see that it updated. The problem here is that
it looks kind of ugly. So now we have to make it
look pretty with colors.
12. Discord Command With Color: Alright, so now we need
to give this color, and there's multiple
ways to do that. For now, we're going to stick
to basic bucket colors. And there's two ways we
can actually do that. But let's say I want
this to be green. We're gonna go to the
very beginning of the statement and
type chat color, dark green, space plus space. Then this is gonna be read. So you're going to hover over
it and click Import Class. And then click chat color and where it says
org dot bucket. And that's at the
top and imported. Just like I said earlier,
which is what happens when you use something that's
from a different class. Now, we're going to
build this. Go back to the Minecraft Server, reload, confirm
and slash discord. Now this still doesn't
look very good. Let's say you want this
discord link to be white, but you actually want
this to be pink. So an easier way
to do this is to go ahead and delete this will
just on a different line. Just to start from scratch, we're going to center
that SYN message. We're going to chat color, dot translate,
alternate color codes. And you can press Tab to
complete that entire line. And you're going to click the
apostrophe symbol and then do shift seven comma. And then this is where we're
going to put the text. So I'm actually going
to press Enter. So that way we're gonna
do it on a new line. We're gonna go to Google and
type in bucket color codes. You're going to be referencing this a lot until you
haven't memorized. But these are all the
bucket color codes and you'll see all
these symbols. 0123456. So keep reading, keep
this page pulled up. So let's say we want to do white for when do white and
then we want to do pink. So white is F and pink is D. It's going to go back
over to intelligent way. We're gonna do. And F, which is the symbol
that we specified here. And then we're gonna do and D, I'm going to grab this
link and paste it here. I'm going to delete
the message at the top. I'm going to build it. Go back to Minecraft, reload and then
type slash discord. And you'll see that it
looks a lot prettier now. Now for one last thing that
I'm gonna do is I'm gonna do, I'm gonna put a space at
the top and the bottom. And you can just
do that by sending a blank message
with nothing in it. Top, bottom, reload. And now we have a nice-looking, simple, clean discord command.
13. Project: Alright, so the project
for this course is to create your own
slash help command. And you're going to want it
to look something like this. As you can see, I
typed slash help. It says server help
with the top displays, both commands that were
created and what they do. And there's three
different colors. You have yellow, dark
gray, light gray. As an optional challenge, I want you to try to make the command we're only
players can execute it. You'll notice right
now if you go to Visual spigot and you type help, the console can also execute it. This is actually not something I taught you and if you
can't figure it out, There's no shame in that at all. I have not gone over this. This is an optional challenge. If you don't know where to
start on the challenge, but you want to take it on. My only hint for you is
Google is your friend.
14. Conclusion: Alright, so that wraps
up everything I have to teach you in this first
boot camp course. And while it may
not seem like you did anything super amazing, because we just did
two little commands. If you made it this far, that's definitely
something to be proud of. You have to completely
functional commands on a running Minecraft Server, and especially if you've
never touched Java before. So anyways, if you
guys really liked this course and you
made it this far, I hope to see you in my
next boot camp course.