#help-development

1 messages ยท Page 2180 of 1

tender shard
#

this should be 17 or later too

grave mason
#

Changed it but still have the problem..

#

i should try restart it

tender shard
#

how are you compiling? with maven?

grave mason
#

Yep

tender shard
#

try to run this:
mvn clean package -U -X

#

then ?paste the full log

grave mason
#

Just got the same error

tender shard
#

?paste

undone axleBOT
grave mason
#

i got no more error then this...

tender shard
#

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

echo basalt
#

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

#

๐Ÿค”

grave mason
tender shard
#

hm then use this:

echo basalt
grave mason
echo basalt
#

unsigned numbers use that bit to extend the number's max value

grave mason
#

can this be a problem?

echo basalt
#

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

tender shard
tender shard
grave mason
#

๐Ÿค”

grave mason
tender shard
#

yes

#

?paste your pom.xml

undone axleBOT
tender shard
#

I think I found the problem but I need to see your pom.xml to confirm

grave mason
tender shard
tender shard
#

move your "spigot-api" dependency to the top

#

it should be your first dependency

#

then compile again, should work now

tranquil viper
#

Can this generated anvil break:
Inventory anvil = Bukkit.getServer().createInventory(player, InventoryType.ANVIL);

tender shard
#

it's an inventory

tender shard
tranquil viper
tranquil viper
#

It opens up the anvil gui

grave mason
echo basalt
#

people do it in funky ways in assembly

tender shard
tranquil viper
#

Alright thanks!

tender shard
#

btw your whole project is messed up

echo basalt
#

like subtracting one, comparing both versions and then having fun

tender shard
#

why did you hardcode the paths to spigot

#

why didn't you just use <scope> provided

echo basalt
tender shard
#

system scope is very bad practice and then having it inside the basedir is even worse

tender shard
#

java isn't C

echo basalt
#

I mean yeah but bit math operates the same

tender shard
#

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

grave mason
worldly ingot
#

if (number < 0)

tender shard
# grave mason 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

grave mason
#

xD

echo basalt
grave mason
grave mason
tender shard
# echo basalt

now run this 100 thousand times and compare it with Math.abs

echo basalt
#

can't bother setting up jmh

#

but it's branchless programming

#

:)

#

there are like 2 less clock cycles after an hour of execution

grave mason
tender shard
grave mason
#

from 1.15 to 1.18

tender shard
#

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 ๐Ÿ˜„

fierce salmon
#

is there a bukkit instance to get the amount of allocated memory / the amount of memory being used on the server?

ivory sleet
#

you can get it from Runtime

quaint mantle
#

use the Runtime class

#

Runtime.getRuntime().totalMemory() is the allocated amount

#

Runtime.getRuntime().freeMemory() gets the amount left

#

subtract them

#

= amount being used

tranquil viper
#

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.

tender shard
#

you can greate a generic array with reflection

grave mason
#

Is there a way to spawn a dropped item client side? 1.18.2

tender shard
#

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

lethal python
#

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

tender shard
tender shard
lethal python
#

woah

tender shard
#

Player#getPersistentDataContainer

lethal python
#

what should you use that for

#

how persistent is it

tender shard
#

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

lethal python
#

wooooah

#

awesome

#

so is it like a hashmap

tender shard
#

"a bit"

lethal python
#

u can add stuf to

tender shard
#

yeah but it uses "NamespacedKeys" as key

#

a NamespacedKey is in the format "pluginname:variablename"

lethal python
#

i've used a namespaced key for something already

lethal python
#

let mne check what it was

#

oh NBT tagts

chilly fox
#

Hi

lethal python
#

so i could store an INT in the player if i wanted to

tender shard
#

sure

lethal python
#

would storing a single int be better done with nbt

#

or not

tender shard
#

tiny example:

#
String surname = "Alex";
PersistentDataContainer pdc = player.getPersistentDataContainer();
NamespacedKey surnameKey = new NamespacedKey(myPlugin, "surname");
pdc.set(surnameKey, PersistentDataType.STRING, surname);
tender shard
#

internally PDC uses NBT anyway

lethal python
#

lol

tender shard
#

PDC is like "API" for NBT

#

plus better

#

lol

lethal python
#

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

tender shard
#

why would you need to store that persistently though?

hexed hatch
#

