#help-development

1 messages · Page 2027 of 1

tender shard
#

the namespacedkeys are a wonderful things

#

it lets two plugins use the same "key names" without getting into trouble

glossy venture
#

ok sure

dire marsh
#

wasn't it mojang that brought about that change

tender shard
#

not for NBT

glossy venture
#

nah normal nbt tags use strings

dire marsh
#

oh right

glossy venture
#

and pdc is a bukkit invention im pretty sure

tender shard
#

Yes

#

it was added in spigot 1.14.1

#

and since 1.16.3, even chunks have PDC

#

that makes you able to store information inside blocks

#

World also implements PersistentDataHolder in 1.18.2 (or in 1.19? i dont remember)

#

nah I think I've seen it being merged so it's probably already added lol

quaint mantle
#

Would it be better for me to make a folder for items, and have a class for every item, instead of loading then in 1 area?

#

Idk it feels inefficient the way im doing it so far

hasty prawn
#

It'd be more organized if you did that

#

Not really more efficient

viral crag
#

one should be able to look at their code and instantly find what they are looking for - If you follow RAD you would break it up into logical chunks that do specific things - however that also has its own issues

quaint mantle
#

only question is: how would I load all of the items

quiet ice
#

items as in?

hasty prawn
#

I assume basically the same way you're doing it now

viral crag
#

do you use the package and import tags now?

sonic idol
#

how do I use net.minecraft imports?

quiet ice
#

bind against spigot instead of spigot-api

sonic idol
#

can I get the example code?

#

oh my pom.xml

hasty prawn
#

There's no code for that, it's changing your imports

#

Not imports

#

Dependencies

sonic idol
#

I changed spigot-api to spigot errors?

hasty prawn
#

What errors

quiet ice
#

Did you run bt yet?

sonic idol
#

1.18.1-R0.1-SNAPSHOT not found

sonic idol
hasty prawn
#

BuildTools

quiet ice
#

?bt

undone axleBOT
young knoll
#

?bt

undone axleBOT
sonic idol
#

I used a plugin to do setup for me

#

in intellij

viral crag
#

that plugin doesnt actually really do that

sonic idol
#

I have to redo the plugin don't I

hasty prawn
#

No

viral crag
#

you just need to setup maven or gradle properly

sonic idol
#

its has maven setup

#

already

quiet ice
#

You just have to run buildtools

sonic idol
#

where do I put the .jar?

quiet ice
#

It's as simple as invoking a java jar

#

Anywhere, though I recommend putting it in an empty folder so you can delete the folder afterwards

sonic idol
#

I cant figure out how to download it from the website lol

viral crag
#

... you sure you actually need it if you cant run build tools?

sonic idol
#

I know it says dangie but its not

#

its wokring

#

working on installing

quiet ice
#

Also you need to pass a few arguments to the bt jar but I have no idea what they are given that I am a staunch anti-nms crusader

viral crag
#

the ones selecting version etc

young knoll
#

All you need is version

tender shard
young knoll
#

Assuming you don’t want 1.18.1

glossy venture
#

oh wait you can force a push using git push origin master -f

#

even if there is a conflict

#

useful to know

quiet ice
#

Or just git push -f

glossy venture
#

i dont have upstream set yet

viral crag
#

yeah, try not to force git

quiet ice
#

That being said DO NOT FORCE PUSH

quaint mantle
#

Any way to store ItemStacks or Entity in PDC

tender shard
glossy venture
#

you can store a uuid

quiet ice
#

Write your own serializer I guess

glossy venture
#

to an entity

tender shard
glossy venture
#

or do you want to store the entity data

quaint mantle
tender shard
#

for entities, you gotta serialize them somehow, someone here did a library

tender shard
#

a lot

quaint mantle
sonic idol
quiet ice
#

I have a ton of custom stuff on the compilation side of things, but noone needs that

tender shard
sonic idol
#

I don't use build tools

#

to run a server

tender shard
#

didnt you ask on how to use NMS?

quiet ice
#

paper?

#

he uses 1.18.1

sonic idol
glossy venture
#

you need to include a server jar

#

fully shaded

#

instead of the api

tender shard
#

I've sent two blog posts about using NMS, if you don't read them, then it's your problem

glossy venture
#

i would recommend using buildtools

#

and then importing it from maven local

quiet ice
#

?bootstrap or just do these steps

undone axleBOT
#

Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.

Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163

viral crag
tender shard
#

?bt

undone axleBOT
quiet ice
#

We already linked them that site a couple of times - Sometimes ignorance isn't bliss.

tender shard
#

well if they don't read, that's none of our business

glossy venture
#

actually im using paperwight

tender shard
#

is there a way to unignore files in .gitignore?

#

I basically want to do this:

viral crag
#

remove them from the file

tender shard
#

.gitignore:

target/*
// but NOT target/log.xml
viral crag
#

or use the command

quiet ice
#

!file

#

iirc

tender shard
#

thanks

opal juniper
#

need a, .gitinclude

buoyant viper
#

true

tender shard
#

you know what

viral crag
#

dont give them ideas

tender shard
#

I just clicked the file in intellij and used git -> add

#

no idea how it did it, but it did it

#

lol

quiet ice
#

it just ran the git add xyz command

buoyant viper
#

yeah u can like override the git ignore

quiet ice
#

if you specify a file directly it'll warn you but will let you add the file regardless of gitignore association

viral crag
opal juniper
#

thats a feature

quiet ice
sonic idol
#

I CANT FIGURE THIS OUT

quiet ice
#

In 99% of cases you are doing it knowingly

viral crag
#

it used to continue to ignore the file

glossy venture
#

easy to configure

sonic idol
#

whats that

#

ALL I NEED IS TO USE NET.MINECRAFT STUFF

quiet ice
#

they are using maven though iirc

glossy venture
#

its a plugin to remap the paper server

quiet ice
#

Why do you need nms in the first place?

glossy venture
#

are you using maven or gradle?

sonic idol
#

for packets

glossy venture
#

if ur using maven use specialsource

sonic idol
#

this packet

#

PacketPlayOutGameStateChange

quiet ice
#

There are libraries for that

tender shard
#

you didn't read them

viral crag
#

maybe they only watch YT

quiet ice
#

And we have sent you the buildtools instructions multiple times so that cannot be the issue either

sonic idol
#

I DONT KNOW HOW TO USE BT

tender shard
#

lol allatori stores it's own log output inside a comment within it's log.xml file. that's... a weird way to do it

tender shard
undone axleBOT
tender shard
#

THEN READ THIS

#

ITS EXPLAINED THERE

glossy venture
# sonic idol I DONT KNOW HOW TO USE BT

download and run buildtools with --remapped, include the uploaded jar in your project through mavenlocal, dependency descriptor io.papermc.paper:dev-bundle:minecraftversion-R0.1-SNAPSHOT, enable specialsource for building and youre good.

#

thats a full guide

quiet ice
glossy venture
#

excluding specialsource setup because i dont use maven

tender shard
glossy venture
#

have you even tried

#

you havent told us anything

sonic idol
#

I DONT KNOW HOW TO USE IT AFTER BUILD

tender shard
#

this felt good

glossy venture
#

lmfaoo

tender shard
#

I suggest everyone to do the same

glossy venture
sonic idol
#

I can even show you

glossy venture
#

I JUST DESCRIBED HOW

sonic idol
#

how

#

hmmmmm

sonic idol
#

i DID RUN BT

quiet ice
#

Just use protocol API instead of nms

glossy venture
#

thats not all it says

sonic idol
#

I tried but I couldn't figure out

quiet ice
#

If you are struggling that hard you will not be able to use it

#

Trust me

sonic idol
#

PROTOCOLLIB

glossy venture
#

here is how i do it in gradle

sonic idol
#

I need maven

quiet ice
#

^

#

Ugh, I should really try to introduce a third build tool into this world to cause more havoc

sonic idol
#

I dont get it

buoyant viper
#

step 0, download and install Java 17 JDK from oracle.com

step 1, download BuildTools.jar from spigotmc.org

step 2, go to the directory you downloaded BuildTools.jar to

step 3, open command prompt (or terminal) and type in java -jar BuildTools.jar --remapped --rev 1.18.2

step 4, ... profit?

sonic idol
#

BT WONT WORK FOR ME TO COMPLICATED

viral crag
#

It makes me feel better I am not the only one who has this type of argument problem

quiet ice
sonic idol
#

GETTING THE PROJECT

#

IMPORTED

buoyant viper
#

u make a new Maven project in something like IntelliJ and add org.spigotmc:spigot as a dependency

sonic idol
#

I DONT KNOW HOW TO DO THAT

tacit drift
#

PotionEffectType#getName() returns this?

sonic idol
#

ANY YOUTUBE TUTOIRALS

buoyant viper
#

theres also specialsource stuff but idk how it works

quiet ice
#

Then you add tons of plugins and plugin configurations and you are done

sonic idol
#

gjfidjgisg

brave sparrow
viral crag
rough drift
#

THANK YOU

buoyant viper
#

what if theyre me, what if they hold their shift key

buoyant viper
#

mf turned irish

brave sparrow
#

But you may not be capable of doing it

tender shard
#

just everyone block this troll

#

he's just messing with you

quiet ice
brave sparrow
#

Regardless of how much you “need” it you’re just not competent enough to pull it off

quiet ice
#

It is at least 200 times easier to use than nms

tender shard
#

WHAT

#

are you drunk

#

protocollib is so much more complicated

quiet ice
#

Especially because it has documentation

tender shard
#

at least for sending packets

quiet ice
#

There are hundreds of other APIs out there, just pick one

#

the beauty of fragmentation

buoyant viper
#

whats that one retrooper contributed to

tacit drift
#

PacketEvents?

buoyant viper
#

yeah

crude loom
#

Is it possible to store objects in config files?

quiet ice
#

It depends

#

What sort of objects?

brave sparrow
quiet ice
#

Wiki.vg is equally applicable to protocollib

buoyant viper
rough drift
#

step 6, fuck off and inject your own handler into the player's netty pipeline

quiet ice
#

it is just the documentation of the protocol, but not the documentation on how nms works

crude loom
# quiet ice What sort of objects?

Because I'm having this weird bug, I'm trying to save a ChatColor object in the config and every time I reload the plugin it removes it, specifically the objects of type ChatColor, but when I turned them into a string, it doesn't remove them. Does this mean storing these isn't possible?

buoyant viper
rough drift
#

ofc it is

quiet ice
#

that is because chatcolor is not ConfigurationSerialisable

rough drift
#

but its much more stuff with PL than standard netty iirc

#

its a single line of code to inject your handler

#

then ofc you need the handler

rough drift
#

but that's beside the point

crude loom
rough drift
#

actually like, 80 chars

rough drift
quiet ice
rough drift
#

unless, ofc, you just write the color code

quiet ice
#

Except for maps, lists, strings and primitive wrapper objects that is

crude loom
#

So there are specific objects I can store in the config?

quiet ice
#

Yes

sonic idol
tender shard
sonic idol
#

see

#

I need to import

#

but Idk how

tender shard
#

because you keep ignoring the blog post I sent

rough drift
undone axleBOT
rough drift
#

thank me later

quiet ice
#

Now you can just delete that folder if I am right

rough drift
#

@tender shard ignore @sonic idol

crude loom
rough drift
#

they are just trolls

quiet ice
#

he already did

sonic idol
#

HELP ME IMPORT

#

NOWWWWWWWW

quiet ice
tender shard
rough drift
#

maybe later

quiet ice
#

Any class that more or less has class ABC implements XYZ { in it's head

brave sparrow
tender shard
#

interfaces are one of the basic concepts of java

sonic idol
#

THIS CHANNEL IS HELPING PEOPLE

quiet ice
sonic idol
#

NOT, NOT HELPING PEOPLE

crude loom
#

I see, I will look into it, thanks for the help! :D

rough drift
quiet ice
sonic idol
#

IM 13

rough drift
#

I HARDLY BELIEVE THAT

brave sparrow
#

@sonic idol you don’t have the requisite base understanding to be helped

sonic idol
#

YOU CANT JUST BELIVE THAT SOMEONE IS UNDER AGED

rough drift
brave sparrow
#

You don’t have enough knowledge for us to build on and help you

sonic idol
#

IM NOT

#

IM 13

brave sparrow
#

13 is a child

sonic idol
#

IM 13 IM 13

brave sparrow
#

Lol

rough drift
#

YOU NEED TO BE 18 TO BE AN ADULT

#

DID YOU FORGET THAT

sonic idol
#

READ TJE TPS

#

TOS

#

ITS SAYS 13 OR OLDER

#

BIG BRAIN

quiet ice
#

@ancient plank uh, I think you need to deescalate this situation right now

visual tide
#

jesus christ just ignore trolls

sonic idol
#

IM NOT A TROLL

visual tide
#

they want a reaction

rough drift
#

(or 13 and less if allowed by guardian/parents)

tender shard
rough drift
#

yeah

#

lemme block

#

done

#

feels good

quiet ice
#

sadly blocking on discord is not as usefull as block over at irc

brave sparrow
#

@sonic idol regardless of whether you’re a troll or not, you simply don’t know enough for us to help you

brave sparrow
quiet ice
#

because in irc space ignoring someone means ignoring

sonic idol
#

IM GETTING HELP SOMEWERE ELSE IM LEAVING SPIGOT MC DEVELPEMENT COMPLETY

rough drift
brave sparrow
#

I’m on here for shits and giggles

#

It’s not like they’re wasting my time

rough drift
#

get rekt

#

get rekt

#

get rekt

#

get rekt

quiet ice
#

yeah, why are we wasting our own time

brave sparrow
#

You lot might be

#

I’m just killing time until dinner

tender shard
#

does BetterDiscord have a noption to completely make blocked messages invisible?

rough drift
#

i don't have BD anymore tho

quaint mantle
#

@tender shard Can you resend that file or whatever

#

for custom values

#

cant remember what its called e.e

tender shard
#

oh you mean my lib for storing itemstacks in PDC?

tender shard
viral crag
#

wonder how they will do on the papermc server

rough drift
#

good lib @tender shard

kindred valley
#

how can i calculate factorial

quaint mantle
quiet ice
#

Just run the algorithm to calculate a factorial

kindred valley
quiet ice
#

Was is the 4! = 1 * 2 * 3 * 4 stuff or nah?

kindred valley
quiet ice
#
long val = x;
while (--x != 0) {
   val *= x;
}

pretty easy until you optimise it

kindred valley
tender shard
#

IntelliJ is really weird sometimes...
why does it ask me to update gson, but doesn't ask me to update Stepsister?

quiet ice
#

okay, wtf

tender shard
quiet ice
#

There is no need for a comment

#

there are children here you know

solar sable
#

cause ik abt the stepsister but idk what the joke is

fallen sandal
#

how to send a command to console using my plugin?

rough drift
fallen sandal
#

i tried this stuff

#

getServer().dispatchCommand(getServer().getConsoleSender(), "tps"))

#

but it didnt worked trying yours

rough drift
#

and you forgot ;

tender shard
tender shard
#

but you don't have any paid plugins?! 😄

rough drift
#

yes, but when i make one

fallen sandal
#

and how to get a exact player name?

rough drift
#

if i will

tender shard
rough drift
fallen sandal
#

partialName?

rough drift
#

you want to convert from like

#

AKA to AKASHBRO_

fallen sandal
#

oh

#

Cannot resolve method 'getPlayer()'

#

cant i make this field empty?

#

like this

#

Player p = Bukkit.getPlayer("").getName();

glossy venture
#

that will probably choose or no player or the first one in the player list

fallen sandal
#

response.editMessageFormat(String.valueOf(Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tps")));

#

no error coming

#

and this thing is not working too

viral crag
#

what do you think it should give you?

#

I am not sure getting the string result of dispatchCommand() is really that useful to you

Returns:
returns false if no target is found
crude loom
#

Is it possible to store chars in a config file?

viral crag
#

sure - can store numbers as well

fallen sandal
crude loom
#

I see, thanks!

fallen sandal
#

i was testing the tps thing

#

if it works then I will test another command here :))

viral crag
fallen sandal
#

but its not working tho

fallen sandal
viral crag
#

all you will get is true or false as a string result

fallen sandal
#

then how to send it to discord am using jda?

viral crag
#

are you trying to get the TPS value as a response?

fallen sandal
#

yes

viral crag
#

you will have to catch the response

fallen sandal
#

but its not sending any command in the console tho

viral crag
fallen sandal
#

maybe

viral crag
#

hahaha

#

okay, you need to figure out which side is not working for you

#

"TPS" is not a valid command on my servers

#

however "tps" is a valid command (that said my response comes from TabTPS)

fallen sandal
#

ok

quaint mantle
#

how do in only drop enchanted items on Deathevent ?

viral crag
#

my guess is that you would have to check the players inventory for them

quaint mantle
#

Do I have to use hasmaps to make.. hashmaps?

Or can I just go like this or smth:

test = {"NoStack":true};
#

kinda lazy and dont wanna have to type out hasmaps

#

:/

hollow bluff
viral crag
hollow bluff
viral crag
quaint mantle
#

for (ItemStack items: event.getDrops()){
if(items.getEnchantments().isEmpty()){

        }
    }

Thats my current code , sorry i dont know how to use codeblocks

hollow bluff
quaint mantle
#

and how to remove all of them, and only drop the enchanted on death ?

#

yea

viral crag
#

ah, then check for non-enchantes and remove them

buoyant viper
quaint mantle
#

so i pass the "items" into remove ?

#

thats it ?

quaint mantle
buoyant viper
#

u could do like

Map<String, Boolean> theMap = new HashMap<>() {
    {
        this.put("NoStack", true);
    }
};```
quaint mantle
#

it still drops everything when i die

undone axleBOT
quaint mantle
#

i forgot the eventhandler, sorry i am stupid haha

#

than thas why it didnt work with 2 of my versions before 😄

#

still dropps everything

#

yup

undone axleBOT
quaint mantle
#

getServer().getPluginManager().registerEvents(new PlayerDeathListener(),this);

#

how do i do that ?

undone axleBOT
quaint mantle
#

it works, thanks a lot

#

can i dm you really quick ?

#

i cant cause we arent friends

viral crag
#

if he checks the player inventory there is no need to wait

#

yeah drop happens after ondeath

#

there are possibly two issues that I can think of with using the drop instead: concurrent players dying and keep inventory turned on

latent pilot
#

can anyone help me? switched my plugin from 1.16 to 1.18 and it's now saying it cant find my main class. tried everything, but nothing works

viral crag
hasty prawn
#

17

latent pilot
#

16? thought it was 17

hasty prawn
#

it is

#

Is your IDE saying that or the server

latent pilot
#

the server

hasty prawn
#

Send your plugin.yml

viral crag
#

what version of java is your server running on?

latent pilot
#
main: com.servers.AllOfTheThings.Main
name: AllOfTheThings
version: 2.2
description: All moderation and extra items for the server.
api-version: 1.18
viral crag
#

api-version

hasty prawn
#

And com.servers.AllOfTheThings.Main exists?

hasty prawn
#

heh, you knew I was gonna ask that

#

That's odd, could you paste the full error?

#

?paste

undone axleBOT
latent pilot
#

and main extends JavaPlugin

viral crag
#
api-version
The version of the API you want to use.
1.13, 1.14, 1.15, 1.16,1.17 and 1.18 are the available versions.
This will signal to the server that your plugin has been coded with a specific server version in mind, and that it should not apply any sort of backwards compatibility measures. 
quiet ice
#

Is there any error around it?

viral crag
latent pilot
#

no i switched it from 1.16 to 1.18

quiet ice
#

spigot-api-1.18.2-R0.1-SNAPSHOT.jar:? how come you think that this is 1.16?

latent pilot
#

so its on a 1.16 server

quiet ice
#

?stash

undone axleBOT
latent pilot
#

or 1.18

hasty prawn
#

It seems like your Main class isn't being compiled

#

Not really even sure how that's possible

#

How are you building the jar

kind hatch
#

How are you compiling your plugin? Manually, maven?

latent pilot
viral crag
#

i think if you specify a repo that doesnt match the api-version intellij is stupid about it

latent pilot
quiet ice
#

ah that explains it

kind hatch
#

Ok

quiet ice
#

Your source dir should be src/main/java

#

not src

#

(just use maven or gradle tbh)

latent pilot
#

so instead of src, it's java?

quiet ice
#

Yeah

latent pilot
#

ill try that

quiet ice
#

You might also want to unzip the jar to check if all files are where you think they are

quiet ice
kind hatch
#

I'd check your artifacts to see if it's set up correctly.

The way I used to do this was as follows.
File ---> Project Structure ---> Artifacts ---> Click the + Icon ---> Select JAR ---> Choose from modules with dependencies ---> Click OK.
Then select everything except your plugin's compile output and delete it from the Output Layout section.

tardy delta
#

maven is something lol

lavish hemlock
#

I like Maven

#

except when I need to do anything complicated

#

that's when Maven becomes 100x worse

latent pilot
#

i should probably use maven

lavish hemlock
#

the other day I had a fucking anger meltdown because I couldn't figure out how to do the following:

  • Compile submodule agent
  • Compile submodule lib with the binary of agent inside lib's binary
viral crag
#

save yourself and learn gradle

quiet ice
#

that is where you are wrong

lavish hemlock
quiet ice
#

Gradle is absolute pain

viral crag
lavish hemlock
#

Maven is at least faster than Gradle so that's why I use it.

quiet ice
#

That is something you do not hear often

lavish hemlock
#

...yeah.

viral crag
#

that speed argument is a red herring

lavish hemlock
#

Wdym?

#

It just is

viral crag
#

it is relative to how the tools are used

lavish hemlock
#

Tip, set the following environment variable: MAVEN_OPTS=-Xmx1G -Xms512M

lavish hemlock
quiet ice
#

1G of mem seems quite a lot low

lavish hemlock
#

There is such thing as a "bottleneck" when it comes to software

viral crag
#

if you delete you cache everytime you use gradle, yes it is slower, just the same as it is with maven if you delete its download cache

lavish hemlock
quiet ice
#

I can affirm that gradle is a bit unnecessary slow

lavish hemlock
#

If you were to use both with caches enabled, Maven would still be faster.

#

I can attest to this because I've used both.

viral crag
#

if you properly used both tools, faster would depend on the scale/size of the code you were building

lavish hemlock
#

Then just benchmark it on the same project lol

quiet ice
#

don't both use javac internally?

lavish hemlock
quiet ice
#

I know that maven can use eclipsec, but that isn't default iirc

lavish hemlock
#

Gradle allows you to use either javac on the command-line or the Compiler API.

viral crag
lavish hemlock
#

Well, that is effectively how you argue speed

lavish hemlock
#

Never looked into it

quiet ice
#

probably the same there though. Which would invalidate the speed argument

lavish hemlock
quiet ice
#

although apparently gradle uses incremental builds, not sure how it is handled

lavish hemlock
#

Isn't Maven 3.6 also outdated?

quiet ice
#

gradle 5 is also outdated

lavish hemlock
#

Yeah

#

I also don't really trust Gradle's reports, but that's my own opinion

ivory sleet
#

From my experience maven suffers in speed when if I were to have a bunch of modules/subprojects, whereas gradle seems to be performing relatively well in that aspect

lavish hemlock
#

Gradle is for-profit

lavish hemlock
#

I blame this primarily on Maven not being designed around modules initially

quiet ice
#

I have maven 3.6.3 installed, so maven 3.6 is not that outdated

lavish hemlock
#

I thought there was a Maven 4?

#

Maven's implementation of modules is also just really bad

hasty prawn
#

I need to optimize my gradle project, takes like atleast 15 seconds to build my project smh

#

It's because of remapping all my sub projects NotLikeThis

waxen plinth
#

After the daemon is started mine all build in <1s

hasty prawn
#

I was too lazy to do it right I just wanted it to work

waxen plinth
#

From a clean build

lavish hemlock
#

I can build my Maven project in like 2s

#

And that's for every run, no need for a daemon

#

Well sometimes it goes up to 13s but that's like when I compile a project for the very first time

#

Actually

#

I don't know why it does that

#

Timing is a bit inconsistent 🤷‍♂️

viral crag
lavish hemlock
#

Ah

#

There is one problem I have with both Maven and Gradle

#

And that's just the fact that they've got terrible APIs

#

Maven is a bit too "enterprise Java," while Gradle is just impossible to use because of its dynamicness.

#

(Note: I'm basing this off my experience with Maven's Resolver API and Gradle's Plugin API)

quiet ice
#

Maven's resolver api is interesting to say the least. Ended up writing my own one

lavish hemlock
#

It makes sense

#

It's just not fun to use

#

I've been trying to find alternatives to it

#

A problem I have libs is that they're overly reliant on javadocs.

#

It is really hard to find the "start" of a library, essentially

#

The piece of code that allows you to access the entrypoint

#

Maven has examples but honestly they're shittily organized

glossy venture
#

i usually call that the bootstrap

quiet ice
#

Well, in the resolver's case it is not a bootstrap but rather a context

glossy venture
#

so the one that for example extends JavaPlugin in the case of a plugin

#

yeah

quiet ice
#

And then you create another context from that context which allows to resolve stuff

lavish hemlock
#

(Also: Maven Resolver essentially forces consumers to use dependency injection frameworks)

quiet ice
#

But before that you need to register you local maven repository at which point you gotta create another context

lavish hemlock
#

(It has a manual service locator system, but that's going to be removed eventually)

quiet ice
lavish hemlock
#

Dependency injection frameworks are cool, except for a few things

hard lion
#

Vectors Help

lavish hemlock
#
  • It is impossible to track the structure of a library when DI is used
  • There is a minor overhead to them (unless you use something like Dagger)
#

(Also they're just not as easy to use as they could be, but that's my opinion)

tardy delta
#

kekw (╯°□°)╯︵ ┻━┻

craggy cosmosBOT
#

:dynoError: The Fun module is disabled in this server.

lavish hemlock
#

Fun is dead

hasty prawn
#

:(

lavish hemlock
#

No more fun

#

Only programming

hasty prawn
lavish hemlock
#

?services

undone axleBOT
lavish hemlock
#

Also

#

$2 is way too little

#

Even if it's a simple plugin

shadow night
#

how do I make a server send a message?

#

wait I said the wrong thing lol

#

I mean how to make a player send a message

#

thanks

dark arrow
#

I have created a custom enchant which works fine but when I add any other enchant with it using anvil the powers of the custom enchants goes

#

So is there any way to fix it

raw ibex
tender shard
#

you should use PDC to store custom enchantments

#

the Enchantment class/interface isn't meant to be used by plugins at all

quaint mantle
#

uhhh, how is itemMeta null?

item = p.getInventory().getItem(mainEvent.getHand());

        if(item != null){
            itemMeta = item.getItemMeta();
            itemPerst = itemMeta.getPersistentDataContainer();
lavish hemlock
#

It isn't

#

IntelliJ is just an obnoxious bastard

quaint mantle
#

error states it is.

tender shard
lavish hemlock
#

Not an error, a warning

quaint mantle
#
private void getItem(){
        item = p.getInventory().getItem(mainEvent.getHand());

        if(item != null){
            itemMeta = item.getItemMeta();
            itemPerst = itemMeta.getPersistentDataContainer();
        }else{
            itemMeta = null;
            itemPerst = null;
        }
    }
dark arrow
lavish hemlock
#

Unless, well

quaint mantle
#

:P

lavish hemlock
tender shard
tender shard
#

PersistentDataContainer

#

ItemMeta implements PersistentDataholder

quaint mantle
#

?paste

undone axleBOT
quaint mantle
dark arrow
tender shard
tender shard
tender shard
quaint mantle
tender shard
#

your item is AIR

quaint mantle
#

its not

#

im holding a paper

tender shard
#

offhand

#

it's air

quaint mantle
#

so?

#

its getting the hand

#

not the offhand

tender shard
#

the event is called once per hand

tardy flame
#

off hand = hand

#

hand =/= off hand

quaint mantle
#

any way to check which hand?

tender shard
#

getHand()

#

you already do that

quaint mantle
#

not descriptive, how do I check which hand

#

off or not

tender shard
#

if you only want to check the main hand, return if the getHand() is == EquipmentSlot.OFF_HAND

tender shard
#

getHand()

#

returns for which hand the event was called

quaint mantle
tender shard
#

you could easily fix it by checking the items amount

#

instead of just doing

#

if(item != null)

#

check this:

#

if(item != null && item.getAmount() > 0)

quaint mantle
#

or just if(event.getHand() == EquipmentSlot.OFF_HAND){return;}

tender shard
#

yeah no

quaint mantle
#

actually yea thats better

#

yours is

tender shard
#

imagine you have a player only having stuff in the off hand

quaint mantle
#

cause that way it also works with off hand

tender shard
#

don't you wanna make that work too?

#

so yeah I wouldn't manually check for offhand at all but make it work for both hands

tender shard
#

the API is a bit weird sometimes

#

one would expect the hand to return null instead of an ItemStack with Material.AIR and an amount of 0 lol

#

but yeah that's the way it is

quaint mantle
tender shard
#

it's not really "a lot" if there's nothing 😛

quaint mantle
#
@EventHandler
    public void interactEntity(PlayerInteractEntityEvent event) {
        if(item != null && item.getAmount() > 0 && !alreadyRan){
tender shard
#

okay I'll go home

quaint mantle
#

already ran is set to false

#

btw

#

to prevent double usage

tender shard
#

it'll be gone

#

not drop anything

#

remove() removes it

quaint mantle
#

???

#
Boolean alreadyRan = false;

    @EventHandler
    public void interactEntity(PlayerInteractEntityEvent event) {
        if(item != null && item.getAmount() > 0 && !alreadyRan){
#

its not passing this value now

#

:P

tender shard
#

set the health to 0

#

why not?

quaint mantle
#

yes there is

tender shard
#

LivingEntity#setHealth

quaint mantle
#

^

#

if the entity is item however just remove it and drop the item intead

tender shard
#

oh nvm it's Damageable#setHealth

quaint mantle
#

is the entity a dropped item?

#

... you do realize dropped items are entities as well right?

glossy venture
#

any entity that has health can be killed with setHealth

quaint mantle
#

If the entity is an item, you cant set its HP

#

its has no health

glossy venture
#

otherwise use remove or something

quaint mantle
#

whats the entity?

glossy venture
#

what is it then

#

entity reveal

#

that has a setHealth method

#

what are you talking about

quaint mantle
#

... your not tracking the entity?

#

at all?

glossy venture
#

do you have it as an Entity or as a LivingEntity

#

or Damageable

quaint mantle
#

send your code please.

glossy venture
#

wdym yes bro

quaint mantle
#

something doesnt sound right here

glossy venture
#

y e s

#

which one

#

yeah cast it

#

Entity doesnt have that method

#

you need to at least cast it to a Damageable

#

so LivingEntity

#

no its not because otherwise arrows and items would have health and ai

#

or at least allocate memory and process time for it

simple anvil
#

when making a class should it be?
ClassName
className
Classname
when making a var what should i tbe?

#

ok

#

String StringName?

glossy venture
#

variables either stringName or stringname

simple anvil
#

ok

#

on

#

and public ItemStack Yeeyee?
yeeYee
YeeYee

hasty prawn
#

yeeYee

#

stringName

glossy venture
#
Classes: MyClass, Class, MyLongClassName
Methods: myMethod, method, myLongMethod
Fields: (Same as methods)
Variables: (Same as methods)
Constants: MY_FIELD, FIELD, MY_LONG_FIELD
simple anvil
#

when should i use a vinal

glossy venture
#

if you dont expect something to change

#

actually only do that on static final

#

otherwise it sucks

#

oh ye

#

thats a better way to describe it

glossy venture
#

a variable in a class

somber hull
#

I probably know

glossy venture
#

or object

somber hull
#

?

#

Wait

#

Then what’s a variable lol

#

Like I would assume a field is the thing you pass into a method

#

And a variable is a variable in a class

#

Am I mixing them up?

glossy venture
#
protected float num = 4.9f; /* field */

