#help-development

1 messages Ā· Page 752 of 1

young knoll
#

Use display/interact entities

sick edge
#

Ah I see thx

#

How do I get a Display Entity?

young knoll
#

Same way you get any other entity

#

TextDisplay is probably the one you want

sick edge
#

Yeah but it hast to always be above the player and move with it šŸ¤”

young knoll
#

Make it ride them

signal kettle
#

hello is it possible to call BerryNoDamage event when in CobaltArmorEquip player have full armor like addding effect?


    @EventHandler
    public void CobaltArmorEquip(final ArmorEquipEvent event) {
        Player player = event.getPlayer();

        Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
            int amountOfArmor = 0;

            for (ItemStack i : player.getInventory().getArmorContents()) {
                if (i == null)
                    continue;

                if (i.getType().toString().contains("DIAMOND")) {
                    amountOfArmor++;
                }
            }
            if (amountOfArmor == 4) { // player has 4 pieces of diamond armor on
                player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 60, 50));
            } else if (amountOfArmor < 4) { // player has less then 4 pieces of diamond armor on
                player.removePotionEffect(PotionEffectType.FIRE_RESISTANCE);
            }
        }, 0L, 20L); //0 Tick initial delay, 20 Tick (1 Second) between repeats
    }

    private void BerryNoDamage(EntityDamageByBlockEvent event) {
        if (event.getCause() == EntityDamageEvent.DamageCause.CONTACT) {
            event.setCancelled(true);
        }
    }
}
vocal cloud
#

Correct me if I'm wrong but wouldn't that queue a task every time they equip armor?

#

That's a memory leak waiting to happen

ivory sleet
#

an out of memory error looks plausible lol

river oracle
#

I've actually done something like this before on accident its much more likely it will lag out the server before the memory loss causes issues

#

considering most modern machines have so much you'll probably notice the TPS drop xD

ivory sleet
#

Oh yeah thats true

signal kettle
#

;/

#

So is there any other way to somehow check if player have full armor on or not?

#

I mean isn't it a good idea when I will add before scheduler first a few "safe checks" that will only run check on certain timings?

ivory sleet
#

Can’t you just get the player’s equipment

#

And check?

signal kettle
#

when I make it without scheduler it's just work like on reverse so when I put 4 pieces then nothing and when i deequip after that one piece of armor then it give me the effect

#

because on the last one I think it doesn't update?

river oracle
#

What is the bukkit equivalent of MobEffectList (spigot) or MobEffect (mojang) in spigot

#

is their anyway to translate?

smoky oak
#

dunno. anyone know the structure of the namespacedKey Enchantment.getByKey() wants?

#

oh ffs is there a non-deprecated way to map String -> Enchant

#

thats not 'list all enchantments then iterate through them'

exotic zinc
#

weird that it is deprecated. JD doesn't show it as deprecated.

#

ah maybe because its marked as internal

#

try NamespacedKey.fromString("Minecraft:" + key)

young knoll
#

NamespacedKey.minecraft

smoky oak
#

šŸ‘

wraith dragon
quaint mantle
wraith dragon
#

makes sense

tacit veldt
#

Is there any way to simulate enchanting at an enchantment table in code?

#

Congratulations, I found this

ItemFactory ify = Bukkit.getItemFactory();
ify.enchantWithLevels();
smoky oak
#

is there a 'common set of sets' in java?

#

like

#

I need the intersection

dry hazel
#

retainAll can work like that

quaint mantle
pseudo hazel
spare hazel
#

how can i create a runnable in bungeecord? (like BukkitRunnable)

quaint mantle
spare hazel
smoky oak
quaint mantle
pseudo hazel
grim hound
#

Know about

#

() ->

#

?

smoky oak
#

wait can you not modify MerchantRecipe instances?

#

I'm trying to change the thing a villager trades

#

is the itemstack a reference?

#

wtf kinda method name is adjust

quaint mantle
#

anonymous function

rough drift
wooden hearth
#

Hey how would I send a message of a players face as I'm thinking to try and learn new things thank you

sullen marlin
#

I don’t think you can…

wooden hearth
#

I've seen plugins do it before

sullen marlin
#

Unless you make it across multiple lines

smoky anchor
#

Well... a small resourcepack with a pixel that you recolor & negative spaces.
Then you just read the texture server-side and color and move the pixels
But this feels like some hacky, janky solution :D

#

by "pixel" I mean a custom character

sullen marlin
#

Yeah a resourcepack could

rough drift
#

You could also just modify a player head's model/texture and show that

smoky anchor
#

you can't show items in chat

rough drift
#

ah shit yeah

#

then I forgor how

wooden hearth
#

Something like AquaCore displays in there lore and Chat Control displays it in image but maybe trying to convert an image into Pixel Array would work right?

young knoll
#

Yes

sullen marlin
#

I suppose heads are only 16*16 right

smoky anchor
#

8x8

sullen marlin
#

Really?

shadow night
#

What

sullen marlin
#

Thats smol

smoky anchor
#

I mean... look at your profile picture ?

young knoll
#

Yeah they are only 8x8

wooden hearth
#

It would be a cool feature to add in but it blows peoples minds to do it haha

young knoll
#

Which is good since a chat line is like 8 pixels tall

sullen marlin
#

Idk how many pixels my avatar is

rough drift
#

A head is 16x16

#
  • the outer layer
smoky anchor
#

no ?

rough drift
#

yes

#

nevermind

smoky anchor
#

show me then

rough drift
#

I am completely high (not really)

shadow night
#

Wait it isn't 16x16?

sullen marlin
#

Drugs are bad mkay

rough drift
#

it's 8x8

rough drift
smoky anchor
shadow night
#

Well, technically it can be anything

shadow night
sullen marlin
#

Steve looks fine for 64 pixels

smoky anchor
#

ty :D

young knoll
#

I don’t think the game will handle higher res skins

#

They aren’t like blocks

smoky anchor
#

Not anymore
RIP HD heads

shadow night
#

Wait what

smoky anchor
#

not skins, but you could make HD heads

young knoll
#

I assume they want it on one line

smoky anchor
young knoll
#

Yeah it’s not that hard

