#custom api questions
1 messages Ā· Page 1 of 1 (latest)
okay so
about question 1:
do you want to access another plugin's API, or do you want your own plugin to provide an API?
i mean this api:
https://minecraft-heads.com/scripts/api.php?cat=
okay, so:
to use the Heads plugin API, you first of all have to add that plugin as dependency
are you using maven?
idk if im using maven and also it's a webpage, not a plugin (i think?)
how do i check if im using gradle or maven
do you have a pom.xml file in your project?
how do i do that
you do not HAVE to but it'll help you in the long term
also what's maven
I wrote a blog post about it
where
oh sorry i thought you might have meant like a spigot forum post, i do not click links that i do not know or trust
you'll be annoyed by maven in the first place, but once you understand what it does, you'll love maven
like, you probably added spigot.jar to your plugin manually
you do not need to do stuff like that anymore with maven
i think i used the buildtools thing for that
yeah to build it, but you had to choose the file in IntelliJ
huh
pls read it first, and once you did everything mentioned in the link, ping me again and I'll explain you how to use HeadDB in your plugin š
i'm sorry but i won't
if I don't reply feel free to DM me
well
if you don't want to use maven, I won't help, sorry
i don't trust random links and no offense but people aswell
i do want to use maven, i just don't want to use your link
no problem but then you'll have to ask other people for help
ok
maven is the number one build tool / dependency manager for java
EVERYONE either uses maven or gradle
if you don't use neither, you'll have a bad time in the future š
ok bai i'll ask other people now
I don't need you to like me but I don't think that I was unfriendly to you or sth
I actually just wanted to help you
but okay
this is an example
Here we go again
and you add C:\Users\iDerpy\Spigot\spigot.jar to your project
now IntelliJ will only work when everyone has the same windows username
maven gets rid of this thing
i wasn't talking about maven, i was talking about how you worded that
but it's okay if you don't understand it yet, I just think that it's quite rude to just say that you don't like me while I'm just trying to explain to you why maven/gradle is a good thing
here it is again
I didn't mean to be rude, I just said that you will profit from using maven or gradle
damn you dont seem very greatful for help
"but it's ok if you don't understand it yet"
bro
i am, i just don't like him insulting me
you are asking for help
of course we know more than you
otherwise you wouldn't ask us for help
and again
Hehe i like your cat š„¶
and that's totally normal bro
maven is a good tool, i started java with it and i find it quite cool especially as i dont have to worry about injecting other jars in magical ways
and again
do you expect us to tell you that you already know everything?
if so why are you asking?
you seem to really like twisting my words here
i never said that i wanted you to say that i know everything
youve uh said "and again" like 40 times
I'm sorry if I offended you, I'm sure other people will help you instead since you don't wanna take my advice, no problem
have a nice day
i just said that how you're wording theses sentences is very annoying and disrespectful
here it is again
him disrespecting me, making him look like the victim, etc etc
I really do not think that I was disrespectful in any way, but okay
and the ", but ok" does not add a lot, it's just annoying
alright
they literally said "sorry if i offended, others can help as you dont want to listen to me"
I'm out, have a nice day
i literally said that i want to use maven...
then google it or smth
you said that you do NOT want to use maven
oh wait you dont trust like any link
no, i said that i do not trust your random link
they can install stuff or see your information
bro it's just a normal wordpress website
under your permission
you have to accept those
i do not know it and therefore i do not trust it
the link won't kill you
there it is again
links directly dont do anything
making fun of me
^^^
noone is making fun of you....
thats a fact not making fun
yeah anyway, as said, I'm out, I don't have time for this childish discussions^^
mfnalex this is the second time you've said that
I just wanted to help
btw here is when i said that i do want to use maven, so quit twisting my words
oh sorry I misread it
these emoji reactions aren't doing anything except annoy me
I thought you said that you don't want to use maven
here's the blog post again, but now translated by google from english to english
sooo
you can now be sure that it doesn't give you any viruses etv
its a wordpress site
i do not know what a wordpress is
used mostly for blogs, website builder
by now I'm pretty sure you're just trolling
did you ever visit any porn website?
no wtf
did you ever visit ANY website?
websites arent harmful themselves if you do nothing
my point is: visiting a website won't immediately get you a virus^^
dont accept them trying to download, quite simple
i don't know if that's true or not so i'mma put it to a maybe
yeah, just don't download stuff. visiting normal websites is no problem
if it auto dowloads, your browser will most likely either block it or you can simply delete it as files dont run themselves
but I see you're being too paranoid for us to help you at all
you haven't even tried to help me in like 20 mins
we were just arguing about websites and what you're doing
I sent you a tutorial that explains on what maven is and how it benefits you and you can use it
from my eyes, it's a website that i do not know of and therefore should not click on it
oh my
okay then simply google it yourself
i'd rather just ask other people for help
okay
clicking links does not blow everything up but if you google it youll still find unknown ⨠scary sites āØ
i googled it and i have no clue what's going on here
i need someone to actually explain it to me
their tutorial does this
I'll copy paste the text from the website then...
why
How to create your first Minecraft plugin using the Spigot API and Maven
Posted on August 8, 2021 by mfnalex
Hi! Chances are high that, when you are reading this, you never created a plugin for the Bukkit/Spigot-API yet, or that you did so without having used Maven. So, letās go right aheadWhat is the Spigot-API?
The Spigot API is the interface between your plugin and the Minecraft server. It provides many useful features for you to interact with the game.What is Maven?
Maven is the most widely used build and dependency management tool for Java. We will use it to include the required dependencies (Spigot-API) and handle building your .jar file.Requirements
You will need the following things to be able to create your first plugin:At least basic knowledge in Java
Having Java and Minecraft installed
A decent IDE that can interact with Maven. I highly recommend IntelliJ IDEA Community Edition.
I will be using IntelliJ IDEA as IDE in this tutorial, because itās free, easier to use than for example Eclipse, and it offers the best Maven support. I highly suggest that you do the same!Letās get started!
Creating your first project
First of all, we create a new empty Maven project. When you opened IntelliJ for the first time now, you can click on New Project in the Welcome Screen. Otherwise click on File -> New -> Project ā¦Now select Maven and click Next. Give your plugin a descriptive name, such as HelloWorldPlugin. If you use another name, please also replace HelloWorldPlugin with the name you chose in all further steps.
IntelliJ will now automatically open your pom.xml file. It is used to tell Maven what dependencies your plugin needs and how it should be compiled. Just copy/paste this example pom.xml:
because that way you do not have to click my "suspicous" link
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- The GroupID is something like your personal "identifier" for maven. If you own a domain, you can just -->
<!-- use it in the backwards way, e.g. if you own "example.com", use "com.example". -->
<!-- You can also just use "me.yourusername" (obviously you have to replace "yourusername" with your username) -->
<groupId>me.yourusername</groupId>
<!-- The name of your plugin. Should only contain normal letters, numbers, and hyphens (-). -->
<artifactId>HelloWorldPlugin</artifactId>
<!-- The version. You should change this on every new release. -->
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- The Java version used to compile the plugin. I suggest to use 1.8 because many servers are still using Java 8. -->
< java.version > 1.8 </ java.version >
</properties>
<!-- In the following section you can define dependencies for your plugin. -->
<!-- Right now, we only need the Spigot API -->
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<!-- Here we tell maven where it should look for the defined dependencies. -->
<!-- Right now, we only need the Spigot repository because we don't have other dependencies -->
<repositories>
<repository>
<id>spigot-snapshots</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<build>
<resources>
<!-- This tells Maven that it should "filter" all files in the resource directory. More on that later. -->
< resource >
<directory>src/main/resources</directory>
<filtering>true</filtering>
</ resource >
</resources>
</build>
</project>
Please replace the <groupId> part in the highlighted line. I added some comments so you know what you can use as Group ID. For example, if you own the domain example.com, you can use com.example for your Group ID. If you do not own any domain, just use me.<yourusername>. Please note that the GroupID may not contain any special symbols, so if your username consists of Chinese symbols or something, just invent a new username for this purpose š
After you have copy/pasted the pom.xml, you will need to tell IntelliJ to read this file again, so that it downloads and detects the Spigot-API. Just click on Maven in the top right corner, and then hit the Reload All Maven Projects button. If this is your first time, it will take some time because it has to download the Spigot-API first. You can see the progress in the status bar at the bottom.
i don't know if it's suspicous, i just don't want to click on it because i do not know it
Creating your plugin.yml file
Now weāre going to add our plugin.yml file. This file is needed by Bukkit/Spigot to actually load your plugin when the server starts.Create a new file inside your src/main/resources directory, called plugin.yml. It should look like this:
Again, just copy/paste the following code into your plugin.yml file:
name: HelloWorldPlugin # The name of your plugin
author: "mfnalex" # Your username.
main: me.mfnalex.helloworldplugin.HelloWorldPlugin # Replace "me.mfnalex" with the Group ID you chose, and adjust "helloworldplugin.HelloWorldPlugin" if you chose another plugin name.
version: ${project.version} # Maven will automatically replace this with the version number defined in your pom.xml
api-version: "1.13" # Optional, but you should add this when your plugin should run on ANY versions above 1.13
thats the end of it like thats how it works
The most important part in your plugin.yml is the main part. It tells Spigot where the Main class of your plugin is located. The most commonly used convention for choosing the name of your Main class is this:
<yourGroupId>.<yourPluginNameInLowerCase>.<YourPluginName>
For example, I was using me.mfnalex as as Group ID and HelloWorldPlugin as plugin name, so my Main class will be called me.mfnalex.helloworldplugin.HelloWorldPlugin.
Creating your pluginās Main class
The Main class is the entry point to your plugin. Spigot will use it to create the instance of your plugin so that it can interact with the game.Important: You MUST use exactly the same name for this class as you used in your plugin.ymlās main section!
On the left side of IntelliJ, right-click the /src/main/java folder and click on New -> Java class:
A menu opens. Give your main class the same name as you defined in your plugin.ymlās main section ā in my case, itās me.mfnalex.helloworldplugin.HelloWorldPlugin:
The actual name of your class is HelloWorldPlugin, but itās located in the me.mfnalex.helloworldplugin package. If you didnāt do something wrong, it should look like this:
From now on, Iām going to assume that you have at least basic Java knowledge.
As you know, every class in Java extends the basic Object class. Bukkit/Spigot however requires your plugin to extend the JavaPlugin class, so we will add extends JavaPlugin behind your class name in itās definition:
As you see, JavaPlugin is highlighted in red, because IntelliJ doesnāt know what JavaPlugin is. So, we have to import the class. Just hover with your mouse over the JavaPlugin part until the following menu appears:
Click on Import class. IntelliJ automatically added import org.bukkit.plugin.java.JavaPlugin; to your class file.
Important: If for some reason the āImport classā button did not appear, you probably didnāt have IntelliJ reload your pom.xml after copy/pasting it. If you are sure that you properly did so, and it still doesnāt work, click on File -> Invalidate Cachesā¦, tick the first and second checkbox, and then click on Invalidate and Restart.
Adding functionality
Congratulations, you just created your first working Bukkit/Spigot plugin! Thereās one downside though: it doesnāt do anything yet. Letās just add a nice message to our plugin that getās printed when the plugin gets enabled.As said, our pluginās Main class extends JavaPlugin. The JavaPlugin class already provides a method called onEnable(). We can simply override this method by adding the following stuff inside our class:
@Override
public void onEnable() {
getLogger().info("Yo bro, my awesome plugin is indeed working!");
}
Important: The @Override part is optional. It tells your IDE that you are overriding the onEnable() function thatās already present in JavaPlugin, but itās not needed for your plugin to actually work. If you decide to add it, you have to import the java.lang.Override annotation just like you did with the JavaPlugin part earlier.
It should look something like this:
Compiling and testing your plugin
Letās try to see if our awesome plugin works. As weāre using Maven to handle the building process, please DO NOT use IntelliJās build feature. Instead, we click on Maven at the top right corner, and then choose Lifecycle -> package. (You have to double-click on package)āPackageā means that Maven will compile our pluginās class files, and store them inside a .jar file, while also adding the plugin.yml.
After you did that, your .jar file will be located in your projectās directory inside the target/ folder, so for example C:\Users\mfnalex\IdeaProjects\HelloWorldPlugin\target. You can simply copy it into your serverās plugins/ folder, restart it and you will see our awesome message in the console once the plugin loads.
Adding actual useful functionality
Adding actual features will be covered in my next post, which will be linked here when Iām done writing it. Thanks for reading š
take it or leave it
TL;DR: Maven allows you to get rid of "hardcoded" dependencies and lets you easily use APIs of other plugins
it also helps you in building your .jar file
mvn clean install is all i do to remake and build the jar
in case that you trust wikipedia: https://en.wikipedia.org/wiki/Apache_Maven
Maven is a build automation tool used primarily for Java projects. Maven can also be used to build and manage projects written in C#, Ruby, Scala, and other languages. The Maven project is hosted by the Apache Software Foundation, where it was formerly part of the Jakarta Project.
Maven addresses two aspects of building software: how software is...
what's a network script
scripts that use your network
huh
Dude
i am website nub
i don't know it, i don't trust it
you dont know half the websites you visit
I know that I'm biased because it's my website, but... dude, how are you using the internet if you do not click on any links?
^
how many websites do you think i visit
are you trolling?
no
i just don't trust random links and websites
anyways i put the thingie in the pom.xml thing
it has like 5 errors
what's line 15?
why do you have spaces between "<" and "java"?
i just copied it from your message
hm maybe discord messed up the formatting
you should really just click on the link
but I accept you're afraid, seems like you don't really know how a webbrowser works
k i fixed it
kk
are u sure this is updated?
yes I am
and if they're not?
https://bstats.org/global/bukkit you can check here how many servers are using java 8/16
it depends
do you want your plugin to work for all people, or just for you?
just for me, but i use a server hosting service
okay, then use java 16
i'm not planning on sharing these plugins
if you're on java 16, then you can change "1.8" to "16"
it will then allow you to use java 16 features
I only use java 1.8 because many people are still using it and my plugins are available to the public
wouldn't java 16 have more features tho?
of course
can i change this later?
alr
the plugin is only meant for you, and you are running java 16, so set it to "16"
so this, right? <java.version> 16 </java.version>
idk if it is, it's on a server hosting service
you forgot thats a scary link they do not know
i was wondering, you have mentioned you use google, google has sites you do not know
websites. do. not. magically. install. viruses. the internet has been developed over many decades to patch security flaws for. this. reason.
they cannot install anything without you going out of your way to click open on a file or accept to a permission
but bstats has .org so it's an organization and so it must be safe š
but scary link
okay lemme summarize
i feel like you're still making fun of me
- You don't click on links
- You don't know what java version your hoster is using
-> You shouldn't try to create MC plugins at this point
uh huh
those other ones are to inform you on how links arent some scary stuff
i think i will
the internet exists, millions upon millions, probably billions use it just okay
Being careful on the internet is important but if you don't even want to visit websites, tbh noone can help you here, we're not here to repeat stuff that can be easily found in the internet
surely you didnt recognise google one day, how did you use that?
I get paid to code stuff, helping people is my free time and I won't invest it into people who do not even click on links I send that exactly explain what you're looking for
I hope you can understand that
if you don't want to help, don't. there's no reason to make fun or continue this argument
oh yeah ill note that every modern browser will notify you of an issue that links have
I'm trying to help you the whole time bro
i'm currently following your tutorial for maven btw
okay nice, let me know if you got any questions
let me know when you're done and we'll add the head database plugin as dependency
also i don't get it, here ^^^ you said that you don't want to help and then you say you do?
you've already said 2 other times that you will leave
yes, sometimes I get a bit upset when people are annoying me, but I get your point in not clicking links which I can understand a bit
ok
i don't see a "lifecycle" thingie in the maven tab on the right
oh nvm it was in the plugin folder
ok i got an error:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project DerpyPlugin: Compilation failure
when i double clicked package
post the full log please
that's it
no, it will give you tons of errors, there must be more information
then you'll get the full log
click on the top most thing on the left side and you'll get the full error
send your pom.xml file pls
inside your pom.xml, inside <properties>, add this pls:
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
then double click "clean", and when it's done, double click on "package" again
liek dis?
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- The Java version used to compile the plugin. I suggest to use 1.8 because many servers are still using Java 8. -->
<java.version> 1.8 </java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>```
yes
nice^^
normally maven should use the java version you're running it with
no idea why it didn't do it now
but anyway, you can override it with the options I sent above
you're now using java 8
but that's no problem unless you specifically need Java 9+ features, which you probably don't
so package is the one i need to double click to build?
is there a way i can change where it puts the plugin? so then i can just like put it in the plugins folder instead of moving it from the target to the plugins folder each time
yeah sure
but I don't know it by heart
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<outputDirectory>/my/path</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
just check the <configuration> section
if you don't have the whole maven-jar-plugin stuff yet: add it. if you already have it, just add the configuration section inside it
you could also use the maven-exec plugin to copy the file to a location of your choice afterwards
how do i add it
I already sent the xml stuff
^
anyway I gotta go to sleep now, DM me when I forget to answer here
i ended up using a tutorial on youtube