#paper-dev

2787 messages Β· Page 3 of 3 (latest)

fierce elm
#

should I turn on auto build?

#

yeah i'll leave it for now i guess

#

tbf it does build quickly since i have a small plugin

#

probably takes like 2-3 seconds

#

so probably dont need it

tiny storm
#

And finally, the code cleanup stuff is from linter suggestions, like sometimes the IDE has suggestions what you can change

tiny storm
tender helm
#

You can see all the suggestions like that if you do Code->Inspect Code

#

There are a bunch of those you can turn on and configure too, beyond the defaults

tiny storm
fierce elm
#

o

tender helm
#

When I was learning Java (not as my first language) the inspections in there were helpful for pointing out some footguns

tiny storm
#

I don't think I have ever used that window, but I agree that it can be useful when starting out

#

But like when you have a file open, it will tell you at the top anyways

tender helm
#

I turned a bunch of them on and read up on them to learn why it was potentially worth a warning

fierce elm
#

i just did git init . why is everything red

#

does that mean untracked?

tiny storm
#

That just means that the files are not added to git

#

Yes

#

If you do git add ., they will turn green

#

And when you commit, they will turn back white

#

Modified files show up blue

fierce elm
#

imo they should show it like vscode beside the named with a letter what the status is

#

i thought for a second EVERY file had an error 😭

tiny storm
#

I think it is much nicer this way

#

Visible at once, and colors are pretty

fierce elm
#

hmm

tender helm
#

vscode uses colors too it just also has a letter

#

Modified files are yellow and have an M

tiny storm
#

Fair enough

#

I don't use VSC, I wouldn't know

fierce elm
#

is there an extension in intellij that maybe brings it back?

dapper pivot
fierce elm
#

vscode-like git tracking

fierce elm
tiny storm
#

Is that one single letter really that big a deal though?

#

I don't even think it changes a lot

fierce elm
#

at a glance when you see the U you instantly know it's untracked
though since you're probably familiar with intelliJ's system that much it doesn't look like a big deal

tiny storm
#

Anyways it doesn't seem like there's a plugin for it

fierce elm
#

awh

tiny storm
fierce elm
#

true

tiny storm
#

Red file name always means untracked. If the file has an error, it will have a red swirly underline instead

fierce elm
#

oh

#

i see

dapper pivot
#

yeah, you get used to the IJ colors pretty quick honestly. it's not better or worse, just different

#

and that red underline for errors definitely saves lives lol

fierce elm
#

Looks like a lot of these plugins already exist... I'll just release the source code and not publish it to modrinth i guess

dapper pivot
#

source code only is fine though.

#

sometimes people just wanna mess with it themselves

fierce elm
#

true but it'd be less likely for someone to stumble against my source code

#

But you never know

dapper pivot
#

yeah true, weird people are everywhere lol

tiny storm
#

It's a project for you to learn, don't put pressure on yourself

fierce elm
#

yeah yeah no pressure

#

this is like my second plugin lol

tiny storm
#

Barely any of my own projects even make it to the surface of my GitHub

#

That's my fault for sure, but it's not a big deal

dapper pivot
true flint
dapper pivot
tiny storm
#

Sure, but I just never put in the effort to properly create and maintain a proper public project

#

I have one single library that I maintain actively

fierce elm
#

i've been there

fierce elm
#

uh should I commit gradle-wrapper.properties?

dapper pivot
dapper pivot
fierce elm
#

oh okay

shrewd spire
fierce elm
onyx portal
#

You can, i usually do since it’s free space and uhh too lazy to redownload it on other machines

dapper pivot
fierce elm
#

oh

dapper pivot
serene cosmos
#

Good practice imo. Means people can just clone your repository without worrying about installing Gradle, or having the correct Gradle version

dapper pivot
novel radish
shrewd spire
fierce elm
#

gotcha thank you everyone!

dapper pivot
dapper pivot
dapper pivot
fierce elm
#

thanks

dapper pivot
#

anytime man

visual prism
#

Should networking be async?

#

I send a networking request every hour, async scheduler or normal one?

tender helm
#

As much as possible IO should always be async

dapper pivot
tender helm
#

Well, IO that happens while the server is running

dapper pivot
tender helm
#

Reading a file in onEnable? Whatever, no one is playing right now anyway

visual prism
#

Oh okay thanks

dapper pivot
visual prism
#

Just a quick java thing, this should be volatile?

private static double something;

It's updated every hour in the network request

dapper pivot
dapper pivot
tender helm
dapper pivot
tender helm
#

Like you might be able to load and parse it async if you have a reload later but for that first start you need it so you either load it on the main thread or spin up a thread and then just block the main thread waiting for it to finish

visual prism
#

So I thought of which one to use

dapper pivot
#

yeah AtomicDouble works too, just depends on what you are doing with it

#

sometimes simple volatile is enough

tender helm
#

If you have a single writer I believe volatile is enough, so long as it's just a single value

#

If you have multiple writers you need at least atomic compare-and-swap, if you have multiple values you probably just need an actual lock

dapper pivot
dapper pivot
tardy atlas
#

volatile is still enough even with multiple writers, no?

#

the issue is if you try to do a divisible operation

#

i.e. n++

visual prism
tardy atlas
dapper pivot
tardy atlas
#

if it's an indivisible op it shouldn't

dapper pivot
tender helm
visual prism
#

I can keep the endpoint link in the plugin itself right? It's an opensource no Api-key service. So I don't think that it hurts

tardy atlas
#

x = 5 on a volatile member would be "atomic"

dapper pivot
dapper pivot
keen echo
#

How can I remove a certain amount of an item, from an existing stack which can have a different amount?

If player has 64 diamonds, the following doesnt remove 5 from the 64

player.getInventory().remove(new ItemStack(Material.DIAMOND, 5));
dapper pivot
dapper pivot
onyx portal
#

Oh or removeItemAnySlot

dapper pivot
onyx portal
#

Not from my memory

dapper pivot
onyx portal
#

Yeah, which is from my memory exactly what that function will do

visual prism
#

I guess you have to implement the removing yourself, it's not a ready method to remove exactly 5 diamonds

keen echo
#