smoky anchor
young knoll
#

Might dos your players with giant chat packets though

#

Kek

smoky anchor
#

ĀÆ_(惄)_/ĀÆ

wooden hearth
#

I was mainly thinking to use it for when the Player Logins and show it in lore so when you hover over an item it will show the skin before disguise

slate tinsel
#

If I want to change which direction a falling sand block that passengers at an armor stand look at, how do I do that?

#

Think it was something with a type of yaw, but didn't really understand

young knoll
#

Try setting the yaw

#

I’m not sure that works when it’s a passenger tho

smoky anchor
#

I am not sure I fully understand this question.

rough drift
#

Rule of thumb:

If there is a passenger, or maybe two
Remember that teleporting will never work for you

lost matrix
#

You could just set the yaw of the armorstand, no?

slate tinsel
young knoll
#

Can’t ya just rotate the armorstand

slate tinsel
lost matrix
smoky anchor
#

Falling block can not change rotation. If you're on 1.19.something, use display entity

rough drift
young knoll
#

Should look into teleporting of mounted entities

rough drift
#

spigot just... doesn't do it

#

I could make an ultra-quiccc pr

young knoll
#

Exactly

#

That’s the look into part

smoky anchor
rough drift
#

looking into it

#

because it fucked stuff at work too

slate tinsel
rough drift
lost matrix
rough drift
#

So you would just need to remove entity.isVehicle()

#

and you're done

#

welp

#

time to PR

lost matrix
#

You want a falling stair block which is facing downwards?

young knoll
#

Can’t break backwards compat

#

:p

rough drift
#

I mean yeah

#

it wasn't being used

#

so like

#

no backwards breakage!

young knoll
#

teleportWithPassengers moment

smoky anchor
#

probably just new method ?

rough drift
#

yeah

#

I'll do that

#

welp

young knoll
#

Wonder if it’ll explode if you try to do it across worlds

rough drift
#

time to remember how to make PRs

slate tinsel
young knoll
#

Rip

rough drift
#

there is literally a check

young knoll
#

Still gotta dismount for that then

#

Sadge

rough drift
#

anyways how do I make a PR I forgor

rough drift
young knoll
#

Fair

rough drift
#

Otherwise it should probs just teleport with it

smoky anchor
rough drift
#

Yeah

#

talking in general

#

it's dumb that you can't tp

slate tinsel
lost matrix
slate tinsel
#

or 1.20.2

young knoll
#

Don’t say legacy don’t say lega- wooo

#

Use display entities

#

You can transform them however you want

lost matrix
#

If you are a little bit patient and willing to copy some math, then this would be a good
place for display entities. They are just a little bit tricky to work with but have a much better
performance for client and server than falling blocks on armorstands.

rough drift
#

wait really quickly

Do I make a PR to the SpigotAPI then to CraftBukkit? Like separately? (And mention them in each-other)

young knoll
#

Bukkit and craftbukkit

#

Don’t need to touch spigot

rough drift
#

Ah

#

aight

lost matrix
#

Wasnt there something something, you need to pr both and reference the impl/api pr in the description for each other?

rough drift
#

yeah you needed to reference each other

#

like

#
Added this API

Implemented in [PR]
young knoll
#

Mhm

rough drift
#
Implemented this API

Added in [PR]
shadow night
#

What can craftbukkit do without bukkit

rough drift
#

Craft

slate tinsel
shadow night
young knoll
#

Craftbukkit can do anything without Bukkit

#

But devs won’t be able to access it :p

shadow night
#

Can I code a plugin in nms

young knoll
#

Sure

#

Might be hard to get it loading tho

shadow night
rough drift
#

fuck

#

I think I forgor my stash pass

#

is it the same as the spigot one?

lost matrix
shadow night
#

If I shade in spigot api in my plugin, how bad is it

young knoll
#

Idk, how big is the api

rough drift
#

~2k classes

#

well ~2.1k

young knoll
#

I only speak in megabytes

#

I know the entire server is 70

rough drift
#

~2MB?

rough drift
#

fuck I actually forgot my stash pass

lost matrix
rough drift
#

?support

undone axleBOT
uncut needle
#

Does it matter what directory I run it in?

lost matrix
uncut needle
#

Do I run it in the projects terminal?

lost matrix
#

Being in the folder of the jar makes it easier as you can just use a relative path

uncut needle
#

the one I want to add dependency

lost matrix
#

You can run it in any terminal you want if you have maven installed on your pc

#

All this command does, is copy a .jar file into the local maven repo of your pc so that all local mvn projects
can find it in their pom.

slate tinsel
#

Okey Thanks! šŸ™‚

orchid gazelle
young knoll
#

Just don’t collide

orchid gazelle
#

I programmed moving vehicles with custom nms FallingBlocks but then I got stuck on collisions

orchid gazelle
orchid gazelle
smoky anchor
#

You can't just "give falling blocks properties of shulkers"
Not server-side

orchid gazelle
#

You can

smoky anchor
#

elaborate

lost matrix
#

I would just draw a bounding box around that thing and check for overlaps. I would never check for individual blocks there. Way too expensive.

orchid gazelle
#

You override the getEntityType method of your nms FallingBlock and let it return Shulker

#

Boom you get collisions just like shulkers

smoky anchor
#

Aah
That ain't even gonna work well for the client

orchid gazelle
orchid gazelle
smoky anchor
#

client will never know about the collision property and will try to fall through
Server will teleport the player back
Could trigger anti cheats

orchid gazelle
#

I gave up after hours over hours of asking on help discords

#

No outcome

orchid gazelle
smoky anchor
#

Ye, you just don't do this.
At best you can use shulkers themselves

orchid gazelle
#

but the client did some weird stuff and entered crawling state all the time

orchid gazelle
#

Did 100% the same thing as the EntityType thing

smoky anchor
#

hmmm maybe if it was moving, stationary shulkers should work normally

orchid gazelle
#

They didn't fully

#

You walk against it, you enter crawling state

smoky anchor
#

huh, weird

orchid gazelle
#

I asked about it sooooo many times

#

Noone was ever able to help me

smoky oak
#