Honestly I think a hashmap is a better approach if you're tracking guis

tender shard
#

player's dont have GUIs open across server restarts

lethal python
#

no it's just a specific gui

#

the gui is tied to an entity with a specific ID

hexed hatch
#

because you don't need to be modifying the player's nbt object and guis being open don't need to be persisted

lethal python
#

i need to keep track of who has what ID open

hexed hatch
#

hashmap can do that fine

lethal python
#

yeah i've done that already

#

just trying to refactor to be better

tender shard
#

anyway, to store a single integer on the player object, PDC is perfect for that

lethal python
#

ok thank you

minor otter
#

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

tender shard
#

are you talking about NBT tags?

drowsy helm
#

nbt

minor otter
#

yes

tender shard
#

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)

minor otter
#

Can you give yourself an item with a PersistentDataType in game?

tender shard
#

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}}

minor otter
#

makes sense to me, ill try it out

tender shard
#

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

minor otter
#

how would I stop this from potentially providing a nullpointerexception?

tender shard
#

you checked "has" so it can never throw an NPE

#

alternatively, use "getOrDefault"

#

but in this case, you can safely ignore that warning

minor otter
#

I thought so but the warning kept persisting to I decided to ask ๐Ÿ˜…

tender shard
#

btw the NBT tag for the PDC values on items is called "PublicBukkitValues"

minor otter
#

okay ill try it out in game real quick

tender shard
grave mason
#

Can anyone help with this?

tender shard
#

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

tender shard
grave mason
#

uhhh whaatt?

#

how and where xD?

tender shard
#

what MC version are you using?

grave mason
#

1.18.2

tender shard
#

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"

grave mason
#

This is the only what shows up

tender shard
#

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

tender shard
grave mason
#

do i need to run that buildtool thing?

tender shard
#

yes

#

the "--remapped" part is the important thing

#

if you wouldn't have to do it, it wouldn't be in the blog post ๐Ÿ˜›

grave mason
#

i never got that buildtool to work

tender shard
#

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

#

but basically it's just "download, open command prompt, enter the command, wait, done"

grave mason
#

*** 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.

#

._.

tender shard
#

you need to use at least java 17 to run buildtools for 1.18

grave mason
#

last time i tried to change the java version

#

then it didn't changed anything

tender shard
#

instead of using "java -jar..." you can specify the full path to your java 17

#

for example:

#

"C:\Java\Java17\bin\java -jar ..."

hexed hatch
lethal python
#

what is nms

tender shard
#

internal minecraft code

hexed hatch
#

no more socks

tender shard
#

nms = basically minecraft itself

lethal python
#

what can you do with it

tender shard
lethal python
#

what power does it give you

tender shard
#

but I'm wearing two sucks right now

hexed hatch
#

because I don't believe you

tender shard
#

nah there's probably some feet fetishists here

hexed hatch
#

dms baby girl

tender shard
#

lol

lethal python
#

hello

#

please

hexed hatch
#

stick to the api

lethal python
#

uh ok

hexed hatch
#

everything you need is in the api

delicate lynx
#

you learn nms just for it to break in the next update

lethal python
#

what if i want to send someone an inventory that's 9 rows big

hexed hatch
#

too bad

tender shard
hexed hatch
#

that won't work

lethal python
#

only because of bukkit

tender shard
delicate lynx
#

forgot mojang mappings exist lol

lethal python
#

mfnalex i was told that didn't work

tender shard
#

of course it works

lethal python
#

like it didn't let you send more than the double chest size

tender shard
#

true but 9 is less than 54

#

oh

#

you said rows

#

sorry my bad

#

yeah that won't work

lethal python
#

you used to be able to though

tender shard
#

no

lethal python
#

and now with custom font textures it would be SO good to be able to make 9 row inventories

delicate lynx
#

I don't think that was ever possible?

hexed hatch
#

actually it was possible to some extent

tender shard
#

it was ALWAYS a multiple of 9 and max 54

lethal python
#

no

hexed hatch
#

wrong, it was possible

lethal python
#

you used to be able to make glitched inventories

tender shard
#

when?

lethal python
#

with more rows

tender shard
#

where?

#

how?

hexed hatch
#

and it bled out of the inventory texture space

lethal python
#

ye

delicate lynx
#

oh with triple chests?

tender shard
#

when?

