#help-development
1 messages ยท Page 2180 of 1
how are you compiling? with maven?
Yep
Just got the same error
i got no more error then this...
the FULL log
in your screenshot, you see that on the left side, the lowest thing is selected
select the uppermost one and then you see the full log
paste that
random thought: isn't it possible to optimize Math.abs by removing the flag bit, instead of doing an if statement, effectively making it a branchless method
๐ค
the flag bit?
hm then use this:
Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.
for signed numbers, there's just a bit saying if it's negative or not
Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.
unsigned numbers use that bit to extend the number's max value
can this be a problem?
basic example:
ubyte (255) is -127 (byte)
ubyte (128) is 128 (byte)
00000001 -> 1
10000001 -> -1
00000010 -> 2
10000010 -> -2
for natural numbers, the left-most bit indicates if it's negative or not
so my theory is that we can just set that bit to 0
instead of doing an if statement
theoretically it should be faster when interpreted in assembly
but tbh javac probably does that automatically
hm I can compile stuff fine that accesses RegionAccessor
no, your mvn ran using java 17
๐ค
using 1.18.2?
I think I found the problem but I need to see your pom.xml to confirm
Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.
yeah and how would you get the leftmost bit without checking the number?
yeah as I thought.
move your "spigot-api" dependency to the top
it should be your first dependency
then compile again, should work now
Can this generated anvil break:
Inventory anvil = Bukkit.getServer().createInventory(player, InventoryType.ANVIL);
that is no anvil
it's an inventory
this?
yes, like this
It's an anvil inventory, no?
bitmask or something
It opens up the anvil gui
still got the same...
people do it in funky ways in assembly
it's a normal inventory that has "anvil" as inventory type. so no, it cannot break or sth
Alright thanks!
is your code on github or sth?
btw your whole project is messed up
like subtracting one, comparing both versions and then having fun
system scope is very bad practice and then having it inside the basedir is even worse
i doubt that you'll find a faster way than the builtin Math class
java isn't C
I mean yeah but bit math operates the same
as said, how would you even find out whether the number is positive? it's not like you could do "boolean isNegative = isLeftMostBitOne()" in java
nope
<dependency>
<groupId>net.minecraft</groupId>
<artifactId>1.15</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${pom.basedir}/libs/spigot-1.15.2.jar</systemPath>
</dependency>
<dependency>
<groupId>net.minecraft</groupId>
<artifactId>1.18</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${pom.basedir}/libs/spigot-1.18.2.jar</systemPath>
</dependency>
wow
I haven't seen such a weird pom in a long time lol
xD
what if we do it without ifs
It's really a project in which I test and do all kinds of things
And after a while it looks kinda corrupt
now run this 100 thousand times and compare it with Math.abs
can't bother setting up jmh
but it's branchless programming
:)
there are like 2 less clock cycles after an hour of execution
o found the problem, thanks for helping me out!
what was it?
uugh
I didnt see you had 1.15 included as spigot-api
yeah in 1.15 that class didnt exist yet lol
you shouldn'T have more than one spigot version in your pom anyway ๐
is there a bukkit instance to get the amount of allocated memory / the amount of memory being used on the server?
you can get it from Runtime
use the Runtime class
Runtime.getRuntime().totalMemory() is the allocated amount
Runtime.getRuntime().freeMemory() gets the amount left
subtract them
= amount being used
Found this on a forums, however, it appears to be deprecated. I like to steer clear of deprecated methods and would like to know what took its place as I can't seem to find anything about it.
getOffers
you can greate a generic array with reflection
Is there a way to spawn a dropped item client side? 1.18.2
Array.newInstance
but
it requires you to have the class
which you don't have in a generic method
so you'd also need to pass the class to your method
e.g. like this:
public <T extends ConfigurationSerializable> T[] deserializer(Class<T> clazz, String base64) {
then you can create your array like this:
T[] items = Array.newInstance(clazz, size);
it's not possible without casting the class, because of type erasure
if you don't wanna pass the class, all you can do is to use an Object[] instead of T[]
alternatively, you could pass an array of the expected return type
is there a way i can store data associated with a player without making a hashmap or using a database
is there a built in way of storing data in the player
anway, you have to pass SOMETHING. otherwise java simply cannot know the class of T
yes, sure
PersistentDataContainer
woah
Player#getPersistentDataContainer
as persistent as something can be I guess
it gets saved in the world files
like at the same place where it stores your inventory, your health, your food level, etc
"a bit"
u can add stuf to
yeah but it uses "NamespacedKeys" as key
a NamespacedKey is in the format "pluginname:variablename"
i've used a namespaced key for something already
Hi
so i could store an INT in the player if i wanted to
sure
tiny example:
String surname = "Alex";
PersistentDataContainer pdc = player.getPersistentDataContainer();
NamespacedKey surnameKey = new NamespacedKey(myPlugin, "surname");
pdc.set(surnameKey, PersistentDataType.STRING, surname);
NO
internally PDC uses NBT anyway
lol
oh ok
so right now in my plugin i've got a hashmap to keep track of what players have a gui open
i will use this instead
this solves a lot of problems
cause now i can get data about the player in every event
why would you need to store that persistently though?
Honestly I think a hashmap is a better approach if you're tracking guis
player's dont have GUIs open across server restarts
because you don't need to be modifying the player's nbt object and guis being open don't need to be persisted
i need to keep track of who has what ID open
hashmap can do that fine
anyway, to store a single integer on the player object, PDC is perfect for that
ok thank you
How could I get the value of a custom item tag of an itemstack
Like I want to give myself some random item in game like stone{test:1} for example and get that value through code
are you talking about NBT tags?
nbt
yes
is there a reason why you don't use PDC tags instead?
NMS is not part of the API and it requires you to either use NMS or a third party library (which will also use NMS)
Can you give yourself an item with a PersistentDataType in game?
hm in theory yes
PDC is simply also just an NBT tag called "BukkitValues" or "PublicBukkitValues"
so basically something like
stone{BukkitValues:{"myplugin:test":1}}
makes sense to me, ill try it out
then you can get the item's PersistentDataContainer and then get the value associated with the namespacedkey "myplugin:test"
or as said, you simply use NBTAPI
which is probably easier in this case but you'd have to rely on a third party library
how would I stop this from potentially providing a nullpointerexception?
you checked "has" so it can never throw an NPE
alternatively, use "getOrDefault"
but in this case, you can safely ignore that warning
I thought so but the warning kept persisting to I decided to ask ๐
btw the NBT tag for the PDC values on items is called "PublicBukkitValues"
okay ill try it out in game real quick
to get rid of the warning, you could also do something like this:
Integer myValue = pdc.get(...);
if(myValue != null) {
doYourStuff();
}
the NPE can happen when you try to turn an Integer into an int
but if you treat it as Integer instead of int, you can do a nullcheck yourself
why aren't you using mojang mappings?
what MC version are you using?
1.18.2
mojang mappings allow you to use the proper names instead of method names like "a.b" etc
btw I think the method you're looking for is "setDisplayName" and not "setCustomName"
This is the only what shows up
hm okay then the method is probably named "c" or "b" or "x" or sth
so yeah I definitely recommend mojang mappings
then all methods and fields will suddenly have proper names
check this out ^ ๐
do i need to run that buildtool thing?
yes
the "--remapped" part is the important thing
if you wouldn't have to do it, it wouldn't be in the blog post ๐
i never got that buildtool to work
you just download the .jar
then you open a command prompt in that folder
and then you just enter "java -jar BuildTools.jar --rev 1.18.2 --remapped"
and then you can get a beer because it takes like 5 minutes
this explains in detail on how to run buildtools https://www.spigotmc.org/wiki/buildtools/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
but basically it's just "download, open command prompt, enter the command, wait, done"
*** The version you have requested to build requires Java versions between [Java 17, Java 18], but you are using Java 8
*** Please rerun BuildTools using an appropriate Java version. For obvious reasons outdated MC versions do not support Java versions that did not exist at their release.
._.
you need to use at least java 17 to run buildtools for 1.18
instead of using "java -jar..." you can specify the full path to your java 17
for example:
"C:\Java\Java17\bin\java -jar ..."
when the error tells you exactly what's wrong
what is nms
internal minecraft code
no more socks
nms = basically minecraft itself
what can you do with it
you won't believe it
what power does it give you
but I'm wearing two sucks right now
show me immediately
because I don't believe you
nah there's probably some feet fetishists here
dms baby girl
lol
nothing it's a waste of time
stick to the api
uh ok
everything you need is in the api
you learn nms just for it to break in the next update
what if i want to send someone an inventory that's 9 rows big
too bad
unless you use mojang mappings
that won't work
only because of bukkit
then you can do Bukkit.createInventory(null, 9)
forgot mojang mappings exist lol
mfnalex i was told that didn't work
of course it works
like it didn't let you send more than the double chest size
true but 9 is less than 54
oh
you said rows
sorry my bad
yeah that won't work
you used to be able to though
no
and now with custom font textures it would be SO good to be able to make 9 row inventories
I don't think that was ever possible?
actually it was possible to some extent
it was ALWAYS a multiple of 9 and max 54
no
wrong, it was possible
you used to be able to make glitched inventories
when?
with more rows
and it bled out of the inventory texture space
ye
oh with triple chests?
when?
if you forced 3 chests together, you could get a larger inventory
gizmonster can you imagine making a custom font texture for that
and implementing triple chests as a plugin
hm didnt know that
well, can nms do it?
i will have to learn it
do it
if you get me a beer sure
"wireless pissing" that would be great
I already asked for a beer myself in #general a second ago lol
1.13 fixed triple chests
then it makes sense that I claimed it wasnt possible because I only started in 1.13 lol
๐ค
they only spawned in dungeons, so they were kinda not known to a lot of people
on what level are they fixed, could i still technically send a player a 7 row inventory?
that I have no idea
1.13 added chests to be placed next to each other, so not sure what they exactly did
oh in that case
let me see if they still exist in the current version
probably a lazy fix
one moment
because the hybrid chest could still be possible to force into the game
if it is i am totally gonna use this
I miss the beta 1.3 days
maybe we'll see it's a long life
why are you so old
beta 1.3 was released on my 16th birthday
I runned that Buildtool thing but what do i need to do with that spigot-1.18.2.jar ?
why did i build it ?
to get it installed to your local maven repository
buildtools already did that for you
you can now just copy paste the pom.xml stuff from the blog post
and then you have mojang mappings
what did you try
they used google
debug stick, putting a left or right state chest on the side of a double chest used to make this occur
and while it's been patched since the debug stick's introduction
if it's possible to force the glitched ui to appear if you somehow create an inventory that's 63 big
I guess I could dig around nms
honestly it's not even a bad idea to try with, trying to get a custom GUI
also another question, where is a players enderchest inventory stored
in their playerdata
just in their player nbt file
ok
but it's completely accessible via the spigot api so don't do anything stupid
of course you are
titles can't be changed after creation
pretty sure the title is not changeable but I could be wrong
can i replace the enderchest inventory with a different inventory
Apparently it doesn't work for me mfnalex
what gamer joep
the renaming thing
then you didn't properly follow my blog post
wrong quote
WHY DO I ALWAYS QUOPTE THE WRONG PEOPLE
then you didnt properly follow my blog post
?paste your pom.xml
area you going to
also can the persistent data store java objects or just primitives
could i store an inventory
not by default but mfnalex made a library that adds more persistent data types
awesom
he probably has one that supports it
that's cool
bruh
your whole pom is totally messed up. create a clean project, STOP FUCKING USING SYSTEM SCOPE and do not add 5 different spigot versions to your pom
this cannot possibly work
I messed around with it and decided I do not want to go this deep into nms tonight
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.minecraft</groupId>
<artifactId>1.18</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${pom.basedir}/libs/spigot-1.18.2.jar</systemPath>
<classifier>remapped-mojang</classifier>
</dependency>
<dependency>
<groupId>net.minecraft</groupId>
<artifactId>1.15</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${pom.basedir}/libs/spigot-1.15.2.jar</systemPath>
</dependency>
for real wtf
what the fuck
I told him two hours ago that this is fucked up
but now this isn't working... https://paste.md-5.net/akadukojob.xml
did you click the maven reload button?
Jap
gizmonser i added u
things like org.bukkit dont show up
what's the output of mvn clean package -U?
looks good.
so im using this code, but for some reason it isnt working, I dont see any error but I know its being ran
you're still using the old names
of course you have to use the new class names
e.g. there is no "PacketPlayOutEntityMetadata" class
it's called totally different in mojang mappings
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
because it doesn't exist
a class named "EntityArmorStand" never existed in mojang mappings
it's called ArmorStand
not EntityArmorStand
but what now?
Im expecting for the itemstack to be given to the player when they join the world through the onjoin event, but im not given any item when I join
?paste the full class pls
But i want use it for packets
you should use the correct class name then, because otherwise you cannot use it at all
the correct class name for NMS armorstands is net.minecraft.world.entity.decoration.ArmorStand
and for this?
does any1 here know how to allow cows to spawn without grass? on 1.8 it was very easy by just replacing the vanilla cow by your custom one like this
public class CustomMushroomCow extends EntityMushroomCow
{
public CustomMushroomCow(World world) {
super(world);
this.bn = Blocks.AIR;
}
}
though in 1.17 i can no longer find a block requirement. thanks in advance
ClientboundAddEntityPacket
where can you find all that?
does it show the "Welcome to Kelzar" message?
ye when testing a few mins ago it did send that
I can check again since I recently changed some things
if it shows the message, then it should also add the item
yeah that's a bit complicated
ok it doesnt show the message
there is no proper "table" to look that up
But I also see no erros in logs or in intellij
please try the latest version of your plugin and let me know if it prints the message
oh wait
wtf
the code you sent is fucked up anyway
you are casting your listener's "this" to plugin
that cannot work
you definitely have got console errors
ClassCastException
public class PlayerJoinRun implements Listener{
NamespacedKey key = new NamespacedKey((Plugin) this, "test");
"this" is not a Plugin
"this" is a PlayerJoinRun instance
you probably got an exception in console when you plugin enabled
Then it becomes almost impossible for me
what do you need NMS for anyway?
I wanted to drop an item that is client side
To like preview something
If you know what I mean :-)
okay why does it need to be client side?
if it really must be 100% client side, it indeed requires NMS
Because each player can choose a different item
that's no problem in theory, you can spawn different items and show them only to certain players
Entity#hide
or was it Player#hideEntity?
one of those
Can you hide a entity for a specific player?
declaration: package: org.bukkit.entity, interface: Player
(it's draft api though)
that means it's basically the opposite of deprecated lol
basically it means "not 100% finished yet"
but it'll work fine and it also won't change
so it's fine to use
idk whats up with console I didnt get any errors
you did get errors
But here i have not "hideEntity"
scroll up
hideEntity is a method declared for Player, not Entity
np
Then I have to constantly update it for every player
yes, true. of course you can use NMS instead but NMS is really a pain in the ass
let me show you my code that I use for "fake entities"
check out the "createHologram" method
and the "showEntityToPlayer" method
Ah thanks i will check tomorrow
oki
And if i do it on the other method, if there are like 100 players online then there are like 100 dropped items
And then for everyone needs to be updated
To hide
yeah true. in this case NMS is better. I thought you had maybe 4 or 5 different items
anyway, I know it's a pain in the ass to switch to remapped but once you've done that... your code will always work in future versions
no need to adjust it for every update etc
True
you just have to rename all your class references once
e.g. PacketPlayOut.... is now always Clientbound...Packet
But most of time i see spigot forum with code
I suggest to just look at the net.minecraft.network.protocol package or what's it called
most packets have a self explaining name
yeah but that's all outdated
And normaly you can copy it and change it how you want
Jap...
if you wait 3 years, you can copy paste again lol
๐
right now, most people are new to mojang mappings and there are no proper tutorials yet
There are also many servers still using a 1.12.2
If i look in my bStats
No one will update to a 1.18
I only have 2% 1.12 users
Depends also what kind of plugin it is
1.12 isn't even supported by ANY of my plugins lol
Yea i have also people that do that ๐
What kind of plugin is this?
ChestSort
Ah looks nice :)
I've uploaded a new premium plugin today, now it's time to wait again lol
I hope
my first premium plugin took 3 months to get approved. my latest took not even 24 hours lol
it's very different all the time
๐
But your plugin has way more uses
But our plugin have almost the same download count
ChestSort has so many users because it's basically the ONLY proper sorting plugin
Ahh okay...
my other plugins also have way less downloads of course lol
ChestSort 110k, AngelChest ~46k, LumberJack 40k, and then for the next plugin it's already down to only 16k
That is nice
true
but what we really need is
more Skript anti cheats
๐
or more Essentials skripts
๐ ๐
i found a good skript today
show
I will go for now, thanks for all and have a nice day :)
Its already morning ๐
xD
it's called "This is an Essentials Skript for your server" lol
best plugin name
Could someone help explain how to setup TabCompletion with CommandMap?
what exactly do you want to do?
btw this skript gives a bread to all players every 60 seconds lol
best essentials replacement ever
I have a command and i wanna have tab completion for it's subcommands
you can create a new class that implements TabCompleter
or make your commandexecutor implement that
it does
similar to onCommand, there's a onTabComplete method
then from that, you can just return a List<String> with the tab completions
and i register all that with CommandMap?
you do not need to mess with any commandmap at all
yea but it makes command handlers easier
what
public void onEnable() {
getCommand("test").setExecutor(myCommandExecutor);
getCommand("test").setTabCompletor(myTabCompletor);
?
are you talking about the PluginManager's SimpleCommandMap?
yes
you shouldn't touch that unless you have good reasons to do so
and registering a normal command + tab complete definitely is not a good reason
because you can easily do that without reflection
so i should just do this then?
yes of course
any1? 
no idea why you thought about touching the commandmap
I have no idea but
what exactly are you trying to do?
the first plugin tutorial i found used it for a handler so i thought i should just keep it like that
that must have been one hell of a shitty tutorial tbh
i am trying to allow cows to spawn without any grass
hmmm
I'm bored anyway so I'll just dig through some NMS, maybe I'll find something useful
the lil piece of code is bassically all it took for 1.8 :/
only thing I found yet is the static checkMushroomSpawnRules method
and some code to replace the entity
so Mob has a "checkSpawnRules" method
the BaseSpawner checks that method before spawning anything
Anyone know a working custom skull API that works in 1.18.2?
thats annoying me
jesus that was quick
so how will i go about to change that 
yeah because it's from my lib lol
Lmao
yeah well
I don't think you can
tysm
np
well pretty sure there are plugins that do change this behaviour
yes, there's events for spawners when they attempt to spawn stuff
but you cannot simply override this method
it's now a static method in the ANimal class itself
np, maybe I'm overlooking something but I fear it's not as simple as it was in 1.8
well normally you should just add it to your pom.xml or build.gradle
but sure you can also just download it
1 sec
never was able to get that working on eclipse
yeah eclipse's maven integration is shitty
well thats a first for me. where a newer version restricts me from doing something that was once possible
tysm
I 100% recommend trying out intelliJ, you won't regret it
I used it once
and also directly switch to maven
here's a blog post I wrote to get a working setup with intellij + maven
but that was a long time ago and used eclipse more so I decided to stick with it but since I'm using more libraries and such now I might just do it
once you got that working you never wanna go back to eclipse + "build artifacts"
lmao
I also used only eclipse back in the days
and I hated maven because I couldnt get it to work in eclipse
then one day I simply tried intelliJ
i hated it because I had no idea about maven
then someone explained it to me and since then I never opened eclipse again lol
i used eclipse for 2 hours. and i was done with it, downloaded intellij never looked back
coming back, i realize how much I fucking hate both maven and gradle because of how inconveinant they are
yeah the more libraries etc you use, the higher is your need to use maven or gradle lol
lol good one
it exponentially gets slower the more libraries you add
Eclipse just seems easier to use at first to me hence why I stuck with it
compared to the golang built in package system its so much worse
btw here's the javadocs for my lib https://hub.jeff-media.com/javadocs/jefflib/
package index
mans a mind reader
Consider trying out intellij for one day, I used eclipse for 2 years and then tried intellij one day
Ill definitely try it out
same
btw my ultimate license expires tomorrow >.<
I also have a university email address but I am too lazy to renew it before the last minute of the license has been used lol
in fact I have an unlimited amount of university email addresses
I can use up to 5 aliases and I can change them at anytime lol
I tried intellij I hated it and never looked back
Ofcourse I'm in the minority I'm sure it's probably ok when you get used to it
Guess I got a bit overconfident, but how would I access the SkullUtils portion of the library?
what are you trying to do?
I basically want to set an ItemStack as a custom head
you want to place it in the world?
or you want to get an ItemStack with a custom texture into an inventory etc?
I want to be able to give a player a customized player head
and them have it in their inventory
okay so SkullUtils.getHead("someBase64String") gets you an itemstack
then you can just do player.getInvenotry().addItem(...)
So I don't gotta do any fancy initalization?
nooo those are all static methods
that makes life so much easier
exactly
ItemStack head = SkullUtils.getHead("eyJ015135af....");
np
btw since you don't use maven - you have to "shade" the lib into your plugin. Not sure how that works in eclipse without maven
you basically have to tell eclipse to "put the library into your .jar" lol
with maven that's only like one additional line, but not sure how it works in eclipse without maven
Usually putting the jar into the build path works
oh oki
alrighty
Thats strange
The string is causing an error
The method getBase64Texture(SkullMeta) in the type SkullUtils is not applicable for the arguments (String)
what's your code?
as said, it works like this:
ItemStack myCustomHead = SkullUtils.getHead("afwuawfkuawfgkawfu (the base64 string)");
ItemStack fCore = SkullUtils.getBase64Texture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzc1YmNhMWFmNWNiMTU1N2MxNzk0ZDIzZDkwN2RmMTE1OTMyMGUxNGViYTA1ODFjMjUxODdkYmViMjJiYTJjYyJ9fX0=");
getBase64Texture is to extract the base64 texture from an existing skull
do it like this
ItemStack fCore = SkullUtils.getHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzc1YmNhMWFmNWNiMTU1N2MxNzk0ZDIzZDkwN2RmMTE1OTMyMGUxNGViYTA1ODFjMjUxODdkYmViMjJiYTJjYyJ9fX0=");
the first method is to convert fCore back into the base64 string
so basically the opposite of what you want
just do this ^
yeah it's a bit misleading but actually it makes sense
you want to GET a head FROM base64, so you use getHead
Didn't realize base64 was the value so that makes sense now
if you want to to do the opposite - get a BASE64 FROM a head, you'd use getBase64Texture
oh yeah base64 is the weird string lol
my bet is - you'll get a ClassNotFoundException because eclipse didn'T shade it ๐
let's see
?paste it
?paste the complete log
yep you have to tell eclipse to "shade" that library
no idea how that works
as said I only use maven to handle that automatically
I think instead of "Add jar" you have to use "Add external jar"
I hope so
if not, this is the proper time to switch to maven ๐
๐
it's really not complicated
in fact it makes your life so much easier
it's only complicated the first 30 minutes
true
I still remember when someone wanted to talk me into maven
better to set it up and be easy afterwards I guess then pure pain
and I was like "ugh what a bullshit"
I know that maven is super useful and good
I just know that its not something im knowledgable in
which I guess I don't like very much lmao
yes I know that feel. someone once converted one of my plugins to a maven project
and I was so upset because I didnt understand anything about it
thank god this dude took much of his time to explain it to me
That dude was insanely nice
but there you can see that I also didn't get maven to work properly with eclipse
when I swithed to intelliJ, everything was simply working lol
yeah
I was totally unfriendly to him at first lol
I was so upset that it didnt work
in my view, he changed something and then everything stopped working lol
little did I know that it was mine and eclipse's fault lol
well
at least from when I first used it
left and right are some menus and in the middle there's your source code lol
not sooo different ๐
I recommend that you create a totally new project
and just write a tiny plugin
just to get started with maven
then when you got that working, you can copy/paste your current project into it
Smart
Woah
wait
in plugin.yml author is supposed to be in quotes
I have never done that
doesn't matter
o ok
got it
and for the main import if I made my group id io.github.darkenedfusion I would import main as:
io.github.darkenedfusion.HelloWorldPlugin
yes, that looks good
your package names does NOT have to match your maven groupID but it's quite common to use matching names
if I was you, I would use the following names:
groupId: io.github.darkenedfusion
artifactId: HelloWorldPlugin
main class name: io.github.helloworldplugin.Main
why remove the darkenedfusion part?
ah
gotcha
ok then its basically the same as eclipse for getting the main class
just wanted to be extra sure so I don't spend a decade figuring out why it wouldn't work and having to find that
normally your package name should be something like "yourname.projectname.Main" or similar
some people would argue that "Main" is not a good name for the main class but lets just ignore this for now
So once you have all of that, thats pretty much it?
the huge advantage when using maven is: when you want to add for example my library, all you have to do is to add the URL to my repository to <repositories> and the name and version of the library in <dependencies> and that's basically it lol
Yeah
I see so many libraries have that maven thing
so it limited my choices when there was no jar
tbh any library that does NOT provide a maven artifact is probably shitty
noted
The Skull Manager that I had before was a file that I found
worked perfectly but I dont remember it having a maven implementation
nvm it did
guess there just was another way of implementing it
you can always also just directly download the .jar files from the maven repository
like the file I sent you was just a link to the file that maven would have downloaded automatically
but maven can also handle stuff like "include that library in your final plugin .jar" etc
ah
that's called "shading"
for example you have the spigot api. you add that as dependency but obviously your plugin should not actually include spigot
because the server already has the spigot .jar
but my library, you must include that in your .jar because the server doesn't have it yet
and yeah that's called "shading" - adding libraries and also putting them into your .jar
it's quite important. there are libraries that you can use without shading - when that library is a standalone plugin
for example WordEdit - you can use that without shading because that pugin is installed on the server already
but other stuff aren't a plugin and your plugin has to "bring it along"
but yeah I highly recommend that you just follow that blog post and create a really simply "Hello world" plugin. like something that says "hello player" when you joined. once you got that going with intellij + maven, we can convert your existing plugin to work with maven. it'll only take like 5 minutes
it's at "<projectFolder>/target"
yep lol
only slight thing I can think of
it's a bit weird to setup because you need the pom.xml but after that, just double click "package" and that's it
since in eclipse when I exported the file it went directly into my servers plugin folder
dang
oh wait
you don't have a <build> section in your pom yet
one second I'll send an example
I do
I think
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>io.github.darkenedfusion</groupId>
<artifactId>HelloWorldPlugin</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>18</maven.compiler.source>
<maven.compiler.target>18</maven.compiler.target>
</properties>
<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>
so just add <plugin>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<outputDirectory>C:\mctest\plugins</outputDirectory>
<finalName>Test</finalName>
</configuration>
</plugin>
</plugins>
should look like this then
this will save it at C:\mctest\pugins\Test.jar
the group and artifact thing dont change right?
you mean when you choose a custom folder for it to build?
no that has nothing to do with each other
you can basically choose ANY group and artifact ID, it would never affect your final plugin jar
group id and artifact ID are more like "meta data"
you only have to worry about those if other stuff uses your plugin as library
perfect ๐
okay now the tricky part is to turn your existing project into a working maven project
I mean it seems simple enough now
since you used eclipse, your whole build setup is probably "messed up" from mavens perspective
I hope
if you like, you can just upload your whole project to github and I'll turn it into a structure that maven undertsands
sure, no problem
Doesn't intelliJ have an auto update github thing as well?
of course
awesome
btw if you are looking for sth and cannot find it:
press shift twice quickly
it opens a menu where you can enter ANYTHING and it'll show you where it is
when I tried intellij the first time, I hated it because I couldnt just do File -> Export .jar
I might've accidently deleted the plugin file
huh
the plugin file? or the source code
if you accidently deleted the source code, that's... fucking inconvenient lol
๐
the source folder somehow ended up going into my plugins folder
which I mistuck as some random plugins config folder
Alright
Prepare for the most professional looking code you've ever witnessed
lol np
can you give me write access for a few minutes?
I'm too lazy to fork it and do a pull request
my github name is mfnalex
I totally know how to do that
did you add any dependencies besides spigot api?
only other thing was ur jar file
oki perfect
okay so I'll quickly explain what I'm doing
first of all, your code has to be in src/main/jave
right now it's in a folder called PheonixNetwork
maven wants it to be in src/main/java though
your plugin.yml has to be in src/main/resources
the rule basically is:
all files etc go to resources, and all source code goes to java folder
then I'll just create a pom.xml
and basically that's it
Seems simple enough
So whenever creating a new project
put the spigot file in the resources folder
oh and I'll adjust your package name
right now you use io.github.DarkenedFusion
but you probably will do another plugin sometime
so package name should rather be io.github.darkenedfusion.<pluginname>
So that will fetch the plugins name without me manually typing it?
so just placeholder text
kk
ok check out this
as you can see, spigot has <scope>provided
that means, we do not need to shade spigot because the server already runs it anyway
however my library is <scope>compile
that means maven will actually include my library in your plugin
that's the shading thing I told you about
seems to be working, one sec
๐
ok I opened a pull request on github
just accept that and now your github repo is ready to go
did you upload the code using intelliJ?
I uploaded it with eclipse
ok
go to your repo on github, then accept my pull request
basically you have to merge it
okay now, do this in IntelliJ:
File -> New -> Project from Version Control
then paste your github URL: https://github.com/DarkenedFusion/PhoenixNetwork
and baaam, now you should have a working maven project in intelliJ
and yeah you can build it by double clicking on maven -> package
oh btw that's something I also would like to explain:
in the maven menu, you have things like "clean", "compile", "package", etc
clean basically means "clean up the whole build folder".
"compile" means "compile all java files" but then you only have a bunch of compiled files, not a wokring plugin
"package" however is the same as "compile" but it also puts everything into a .jar file and includes all the libraries (the "shading part")
so if you want to get a working jar, "package" is the thing you wanna use
package = compile + include needed libraries + put it into a .jar file
Interesting