@orchid gazelle shulkers retain collission when moving. spawn a ai false shulker following the moving block

orchid gazelle
#

I did

smoky oak
orchid gazelle
#

Wdym?

#

I had NoAI Shulkers being stationary in the air

#

You walk against it with your head, you get into crawling state mid-air

smoky oak
#

no like

#

ive been trying for a while to place shulkers where they shouldnt be

#

namely, at xz coords that arent mod 1 = 0

smoky anchor
#

You can do that if they ride a different entity

smoky oak
#

bleh i feared thatd be the case

wooden hearth
#

How would I make my plugin support all server versions and features for each version?

lost matrix
wooden hearth
lost matrix
wooden hearth
lost matrix
#

Hm?

#

Im just saying that programming in 1.8 is generally a horrible experience.
Its a decade old and it shows.

smoky oak
#

no, protocollib is easier than doing it yourself. some things require packets

wooden hearth
#

Ah okay, I use 1.8.8 because I've took a long break and that use to be the latest version but I've now came back and there's loads of different versions that's why I was asking

smoky oak
lost matrix
#

Spigot just deprecates methods until the heat-death of the universe

rough drift
#

Attempting to compile Bukkit with JDK 1.8 seems to fail due to org/eclipse/jdt/core/compiler/CompilationProgress being compiled by a newer JDK

shadow night
wooden hearth
#

Is it better to make plugins from 1.8 or 1.12 because I know people like 1.8 due to the PVP

smoky anchor
lost matrix
#

Depends on your audience and what your plugin achieves.
If you want to target pvp kiddies then go for 1.8
Otherwise dont

smoky anchor
#

lmao, nearly same thing

lost matrix
#

smileybolb m

wooden hearth
pseudo hazel
#

then just go latest

smoky oak
#

i am fairly sure thers a 1.5.2 server somewhere lol

shadow night
smoky oak
#

youre not that important lol

wooden hearth
#

Damn they use 1.20.1 the most

mortal hare
#

wtf

#

why

rough drift
#

I support 1.17.1 and up, seems to work fine

smoky oak
#

funny mods

mortal hare
#

that's called nostalgia

smoky oak
#

beeeg tree

mortal hare
#

what i miss from previous minecraft versions is the auto updating

mortal hare
#

due to that removed now the community is fragmented between versions

rough drift
#

what auto updating

mortal hare
#

there was auto updating

#

in the minecraft launchers

#

when new minecraft version got released

young knoll
#

Back in Ye old days you played latest or you shut up

smoky anchor
#

Even then you had chance of going back (through third party program)

young knoll
#

Well you could still get old versions, but the launcher only ran latest

mortal hare
#

by switching bin/minecraft.jar šŸ˜„

#

nah i liked it tbh

#

at least we didnt had 1.8 situation

young knoll
#

That’s a them issue

sterile token
#

If You have issues with armó stand try using the client SIDE armor stands they don't have much issues. Because they are directly in the client itself

smoky anchor
#

I think you forgot to reply :D

young knoll
#

Most entities are in the client itself

#

:p

thorny berry
#

eee

#

ee

#

e

#

e

#

e

#

e

#

eeeee

shadow night
#

Don't e mf

sick edge
#

Can I somehow make it so that my custom TextDisplay rotates when a player looks at it (like normal NameTags) and so that its hidden to the vehicle (player)

quaint mantle
#

Hi , is there server need spigot developer ?

smoky anchor
#

?services

undone axleBOT
rough drift
#

as otherwise it will end up straight to the shadow realm

sick edge
#

Its not really working for me anyway as the TextDisplay is to low compared to the player body, the original name is still being shown and the player can see his own name... so I think might just use teams for color and prefixes

rough drift
#

Yep

ivory sleet
#

No it can’t but it can produce NPE @solar musk

#

Its specifically getOfflinePlayer(String) that may request mojang since UUID mustnt be null

#

Yes

young knoll
#

Does a display entity as passenger not hide your name?

#

Normally passengers hide the names of entities they ride

orchid gazelle
#

is there any easier way to check if an ItemStack is a Spawn-Egg than creating a Method with a Switch-Case for all spawn eggs?

young knoll
#

You could create a set of Materials to check against

#

Or check if it has SpawnEggMeta

orchid gazelle
#

ohhh so I can get the Meta and check if it is instanceof SpawnEggMeta

#

nice ty

bronze crystal
#

change the bstats code so the plugin is always tracked even if he disables bstats in config🤯

eternal oxide
#

you would need to declare that your plugins forces tracking, if you did that

scenic onyx
#
public boolean doesPlayerTargetPlayer(Player p, LivingEntity target){

        if(!target.getWorld().equals(p.getWorld())) return false;


        Location head = p.getLocation().add(0, p.getEyeHeight(), 0);

        Vector look = p.getLocation().getDirection().normalize();


        Vector direction = head.subtract(target.getLocation()).toVector().normalize();



        Vector cp = direction.crossProduct(look);


        double length = cp.length();

        return (length < 0.1);
    }

becuse dont go, dont get error.

shadow night
#

Please don't name your variables cp

ivory sleet
#

Lol dont think thats what they were after

young knoll
#

I mean I don't think the FBI is gonna show up over a variable name

ivory sleet
ivory sleet
young knoll
#

Idk

#

I've seen people use interact entities instead and that seems to work

ivory sleet
#

hmm thats interesting

young knoll
#

Maybe mojang hardcoded that

ivory sleet
#

yea fair enough

orchid gazelle
#

Alright, so I wanna apply special code to an Entity if it got spawned by an Item a Player was using(So ArmorStand, any Spawn Egg or ItemFrames). How tf do I do that? EntitySpawnEvent sadly does not provide a way to get the player who caused it

young knoll
#

EntityPlaceEvent iirc

#

mmh that only fires for armor stands, boats, minecarts, and end crystals.

#

According to the docs anyway

orchid gazelle
#

Hmmm

#

Need Eggs too

sick edge
#

Hi, when using getNewScoreboard() setPrefix() and so on dont work but with the mainScoreboard it does.. do I have to register it or smth couldnt find anything on the api

eternal oxide
#

if you get a new SB you have to set it for the Player