hexed hatch
#

if you forced 3 chests together, you could get a larger inventory

lethal python
#

gizmonster can you imagine making a custom font texture for that

#

and implementing triple chests as a plugin

tender shard
#

hm didnt know that

hexed hatch
#

wouldn't be hard

#

now just figure out if that's still possible in 1.18 lol

lethal python
#

well, can nms do it?

hexed hatch
#

you tell me

#

try it and see

lethal python
#

i will have to learn it

hexed hatch
#

do it

tender shard
#

can someone go to the toilet for me?

#

i dont wanna get up

hexed hatch
#

if you get me a beer sure

tender shard
#

"wireless pissing" that would be great

tender shard
delicate lynx
#

1.13 fixed triple chests

tender shard
delicate lynx
#

they only spawned in dungeons, so they were kinda not known to a lot of people

lethal python
delicate lynx
#

that I have no idea

#

1.13 added chests to be placed next to each other, so not sure what they exactly did

lethal python
#

oh in that case

hexed hatch
#

let me see if they still exist in the current version

lethal python
#

probably a lazy fix

hexed hatch
#

one moment

lethal python
#

probably still exists

#

woah really

#

gizmonster are u gonna do nms o_o

hexed hatch
#

because the hybrid chest could still be possible to force into the game

lethal python
#

if it is i am totally gonna use this

tender shard
#

I miss the beta 1.3 days

hexed hatch
hexed hatch
lethal python
#

? โธฎ

#

are you nms-ing or not

tender shard
hexed hatch
#

I was 10

#

god you're old

grave mason
#

I runned that Buildtool thing but what do i need to do with that spigot-1.18.2.jar ?

tender shard
#

nothing

#

read the blog post

grave mason
#

why did i build it ?

tender shard
#

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

hexed hatch
#

no longer works

lethal python
#

what did you try

tender shard
#

they used google

hexed hatch
#

debug stick, putting a left or right state chest on the side of a double chest used to make this occur

lethal python
#

oh right that's not what i meant

#

i just meant the glitched ui

hexed hatch
#

and while it's been patched since the debug stick's introduction

lethal python
#

if it's possible to force the glitched ui to appear if you somehow create an inventory that's 63 big

hexed hatch
#

I guess I could dig around nms

delicate lynx
#

honestly it's not even a bad idea to try with, trying to get a custom GUI

lethal python
#

also another question, where is a players enderchest inventory stored

delicate lynx
#

in their playerdata

lethal python
#

in the persistent thing?

#

mentioned earlier>

hexed hatch
#

just in their player nbt file

lethal python
#

ok

hexed hatch
#

but it's completely accessible via the spigot api so don't do anything stupid

lethal python
#

yes

#

am i able to edit it

#

the inventory

hexed hatch
#

of course you are

lethal python
#

like change the title

#

awesome

hexed hatch
#

oh

#

no

#

lol

lethal python
#

what

#

that sucks

delicate lynx
#

titles can't be changed after creation

hexed hatch
#

pretty sure the title is not changeable but I could be wrong

lethal python
#

can i replace the enderchest inventory with a different inventory

delicate lynx
#

you could show a "copy" of the enderchest

#

just make sure to save the data

grave mason
#

Apparently it doesn't work for me mfnalex

lethal python
#

what gamer joep

grave mason
#

the renaming thing

hexed hatch
#

try harder

#

what didn't work?

grave mason
#

nothing is renamed

#

or something

#

still this

tender shard
#

wrong quote

#

WHY DO I ALWAYS QUOPTE THE WRONG PEOPLE

tender shard
#

?paste your pom.xml

undone axleBOT
grave mason
lethal python
#

also can the persistent data store java objects or just primitives

hexed hatch
#

only supported types

#

you can add your own too

lethal python
#

could i store an inventory

hexed hatch
#

not by default but mfnalex made a library that adds more persistent data types

lethal python
#

awesom

hexed hatch
#

he probably has one that supports it

lethal python
#

that's cool

tender shard
#

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

grave mason
#

and this?

hexed hatch
tender shard
#
        <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

hexed hatch
#

what the fuck

tender shard
#

I told him two hours ago that this is fucked up

tender shard
#

did you click the maven reload button?

grave mason
#

Jap

lethal python
#

gizmonser i added u

grave mason
#

things like org.bukkit dont show up