I will try, one moment

dapper pivot
#

yeah pretty sure that's it too.

#

Void should just modify the stack size directly and be done with it.

onyx portal
#

removeItem should work, removeItemAnySlot for player inventories though

tender helm
dapper pivot
#

nah Jan, I still think that might clear the whole stack if it matches the item type exactly. at least last time I checked that's what happened

tender helm
#

Or it'll return an itemstack of 3 diamonds if the player only had 2 of them

#

You did it wrong then

onyx portal
#

See, i remembered correctly

dapper pivot
#

modify the itemstack itself is safer

onyx portal
#

No?

tender helm
#

If you already have the relevant slot then sure, just modify it

dapper pivot
dapper pivot
tender helm
#

If you're just trying to remove items from a player for a shop you probably need removeItem though

#

If you're trying to remove the items from their hand then you already know what slot to check and modify

keen echo
#

removeItem works as suggested by @onyx portal,
it removes the given amount from a stack that has enough, OR if there are enough across the inventory (e.g spread out)

thank you very much πŸ™

tender helm
#

Make sure you don't ignore the return value

dapper pivot
#

yeah that's true

onyx portal
#

Empty hahsmap = success, anything else = not success

dapper pivot
#

always gotta check if it actually removed everything you wanted

tender helm
#

If it's not empty you need to give them their items back and cancel (or do a partial action if that's a thing you can do)

keen echo
#

good idea, thank you

keen echo
dapper pivot
#

yeah that's true

#

always gotta check if it actually removed everything you wanted

lament venture
#

not the place

dapper pivot
#

wrong channel bud

silk bough
#

Oh wich Channel is the Right

lament venture
urban dew
#

This is currently the GUI where all our server replays are listed, but I find it a bit cluttered and also pretty boring. Do you have any ideas on how we could improve it? Feel free to suggest something out of the ordinary, I like to experiment, so it doesn't even have to be a GUI...

tender helm
urban dew
#

Fair, what type do you recommend? Never had things listed in a Dialog. just some basic settings

dapper pivot
dapper pivot
dapper pivot
tardy atlas
#

instruction reordering moment

dapper pivot
#

I think just using lists in standard inventory GUIs usually works best.

#

keeping it clear and simple unless you really wanna try to push the visual side

cursive crypt
#

Inventory GUIs as a list are nightmares because you have to hover over everything to figure out wtf it is. Dialogs let you use text. Whether for buttons or just for a big body with clickable text, it's much easier to communicate info to the user.

dapper pivot
dapper pivot
hollow glen
#

x = 5 is atomic […] for volatile variables, except for long and double, […] unless also volatile

#

πŸ€”

cursive crypt
#

Don't let "people got used to garbage" get in the way of progress!

bitter gale
cursive crypt
#

I mean, doesn't look like it extends persistent data type but that's also not our library

bitter gale
#

okay

unborn mist
#

hey everyone, what is the easiest way of preventing players from changing their helmet?
i already use the inventoryclickevent and it works fine but when the player right clicks the air with a helmet it still changes.
what event would be best to cancel for that?
this is for a minigame so it doesnt need to be pretty

dapper pivot
unborn mist
#

ah yeah, makes sense, ty

severe orbit
#

when im kicking a player from my mc server in the backend code, it shows the velocity You were kick from ... and then my message, can i somehow override that?

tender helm
#

Maybe with a velocity plugin?

dapper pivot
tender helm
#

Or maybe it has some config option, I dunno

dapper pivot
tender helm
#

They are changing the reason, velocity is wrapping that reason with an extra message

dapper pivot
severe orbit
dapper pivot
severe orbit
#

thank you guys, i guess im gonna put that code on the proxy

dapper pivot
severe orbit
#

yeah

dapper pivot
tender helm
#

You don't need to move all the logic over, assuming you just always want to kick them when a server kicks them and always want to only show the server's kick message

#

I think, I've never used velocity before so this is just from reading javadocs

dapper pivot
severe orbit
#

ohh

#

i see

dapper pivot
#

nah it's data on the block, check BlockData for farmland

bitter gale
#

yeah i realized thanks

keen echo
#

What is the recommended way of accessing config.yml data from another class?

I have an entry class which extends JavaPlugin and loads the config when onEnable is called.
Then I have a separate class which contains logic for a /command - what is the recommended way for this case?

cursive crypt
#

Any standard java technique. Pass the reference to the main plugin class into the command is a fine strategy. Then you can plugin.getConfig or whatever.

dapper pivot
dapper pivot
cursive crypt
#

Also maybe don't have AI build your questions so formally. πŸ™‚

dapper pivot
keen echo
keen echo
spring haven
cursive crypt
dapper pivot
#

yeah that headings markdown is kinda unusual to do by hand

#

but it made the point clear at least lol

cursive crypt
#

It's all good, I wasn't assuming malice.

bitter gale
#

how do i create a fake display entity? is there docs i can read to

true flint
#

using nms or packets also you can just hide it by default

keen echo
#

You're right, its quite formal how I present it Xd

bitter gale
dapper pivot
dapper pivot
true flint
# bitter gale by default?

i mean you can spawn a simple display entity, then set it to be hidden by default then just show to whoever you need

bitter gale
#

oh okay

true flint
#

if not just use packet events + EntityLib or nms

bitter gale
#

i more wanted the like removal aspect

true flint
#

wym by removal aspect

dapper pivot
#

just send a destroy packet for that entity to the players who shouldn't see it

hollow glen
#

or you can just use Player#hideEntity, or alternatively Entity#setVisibleByDefault + Player#showEntity

true flint
#

yeah thats what i said

cursive crypt
#

Why manually send destroy packets when you can use the proper hiding setup? Otherwise the clients will still get info about entities as they change.

true flint
#

display entities are not expensive you dont need them to be packet based

cursive crypt
#

Lancelot had a very different proposal, which is what Emily's replying to

dapper pivot
dapper pivot
cursive crypt
#

Combining creating real entities and hiding with packets makes for a nasty mess, and is what the whole hiding API exists to solve.

true flint
#

i think that lancelot just said that if he wanted to do the packet way

bitter gale
#