sick edge
#

So adding the player to it isnt enough?

hoary wing
#

whats the best way to get the color of a block, ive already tried getMapColor() and it works pretty decent except for the fact that is doesnt work for transparent blocks.

subtle folio
#

do transparent blocks have a color?

hoary wing
#

glass, slime,etc

subtle folio
#

yeah not sure if spigot has a really sure fire way of doing it

#

bc texturepacks

dawn flower
#

is it possible to change the fishing speed

mortal hare
#

./gamerule randomTickSpeed 10000

#

probs šŸ˜„

sick edge
#

Does someone know how to change the chat format (remove the <> around player name) with Adventure API?

hoary wing
dawn flower
#

no like

#

i dont want an enchant

#

or changing tick speed

#

yea ik but how in the owrld would i do that

mortal hare
#

you can hook into fishing event and cancel it in the period you dont want to

#

maybe

dawn flower
#

hm

#

"
setWaitTime(int min, int max)"

#

"Set both the minimum (default 100) and maximum (default 600) amount of ticks one has to wait for a fish appearing."

#

but how do i listen for when ur hook is in water

#

theres multiple events for PlayerFishEvent iirc

young knoll
#

Just set it on cast

bronze crystal
#

can I modify the plugin.yml with java? I would like to add for example a command into the plugin.yml if the user sets it to true in the config.yml

hoary wing
#

i'm working on this parkour generating plugin, anyone have any ideas for extra features, it can already generate parkour and it has a preview mode

sterile token
#

Could You the task about scheduling?

#

If You did the blog about using async un spigot

#

Just learn more about spigot scheduling

#

Si far i know that they don't run anything async they are just parallel executed

#

Using ?

#

Because You cant use threafs because they block the server

#

Right

#

What the diferente between running them with a executor or none

dry hazel
#

it runs in the forkjoin common pool if you don't specify

eternal night
sterile token
#

But if You don't pass an executor the Main thread is blocked untik You get the result

young knoll
#

No?

sterile token
#

Yes

young knoll
#

By default it uses the forkjoin common pool

#

Which is not in fact the main thread

#

Well yeah

#

But why tf are you using get

sterile token
#

Result.result = future.get()

#

I must get the result tho

eternal oxide
#

you can;t get the result until its finished

#

if you try , you lock the main thread waiting

sterile token
#

But thats messy You have yo writen many future thing

#

Why there isnt a thing that wait untik completaron on other thread and then jus treturn the value directly

#

Instwad of doing thousans of then()

young knoll
#

How would that work

#

You want to wait for the value but not wait for the value

sterile token
#

Also that make you not able to call none async field

#

Wait until is computed on another thread and then return yo the thread caller

#

šŸ¤”

#

Is nt it that possible

slate tinsel
sterile token
#

Yes but yo need to use thousans of then for compelz fuctions

young knoll
#

By default the blocks will be whatever size the normally are

#

But you can scale them

sterile token
#

I mean is not posible yo get te value async and get it back yo Main thread

slate tinsel
eternal night
#

Otherwise the main thread would have to ✨ wait for the value

#

Crazy concept

sterile token
young knoll
#

Yes

#

That’s what thenRun is for

eternal night
#

And what does the main thread do in that time

sterile token
#

But can't get blocked

#

Because awaition is done in another thread

eternal night
#

Okay so

#

You send your friend to go get apples

#

The friend plants the apple tree seed

#

Waits 3 years

#

Gets the apple

#

Comes back to you

#

In this time you can do stuff sure

#

But you can't do anything with the apple you wanted

#

It does not matter that it's your friend waiting for the apple to grow

#

It does not exist yet

sterile token
#

But why that? Can't you just tell many of then to plant, continue asking more yo plants while the Friends are planting

Finally when the plant grown up get notified with the value to the requested

eternal night
#

Yes

#

You can get notified 3 years down the line

#

That your first Apple is grown

#

That is what the run can do for you

#

You pass something that should be run/notified when the first Apple is there

wet breach
eternal night
wet breach
#

I do like your explanation though lol

sterile token
#

I have seen JDA with something like:

TextResppnse smth = message.send().enqueu();

And your threead doesnt get blocked

eternal night
#

Because enqueue doesn't send the message

#

You ask your friend to give an apple to your mom

young knoll
#

It queues it to be sent, it’ll be sent at some point in the future

eternal night
#

The friend goes off

#

Plants the tree

#

Waits 3 years

#

Gives the apple to your friend

#

You never get notified if that actually happened or not

#

You just trust your friend

#

The text response you get there isn't resolved yet iirc

#

It's a "trust me bro, I'll get a response for you at some point"

sterile token
young knoll
#

No it isn’t

#

You don’t get a response, you just get the message that will be sent

#

It hasn’t actually been sent yet

wet breach
#

sometimes, you just don't need a response

sterile token
#

I know but how info that

#

I want to implement that System

#

Because si really ugly having thousans of andThen, thenAccept

#

ImaginƩ having 1k of lines yo get runa async

eternal night
#

Literally just make a method

#

Call the method in your the accept

#

Be happy

#

No one is stopping you

sterile token
#

Hwo??

dry hazel
#

I am

eternal night
#

Bro what ?

#

You can call methods from lambdas

sterile token
#

Because if in do future.get get blocked

eternal night
#

No

#

Don't use get

#

Use the accept

sterile token
#

let me translate it

eternal night
#

And in the consumer

#

Call a method

sterile token
#

I want to do some sort of consumer which allow me to get the final value directly

#

Instwad of using weird accept, etc

eternal night
#

You literally cannot

sterile token
#

Why?? Doesnt makese sense

eternal night
#

I don't know how much I can dumb it down for you

#

I

eternal oxide
#

you are not understanding Async

eternal night
#

Bro I dumbed it down to a fucking apple tree

#

How are you so dense

#

The apple tree takes 3 years to grow

#

For the apple

#

There is fucking nothing you can do to get it instantly

#

You can do stuff while you wait

#

You can do nothing

sterile token
#

If the value is sent on the future none knowing when. You can just add many if then to queue, when is sent. Notified the Main thread giving the result object