tender shard
#

what's the output of mvn clean package -U?

tender shard
#

looks good.

minor otter
#

so im using this code, but for some reason it isnt working, I dont see any error but I know its being ran

tender shard
#

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

undone axleBOT
#

"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.

grave mason
#

also things like this

#

cant import it

tender shard
#

because it doesn't exist

#

a class named "EntityArmorStand" never existed in mojang mappings

#

it's called ArmorStand

#

not EntityArmorStand

grave mason
#

but what now?

tender shard
#

net.minecraft.world.entity.decoration.ArmorStand

#

is the correct class name

minor otter
# tender shard ?notworking

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

undone axleBOT
grave mason
tender shard
#

the correct class name for NMS armorstands is net.minecraft.world.entity.decoration.ArmorStand

grave mason
#

and for this?

tall dragon
#

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

tender shard
grave mason
tender shard
minor otter
#

ye when testing a few mins ago it did send that

#

I can check again since I recently changed some things

tender shard
#

if it shows the message, then it should also add the item

tender shard
minor otter
#

ok it doesnt show the message

tender shard
#

there is no proper "table" to look that up

minor otter
#

But I also see no erros in logs or in intellij

tender shard
#

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

grave mason
tender shard
grave mason
#

I wanted to drop an item that is client side

#

To like preview something

#

If you know what I mean :-)

tender shard
#

okay why does it need to be client side?

#

if it really must be 100% client side, it indeed requires NMS

grave mason
tender shard
#

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

grave mason
#

Can you hide a entity for a specific player?

tender shard
#

(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

minor otter
tender shard
#

you did get errors

tender shard
tender shard
grave mason
#

ooo waitt

#

alrighttt

#

Jap that worked, thanks!

tender shard
#

np

grave mason
tender shard
#

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

grave mason
#

Ah thanks i will check tomorrow

tender shard
#

oki

grave mason
#

And then for everyone needs to be updated

#

To hide

tender shard
#

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

grave mason
#

True

tender shard
#

you just have to rename all your class references once

#

e.g. PacketPlayOut.... is now always Clientbound...Packet

grave mason
#

But most of time i see spigot forum with code

tender shard
#

I suggest to just look at the net.minecraft.network.protocol package or what's it called

#

most packets have a self explaining name

tender shard
grave mason
grave mason
tender shard
#

if you wait 3 years, you can copy paste again lol

grave mason
#

๐Ÿ˜‚

tender shard
#

right now, most people are new to mojang mappings and there are no proper tutorials yet

grave mason
#

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

tender shard
#

I only have 2% 1.12 users

grave mason
grave mason
tender shard
#

1.12 isn't even supported by ANY of my plugins lol

grave mason
grave mason
tender shard
#

ChestSort

grave mason
#

Ah looks nice :)

tender shard
#

I've uploaded a new premium plugin today, now it's time to wait again lol

grave mason
#

I hope

tender shard
#

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

grave mason
#

๐Ÿ˜‚

#

But your plugin has way more uses

#

But our plugin have almost the same download count

tender shard
#

ChestSort has so many users because it's basically the ONLY proper sorting plugin

grave mason
#

Ahh okay...

tender shard
#

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

paper viper
#

We need less anticheats and more unique plugins

#

Lol

grave mason
#

That is nice

tender shard
#

but what we really need is

#

more Skript anti cheats

paper viper
#

๐Ÿ˜‹

tender shard
#

or more Essentials skripts

paper viper
#

๐Ÿ˜‹ ๐Ÿ˜‹

tender shard
#

i found a good skript today

paper viper
#

show

grave mason
#

I will go for now, thanks for all and have a nice day :)

grave mason
tender shard
#

who cares

#

yesterday I went to sleep at 7.30 am

grave mason
#

xD

tender shard
#

best plugin name

quaint mantle
#

Could someone help explain how to setup TabCompletion with CommandMap?

tender shard
tender shard
#

best essentials replacement ever

quaint mantle
#

I have a command and i wanna have tab completion for it's subcommands

tender shard
#

you can create a new class that implements TabCompleter

#

or make your commandexecutor implement that

quaint mantle
#

it does

tender shard
#

similar to onCommand, there's a onTabComplete method

#

then from that, you can just return a List<String> with the tab completions

quaint mantle
#

and i register all that with CommandMap?