i want the entity to like disappear if the player isnt close to it so i was worried that tracking the entity would be difficult since fake entities time out

dapper pivot
bitter gale
#

but i realized you can probably just save the entity to the player anyway

true flint
hollow glen
#

just use the api

true flint
#

that destroys the entity if the chunk was unloaded

bitter gale
#

hm okay ill experiment thanks

dapper pivot
bitter gale
#

🫢

true flint
#

spawn your think, hide by default, show when needed, leave persistent property do his things when chunk unloaded, then respawn it on ChunkLoadEvent or PlayerChunkLoadEvent when needed

dapper pivot
visual prism
#

Can I make a bossbar with no bar? Like just the text

bitter gale
dapper pivot
hollow glen
#

what…?

dapper pivot
finite novaBOT
bitter gale
#

😭

#

smited

visual prism
cursive crypt
#

Ban reason covers it. Also this ain't the channel for ban stories πŸ™‚

visual prism
#

Ah

severe orbit
#

can i set gamerules in code, for the whole server?

true flint
#

i guess you can use WorldLoadEvent for that or onEnable method using postWorld

keen echo
#

Is it a good or bad practice to not replace a config file ?

saveResource("config.yml", false);
cursive crypt
keen echo
#

or is it better to just use defaults if the new settings dont exist in the local file

hollow glen
#

how should it be handled by the admin of server πŸ€”
by reading the changelog before updating plugins πŸ˜„ you can probably do some sort of config migration if you really want to, adding new entries, deleting removed ones and keeping the user's ones

#

or yeah just run defaults for missing settings, that's the simplest option, but you ought to document config changes on updates

keen echo
#

okay, that makes sense 🫑

#

Imma do that

buoyant barn
#

try out configlib

#

handles that all for you and puts your config into an ODM

true flint
#

configurate >

buoyant barn
#

eh

#

nah

#

πŸ˜‹

heavy cape
#

umm hi, could someone pls explain how I can get the attack cooldown at the moment of hitting an entity?
i use to do this by getting Player.getAttackCooldown() during an EntityDamageEvent, but now the cooldown resets before the event is fired D:

open tendon
#

try PrePlayerAttackEntityEvent

clever stream
#

then delete the old one

heavy cape
#

truly a paper moment, ty tho

thin patrol
#

How long does it typically take for paper pr’s to get reviewed?

winter anvil
thin patrol
azure karma
#

how I can teleport player into custom dimension

muted gale
#

you can get the dimension with Bukkit.getWorld(Key.key("yourns:yourdim")) and then you can do Player#teleportAsync(new Location(theworld, 0, 200, 0));

azure karma
#

can i create custom dimension (in plugin)

#

not json

muted gale
#

you can

azure karma
#

ok

muted gale
#
Bukkit.createWorld(new WorldCreator(new NamespacedKey("ns", "key"))
                .environment(World.Environment.NORMAL)
                .seed(1234));
#

@azure karma

#

this will either create or load if it exists

#

and it will return the World instance

obsidian phoenix
#