eternal night
#

But you'll get your first Apple 3 years in, not a minute earlier

eternal oxide
#

if you call get you are WAITING for teh task to do all its work and return the result.

sterile token
#

Right thats okay, i need some sort of awaition but Nome blocking

hazy parrot
eternal night
hazy parrot
#

if you want to do something with result, you use queue consumer in jda lol

sterile token
#

Sorry if i didnt epzlain before

young knoll
#

Maybe let’s do an example

sterile token
#

right because i understand how async works

#

But Java is a mess

eternal night
#

You clearly have 0 idea on parallel Programm

#

None of the concepts are java specific

#

If you are used to the "async" keyword magic in other languages

young knoll
#
CompletableFuture.supplyAsync(() -> *something that returns an object*).thenAccept(object -> doThing(object));
eternal night
#

They just do thenaccept for you under the hood (not really, but think of it that way)

sterile token
#

Sorry if i didnt udnerstnaf well

eternal night
#

It is literally just syntax sugar on crack

#

It does the same thing

#

Just in pretty

eternal oxide
#

you create a method which will deal with the result so you call it in your thenAccept

eternal night
#

Given java does not allow you to implement new keywords, get reckt

sterile token
eternal night
#

Future is the utility class

slate tinsel
young knoll
#

I mean if you really wanted to you could make

eternal night
#

You are trying to reinvent a wheel that people a lot smarter than us have already invented

young knoll
#

doThingAsync(supplier, consumer)

sterile token
#

Yes but future conpletable is a mess

eternal night
#

Bro 😭😭😭😭

sterile token
#

I mean i sound clound but i'm not

#

Just trying to ezplain nyself but can't really get understand because i ezplain nyself too bad

eternal night
#

You literally pass a "run this code when value" consumer and are happy

sterile token
#

okay but i want to get the value directly thru the consumer. I understand know?

#

I Will then give a deeper research thanks to all

karmic phoenix
#

Also it connects to the database but it doesn't save.

young knoll
#

Shh that’s too advanced

#

Callback stuff is fun

#

Sadly we can’t have callbacks for entity ticking

sterile token
#

I want to some sort of callbsck which return the value get from future directly

#

But wit none blocking

young knoll
#

That’s called time travel

#

Java doesn’t have an api for time travel(yet)

hazy parrot
#

how can you get apples from your friend if you dont wait for him ?

sterile token
#

Why won't exits? You can just queue many futures while they are running, if one is completed notify the thread caller and return the computation

hazy parrot
#

😭

eternal oxide
#

if you call get on any future you just locked the main thread (unless the future has finished).

wooden hearth
#

Do you think this is a reasonable format for a plugin I'm working on these are all the messages ```yml
New_Player_Join: "Welcome to the server!"
Player_Join: "Welcome back to the server!"
Commands:
Spawn:
Spawn_Set: "&aSpawn was set!"
Spawn: "&aYou have been sent to the spawn!"
Invalid: "&4Invalid please do /setspawn"

sterile token
eternal oxide
#

because get is blocking

sterile token
#

Right thanks i Will check that

#

Okay why is blocking? Can't you await in another thread and finally return the result to Main thread once task is done

eternal night
#

Honestly trolling at this point

#

Pls for the love of god stop the trolling

#

It's not even funny

sterile token
#

Lmao i'm not trolling

#

You kis tdont understand what i'm trying to do

eternal night
#

We do

#

You want to implement e.g. JavaScripts async keyword in java

sterile token
#

let leave it here because me i'm troller come one bro. Im not trolling that sound rude

hazy parrot
#

You literally said yourself "once task is done", how can you wait for it to be done without blocking?

eternal night
#

You don't understand whatsoever what that keywords does in Javascript

#

So you think it instantly returns to the main thread

#

Which is completely wrong

eternal oxide
#

You ask a future to count to a MASSIVE number and then return the last value. If you call get on that future it can't return the result until it has finished counting. So your get forces your main thread to wait. The result doesn;t exist until the future is finished.

sterile token
#

Once i'm Home i Will translate what i mean

#

Sorry if sound trolling but i'm not trolling

#

Just being wrongly explaiened

eternal night
#

Yea I think you just don't understand at all what other languages do when you use the "async" keyword in them

#

So you are under the impression that something is possible when it is not

sterile token
#

Right thats true i Will fully read in deep hwo the cpu manage that

young knoll
#

Why doesn’t java have async keyword smh my head

sterile token
#

any sugesttion forbette runderstnsdign

#

Of Java async

#

I wanna read first before trying to re ezplain what i was trying to do

#

Sorry for taking your time

fading gull
#

this guy is so polite

#

and actually wants to learn

wet breach
eternal night
#

No I think they just think the async keyword magically gets the value back to the thread it was "called" on XD

ivory sleet
#

JavaScript async is almost equivalent to Java CompletableFuture

JavaScript await is almost equivalent to CompletableFuture#join()
@sterile token in short

#

thats pretty much all u need to know to understand their similarities (not true but to dumb it down)

eternal night
#

Dangerous statement for the JS experts in the discord

ivory sleet
#

🄲

wet breach
#

lol

ivory sleet
#

and async is pretty much just shorthand for Promise in JavaScript if you haven't realized it

sterile token
#

I know promise

ivory sleet
#

mhm

sterile token
#

I'm trying to soft of it but getting the value directly

ivory sleet
#

soft of it?

sterile token
#

Wait now i'm free in break

#

Let me translate

eternal night
#

async in Javascript is pretty much just a syntactic sugar to configure the promises for you.

Promises are CompletableFutures in java.

Java does not have a syntactic sugar like JavaScripts async keyword to configure the promise chains for you

#

(I say pretty much because async does some more complex stuff, but think of it that way)

young knoll
#

Java 22

#

Now with async

eternal night
#

Revolutionary

#

I need it

#

Actually sorry, I need Valhalla

ivory sleet
#

yeah we need valhalla and structured concurrency

sterile token
ivory sleet
#

so sad it just got set to preview in j21

young knoll
#

No

#

Well, probably not

ivory sleet
#

def not

young knoll
#

Idk maybe John java has plans

eternal night
#