tender shard
#

you do not need to mess with any commandmap at all

quaint mantle
#

yea but it makes command handlers easier

paper viper
#

what

tender shard
#
public void onEnable() {
  getCommand("test").setExecutor(myCommandExecutor);
  getCommand("test").setTabCompletor(myTabCompletor);
tender shard
#

are you talking about the PluginManager's SimpleCommandMap?

quaint mantle
#

yes

tender shard
#

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

quaint mantle
tender shard
tender shard
#

no idea why you thought about touching the commandmap

tender shard
#

what exactly are you trying to do?

quaint mantle
#

the first plugin tutorial i found used it for a handler so i thought i should just keep it like that

tender shard
tall dragon
tender shard
#

so that the vanilla server spawns them by itself?

#

like "naturally" on stone etc?

tall dragon
#

uhuh

#

or from spawners in mid air ๐Ÿ˜„

tender shard
#

hmmm

#

I'm bored anyway so I'll just dig through some NMS, maybe I'll find something useful

tall dragon
#

the lil piece of code is bassically all it took for 1.8 :/

tender shard
#

only thing I found yet is the static checkMushroomSpawnRules method

tall dragon
#

and some code to replace the entity

tender shard
#

so Mob has a "checkSpawnRules" method

#

the BaseSpawner checks that method before spawning anything

next zinc
#

Anyone know a working custom skull API that works in 1.18.2?

tender shard
tall dragon
#

ah yea

#

that indeed looks like the method

tender shard
tall dragon
#

thats annoying me

next zinc
#

jesus that was quick

tall dragon
#

so how will i go about to change that Hmmm

tender shard
next zinc
#

Lmao

tender shard
#

I don't think you can

next zinc
#

tysm

tender shard
#

np

tall dragon
tender shard
#

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

tall dragon
#

well thats extremely unfortunate

#

well thanks for looking into it anyway ๐Ÿ‘

next zinc
#

Is there a way to use the library by getting a jar of it?

#

to insert into a build path

tender shard
tender shard
#

but sure you can also just download it

#

1 sec

next zinc
#

never was able to get that working on eclipse

tender shard
tall dragon
next zinc
#

tysm

tender shard
#

I 100% recommend trying out intelliJ, you won't regret it

next zinc
#

I used it once

tender shard
#

and also directly switch to maven

#

here's a blog post I wrote to get a working setup with intellij + maven

next zinc
#

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

tender shard
#

once you got that working you never wanna go back to eclipse + "build artifacts"

next zinc
#

lmao

tender shard
#

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

tall dragon
#

i used eclipse for 2 hours. and i was done with it, downloaded intellij never looked back

paper viper
#

coming back, i realize how much I fucking hate both maven and gradle because of how inconveinant they are

tender shard
paper viper
#

it exponentially gets slower the more libraries you add

next zinc
#

Eclipse just seems easier to use at first to me hence why I stuck with it

paper viper
#

compared to the golang built in package system its so much worse

next zinc
#

mans a mind reader

paper viper
next zinc
#

Ill definitely try it out

paper viper
#

and now i always use it

#

lol

tender shard
#

btw my ultimate license expires tomorrow >.<

paper viper
#

hah i have github student dev

#

L

tender shard
#

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

river oracle
#

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

next zinc
#

Guess I got a bit overconfident, but how would I access the SkullUtils portion of the library?

next zinc
#

I basically want to set an ItemStack as a custom head

tender shard
#

you want to place it in the world?

#

or you want to get an ItemStack with a custom texture into an inventory etc?

next zinc
#

I want to be able to give a player a customized player head

#

and them have it in their inventory

tender shard
#

okay so SkullUtils.getHead("someBase64String") gets you an itemstack

#

then you can just do player.getInvenotry().addItem(...)

next zinc
#

So I don't gotta do any fancy initalization?

tender shard
#

nooo those are all static methods

next zinc
#

that makes life so much easier

tender shard
#

it's just SkullUtils.getHead(...)

next zinc
#

Ah

#

So then would the base64texutre accept like IDs from the heads value?

tender shard
#

yes, like from all those websites

#

one sec

next zinc
#

That is exactly what I was looking for

#

Awesome!

tender shard
#

example for this

#

scroll down where it says "Value"

#

the second last field

next zinc
tender shard
#

exactly

next zinc
#

this one right?

#

I had an API that did it before, but it doesnt work in 1.18.2

tender shard
#

ItemStack head = SkullUtils.getHead("eyJ015135af....");

next zinc
#

so the fact that this does is awesome

#

tysm

tender shard
#

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

next zinc
#

Usually putting the jar into the build path works

tender shard
#

oh oki

next zinc
#

im about to test it to see if it works

#

so Ill lyk

tender shard
#

alrighty

next zinc
#

Thats strange

#

The string is causing an error

#

The method getBase64Texture(SkullMeta) in the type SkullUtils is not applicable for the arguments (String)

tender shard
#

what's your code?

#

as said, it works like this:

#
ItemStack myCustomHead = SkullUtils.getHead("afwuawfkuawfgkawfu  (the base64 string)");
next zinc
#
ItemStack fCore = SkullUtils.getBase64Texture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzc1YmNhMWFmNWNiMTU1N2MxNzk0ZDIzZDkwN2RmMTE1OTMyMGUxNGViYTA1ODFjMjUxODdkYmViMjJiYTJjYyJ9fX0=");
tender shard
#

getBase64Texture is to extract the base64 texture from an existing skull

next zinc
#

Ah

#

so whats the first string then?

tender shard
#
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

next zinc
#

Ohhh

#

gotcha

tender shard
#

yeah it's a bit misleading but actually it makes sense

#

you want to GET a head FROM base64, so you use getHead

next zinc
#

Didn't realize base64 was the value so that makes sense now

tender shard
#

if you want to to do the opposite - get a BASE64 FROM a head, you'd use getBase64Texture

tender shard
next zinc
#

lmao

#

alr moment of truth

tender shard
#

my bet is - you'll get a ClassNotFoundException because eclipse didn'T shade it ๐Ÿ˜›

#

let's see

next zinc
#

I really dont want to admit that you're correct

#

but there was an error

tender shard
#

?paste it

undone axleBOT
next zinc
#

idek what that error is even saying

tender shard
#

?paste the complete log

undone axleBOT
tender shard
#

there was another exception above

#

which prevented your plugin from enabling

next zinc
#

Yep

#

you right

#

ClassNotFoundException

#

?paste

undone axleBOT
next zinc
#

might be a new error

tender shard
#

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"

next zinc
#

I hope so

tender shard
#

if not, this is the proper time to switch to maven ๐Ÿ˜›

next zinc
#

oof

#

think you rightg

#

*right

tender shard
#

๐Ÿ˜„

#

it's really not complicated

#

in fact it makes your life so much easier

#

it's only complicated the first 30 minutes

next zinc
#

true

tender shard
#

I still remember when someone wanted to talk me into maven

next zinc
#

better to set it up and be easy afterwards I guess then pure pain

tender shard
#

and I was like "ugh what a bullshit"

next zinc
#

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

tender shard
#

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

next zinc
#

That dude was insanely nice

tender shard
#

indeed

#

I am so glad

#

I thanked him like again 3 years later lol

next zinc
#

im just on that part

#

insane lore

tender shard
#

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

next zinc
#

yeah

tender shard
#

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

next zinc
#

lmao

#

dang intelliJ looks different

tender shard
#

well

next zinc
#

at least from when I first used it

tender shard
#

left and right are some menus and in the middle there's your source code lol

#

not sooo different ๐Ÿ˜„

next zinc
#

true

#

alr ima follow your blog

#

see how that goes

tender shard
#

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

next zinc
#

Smart

#

Woah

#

wait

#

in plugin.yml author is supposed to be in quotes

#

I have never done that

tender shard
#

doesn't matter

next zinc
#

o ok

tender shard
#

it's normal YAML syntax

#

everything that is valid YAML is okay

next zinc
#

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
tender shard
#

yes, that looks good

#

your package names does NOT have to match your maven groupID but it's quite common to use matching names

next zinc
#

I made my package name something else?

#

Or was that just a general statement

tender shard
#

if I was you, I would use the following names:

#

groupId: io.github.darkenedfusion

#

artifactId: HelloWorldPlugin

#

main class name: io.github.helloworldplugin.Main

next zinc
#

why remove the darkenedfusion part?

tender shard
#

oh

#

mstake

next zinc
#

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

tender shard
#

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

next zinc
#

So once you have all of that, thats pretty much it?

tender shard
#

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

next zinc
#

Yeah

#

I see so many libraries have that maven thing

#

so it limited my choices when there was no jar

tender shard
#

tbh any library that does NOT provide a maven artifact is probably shitty

next zinc
#

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

tender shard
#

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

next zinc
#

ah

tender shard
#

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

next zinc
#

Interesting

#

Never heard of that term till now

tender shard
#

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

next zinc
#

I just built the plugin

#

now I gotta find where it went

tender shard
#

it's at "<projectFolder>/target"

next zinc
#

YO

#

THATS SO EASY

tender shard
#

yep lol

next zinc
#

only slight thing I can think of

tender shard
#

it's a bit weird to setup because you need the pom.xml but after that, just double click "package" and that's it

next zinc
#

yeah

#

would there be a way to like

#

auto build it to a specific folder?

next zinc
#

since in eclipse when I exported the file it went directly into my servers plugin folder

#

dang

tender shard
#

oh wait

#

you don't have a <build> section in your pom yet

#

one second I'll send an example

next zinc
#

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>
tender shard
#

at the bottom you have the <build> thing, yes

#

insert this:

next zinc
#

so just add <plugin>

tender shard
#
        <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

next zinc
#

the group and artifact thing dont change right?

tender shard
#

you mean when you choose a custom folder for it to build?

#

no that has nothing to do with each other

next zinc
#

mk

#

just making sure

tender shard
#

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

next zinc
#

I see

#

Well the good news

#

is it worked!

tender shard
#

perfect ๐Ÿ™‚

#

okay now the tricky part is to turn your existing project into a working maven project

next zinc
#

I mean it seems simple enough now

tender shard
#

since you used eclipse, your whole build setup is probably "messed up" from mavens perspective

next zinc
#

I hope

tender shard
#

if you like, you can just upload your whole project to github and I'll turn it into a structure that maven undertsands

next zinc
#

that would be awesome

#

gimme one second

tender shard
#

sure, no problem

next zinc
#

Doesn't intelliJ have an auto update github thing as well?

tender shard
#

of course

next zinc
#

eclipse doesnt have that ๐Ÿคก

#

Ive just been dragging files

tender shard
#

File -> Settings -> Version Control -> GitHub

#

then you can login with your account

next zinc
#

awesome

tender shard
#

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

next zinc
#

Ooo

#

Thats useful

tender shard
#

you'll love intellij

next zinc
#

I can definitely see the appeal

#

oh frick

tender shard
#

when I tried intellij the first time, I hated it because I couldnt just do File -> Export .jar

next zinc
#

I might've accidently deleted the plugin file

tender shard
#

huh

#

the plugin file? or the source code

#

if you accidently deleted the source code, that's... fucking inconvenient lol

next zinc
#

just a tiny bit

#

It aint showing up in my recycling bin

#

FOUND IT

#

THNAK GOD

tender shard
#

๐Ÿ˜‚

next zinc
#

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

tender shard
#

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

next zinc
#

I totally know how to do that

tender shard
#

yeah okay then fuck it

#

then I'll just fork it

next zinc
#

lmao sorry

#

Most I've done is commit a repository

tender shard
#

np lol

#

ok gimme 5 minutes

next zinc
#

Take as much time as you need

#

You've already helped me so much

tender shard
#

did you add any dependencies besides spigot api?

next zinc
#

only other thing was ur jar file

tender shard
#

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

next zinc
#

Seems simple enough

#

So whenever creating a new project

#

put the spigot file in the resources folder

tender shard
#

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>

next zinc
#

So that will fetch the plugins name without me manually typing it?

tender shard
#

no, actually it is irrelevant how you call it

#

it's just convention

next zinc
#

so just placeholder text

tender shard
#

I'll also directly add my library to your pom

#

afk 3 mins

next zinc
#

kk

tender shard
#

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

next zinc
#

Ahh

#

Thats pretty cool

tender shard
#

seems to be working, one sec

next zinc
#

๐Ÿ‘Œ

tender shard
#

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?

next zinc
#

I uploaded it with eclipse

tender shard
#

ok

#

go to your repo on github, then accept my pull request

#

basically you have to merge it

next zinc
#

yep

#

I believe it merged

tender shard
#

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

next zinc
#

Interesting