private void method(String str /* parameter */) {
  int i = 0; /* variable */
}
#

thats getting really technical

glossy venture
#

np

lavish hemlock
#

Technically untrue

#

Things like primitive variables within methods don't technically have a memory location

lavish hemlock
#

That's not a memory location though

glossy venture
#

yes it is bruh

#

its not a heap location

#

the stack is also stored in memory

#

as well as vm internals

#

and native allocated memory

lavish hemlock
#

I would imagine JIT converts it to use the actual stack pointer

glossy venture
#

all count as memory locations

#

wdym

#

its on the stack frame

#

its not on a stack

#

i believe

#

also a stack pointer is also just a pointer to memory

lavish hemlock
#

The x86 instruction set uses a pointer to refer to the topmost element of a stack, as the stack is separate from memory and is instead part of the CPU.

glossy venture
#

is the stack in the cpu

#

what

#

oh in cache

lavish hemlock
#

(The stack pointer is actually just a register as well, x86 identifies it as rsp)

glossy venture
#

yeah but generally speaking the stack is stored in memory

#

in java

#

i mean

lavish hemlock
#

Either way, the way it was phrased suggests that each element of a stack has its own pointer

#

Which just simply isn't true

glossy venture
#

or in the cache of each core

simple anvil
#

how would i remove the [ ] , from a list and then send it to a player