You still have the wrong concept

sterile token
eternal night
#

We have told you this

#

Like 5 times

#

Before I asked if you were trolling

ivory sleet
sterile token
ivory sleet
#

doesnt matter

sterile token
#

Okay, perfect thats okay

ivory sleet
#

doesnt matter what language, what object or what interface u use

#

if u wna do something once the value returns without blocking you will need to use callbacks

sterile token
#

I thought it worked this way.

You load a lot of tasks to be completed at another time, while they are being processed your thread is still on something else. Once x task is finished, the thread that called it is notified and the result is returned.

ivory sleet
#

basically a callback

#

except

#

"and the result is returned"

#

cuz that means blocking essentially

sterile token
#

Like they do with SQL, once value si received they expose it

eternal night
#

once

sterile token
#

okay the rgijt name si a callback

ivory sleet
#

yea, but callbacks are called by the task when its finished, IN COMPARISON to join() or get() which is called by you

#

and well... if the task is not finished, then join() or get() will wait for the task to finish => shiaazzzooop BLOCKING

karmic phoenix
ivory sleet
#

any errors or anything in console?

karmic phoenix
#

No errors.

sterile token
karmic phoenix
#

via pom.xml?

sterile token
#

You can't execute SQL witout the MySQL conector driver

karmic phoenix
#
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <version>8.1.0</version>
        </dependency>
sterile token
#

Because if you don't include the driver within your plugin, it won't run any sql requeste

young knoll
#

The driver is already shaded in spigot

sterile token
karmic phoenix
#

Is the code fine tho?

sterile token
#

Have try souting the connection.isConnected()

karmic phoenix
#
        if (databaseManager.testConnection()) {
            getLogger().info("Connected to the database.");
        } else {
            getLogger().severe("Plugin could not connect to the database.");
            setEnabled(false);
        }
quaint mantle
wooden hearth
#

Hey is there a way to get an alt account without buying a new account for development purposes

karmic phoenix
# quaint mantle Cache the connection in getConnection method

I've got this warning in ij:

NameColors-1.0.jar, SpiGUI-1.3.1.jar, mysql-connector-j-8.1.0.jar, protobuf-java-3.21.9.jar define 1 overlapping resource: 
  - META-INF/MANIFEST.MF
maven-shade-plugin has detected that some class files are
present in two or more JARs. When this happens, only one
single version of the class is copied to the uber jar.
Usually this is not harmful and you can skip these warnings,
otherwise try to manually exclude artifacts based on
mvn dependency:tree -Ddetail=true and the above output.
See http://maven.apache.org/plugins/maven-shade-plugin/
karmic phoenix
#

Also still same issue

#

Not saving anything.

young knoll
#

Just be careful testing in offline mode

quaint mantle
young knoll
#

Since it’s a bit different than online

quaint mantle
#

uuid is cursed

karmic phoenix
quaint mantle
#

Idk. It just a warning

young knoll
#

Should be fine

karmic phoenix
#

Alright what next?

young knoll
#

Have you tried it without shading the connector

karmic phoenix
#

Shading as in?

#

adding it to the pom.xml?

young knoll
#

Marking it as provided

#

So it doesn’t get included in your jar

karmic phoenix
#

I don't quite understand

#

scope thingy?

wooden hearth
karmic phoenix
#

makes making GUIs easier

#

its an api

wooden hearth
karmic phoenix
wooden hearth
young knoll
#

Notice how for spigot api you have <scope>provided</scope>

karmic phoenix
#

Yes, should I do the same for the mysql?

#

I discovered something, I've added a row in data having my uuid and namecolor selected and it works fine, even if i change colors but once i remove that row it doesnt add it back once i change the color.

young knoll
#

Okay so the sql stuff is working fine

#

Sounds like you have a logic issue

wooden hearth
karmic phoenix
#

Once a player select a name color via /color it supposed to save the color selected in the MySQL and retrieve it once they join back.

#

But it doesn't save it for some reason.

wooden hearth
karmic phoenix
#

Got a question lmao, is chatgbt illegal here, cuz it fixed the issue 🤣

wooden hearth
karmic phoenix
#

A name color system for my server.

#

Players can select name colors and go to different gamemodes and it would sync.

#

via Mysql.

wooden hearth
#

Oh nice, dm if you want I'm making something similar but has way more features

#

I like to connect with other devs aswell

karmic phoenix
#

All I'm good at is making good GUI designs

wooden hearth
karmic phoenix
#

Feel free to dm me whenever u need me

wooden hearth
brazen badge
#

Anyone can help me? I want that when I click a block I want to check if the block clicked is a skull with a custom base64 that I've in config

quaint mantle
#

or

worldly ingot
#

I'd opt for the first so you're not creating new objects when you don't need to

hushed spindle
#

why would you use an air item instead

#

cant you just return null

worldly ingot
#

Depends on the expected use case

#

ĀÆ_(惄)_/ĀÆ

quaint mantle
#

the bukkit api is annoying when they return null instead of air

#

but then u cant use null in place of air in their api

quaint mantle
#

they both create new objects

worldly ingot
#

Yes but the second one does it conditionally

#

The first one does it every time to pass it as a method argument

quaint mantle
#

ohh i see

worldly ingot
#

That requireNonNullElse() is best used for something like a constant default value

hushed spindle
#

i'm trying to restructure my project to have multiple modules so that i can support multiple versions of nms, but now im getting a maven error saying i don't have the mojang mappings during packaging

Failure to find org.spigotmc:minecraft-server:txt:maps-mojang:1.19-R0.1-SNAPSHOT-R0.1-SNAPSHOT
though in my .m2 folder i just used buildtools to generate them. i've invalidated caches too and stuff, any ideas?

quaint mantle
#

idk why null lore can be returned tho

#

why cant an empty list be returned in stead

worldly ingot
#

If no lore is set the list will be null

#

You can have lore with no entries

#

_Not that it renders any differently, but that's just how it works :p _

quaint mantle
#

alr

worldly ingot
#

Lore: [] vs no Lore tag at all

young knoll
#

You can check the data of a skull on the ground via its BlockState

lilac dagger
#

I love block states