I am fairly new to the plugin development game. I developed a mob stand that kills adults and leaves babies along. Not quite done yet but stress test is here. What would be acceptible time considering it is 1) Scanning for all mobs and getting the ones that are slated for slaughter (babies and adults are set seperately on the stand config so user can decide wether to kill babies or leave them for each animal type, same for adults. then dealing damage to cause them to die and letting game mechanics determine drops.

serene parrot
#

100ms seems massive

#

What exactly are you doing? And hopefully not on the main thread?

obsidian phoenix
#

scans every so often and kills qualifying mobs. I have a string of command blocks set up on repeat to summon mobs and this scans every few seconds.

serene cosmos
#

seems rather slow to me

#

though I guess calculating drops for 2k entities might take a bit.
Best to use spark with --only-ticks-over 50 or so to see what exactly is slow there. if its your plugin, or the loot stuff

obsidian phoenix
#

This isn't calculating drops. It is dealing each mob damage and letting the game sort it.

serene cosmos
#

yes, and the game will calculate drops

obsidian phoenix
#

2,300 mobs in that screenshot alone.

serene cosmos
#

if its not that I can't imagine 2k mobs taking 100ms

#

getting nearby entities is very fast. removing them should be too

muted gale
#

does it load chunks or do you just get loaded entities?

#

ah so loaded

obsidian phoenix
#

only entities.

muted gale
#

you just do getNerbyEntites?

obsidian phoenix
#

[02:45:33 WARN]: [RS-MobStand] Slow cycle: 50.60ms | Killed: 266 | world -8 -60 -9

muted gale
#

or World#getEntities

obsidian phoenix
#

armorStand.getNearbyEntities(
radius,
radius,
radius
)

serene parrot
#

Can you send a spark report? Something seems really off

obsidian phoenix
#

Not sure how to do that.lmao

obsidian phoenix
#

ive never used spark

serene parrot
#

Spark is a profiler, you can install it as a plugin, then you just start with that additional param, let your plugin do stuff and then stop and send us the link

obsidian phoenix
#

ok gimme sec.

scarlet orbit
#

(it also comes with Paper directly, no need to install it manually)

serene cosmos
#

/spark profiler start --only-ticks-over 50, then run your kill stuff, then do /spark profiler stop and send the link here

#

Just did the same with my custom mob plugin, killing 5k entities in a radius takes 16ms. So something is off there for sure

muted gale
obsidian phoenix
#

[02:45:13] [Server thread/WARN]: [RS-MobStand] Slow cycle: 102.86ms | Killed: 1564 | world -8 -60 -9
[02:45:33] [Server thread/WARN]: [RS-MobStand] Slow cycle: 50.60ms | Killed: 266 | world -8 -60 -9
[02:45:43] [Server thread/WARN]: [RS-MobStand] Slow cycle: 59.95ms | Killed: 806 | world -8 -60 -9
[02:48:19] [Server thread/WARN]: [RS-MobStand] Slow cycle: 85.24ms | Killed: 2323 | world -8 -60 -9
[02:53:09] [Server thread/WARN]: [RS-MobStand] Slow cycle: 46.94ms | Killed: 997 | world -8 -58 -10
[02:53:19] [Server thread/WARN]: [RS-MobStand] Slow cycle: 44.61ms | Killed: 1092 | world -8 -58 -10
[02:54:48] [Server thread/WARN]: [RS-MobStand] Slow cycle: 36.31ms | Killed: 1134 | world -8 -58 -10
[02:54:58] [Server thread/WARN]: [RS-MobStand] Slow cycle: 7.45ms | Killed: 137 | world -8 -58 -10
[02:55:08] [Server thread/WARN]: [RS-MobStand] Slow cycle: 5.29ms | Killed: 75 | world -8 -58 -10
[02:55:18] [Server thread/WARN]: [RS-MobStand] Slow cycle: 25.24ms | Killed: 362 | world -8 -58 -10
[02:57:07] [Server thread/WARN]: [RS-MobStand] Slow cycle: 40.33ms | Killed: 751 | world -8 -58 -10

scarlet orbit
#

send the link

obsidian phoenix
serene cosmos
#

that really seems more like the server is struggling with the entities themselves than your killing logic being the issue

#

how are you measuring those "slow cycles"? because if that just tick time, its somewhat meaningless.
But otherwise that looks like expected performance with 1k entities on 13 year old mid-tier CPU

obsidian phoenix
#

Measures execution time of the scan/kill cycle.

#

Scan entities, check against stands filters, deal damage is need and move to next.

#

And yeah, the game was laggy as all get out when it cycled. I have it waiting a long time in between kills so I can stress test it.

#

actually it was lagy BEFORE it cycled. it just cleaned it up and sped it back up.

serene cosmos
#

But generally spark shows what I suspected. you can expand the individual entries of the profiler (starting at your SlaughterTask) to see what exactly is taking how long.
And what takes the most time is indeed creating the items for the dropped loot

#

If you want to fix that the best way is probably precalculating the loot. e.g. loot for mob type X times amount of mob. And then just removing the entities instead of vanilla damaging them, and handling the loot separately in your plugin

obsidian phoenix
#

Ok. Thanks. backto the drawing board. lmao. This thing so far has totally pushed the limits of what I know. lmao

glad kayak
#

where should I define my command trees and register them? in a new class or? I am new to java and plugin development

bitter pythonBOT
#

that's basically up to you. general rule of thumb is to not have classes that are longer than a couple hundred lines

#

(of course the structure should be logical, but large classes are often an indicator for a messy design

glad kayak
#

Alright thanks mr webhook

brittle marten
#

is EventPriority.LOWEST the first or last to get called

bitter pythonBOT
#

first

#

the priority for events is from the perspective of who should have the last say on the result, so lowest goes first, highest and then monitor go last

brittle marten
#

okay

glad kayak
#

might be a stupid question but can those classes go into a seperate commands folder or just in the same directory as the main class? And in what way should i connect the other classes like commands to the main class?

bitter pythonBOT
#

they can go wherever you want

#

of course you need to invoke their code somehow from your plugin's entrypoints in the main class (or from registered event listeners)

azure karma
muted gale
#

in this context World = dimension

#

this will create a new entry in dimension subfolder

#

in relevant ns folder

azure karma
muted gale
#

what version are you on?

azure karma
#

1.21.11

muted gale
#

ah

#

I am talking about 26.1

#

I would say dimensions are not supported this way pre 26.1

azure karma
#

uhhh

novel radish
#

Mojang fixed up their world storage, paper followed

#

pre 26.x will use the older craftbukkit layout of the files being in the world container folder (the working directory by default)

tight osprey
#

is this bad?

#

what do I need todo

maiden birch
#

before the migration

#

This is due to vanilla changing the world format in 26.1

#

And then run the server again and let it migrate

#

It is necessary

tight osprey
#

oh so I don't have to do anything, but just back it up? thanks πŸ™‚

zealous dome
#

Is there a way to distinguish (or maybe is there another event called for that) whether PlayerDropItemEvent was dropped from hand or while viewing inventory?

glad kayak
#

how can you add a material argument with argument()

spring haven
glad kayak
zealous dome
#

I should've explained what I wanted to do first, sorry. I'm trying to prevent changing amount of certain item stacks by players. I already implemented that by doing checks in InventoryClickEvent listener, but now I want to prevent one-item drops outside inventory. How could I do that?

#

I want to allow the one-item drop if the quantity is 1

zealous dome
muted gale
#

Inventoryclickevent is the way to go, you can check clicked item or cursor item

#

Depends if it is q drop or click outside

balmy ocean
zealous dome
muted gale
#

That should be the playerdropitemevent

#

Or I am not sure if I follow

spring haven
zealous dome
zealous dome
novel radish
#

Outside of basically tracking if a click event was fired, there probably isn't a way to do what you're asking

#

lack of a cause stack means that there is often 0 real context of what triggered an event as a side-effect, and the client is basically always considered to have the player inventory open

azure karma
#

i can delete dimension file in runtime?

#

Deleting a folder using File.delete() doesn't work.

zealous dome
muted gale
novel radish
novel radish
zealous dome
novel radish
#

The problem is generally how invasive in getting the context to the event is

#

not "is it technically possible"

grand cave
#

what are these about? im on paper

zealous dome
novel radish
#

Yea, but those events usually have a shallow enough context surface that it's not a design nightmare or have so much utility that said nightmare is worth it

hallow lark
#

that used to be the biggest API difference between those platforms so its a sensible port, although obviously the same call doesn't do the exact same thing on folia and paper

glad kayak
novel radish
#

There is a method to convert to a Material somewhere iirc

#

otherwise the name should generally match across the XType to the Material enum

#

just a "The Type things aren't really first class yet"

crisp knoll
#

hypothetically could paper ever have custom blocks that the minecraft client sees as an existing block? for example could there be a "Super Stone" that drops an item with meta data but the client sees it as regular stone block?

midnight carbon
#

im 99% sure this has to do with the fact that the command trees are not sent the same in the DECLARE_COMMANDS packet between the two versions. i am not sure if this has to do with the patch (the PR you mentioned) the Machine Maker authored

#

if someone from the Paper team can shed some more light on this that would be great

#

if the intent of the PR was to always force the client to ask the server for completions, then that clearly doesn't seem to be the case.

also- its worth noting that i am able to get the intended suggestions by modifying the DECLARE_COMMANDS packet before it reaches the client.

edgy plank
#

people usually do that via PDC + listening to specific events

crisp knoll
#

man i wish mojang would just allow for custom blocks with their datapacks. it would be so nice to have that on paper

edgy plank
midnight carbon
#

oh so you're saying the patch was reverted in this commit. i understnad

edgy plank
#

yeah, so the behavior you saw before was due to a Paper change, not necessarily how it works

#

whether that was intended or not is something probably worth making an issue. I imagine there's more to just modifying the declare commands packet that we're not seeing here, like the duplicated names in the tp command

#

though not sure if it is gonna get much attention since they removed the patch because Paper doesn't want to deal with it lol

maiden birch
#

right now they’re doing that for items

#

and blocks are next

crisp knoll
#

seriously? where have you heard that from?

maiden birch
#

they’re slowly (or even fast) making everything data driven

maiden birch
#

you can see how many changes they’re doing to make things data driven

#

No soliciting here

#

<@&748618676189528155>

crisp knoll
maiden birch
#

i just have a habit atp of pinging mods cuz almost every day there are some people soliciting and not listening when people tell them not to

maiden birch
#

They have been working on items since 1.20.5 iirc

crisp knoll
#

yeah ive been really enjoying the item changes

maiden birch
#

oh and also they’re now focusing mostly on VV so the development of data driven features has been subsided

dawn kiln
#

Is PlayerTradeEvent called when a trade is completed through a custom merchant inventory?

karmic citrus
dawn kiln
#

Alright.

#

It is not.

bright flame
#

Id say thats probably an impossibility ngl do you know when this event is triggered?

#

Do you have a villager? Or a bukkit created merchant

dawn kiln
#

Bukkit created merchant for a custom trader system.

bright flame
#

You want to be using PlayerPurchaseEvent

dawn kiln
#

Is that the same event but for custom merchant menus?

dawn kiln
#

Thank you, Miles.

bright flame
#
            if (this.merchant instanceof AbstractVillager abstractVillager) {
                event = new PlayerTradeEvent(...);
            } else if (this.merchant instanceof CraftMerchantCustom.MinecraftMerchant minecraftMerchant) {
                event = new PlayerPurchaseEvent(...);
            }```
#

honestly this difference kinda sucks and makes pretty little sense, but hey we ball

dawn kiln
#

Yea I don’t see why it’s two separate events for the same things.

bright flame
karmic citrus
#

The difference is that trade event also gives you the villager mob, that doesn't exist for custom merchants

bright flame
#

oh yeah there you go ^

dawn kiln
#

But you could just do a null check for that and have it in one event. Oh well I guess it doesn’t really matter.

novel radish
#

The event was added 5 years ago when the logic between merchants and villagers was more seperate

#

[Amendment: Alexander protonull@protonmail.com]
PlayerTradeEvent is used for player purchases from villagers and wandering
traders, but not custom merchants created via Bukkit.createMerchant(). During
discussions in Discord it was decided that it'd be better to add a new event
that PlayerTradeEvent inherits from than change getVillager()'s annotation to
@Nullable, especially since that'd also infringe on the implication of the
event being about villager trades.

#

making a method return nullable is a breaking API change

soft island
#

Hello guys is there an alternative to ChatColor.Bold I'm aware ChatColor is now deprecated so I'm just curious if there's an alternative to it

karmic citrus
#

Or text decoration when making the component

quartz nacelle
#

Is there any way to reliably disable sprinting/crouching?

solemn bluff
#

is there a way I can detect a held right click on like a skull item or like a wither skull? looking through java docs and i'm lowkey stuck

soft island
karmic citrus
toxic aspen
#

@unborn mist
My plugin doesn't have a traditional event handler, because it handles different players differently, it uses protocollib and hooks into SYSTEM_CHAT, DISGUISED_CHAT and CHAT packets.
This makes it even worse for interference because it's guaranteed to run after ANY event handler, on the flip side it's more consistent and I know my message won't be modified afterwards.

karmic citrus
plucky sundial
#

Is there an API way to get the owner of an ender chest? I see PlayerEnderChestContainer.getOwner, but there doesn't seem to be a way to access it.

unborn mist
toxic aspen
solemn bluff
toxic aspen
#

yeahhh it's advancedchat stripping messages

unborn mist
#

this really feels like one of your plugins sanitizing the string

toxic aspen
#

already figured it out, AdvancedChat is :P

plucky sundial
toxic aspen
# toxic aspen already figured it out, AdvancedChat is :P

definitive fix:
give permissions advancedchat.chat.colors and advancedchat.chat.magic and it stops stripping minimessage tags.
was 100% not a paper sanitation check as I had initially suspected.
this behavior is documented nowhere...

soft island
#

oh lol

toxic aspen
soft island
#

just saw the username

#

i mean the bio

#

hahahaha

#

mb

toxic aspen
#

Anyway other than clickevent is there any minimessage that would be dangerous to allow in player messages?

solemn bluff
keen echo
#

Is there are more preferred way of defining and parsing vanilla minecraft enchantments?

[06:32:44 WARN]: [org.bukkit.craftbukkit.legacy.CraftLegacy] Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!

In config.yml file, enchantments are named like minecraft:protection

and in the code, it is parsed with:

Material material = Material.matchMaterial(materialKey, true);
tender relic
#

? enchantments aren't materials?

keen echo
#

oh 🀣 youre right, im tired 😩

edgy plank
#

though your example leaves me confused as hell as to whether you actually meant enchantments or materials

#

Registry.MATERIAL.get(Key.key(materialKey))

#

ideally you'd use Registry.ITEM/BLOCK accordingly depending on what you're parsing though

keen echo
#

Forget the material stuff, I was thinking wrong about it. What im trying to achieve is define enchantments inside the config.yml file and use them in code to get certain other related config

perhaps i was overthinking about "minecraft:" prefix, wondering if using the name directly would conflict with some other plugin. πŸ€”

hollow glen
#

you just get it from the enchantment registry

#

RegistryAccess.registryAccess().getRegistry(RegistryKey.ENCHANTMENT).get(Key.key("minecraft:sharpness"))

keen echo
#

I see now, thank you 🫑

edgy plank
#

so how you obtain them ends up being the same all around

dawn kiln
#
    public void onPlayerMapFilled(PlayerMapFilledEvent event) {
        Player player = event.getPlayer();
        ItemStack item = event.getCreatedMap();

        MapMeta mapMeta = (MapMeta) item.getItemMeta();

        if (!mapMeta.hasMapView()) return;
        MapView view = mapMeta.getMapView();
        if (view == null) return;
        view.setCenterX(0);
        view.setCenterZ(-15);
        view.setWorld(SUMMER_WORLD);
        view.setScale(Scale.NORMAL);
        mapMeta.setMapView(view);
        mapMeta.displayName(MiniMessage.miniMessage().deserialize("Treasure Map"));
        item.setItemMeta(mapMeta);
        
    }```

Can anyone tell me why the item name isn't being changed? Everything else such as the map view is being changed properly.
plucky sundial
#

In what event would a world lose its UUID and be given a new one? I'm trying to figure out if it's worth storing the world UUID AND world name in my database for a home location.

dawn kiln
#

UUIDs are persistent.

cursive crypt
#

I suppose someone could edit the file storing the uuid

plucky sundial
#

So basically in no common/uncommon scenario would that happen?

honest tartan
#

World uuids are a bukkit thing, maybe loading the world in singleplayer then back on server could change its uuid

plucky sundial
#

hmm

echo terrace
#

i always store just the world name, so server admin can switch worlds if they have to

plucky sundial
#

I'll test that

dawn kiln
#

World names are perfectly safe to go off as well, like teeth said. The only thing that can go wrong there is if someone changes the world name. But if you just leave the server running normally it should be fine.

plucky sundial
dawn kiln
#

How?

honest tartan
dawn kiln
#

Thank you. I will do that.

plucky sundial
dawn kiln
#

No. You can just use the world's name to save homes rather than UUID.

#

So in your file or database or whatever, you can store it as just "world" rather than the overworld's UUID.

#

Do exactly what you were doing before, but don't use UUID: just use the world folder's name.

plucky sundial
#

I was doing both before (name as a backup), but I guess that'll work

dawn kiln
#

You only need one, as long as you don't have two worlds with the same folder name (which should be impossible anyways) you're fine.

#

Is it possible to define custom map dimensions to make the map be exactly the size of the build you want it to be?

plucky sundial
dawn kiln
#

Yea but I have to have a border around it with that.

plucky sundial
#

There is MapRenderer

dawn kiln
#

Is there any way to get a client's distortion effects value? Packets, NMS, etc are all ok for me.

serene cosmos
#

no, those accessibility settings values are not sent to the server at all

keen echo
#

is there a way to reload a certain plugin ?
bit awkward to stop/start server each time

spring haven
#

you can setup hotswapping in your ide, given your server is started through the runServer task and not externally

keen echo
spring haven
#

are you using intellij?

keen echo
#

yes

spring haven
#

then you can just run the task in debug mode

#

make your changes, then rebuild

keen echo
#

Im not sure how to go about that πŸ€” Currently what I do is build the project, take the jar, place inside plugins folder and restart server

spring haven
#

why not use the runServer task instead?

keen echo
spring haven
zinc brook
#

LivingEntity#setNoDamageTicks(0); remove invincible time after damaged only one-time or permanently?

serene cosmos
#

once

zinc brook
#

cool, thanks πŸ™

amber anchor
#

Hi, is it normal for TextDisplay entities to disappear on world change?

#

It does for me

queen plinth
#

What do you mean by world change? Maybe chunk unloading?

amber anchor
queen plinth
#

Are the displays still there?

amber anchor
#

yes other players can see it

winter anvil
#

They are packet based or what

#

Can you show your code

karmic citrus
amber anchor
#

I am using FancyHolograms

#

However, displays summoned using /summon command don't show up either

karmic citrus
karmic citrus
amber anchor
#

Hm no I was wrong, displays which are summoned are indeed visible after changing worlds

#

Must be a plugin issue

zealous dome
#

Do I understand correctly, does the radius set using Explosive#setYield get doubled in actual calculations?

golden estuary
#

im trying to mimic fishing loot as if the player actually fished, but not 100% sure im doing it correctly:

ItemStack rod = player.getActiveItem();
if (rod.getType() != Material.FISHING_ROD) return;

AttributeInstance luckAttr = player.getAttribute(Attribute.LUCK);
double baseLuck = luckAttr != null ? luckAttr.getValue() : 0.0;
int rodLuckLevel = rod.getEnchantmentLevel(Enchantment.LUCK_OF_THE_SEA);
float totalLuck = (float) (baseLuck + rodLuckLevel);

LootContext context = new LootContext.Builder(player.getLocation())
        .luck(totalLuck)
        .build();

Collection<ItemStack> loot = LootTables.FISHING.getLootTable().populateLoot(ThreadLocalRandom.current(), context);

Am i interpreting how luck of the sea works correctly? the wiki doesn't really state how this modifies luck, only how it changes the drop chance for each category. Did i also create the context correctly? theres builder methods for Β΄lootedEntityΒ΄ and killer but i assumed it didnt apply for fishing

golden estuary
#

ah, looks like theres some unexposed params i need to set in the loot context, like the item used itself, ill just use nms in that case

vocal ember
#

If I want a screen shake effect (and also shake on third person), is it best to do this on a shader? Not sure if there's a pure plugin way to do it

vocal ember
winter anvil
vocal ember
#

Oooh

winter anvil
#

See message from this line

#

Basically setrotation and fov ability

vocal ember
#

This is seriously cool, how does it manipulate fov in there, though?

#

Since the coroutine seems to only be updating pitch and yaw

keen echo
#

Regarding permissions, is it enough to have permissions declared in the plugin.yml file? or do I also have to perform a check within the code itself?

# ...

permissions:
  kebab.abc:
    default: true
    description: Allows a player to eat kebab, yumyum.

commands:
  kebab:
    description: "something something..."
    permission: kebab.abc
    permission-message: "You dont have the required permission."
    usage: "/kebab"
bitter pythonBOT
#

if you register the commands via the plugin.yml then it is enough

#

if you manually add them to the command map via the API then you need to set their permission in code

timid dirge
#

What's the best way to register permissions for a paper plugin?
rn I'm just awkwardly registering them in on enable, but it's kinda awkward bc if i register a perm that already exists it just throws an error >.<

crude tendon
hollow glen
#

i mean you can just shove your permissions in your paper-plugin.yml ?

#

if you're doing things dynamically, the api for registering permissions hasn't changed for over a decade

grand cave
#

why is ChannelInitializeListenerHolder not in my classpath

hollow glen
#

i don't know, are you using paperweight.userdev to depend on server internals?

grand cave
#

no

hollow glen
#

well, that's why

#

that class is an internal class, not exposed in the API

#

to access server internals you need to use the paperweight.userdev gradle plugin

white treeBOT
grand cave
#

will this make my plugin version specific if im only using ChannelInitializeListenerHolder?

novel radish
#

I mean, you're accessing internals and while that is not around logic which changes often, it does not have the safety holds of the API when it comes to compat, etc

hollow glen
#

that class was not always present, and you are at the mercy of, netty APIs, minecraft changing the name of its pipeline handlers, etc

grand cave
#

i mean as long as paper loads my plugin thats fine

hollow glen
#

while it isn't going to lock you to one version only and exclusively, it is something you need to take care of and read up potential changes when new versions are relased

rotund mulch
#

Is it possible to disable totem use on death (I want to add a limit for max one totem use per minute)

hollow glen
#

you can cancel the EntityResurrectEvent

rotund mulch
#

thx

winter orchid
#

Is there an know issue that PreFillProfileEvent and FillProfileEvent have no function?

hollow glen
#

yes

visual prism
#

While Networking, I am sending a request, and the response contains ASCII letters. and when I use that response I always get question marks. I always specify the charset as UTF-8 but still doesn't work

#

I specify UTF-8 in the ContentType header, in the BodyPublishers of the request, and in the BodyHandlers of the response, nothing works

visual prism
mossy timberBOT
echo terrace
visual prism
#

Printing what sendMessage() returns

echo terrace
#

intellij idea terminal?

visual prism
echo terrace
# visual prism Yes?

well, i've got question marks too thinking it was my issue, however then i tried sending same message in minecraft and it worked

#

are you using gradle runServer by a chance

#

i suspect it's either gradle or intellij idea terminal just does not support non ascii charactors

visual prism
#

I tried this networking in a normal Gradle app

#

To print the response and see how it looks like

echo terrace
#

try setting
org.gradle.jvmargs=-Dfile.encoding=UTF-8 in gralde properties

#

i havent tried this though

tawny zodiac
#

hmm you cannot set a Type of block using BlockType?

visual prism
edgy plank
#

gotta convert to Material

echo terrace
#

gradle.properties

#

i meant

edgy plank
#

it is usually advised that you set the file encoding of the compile tasks

hollow glen
edgy plank
#
tasks.withType<JavaCompile>().configureEach {
  options.encoding = Charsets.UTF_8.name()
}
tasks.withType<ProcessResources>().configureEach {
  filteringCharset = Charsets.UTF_8.name()
}
winter anvil
echo terrace
#

okay that did not work unfortunately

hollow glen
#

:):)