lavish hemlock
#

And it's more of an implementation detail that the JVM's stack uses memory

glossy venture
#

yeah i know

simple anvil
#

how u mean

lavish hemlock
#

I believe there's a method to join lists now...?

simple anvil
#

ohh

glossy venture
#
StringBuilder b = new StringBuilder();
for (... elem : list)
  b.append(elem).append(" ");
String str = b.toString();
``` will result in something like `1 2 3 4 5 `
#

with a space at the end

lavish hemlock
#

That's probably not what you want though :p

#

You'd have to use a regular for-loop and track the index

#

If index != the last index, then add a comma

glossy venture
#

why a comma

lavish hemlock
#

Because I assume he wants to use a comma

#

It's being sent to a player

glossy venture
#

he says without a comma

lavish hemlock
#

Oh in that case then just add a space

#

No need to track the index if said list of elements comes before something else.

#

Also

glossy venture
#
StringBuilder b = new StringBuilder();
for (int i = 0; i < list.size(); i++) {
  if (i != 0) {
    b.append(" ");
  }
  b.append(elem);
}
String str = b.toString();
lavish hemlock
#

Technically you don't need to do any of this at all

#

Because of

#

StringJoiner

glossy venture
#

yeah

#

new thing

#

fancy

lavish hemlock
#

Well StringJoiner is as old as Java 9

#

8*

#

So it's not really new

glossy venture
#

true

lavish hemlock
#

It's just obscure

#

Since people always use StringBuilder

#

Which StringJoiner is a wrapper of

glossy venture
#

ah

lavish hemlock
#

Anyway, so a variable is truly just a name assigned to some local variable index, if the compiler has decided to persist the value so that it actually uses up a local variable slot.

#

Sometimes the compiler optimizes away variables

#

Mainly if they're not re-used

tardy delta
#

what is a stringjoiner lol

lavish hemlock
#

Joins strings

glossy venture
#

does this make sense for logging levels

#

or should i make info 0

lavish hemlock
#
StringJoiner j = new StringJoiner(", ");
j.add("Hello").add("World!");
System.out.println(j.toString());

^ This outputs "Hello, World!"

glossy venture
#

its kinda cool

lavish hemlock
#

Nothin' wrong with using StringJoiner, it's just your typical utility.

#

Funny how nobody knows it exists though.

#

Oh yeah it also supports prefixes/suffixes

simple anvil
#

String message = String.join(" ", messageList);
lavish hemlock
#

Yeah

simple anvil
#

ok

glossy venture
#

is that a method

lavish hemlock
#

At least I think lists can be used as the second parameter?

#

Lemme check

simple anvil
#

i think think so

lavish hemlock
#

It's a Java 9 method iirc

simple anvil
#

let me send u my code

glossy venture
#

or array

lavish hemlock
#

Wait no it is actually Java 8

#

Huh

tardy delta
buoyant viper
#

they are very not cooperative

lavish hemlock
#

Fibers ftw

simple anvil
#
Player p = (Player) sender;
            List<String> messageList = new ArrayList<>();
            String message = String.join(" ", messageList);

            for (int i = 0; i < args.length; i++){
                messageList.add(args[i]);
            }


            p.sendMessage(message);

i WoNdEr wHy iTs NoT WoRkINg

glossy venture
#

why did paper deprecate LITERALLY THE ENTIRETY OF net.md_5.bungee.api.ChatColor

lavish hemlock
buoyant viper
simple anvil
#

im glad i relized it before banging my head on the wall

glossy venture
#

i dont want adventure i just want simple chat colors bruh

buoyant viper
#

NamedTextColor

tardy delta
lavish hemlock
#

T o o b a d

buoyant viper
#

but also just bc its deprecated doesnt mean its not usable 🙄

glossy venture
#

how do i reset a color sequence with adventure

#

or am i using it wrong

unreal quartz
simple anvil
#

how do i set the command sender as the console

glossy venture
#

use the result of Bukkit.getConsoleSender()

#

as the sender

quiet ice
glossy venture
#

i just realized i want this to be compatible with spigot so ill just use bungee chatcolor

#

which is annoying to use

#

because its deprecated

#

and intellij avoids deprecated shit

quiet ice
#

You can use the adventure bukkit plattform or however it is called

tardy delta
#

if you have twenty taskes which use the same field and you add a lock to that, wont the tasks be executed slower because they have to wait for the lock to release?

quiet ice
#

depends on what sort of lock

#

And how the tasks are scheduled.

simple anvil
#
if (!(sender instanceof Player)) {
            sender.sendMessage("Use command 'say' in the console");
        } else if (sender.isOp()) {
            Player p = (Player) sender;
            List<String> messageList = new ArrayList<>();


            for (int i = 0; i < args.length; i++) {
                messageList.add(args[i]);
            }
            String message = String.join(" ", messageList);
            Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "say " + message);
        } else {
            sender.sendMessage("You don't have permission to run this command");
        }
#

should i return true at the end of all the if statments

tardy delta
#

idk a lock that prevents two threads from accessing the variable at the same time

lost matrix
simple anvil
#

what would u recoment

tardy delta
#

hmm yes it says that it will slow down performance

simple anvil
#

should i use a for statment or a
Collections.addAll(messageList, args);

tardy delta
#

whats wrong with messageList.addAll(args) lol

quiet ice
somber hull
tardy delta
simple anvil
quiet ice
#

There are hundreds of locks out there. Examples include ReadWriteLock and ReentrantLock among others

tardy delta
#

oh but in general locks slow down performance right?

somber hull
simple anvil
#

what is that

quiet ice
#

Yes. But it really depends on the form of the lock on how much the performance drops. A simple synchronized block is going to be much faster than for example a ReentrantReadWriteLock

somber hull
#

😋🤤

simple anvil
#

im so lost

somber hull
#

I love cement, and lean 💜

waxen plinth
#

haha guys purple drink funny right??!

simple anvil
#

drugs are for loosers

somber hull
#

Get it

#

Cause it’s purple

simple anvil
somber hull
#

I’m sorry I didn’t mean to bring this chat down into chaos

glossy venture
#

i hate that the bukkit logger doesnt support colors

#

at least not for me

#

the console sender does

#

but the plugin loggers dont

tardy delta
#

Bukkit#getConsoleSender#sendMessage does

#

atleast on cmd.exe

chrome beacon
tardy delta
#

ah im bad

quiet ice
#

You might be able to use ANSI escapes though

fervent gate
#

Is there a way I can pass a variable from one listener to the other. I need a hologram variable, but I don't have it in the other listener, can't get it through the world or anything nor can I save it in a db

glossy venture
#

ok i got something

ivory sleet
undone axleBOT
quiet ice
#

Though CAS will always be slower than a direct assignment

tardy delta
#

not starting at zero ._.

ivory sleet
#

Myes but it will most likely out perform synchronized or any lock implementation

quiet ice
#

And multiple threads CASing at the same time will be slower than a single thread CASing

ivory sleet
#

I mean, in/with synchronized all the threads that operate on said variable has to still wait for one and another

quiet ice
#

Yes

ivory sleet
#

And then iirc synchronized is by definition always LIFO, whereas if you’d use sth like Lock you could opt in for a FIFO implementation. Idk if thats even a thing in CAS, probably too unpredictable.

tardy delta
#

oh

ivory sleet
#

In terms of speed, if you’re just managing a variable probably wrapping it with a AtomicReference and using getAndUpdate or updateAndGet will do the job

#

Some time ago synchronized was supposedly much slower than the ReentrantLock but that’s no longer the case, they’re almost equally fast. Not sure if same thing could be said to ReentrantReadWriteLock. However they’re great when it comes to more advanced multi threaded operations, they they get outperformed by CAS in trivial cases.

glossy venture
#

because all levels mean severeness

#

except info

#

as it provides information

#

so ye

#

thats the logic behind it

tardy delta
#

what about threadlocal?

ivory sleet
#

That’s just a Map<Thread,O> at most

#

A bit more sophisticated

#

But it keeps an instance per thread

tardy delta
#

ye

ivory sleet
#

for instance when SimpleDateFormat (which no one should ever use) was the way to format dates, people often had to use a thread local when dealing with date formats across multiple threads as it wasn’t thread safe because it had some damn static shit inside it

#

Yeah you could really ask who wrote the jdk

tardy delta
#

👀

ivory sleet
#

Well fortunately we do have better shit now

tardy delta
#

i forgot lol

ivory sleet
#

DateFormatter and LocalDateTime

tardy delta
#

oh right

#

used it in my plugin but i always keep forgotting thee names

ivory sleet
#

Yeah LocalDateTime, LocalDate, OffsetTime, OffsetDateTime, JapaneseDate, DayOfWeek etc

#

Aj yeah

#

TemporalAccessor (and its subclasses) and DateFormatter in principle is what you want to use

tardy delta
#

the first time i used it, it gave an exeption

#

and now im scared of it

#

:(

ivory sleet
#

DateTimeException?

tardy delta
#

i forgot, something about a temporal accessor, i was using Instant too

glossy venture
#

what are these \s characters

tardy delta
#

space?

#

idk

glossy venture
#

there are normal spaces under there

ivory sleet
#

But yeah fourteen, ThreadLocal is more of a one instance per thread, whereas AtomicReference deals with same variable across multiple threads

tardy delta
#

by introducing synchronized mechanism or something related?

ivory sleet
#

No

#

they avoid locking

#

ThreadLocal has nothing do with locking because it doesn’t address the problem of sharing a variable across threads since it just provides a new instance per thread instead

tardy delta
#

uhu

#

atomicreference is volatile wrapper right?

#

i remember

ivory sleet
#

AtomicReference makes sure the value of the variable is uncached (in simple terms) when other threads look at it. And it has some methods such as updateAndGet, which will try to update the variable by comparing and setting (CAS)

#

Yes

#

In principle

lavish hemlock
ivory sleet
#

Altho it has methods to get the value as if the variable weren’t volatile

tardy delta
#

im not completely understanding what volatile means, does it keeps the value of a variable up to date on the threads which use it?

ivory sleet
#

Synchronized is just like a key, whatever thread has it can do what it wants whilst all other threads must way until said thread is done with what it wanted to do

tardy delta
#

ye i understand that

ivory sleet
#

volatile is interesting…

lavish hemlock
#

I believe volatile is in reference to memory ordering or some shit?

#

I dunno, been a while since I worked with concurrency

ivory sleet
#

Yeah

#

Like it’s very low level and intricate if you want to understand exactly what’s going on under the hood

tardy delta
#

something to do not apply memory optimisations to it or something lol

lost matrix
tardy delta
#

👀

ivory sleet
#

Myeah, but like think of it as a thread might have a local list of variables with values, to some extent volatile makes sure that whenever the value of a variable changes, that local lists get updated.

ivory sleet
#

It does establish a happen before relation/semantic

lost matrix
#

There is probably a bit more to it. But thats the essence.

ivory sleet
#

Indeed

simple anvil
#

is there a way to make a new block with a custom texture?

glossy venture
#

best naming scheme

lost matrix
#

gradient to double to float Tealight blindlead

lost matrix
simple anvil
#

hm

tardy delta
#

wouldnt you still need for the texture to it being applied by a resourcepack?

glossy venture
lethal iron
#

hey does anyone here know what's the equivalent of PathfinderGoal in the mojang mappings? Apparently it's just Goal but that doesn't seem quite right

eternal needle
#

How do i get so color vises work in cobfig file? Like normal minecraft codes tag me

tardy delta
#

heh?

#

color codes?