young knoll
#

Meh

#

Kinda weird

brisk estuary
#

does anybody know any plugin that mocks players so I can execute commands on them? (1.20 compatible) So I can test my plugin 🄲

young knoll
#

You can try mockbukkit, which isn’t a plugin but a library for unit testing

#

Other than that idk if anything exists for it

brazen badge
#

?

young knoll
#

No

quaint mantle
#

bro

#

you need key

#

not value

young knoll
#

GetState, cast to Skull, then use getOwnerProfile

#

Then you can get the textures from that, then the url, then do all the base64 stuff

#

Alternatively, just add some pdc to the placed skull

lost matrix
young knoll
#

Don’t forget like 10 bill checks along the way

#

Kek

quaint mantle
#

can i get help with nametagedit and why wont it display the tags?

ocean hollow
#

Do chunks have a Persistent Data Holder? When turned off, does the server save information from there?

lost matrix
hushed spindle
#

i ran buildtools with the following command
java -jar BuildTools.jar --rev 1.19 --remapped
and still get the error when packaging
Failure to find org.spigotmc:minecraft-server:txt:maps-mojang:1.19-R0.1-SNAPSHOT-R0.1-SNAPSHOT

anyone have an idea where else this error could come from

#

wait its saying snapshot twice maybe thats it lol

hushed spindle
#

1.19 is invalid?

#

why?

eternal oxide
#

1.19 is valid

#

two snapshots isn;t

peak depot
#

do serialized Itemstacks also serialize Enchanments?

hushed spindle
#

yeah that was the issue, im not sure how it got there to begin with but

hushed spindle
peak depot
#
            ByteArrayOutputStream io = new ByteArrayOutputStream();
            BukkitObjectOutputStream os = new BukkitObjectOutputStream(io);
            os.writeObject(is);
            os.flush();

            byte[] serializedObject = io.toByteArray();

            encoded = Base64.getEncoder().encodeToString(serializedObject);
#

is in that case "is" is the itemstack

storm crystal
#

is is actually okay to ask java specific questions here?

storm crystal
#

is it possible to make an instance of a class inside of it?

hazy parrot
#

How would that make sense

#

Class already have "state" of its instance

#

Idk if I worded that correctly

#

What are you trying to do

storm crystal
#

im... well learning basics of java

#

and this one seems to work just fine

#

it prints out 5

hazy parrot
#

I mean you can create instance of class inside of it, it's used for singleton for example

storm crystal
#

can I create main method that system would start from outside of class?

#

or do methods need to be inside of a class?

hazy parrot
#

Main have to be inside of class currently

#

But it will soon be possible

#

It's in preview state

lilac dagger
#

I'd love if they expand this concept to utility methods

#

Tho i assume main being classless is just sugar

quaint mantle
#

hii im new to spigot, is there a reason why Player#isOnGround() is deprecated?

eternal oxide
#

read the deprecation note

lilac dagger
#

Because there are better ways to check it

eternal oxide
#

?jd-s

undone axleBOT
storm crystal
#

why do I get this error all the time, Im trying to edit array in my method, while array is declared in class

lilac dagger
#

Sounds like static abuse

storm crystal
#

great but it doesnt explain what static context even is

quaint mantle
#

basic java knowledge

#

can we see what you're referencing

storm crystal
lilac dagger
#

You need to access fields through objects

#

You're trying to get a field that is object specific by using the class name

hushed spindle
#

you're basically trying to access a property like
Class.property
this property is not static, and so it can't be referenced from a static context

static properties are properties belonging to the class, while non-static properties are properties belonging to instances of said class
you're probably misusing static as an easy way to just "get" a property you think you want

#

show your class and we can show you

storm crystal
#

eh ill just dump everything into a method

hushed spindle
#

how to avoid learning 101

peak depot
#

how should I do potions if all of the constructors are deprecated:

storm crystal
#

why i cant make empty array and then add numbers

hushed spindle
#

we dont know if you dont show us what you got

#

oh an array, no thats because arrays are of a fixed length

eternal oxide
hushed spindle
#

if you want a list you can add elements to you need an arraylist

young knoll
#

If you want variable length

#

Use list

storm crystal
hushed spindle
#

or a set if you don't need duplicate entries, sets are faster too

eternal oxide
#

list or set

storm crystal
#

idk it worked in python

hushed spindle
#

python isnt java

eternal oxide
#

this is not python

hushed spindle
#

i believe arrays are converted to lists under the hood in python

#

so you can just add shit to it

lost matrix
storm crystal
#

just doesnt work

hazy parrot
#

You have to import it

#

Also please use generic types

hushed spindle
#

you said you want numbers in that list right
List<Integer> list = new ArrayList<>();

lost matrix
# storm crystal just doesnt work

Your IDE should import it automatically. Also a list cant store any arbitrary object.
Only objects of one type.

List<String> someList = new ArrayList<>();
hushed spindle
#

every..?

#

no

#

why do you want every type

storm crystal
#

well at least integer and strings

hushed spindle
#

what kind of things are you adding to this list

#

for what use case

storm crystal
#

numbers 0-9 and operators like + - / * =

lost matrix
hushed spindle
#

you wanna allow players to make formulas?

#

sounds like you dont need a list at all and just a string

#

which is just an array of chars but thats besides the point

storm crystal
#

no im trying to make a calculator

hushed spindle
#

..right

storm crystal
#

which I have already done in python but it just doesnt work at all

hushed spindle
#

because you're refusing to learn away from python

#

java is a very different language from python

lilac dagger
#

How exactly does it work?

hushed spindle
#

on a surface level anyway

lost matrix
storm crystal
# lilac dagger How exactly does it work?

it gets input from you by order number, operation, number, operation etc. until you hit "=" and then merges let's say 5/2 into 2.5 by changing "/" into 2.5 and deleting both 5 and 2

#

does it until there is no +, -, * or / left

lost matrix
storm crystal
#

why

#

xd

lost matrix
#

So you have clean, readable and reusable code and not just an utter mess like you often get with python.

warped shell
#

when was EntityChangeBlockEvent added to the api?

slate tinsel
#