echo terrace
#
jvmArgs("-Xms1G", "-Xmx1G", "-XX:+AllowEnhancedClassRedefinition", "-Dfile.encoding=UTF-8")
    minecraftVersion("1.21.11")
    downloadPlugins {
        github("MilkBowl", "Vault", "1.7.3", "Vault.jar")
        //   url("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/build/libs/ProtocolLib.jar")
        hangar("PlaceholderAPI", "2.11.6")
        github("GoldenShad0w", "DisplayEntityEditor", "v1.0.17", "DisplayEntityEditor-1.0.17.jar")
        url("https://ci.minebench.de/job/FakeEconomy/lastSuccessfulBuild/artifact/target/FakeEconomy.jar")
        url("https://download.luckperms.net/1631/bukkit/loader/LuckPerms-Bukkit-5.5.42.jar")

    }
}
``` i'm crine this also doesnt work
hollow glen
#

which is also different to your terminal's encoding

#

and your shell

#

text is beautiful

edgy plank
#

intellij run terminal sucks

#

it doesn't display colors either, I just run the gradle tasks on a separate terminal now that IJ handles outside changes well enough

tawny zodiac
hollow glen
#

i don't really use intellij for anything other than programming and managing the project's files

#

git and gradle i do wholly on my system terminal

edgy plank
#

same, except maybe for the merge conflict view, IJ's one is pretty nice

hollow glen
#

i just don't have merge conflicts

echo terrace
#

😒

hollow glen
#

i mean, i have no idea what you're printing

echo terrace
#

text in cyrillic

#

look fine in game

hollow glen
#

blame powershell Β―_(ツ)_/Β―

verbal kettle
#

Everything works fine for me.

hollow glen
#

well, i don't use powershell so i can't know

karmic citrus
# echo terrace 😒

built in powershell doesn't support other charsets like utf 8 from what I remember, try installing latest powershell or use command line

timid dirge
lucid canopy
#

Well, the docs only mention differences to the normal plugin.yml, and there is no difference at that point.

timid dirge
#

ah, I see...

lucid canopy
#

Since commands and permissions are mostly tight (tied?) together the assumption is understandable.

timid dirge
#

for some reason I thought that everything not mentioned in the guide just didn't exist. Since the only thing hinting that it only shows the differences is:

This will not act as a drop-in replacement for plugin.yml, as some things, as outlined in this guide, need to be declared differently.
tho I understood that as, you'll see the differences by reading the guide, not this guide shows the differences.

#

so I just thought, no commands mentioned? makes sense, since brigadier is the new norm.
no permissions mentioned? I guess I'll need to register them myself.

lucid canopy
lucid canopy
timid dirge
timid dirge
novel radish
# echo terrace 😒

Stuff like that is generally going to be down to your windows config, there is an option to enable beta support for Unicode somewhere that will probably fix it

edgy plank
echo terrace
#

Wdym powershell core

edgy plank
#

it comes installed with windows 11 nowadays, the old windows powershell has been long deprecated though still shipped with the system

#

the readme explains the difference

slim urchin
#

Hello y’all,

Am new to plugin development, but I do have a bucket goal in mind for down the road

I wanted to know how feasible it would be to detect when a village is being generated and then add an additional building (via an nbt structure file) to that village

edgy plank
echo terrace
edgy plank
edgy plank
#

you also have to make sure the chunks are loaded when you try to place the structure iirc

echo terrace
#

i mean, utf-8 output works fine as far as i can tell, i think issue is in gradle

edgy plank
echo terrace
#
try {
            MiniMessageTranslationStore store = new LocalizationLoader(
                    new File(getDataFolder(), "locale"))
                    .loadStore(Key.key("cult:clans"));
            GlobalTranslator.translator().addSource(store);
        } catch (IOException | URISyntaxException e) {
            SneakyThrow.sneaky(e);
        }

        getServer().getScheduler().runTaskTimer(this, () -> {
            getServer().sendMessage(Component.translatable("clans.already_in_clan"));
        }, 20L, 20L);
#

pardon formatting

edgy plank
#

your localization loader I assume is the one you shared earlier in #adventure-help?

echo terrace
#

yep

edgy plank
#

my pet peeve with it is that it is using the old File and JarFile APIs, even though they end up being more succinct which bothers me even more

edgy plank
slim urchin
echo terrace
#

i'd like to not use old api but is it possible

edgy plank
#

the fact that the new APIs are more annoying to use justifies using the old ones lol

edgy plank
echo terrace
#

yeah, another ugly workaround i had to do to achieve my goals

true flint
#

why itemInOffHand is NotNull?

#

cant it be air

bright flame
#

yes

#

air is not null

#

its an empty item stack the only place where items are really null is the inventory which is just legacy ick

true flint
#

but it has @NotNull

#

oh ok

timid dirge
#

Air is an ItemStack with the type air

bright flame
true flint
#

yeah i was using that but is curious

timid dirge
#

its just nicer than having null

true flint
#

i would prefer null tbh

bright flame
#

sadly for you the API moves in the polar opposite direction

true flint
#

yeah i was looking that

winter anvil
#

Some items are null in api and some are not

#

Very not consistent

true flint
#

yeah offhand is notnull and equipment can be null lol

void minnow
#

checking if something is null is alot easier to do and looks cleaner imo

timid dirge
#

how is it a lot easier tho? its the same amount to write?
if (itemStack.isEmpty()) vs if (itemStack == null)
and its easier to do if you just wanna check the type
if (itemStack.getType() == Material.STICK) vs if (itemStack != null && itemStack.getType() == Material.STICK)?

edgy plank
#

if it is non-null then it can only be empty or whatever type you're thinking it is. If it is nullable it can be null, empty, or another type

karmic citrus
karmic citrus
timid dirge
heady trout
#

question, can a bukkittask be cancelled if its scheduled to run later?

heady trout
karmic citrus
edgy plank
#

cursed

serene parrot
#

Luckily that's something that java is designed to deal with

buoyant barn
#

zbarriers explosion

#

im disgustingly overexaggerating how many allocations that would be

echo terrace
#

didnt care

karmic citrus
echo terrace
#

when i do 3 more allocations on tick which has 100k allocations πŸ’€

zenith marlin
#

I personally always use new String(new String(β€œhi”))

echo terrace
#

i do Optional.of(new String("hi")).map(String::toUpperCase).ifPresent

just for the love of the game

zenith marlin
#

Always wrap your literals so they are literally new

karmic citrus
zenith marlin
#

That is true

patent pollen
#

Intern strings? All my strings are seniors.

wild bloom
#

I don't hire strings in the first place
they don't work as efficient as humans

#

even if the string is a senior

timid dirge
#

interns? thats too much legal liability, I just contract my strings

tranquil epoch
zenith marlin
#

its again all inconsitent

tranquil epoch
#

I was just throwing it out there, in case anyone were to take his statement literally.

light grove
dawn kiln
#

Is there a method to make a villager hold an item like they do when you hold an item they trade for?

#

Also is it possible to make mannequins move like mobs?

#

If I wanted them to swim like a drowned or attack you like a zombie.

edgy plank
radiant steppe
#

Mannequins were designed to be like players without the actual player, so I'd imagine so

#

If they can't then maybe not yet but I'm sure it will in the future

edgy plank
#

@dawn kiln nevermind, I was wrong

#

they support all the standard poses

#

I guess only sitting is left out

dawn kiln
#

But how would you make them move?

edgy plank
#

by teleporting them

dawn kiln
#

With proper pathfinding.

edgy plank
#

same deal

#

you just use teleport instead of Pathfinder#moveTo or whatever

#

it is more manual

dawn kiln
#

I feel like there has to be a better way than constant teleporting.

edgy plank
#

there is not because mannequins aren't pathfindable mobs

dawn kiln
#

Could you just copy a zombie's nms or something into a mannequin?

edgy plank
#

you could disguise a zombie as a mannequin

#

but at that point why not just disguise it as a player

serene cosmos
#

players require you to do the fun tablist stuff to show up

#

mannequins don't

sinful sedge
timid dirge
#

is there a way to do different quick action dialogs for different players?

dawn kiln
true flint
#

why player.teleport can return false?

tranquil epoch
#

can't tp with passengers on

#

at least not between worlds

true flint
#

im removing the vehicle before

#

oh wait i just added a new dumb TeleportEvent somewhere else that should be the reason!

tender helm
#

That flag doesn't do anything

true flint
#

yeah i just found why it doesnt work

#

past me mistake

edgy plank
#

which I would recommend using rather than trying to do it yourself

serene cosmos
#

did they improve performance? last time I tried it was surprisingly heavy

#

its not particularily hard to do yourself, extend the NMS mob, override the entity spawn and entity data methods, done

buoyant barn
#

ultimately i want to avoid nms

#

lol i figured out a way that works for me but still confused by overriding tick working

violet hollow
winter anvil
#

an invisible area effect cloud for what