If I want to rotate the block to the right so that it is in the opposite direction as the block to the left what should I write then if the first block is "1" on "transformation.getLeftRotation().x" it shouldn't be like -1 or I think all wrong?

#

So it goes like this:

storm crystal
#

but thats beside the point

#

point being Ive got no idea how to conceptualize how I would do things in python to java

lost matrix
#

How extensive do you want your expressions to be? Because writing even a half decent expression evaluator
is very difficult.

lilac dagger
#

It can be done statically, but java is a oop language

#

If you're just parsing the string

storm crystal
#

neither do I know parsing the string

hushed spindle
#

what you're trying to make is an expression evaluator

storm crystal
#

you mean calculator?

hushed spindle
#

a calculator evaluates expressions

storm crystal
#

well whatever what does static even mean

hushed spindle
#

i said earlier

#

static properties are properties belonging to the entire class

lilac dagger
#

Static let's you attach methods fields to a class rather than a object

hushed spindle
#

non-static properties are properties belonging to an object, or an instance of said class

lost matrix
#

A class cant really be used on its own. Its just a blueprint for an object.
You need to create instances of that class if you want to use it by using the new keyword.

hushed spindle
#

i.e. all vehicles (for the sake of simplicity) have wheels
not all vehicles are electric

#

flawed analogy but just so you can picture it

quaint mantle
#

java doesnt have properties

#

it has methods, fields and objects

hushed spindle
#

its just for the sake of simplicity

quaint mantle
#

and primitives

hushed spindle
#

the guy is new

#

if you want people to learn things you gotta start with something at their level

#

and build on that

quaint mantle
#

and dont forget about lambdas

hushed spindle
#

why use nms when server#getEntity() exists

lilac dagger
quaint mantle
storm crystal
hazy parrot
quaint mantle
#

they arent objects as you may think, they have own type called Lambda in reflection

#

and they cant really store anything

lost matrix
storm crystal
#

great but I literally have main method that starts from inside of a class, if it starts code from that class why I cant take a variable that I made in that class as well?

lilac dagger
#

It's weird, i can pass them into lists and such, doesn't make sense for them not to be objects

quaint mantle
#

they behave as an unnamed interface

#

that has only one method to implement

lost matrix
#

Hm?

#

You mean an anonymous class?

quaint mantle
#

they dont have name and true type is hiden

quaint mantle
slate tinsel
quaint mantle
#

where interface isnt an object

#

also anonymous class in java is lost potential

lost matrix
quaint mantle
#

and Runnable is interface

#

not an actual class

lost matrix
slender elbow
#

šŸ¤“ erm actually it's a hidden class

hushed spindle
#

whats the point of any of this

#

arent we trying to help a guy

quaint mantle
#

lambda expression werent added before java 1.8

storm crystal
#

whats the difference between class, method, field or object

hushed spindle
#

why overcomplicate this with technicalities

lost matrix
#

Bc last time i checked the Java compiler generates bytecode that creates an anonymous class that implements the Runnable interface and provides the implementation for the run method by using the lambda expression as the body.

slender elbow
#

no

quaint mantle
#

anyways

#

class is a declaration of type
method is a function on some class
field is just variable on some class
and object is initialization of class

smoky oak
#

can someone help me for a sec? my intellij aint starting

hushed spindle
#

lets use cars as analogy
class is the "blueprint" for the car
object is a new Car
method is the behavior of the car, a car can drive()
field can represent a property of the car, a variable, like a car has int wheels = 4

lost matrix
#

Im just gonna use 17

quaint mantle
storm crystal
hushed spindle
#

because java always starts at the main class

quaint mantle
#

becuz jvm makes it exist

hushed spindle
#

you gotta start somewhere and so java makes you start at main

storm crystal
#

okay but why doesnt it also start variables when i set them in here

hushed spindle
#

well it should, depends on how you do it and how you're accessing them

#

thats the part you're likely not understanding

#

and we cant help you until you show us

storm crystal
#

like what

hushed spindle
#

tf you mean like what

ivory sleet
rough drift
ivory sleet
#

I mean if u anonymously instantiate a functional interface then yes it would be anonymous

#

else nope

storm crystal
hushed spindle
#

your class that you're having this problem in??

rough drift
hushed spindle
#

your code

#

anyway, i got a multi-module project and the server isnt seeing where my plugin.yml is, im not sure where to look on how to sorta set one of these modules as the main plugin

rough drift
#

so what you do is you have your module with your plugin.yml in resources and it depends on all the other modules as dependency

#

and you just shade the others in

ivory sleet
hushed spindle
#

it should already be doing that

ivory sleet
#

(and yes as emily said, there is sorta hidden class which is classloaderless^^)

storm crystal
hushed spindle
#

right

#

this main is static

#

so your list should also be static

rough drift
#

and a list isn't an array

hushed spindle
#

you cant access non-static stuff from static methods

storm crystal
#

why not make main non-static

hushed spindle
#

main gotta be static

#

thats the rule

storm crystal
#

so I need to add static to every single piece because yes?

#

why isnt it default then

ivory sleet
storm crystal
#

I still cant run code

rough drift
#

you shouldn't run your code in main

#

main should be the entry point which launches a non-static class

karmic phoenix
rough drift
#

and you're missing generic types

storm crystal
#

so where am I supposed to run code

rough drift
#

let me give an example

lilac dagger
#

Oh, so lambdas are mostly anonymous methods

rough drift
#

lambdas create an instance of the interface and it is stored as a non-named class

slate tinsel
ivory sleet
rough drift
#
public class MyClass {
  public static void main(String[] a) {
    new MyClass().runCode();
  }

  public void runCode() {
    // Run your code
  }
}
```I would do this (maybe even main in another class)
storm crystal
#

why

rough drift
#

because you shouldn't make everything static

ivory sleet
rough drift
#

also that ^

storm crystal
#

which is?

lilac dagger
#

Java is object oriented

#

Python and c are different in this aspect

#

Tho python also has object support

#

It's just a later lesson

#

And not needed for most basic tasks

slender elbow
#

i mean python is also oo

#

just, it's garbage at doing it

rough drift
#

it looks up the name every time you call the function

#

and loads it