#help-development

1 messages · Page 974 of 1

eternal oxide
#

9:14

polar forge
#

Can’t I do it like this?

worthy yarrow
#

jeez early for ya

#

or late maybe

polar forge
#

Edited

eternal oxide
#

no

#

you return null if there is no user

#

that method should always return a String even if LP bombs out

worthy yarrow
#

It's a String method hence it needs to always return a String value

eternal oxide
#

and you never translate the prefix

polar forge
eternal oxide
#

no

polar forge
#

Look at the code here

eternal oxide
#

you do this in the getFormattedName method, you have no use for teh player join event

#

all your code in the player join event is useless

#

all you need is your getFormattedName method and use it in your chat event

polar forge
#

So do I need to delete the playerjoinevent?

worthy yarrow
#

Hey elgarl if you've got any interest :p

eternal oxide
#

Spawning all at the same time looks bad

#

you shoudl space their spawnign out

worthy yarrow
#

yeah

eternal oxide
#

so it looks more random

worthy yarrow
#

I'm not sure how to do this

#

This is (somehow) my first time messing with particle effects

eternal oxide
#

they also have a verticle velocity when spawned

#

you should zero the y velocity

worthy yarrow
#

OH?

#

wish I knew that

eternal oxide
#

you can see them bounce up first before falling

worthy yarrow
#

It's kinda goofy right now considering I was just doing particles at the feet before

eternal oxide
#

the rain doesn;t look bad, but it's velocity is also off, same as the snow

worthy yarrow
#

Yeah if it was randomized it'd look better

eternal oxide
#

zero on x and z and try a negative y when spawning

#

you only want a slight random in the downward velocity on teh particle

#

no x and z movement

rough drift
#

setDisplayName accepts a null display name to reset

#

Egitto is correct here

worthy yarrow
eternal oxide
#

No, he should not be setting Display name at all

worthy yarrow
#

Or the other way around?

eternal oxide
#

he's creating a chat formatting plugin. he shoudl not be going anywhere near display name

worthy yarrow
#

lets find out haha

eternal oxide
#

lol nope

#

I thought you were spawning individuals

#

not lots just spread out

worthy yarrow
#

I'm pretty sure the values I changed were not velocity rather density

eternal oxide
#

they are the random position across x/z

worthy yarrow
#

right

eternal oxide
#

I thought you were doign individual particles not 512 with random location

#

you will not get it to look any better using a single emitter

worthy yarrow
#

hmm

#

So then should I redesign the runnable as well as the particle spawning method to handle individual particle spawns to try and get it looking better?

eternal oxide
#

if it was me I would

#

however, doesn;t MC already have rain and snow?

worthy yarrow
#

It's just world#hasStorm/setStorm

#

rain/snow dependant on player location; temperature

eternal oxide
#

yep

worthy yarrow
#

Also custom effects are cooler

eternal oxide
#

I guess you don;t want that

worthy yarrow
#

Individual particle spawns sound difficult in the way I'm trying to...

#

Should I define a region of sorts around the player for the particles to randomly spawn in?

eternal oxide
#

I'd define a radius

worthy yarrow
#

gotcha

#

And the runnable, how frequently should this be ran to handle the random spawning

#

perhaps just have to test and figure something out?

eternal oxide
#

however fast it needs to look good 🙂

worthy yarrow
#

Yep figured that haha

#

Also can / should I do this async?

eternal oxide
#

more emitters per tick to make the rain heavier

#

you could do it async if you swith to packets

#

actually, try it async as particles literally just send a packet

worthy yarrow
#

That was what I thought so

#

Is there more manipulation to be done to the particles given I switch to packets?

eternal oxide
#

no

worthy yarrow
#

damn that sucks

#

It'd be cool to change the color of particles

valid burrow
worthy yarrow
#

gross

valid burrow
#

mhm

eternal oxide
#

it depends on teh particle

#

some you can color

valid burrow
#

you can color some if they already exist in different colors

#

but u cant create colours that do not exist in the base game

eternal oxide
#

nope

worthy yarrow
#

Hmm well that's disappointing

#

Alright so final notes are basically:

Define a radius around the player,

Handle individual particle spawns,

And update runnables to make the particles look good

#

Oh hey do you guys have any suggestions for custom effects applied to players when a specific season is active?

lean arrow
#

When instantiating a new WorldCreator is it possible to set a size of the world? I know you can set a world border but that still generates the chunks outside of the border and I'm using the World#vanillaBiomeProvider() to get the BiomeProvider but then because that can detect biomes in ungenerated chunks, it means that it can detect biomes outside of the world border, which I don't want. The goal I'm trying to achieve is find the nearest biomes.

#

I was previously using World#locateNearestBiome() and iterating through a list of biomes, but that's not particularly optimised.

cinder abyss
#

Hello, how can I get the total available modificable surface using LimitedRegion#getBuffer?

#

because for 48*48 it returns 16, so do I need to multiply by 3 or something like that?

eternal oxide
#

(getBuffer * 2) + 15

cinder abyss
sullen marlin
#
  • 16 I thjink
#

and square it for area

cinder abyss
#

hmm

eternal oxide
#

15 as zero indexed

cinder abyss
#

it's from 0-15 yeah

#

so idk

sullen marlin
#

oh, you dont actually mean area

cinder abyss
sullen marlin
#

as in the unit, you mean area as in the region

cinder abyss
#

yeah

#

a random coordinate between the min available and the max available in x and z

cinder abyss
#

should I use a minus before the rest for the low in randomBtw?

eternal oxide
#

no

#

why are you multiplying by 3?

#

the buffer is a value added to either side of the chunk

#

I do not understand your line 8

#

if you are spawning somethign or setting a Block in a populator you shoudl not use teh buffer at all, unless you are creating a multi block structure

cinder abyss
#

so between 0 and buffer?

polar forge
#

You forgot here at the end of the if statement a {} or ;

#

Which one do I need to use?

eternal oxide
#

I didn;t forget anything, its a split line conditional

cinder abyss
rapid vigil
eternal oxide
#

age

cinder abyss
eternal oxide
#

littel finger is too bent to reach ' reliably

cinder abyss
#

now?

#

I forgot to put *16 so it was returning the chunk coordinate

#

not the coordinate of the first pos of the chunk

rapid vigil
remote swallow
#

typing too quick

eternal oxide
#

age, brain is too old to keep my fingers in sequence 😛

rapid vigil
#

okay :>

polar forge
#

Still doesn’t work

#

I still see a white username

icy beacon
eternal oxide
#

lets just say, I remember the 60's

cinder abyss
icy beacon
cinder abyss
eternal oxide
#

Nope. I remember punch cards to program.

rough drift
#

Elgar it's not the 1980s anymore

cinder abyss
icy beacon
#

Well frostalf and alex are two exceptions, they are like 80 at this point

sullen marlin
eternal oxide
#

alex is a baby though.

rough drift
#

Elgar is over 40????

icy beacon
polar forge
#

Bruh

cinder abyss
eternal oxide
#

you can almost add another 20 years on that

rough drift
#

there is no shot

cinder abyss
#

no way

#

incredible

icy beacon
sullen marlin
#

I can vouch for him

rough drift
#

oh wait isn't md ancient

#

no offense

cinder abyss
rough drift
#

yes that is

#

obvious

eternal oxide
#

lol, I had paid my mortgage by then 🙂

rough drift
icy beacon
#

md joined discord in 2016, subtract 13 years so that he's of legal age to have joined discord at that period of time, means he was born at least in 2003

rough drift
#

specific emoji

polar forge
icy beacon
sullen marlin
icy beacon
rough drift
cinder abyss
rough drift
polar forge
#

And not with the LuckPerms prefix &c

eternal oxide
polar forge
#

AsyncPlayerChatEvent?

eternal oxide
#

yes

remote swallow
#

istg if the next paste i see has that method inside async chat event im gonna scream

polar forge
#

Why lol

remote swallow
#

because its a basic issue that you should know how to resolve before starting spigot

cinder abyss
eternal oxide
polar forge
#

Sure

eternal oxide
#

ok because you ned to subtract getBuffer

polar forge
#

But what should I write in my chat event?

cinder abyss
remote swallow
#

use setFormat

eternal oxide
#

that will give you relative coord

icy beacon
eternal oxide
#

haha you been searching

remote swallow
icy beacon
#

Additionally he says this a couple of times

icy beacon
#

I guess I believe him now lol

#

I'll go do my homework I have 36 minutes before the lesson starts

eternal oxide
#

Great grandad

remote swallow
#

when did that happen

rough drift
#

why are you here then

eternal oxide
#

shoudl I be in a home?

rough drift
#

no like

#

why

#

what's your motive

remote swallow
#

he wants to stay hip with the kids

polar forge
echo basalt
#

elgar when you perish can I have your retirement fund

remote swallow
echo basalt
#

.<

cinder abyss
eternal oxide
#

I plan to go out with a bang and spend every penny I have 🙂

#

hookers and blow

quiet ice
#

🙂 indeed

remote swallow
#

elgarl whats your favourite supermarket

eternal oxide
#

Being old I hate them all.

cinder abyss
remote swallow
#

you seem like a holland and barret kinda person

cinder abyss
#

You prefer the first farmer in your area?

eternal oxide
#

UK here so no first farmer

#

I'm assuming thats a store name.

cinder abyss
#

:)

#

he would never help me anymore after what I've said

cinder abyss
polar forge
#

So I wrote

eternal oxide
cinder abyss
#

I'll try that after eating

polar forge
#

public void ChatEvent(AsyncPlayerChatEvent event) { String format = event.setFormat(); }
What should come inside the brackets of setFormat?

eternal oxide
#

you shoudl getFormat() then replace what you need

rapid vigil
vast ledge
#

Don't usually use that

eternal oxide
#

then setFormat

vast ledge
#

Just set the message

remote swallow
#

setting format is better

polar forge
remote swallow
#

setting the message can cause issues from other plugins modifying

eternal oxide
#

however as you are just cancelign the event and sending yrou own chat you don;t need getFormat/setFormat

vast ledge
remote swallow
#

you can still set it urself

#

on format

polar forge
#

I don’t even know what to write inside the AsyncPlayerChatEvent

vast ledge
#

What do ,out want to achieve?

#

You**

polar forge
#

The username is still white

#

Even tho I’m in a LuckPerms group where I have a prefix of &c

vast ledge
#

That's the join message

#

Oh

#

That

#

You need to use the prefix/apply it

eternal oxide
#

something likejava String format = event.getFormat(); format = format.replace("%1", getFormattedName(event.getPlayer())); event.setFormat(format);

polar forge
vast ledge
#

Yea

#

You're only returning play name there

eternal oxide
#

he returns in his if nest

vast ledge
#

prefix + player.getDisplayName is what you have to return

vast ledge
#

Didn't see that

remote swallow
#

some weird plugins (essentials) likes to modify display name and might add the prefix to that and it then breaks

eternal oxide
#

thats where MC would normally place the player name

rapid vigil
remote swallow
#

essentials just is

polar forge
#

Oh ok

eternal oxide
#

it might be %1s I forget

#

try it and see

rapid vigil
vast ledge
#

You could also cancel the event and then just send Bukkit.getPlayers().for each(player -> player.sendMessage(getPlayerName() + ": " + event.getMessage()));

eternal oxide
#

he was

#

originally

vast ledge
#

And that didn't work?

eternal oxide
#

it did but the rest of his code was broken so he still had no prefix 🙂

vast ledge
#

Ah

vast ledge
#

Lambda is epic tho

eternal oxide
#

may as well broadcast if sending to all

vast ledge
#

True

polar forge
#

So

#

Here’s the final code

#

Is this right?

eternal oxide
#

add @Eventhandler

#

needs tha annotation

polar forge
#

Ok added before ChatEvent

#

Should I try and see?

eternal oxide
#

?tas

undone axleBOT
polar forge
#

Ok Boss

#

And no

#

It doesn’t work

#

Still white username

eternal oxide
#

are you sure you replaced the jar on your server?

polar forge
#

Yes

#

Why is it such a difficult plugin to make

eternal oxide
#

print the getFormat

#

so you can see what it is originally

rapid vigil
eternal oxide
#

it may just be %s not %1s

polar forge
#

So instead of %1 I should write %s?

eternal oxide
#

its been so long since I played with chat formatting

#

yes

polar forge
#

So this might be the problem why it doesn’t work

#

Is it possible that the problem is cause by the other classes?

eternal oxide
#

no

valid burrow
#

learn java

#

?learnjava

undone axleBOT
#

For Beginners:

Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/

For Intermediate to Advanced Learners:

Oracle Java Tutorials: The official guides by Oracle for Java programming—great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/

Practice and Hands-on Learning:

Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/

Free Resources and Documentation:

Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/

Community and Support:

Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/

Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! 🎉

polar forge
#

Ok so

#

AAAAAH

#

no still nothing

#

Doesn’t work

eternal oxide
#

print the result of getFormat

#

The correct format to replace is %1$s

cinder abyss
eternal oxide
#

I knew is was something close

polar forge
#

So it wasn’t %s but %1$s?

eternal oxide
#

yes

polar forge
rapid vigil
#

._.

eternal oxide
#

no need now, just use that string

polar forge
#

Ok ill write %1$s

#

Im testing it now

#

Let’s see…

#

Nop still doesn’t work

eternal oxide
#

show code

polar forge
#

All the plugin or only chat listener?

eternal oxide
#

just chat

polar forge
cinder abyss
eternal oxide
#

What does it look like in game

eternal oxide
polar forge
polar forge
#

White username instead of my prefix

eternal oxide
polar forge
eternal oxide
#

then I can only guess you didn;t update teh jar on your server

#

the code is fine

#

you are doing something wrong when updating your server

#

stop the server before changing the jar

polar forge
#

That’s what I do

#

Wanna try the file then?

cinder abyss
#

74, 75... 🎶

eternal oxide
#

drop the file in here

polar forge
#

Ill build it one more time

#

To make sure

eternal oxide
#

Spigot builds on SnakeYaml

rough drift
polar forge
#

Just to be sure, should be there a space here

#

In between package and name?

eternal oxide
#

makes no difference

polar forge
#

Here is it

rough drift
#

why would you

#

send it

polar forge
#

Elgarl asked for it

eternal oxide
#

I told him to

rapid vigil
polar forge
lilac dagger
#

yes

rapid vigil
polar forge
#

Idk I also tested it as it was

lilac dagger
#

you've compiled kyori

#

and the intellij annotations

river oracle
#

Shading Kyori is fine

eternal oxide
#

you have two HoverListeners

river oracle
#

Exclude the annotations tho

polar forge
eternal oxide
#

delete the one in the root

#

keep the one in the listeners package

river oracle
#

Jar size doesn't matter unless you're dead set on uploading to spigot then you need to be under 5mbs

polar forge
#

Which one

river oracle
#

Believe it or not

rapid vigil
#

ooh so they're stingy

eternal oxide
river oracle
polar forge
#

Does it work with u?

eternal oxide
#

but thats your issue, you are cancelling the chat event in your HoverListener

polar forge
#

So what’s the solution?

eternal oxide
#

don;t cancel

vast ledge
#

Just modify the message

eternal oxide
#

you are preventing the listener from running that sets your prefix

polar forge
#

So I should setCancelled False?

eternal oxide
#

no

#

just don;t cancel

#

default is false

polar forge
#

Just delete event.setCancelled(true);?

eternal oxide
#

yes, and instead setMessage

polar forge
#

I should delete this line?

#

So

#

event.setMessage(true);

rapid vigil
eternal oxide
#

event.setMessage((BaseComponent) comp);

polar forge
#

In hover listener

#

Sure

eternal oxide
#

delete all the for loop sending the message

#

delete setCancelled

polar forge
eternal oxide
#

just use event.setMessage

#

Delete all

#

instead event.setMessage((BaseComponent) comp);

polar forge
#

I get an error

#

Wait I’m sending screenshot

eternal oxide
#

ah text only

polar forge
#

Wrong import?

#

Should I ignore it?

eternal oxide
#

no

polar forge
#

And what’s the solution to this error?

hearty moat
#

Uhm I am trying to save player stats to a YML file, such as their kills, their bounty and their name. This is my main class (pay attetion to the last EventHandler):
https://paste.md-5.net/izawuvakuf.cs
And this is the PlayerDataHandler which is responsible for saving these stats to a file:
https://paste.md-5.net/ceguhotisi.cpp
However, when I kill someone, the plugin doesn't create any file on its folder as it should. Am I missing something?

rapid vigil
eternal oxide
#

good question. I've not used hover events

polar forge
#

Text only? Wdym

eternal oxide
#

you can;t use setMessage as it only accepts a String

#

the only way to send with components is to use sendMessage

polar forge
#

So event.sendMessage((BaseComponent)comp);?

eternal oxide
#

no

#

you are being a pain as you are doing hover and format in the same event in different listeners

orchid trout
polar forge
#

How do I divide them then?

eternal oxide
#

you actually need to combine them

polar forge
#

Combine the listeners?

hearty moat
eternal oxide
#

yes

polar forge
#

Ok ill copy paste and let’s see what I get

eternal oxide
#

when using Components you can;t apply them back to the AsyncChatEvent

#

so you do have to cancel and send the formatted message yourself

echo basalt
#

isn't AsyncChatEvent paper

#

And I'm pretty sure you can

#

the method's just poorly named

eternal oxide
#

not in Spigot

young knoll
#

AsyncChatEvent is paper

echo basalt
eternal oxide
#

He's using AsyncPlayerChatEvent

young knoll
#

AsyncPlayerChatEvent is spigot

eternal oxide
#

Which is Spigot

#

so no Component support

echo basalt
polar forge
#

Omg it’s so difficult to put them together

eternal oxide
#

nah it's quite simple

polar forge
#

I get errors if I put them together

#

Put this remove this import this

eternal oxide
#

yeah its likely beyond your level of java

polar forge
#

Nah it’s not that, it’s just I’m scared I break something

eternal oxide
#

breakign is good, best way to learn

rapid vigil
eternal oxide
#

it is

#

he's trying though

rapid vigil
polar forge
#

So like this?

grim hound
#

What packets does bungeecord send to inform the player about a server change?

polar forge
#

I get 2 errors

#

The same error as before

#

And

eternal oxide
#

one sec

polar forge
#

plugin might have not been initialised

eternal oxide
#

take a look at that

#

a single chat event

#

using your code

#

but the formatted name I showed you

polar forge
eternal oxide
#

chat listener

#

scrap your hover listener

polar forge
#

No ok

#

I understood

#

But

#

What should i do with the event.setMessage?

eternal oxide
#

I haven't checked any of that hover code so I'm assuming its working

#

nothing

#

I literally gave you the whole method

polar forge
#

Yes

valid burrow
# polar forge Im learning

You are infact not. You have yet to discover the difference between a string and an integer. If you wouldve done yet so much to watch a simple video for first time coders that would already have doubled the knowledge you contain about java

polar forge
#

Should I delete the ChatListener?

eternal oxide
#

keep the one that has teh getFormattedName

#

delete the other

polar forge
#

What the other

#

I have ChatListener, here is where I coded the get formatted, HoverListener, and now ChatEvent

eternal oxide
#

what?

#

the jar you sent me has two listeners

#

delete teh HoverListener

polar forge
#

If I hover on top of an username

eternal oxide
polar forge
#

Should I then keep the HoverListener?

eternal oxide
#

no

polar forge
#

Does it get prefixes from LuckPerms?

eternal oxide
#

?tas

undone axleBOT
polar forge
#

Why do I get this error

#

I don’t understand I’m registering it

eternal oxide
#

check yoru import in ChatListener

#

its still set as JavaPlugin probably

valid burrow
#

this needs to be Plugin not JavaPlugin

eternal oxide
#

I sent the correct code so its just your imports

#

ah that needs to be HoverInfo not JavaPlugin

polar forge
#

True lol

#

Forgot

valid burrow
#

or HoverInfo

#

both works

eternal oxide
#

has to be HoverInfo as he has a method in there for getLP

glad prawn
#

registerEvents take 2 params btw

valid burrow
valid burrow
#

registerEvents(new ChatListener(this), this);

polar forge
#

So like this

eternal oxide
#

yes

valid burrow
#

yea

polar forge
#

Let’s try it

#

I would say, it works

#

Thanks, but I got a problem

#

If I’m an user, I don’t have any prefixes so it’s null

#

And it can’t be translated

eternal oxide
#

then add a check for null before teh translate

#

just do if (prefix == null) prefix = "";

#

before the translate

#

can getPrefix() in LP return null?

polar forge
eternal oxide
#

I don;t use LP so no idea if that method can return null

polar forge
#

@rapid vigil is a master in LP

echo basalt
eternal oxide
#

github says it can be null

#

odd choice

polar forge
eternal oxide
echo basalt
#

great question

lilac dagger
#

It's not a packet

#

It's a plugin message

echo basalt
#

Uh no

lilac dagger
#

Listen to incoming bungeecord messages

echo basalt
#

That's a completely different question

grim hound
#

Not what I'm asking here

lilac dagger
#

Ah nvm

#

You can look at the api

grim hound
eternal oxide
#

?stash

undone axleBOT
grim hound
#

It just claims "No usages in All Places"

eternal oxide
#

no bungee

echo basalt
#

It's a little complex

#

In short the client's always in a "play" state

#

But the handshake process is copied, send to the original server up until the login phase, bossbars are removed etc

echo basalt
#

Given we're using the original handshake I'm pretty sure packets should be encrypted the same way

grim hound
#

Since this just means Handshake and LoginInStart were copied

grim hound
#

Packet

echo basalt
#

Isn't that part of the handshake

#

nvm I'm a clown and don't know how the encryption part works

slender elbow
#

afaik there is no encryption between the server and the proxy

echo basalt
#

Yeah prob not

#

Proxy <-> Client is encrypted

slender elbow
#

yes

echo basalt
#

Backend <-> Proxy is not

cinder abyss
eternal oxide
#

if you are using chunk relative its 0-15

cinder abyss
eternal oxide
#

if its a Limited region with buffer then its world relative

grim hound
cinder abyss
#

relative to the world

#

using getBuffer

eternal oxide
#

usable wher?

grim hound
eternal oxide
#

in the limited region?

cinder abyss
eternal oxide
#

show how you are accessing the region

cinder abyss
eternal oxide
#

then you should not be going anywhere near teh buffer

#

you should stay within the chunk

cinder abyss
eternal oxide
#

no

cinder abyss
eternal oxide
#

then chunkj is the "chunk" you are populating. The buffer is a measurement of distance around the chunk which "shoudl" be loaded and available if you need to create a structure outside the chunk boundaries

cinder abyss
grim hound
eternal oxide
#

Yeah you are just populating blocks, so 0 to 15

grim hound
cinder abyss
#

like this?java return randomBtw(chunkCoordinateType*limitedRegion.getBuffer(), (chunkCoordinateType*limitedRegion.getBuffer())+15);

eternal oxide
#

no

grim hound
eternal oxide
#

just 0 to 15

cinder abyss
#

but that's relative to the chunk?

#

not world-relative?

eternal oxide
#

yes, you add that to the chunk *16

cinder abyss
eternal oxide
#

it gets you world relative coords

cinder abyss
#

humm okay

#

so

#
return randomBtw(0, 15)*16;```
?
eternal oxide
#

no

cinder abyss
#

😭

eternal oxide
#

ChunkX * 16 + random (16)

cinder abyss
#

oh okay thanks

#

sooo

#
return chunkCoordinateType*16 + randomBtw(0, 15);```
?
eternal oxide
#

well 0, 15 in your code

#

yep

cinder abyss
#

perfect

#

so, I can merge those two?

eternal oxide
#

if your type is a X/Z chunk value

cinder abyss
cinder abyss
eternal oxide
#

then yes

cinder abyss
#

okay

#

so it will always use the buffer?

eternal oxide
#

no]

cinder abyss
#

I don't understand how I can use the buffer in this method if it is not mentionned

eternal oxide
#

ignore there is a buffer

cinder abyss
#

okay

eternal oxide
#

the only part you populate is the chunk itself

#

as you are placing rocks you do not need the buffer

cinder abyss
#

it's for future structure that might be biggers

eternal oxide
#

when you get to structures come back and ask 🙂

cinder abyss
eternal oxide
#

yes

cinder abyss
#

okay perfect thank you

sand spire
vast ledge
#

Player Interact, check if #isBlocking()

sand spire
slender elbow
#

set a very high cooldown on the shield :^)

vast ledge
#

disarm the shield when its clicked

sand spire
# vast ledge Yea, you only need to check once

I want to disarm when I hit the player with a custom attack, I can give the shield a cooldown and play the sound but the shield stays up with a cooldown if you don't release your mouse

sand spire
slender elbow
#

i mean the game does set a cooldown when you do a hit with the axe while they're blocking

#

to prevent it from being used

#

that's kinda the intended way

sand spire
slender elbow
#

yeah, so, set the cooldown

#

to however much you want

sand spire
#

in vanilla when you get hit with an axe the shield gets a cooldown AND goes down

#

I want to recreate that

#

and I was wondering if there is a method to 'unraise' the players hand

eternal oxide
#

possibly set swimming twice

#

forcing them to any animation wher the shield drops even if only for 1 tick

#

player.setSwimming(!player.isSwimming())

#

twice

sand spire
#

I'll give this a try thanks

eternal oxide
#

or

#

have you tried setItemInUseTicks

#

no idea if it would work on a shield but try setting to 0 or 1

sand spire
#

setItemInUseTicks(int)' is deprecated since version 1.20.4 and marked for removal

eternal oxide
#

not in spigot

sand spire
#

it is in my IDE

slender elbow
#

minecraft calls stopUsingItem(), i don't think spigot has api for that

#

but a certain downstream fork does

eternal oxide
#

You are not using spigot

sand spire
eternal oxide
#

it may be deprecated in paper. Its not in Spigot

#

everythign is deprecated in paper

sand spire
slender elbow
#

yes you can?

#

the choice is yours

sand spire
#

for most methods and classes I can choose between spigot paper and bukkit but the paper overwrites the spigot one so as long as I have paper API i probably can't

slender elbow
# eternal oxide

that won't work, shields don't really have a "remaining use time", as opposed to e.g. potions, there is some extra logic the server runs to force the shield down (in n.m.w.e.LivingEntity#stopUsingItem())

slender elbow
#

the spigot api is still there

sand spire
#

This is when I have paper API

#

And this is when I remove the API from my pom

slender elbow
#

sure?

#

the method is right there

#

you can 100% use it

sand spire
#

its both org.bukkit.entity.LivingEntity

sand spire
#

deprecated gives warning

slender elbow
#

sure but the method is the same and works on spigot

#

that is a spigot method

sand spire
#

yeah but I can't compile with an error

slender elbow
#

a warning is not an error

sand spire
#

red is an error, yellow is a warning. Deprecated gives a warning, marked for removal gives an error

slender elbow
#

it's red in your ide because it's deprecated for removal

#

javac will compile it fine

#

it will warn you, but it will compile

#

the fact it's red is your ide configuration

eternal oxide
#

You are depending on paper in your pom

sand spire
eternal oxide
#

you could even add teh spigot dependency above the paper dependency

slender elbow
#

it does compile if you have an error

#

but that is not an error

eternal oxide
#

then you'd have both API and still be able to support paper, without crazy warnings

sand spire
#

IntelliJ is very confusing then

icy beacon
#

IDE error != compile time error (sometimes)

#

Most often it is but you can configure anything to be an IDE error

#

And you can disable the checks altogether

#

Javac will not care about your ide warning preferences

sand spire
#

welp java.lang.NoSuchMethodError: 'void org.bukkit.entity.Player.setItemInUseTicks(int)

#

it doesn't work anyway so it's fine I'll try something else

icy beacon
#

Must be a version mismatch

slender elbow
#

that method is fairly recent, yes

sand spire
#

well I am on 1.20.4 and it says deprecated since 1.20.4 so

slender elbow
#

it was added in mid-1.20.4

#

like, a few weeks ago

icy beacon
#

If paper devs got a dollar for every time they've deprecated a method they'd be swimming in money

slender elbow
#

, run buildtools and get the latest 1.20.4 build

#

that method works on spigot if you're running the version it was added in

#

in the versions it didn't exist it won't work because it didn't exist

sand spire
#

idk how to run buildtools but it doesn't matter cause what I need is a stopUsingItem() method but it probably doesn't exist

remote swallow
#

?bt

undone axleBOT
remote swallow
#

use the gui

slender elbow
#

stopUsingItem is minecraft code

#

spigot doesn't have api for that

sand spire
#

damn

icy beacon
#

not much learning required, too

slender elbow
#

you just need to run one command and you have the server jar ready to run

sand spire
remote swallow
#

run it again

slender elbow
#

you are not running the latest build, that method does exist on the latest build

upper hazel
icy beacon
#

Latest

#

Experimental is not necessarily stable iirc

sand spire
#

guess I'm experimental rn

remote swallow
#

ur not

#

use latest

icy beacon
remote swallow
#

experimental is features that are not ready for prod or are for end user testing

icy beacon
#

ok then im not experimental

remote swallow
#

currently it has de-enum

#

iirc

icy beacon
remote swallow
#

it always was

#

its just making sure every likes it and agrees with impl

icy beacon
#

i thought it would be like waaaay down the line

remote swallow
#

it might be 1.21

#

might be 1.25

icy beacon
#

😳

shadow night
wraith imp
#

Hello, how can i make a part of a message clickable link? For example: Welcome to the server! Visit our [discord-link] and our [website-link].

chrome beacon
cursive loom
#

Hello I trying to update an item inside a player inventory but I don't find a solution can you help me ?

Current code:

            if(player.getInventory().getItemInMainHand().equals(countablePickaxe())){

                ItemStack itemStack = countablePickaxe();
                ItemMeta itemMeta = itemStack.getItemMeta();

                for(int i = 0; i < itemMeta.lore().size(); i++){
                    List<Component> lore = itemStack.lore();
                    if(lore.get(i).toString().contains("§fNombre de blocs cassé:")){
                        int utilisation = Integer.valueOf(String.valueOf((TextComponent) lore.get(0)).replaceAll("[^\\d]", ""));
                        lore.set(0, Component.text(((TextComponent) lore.get(0)).content().replaceAll("-?\\d+", utilisation + 1 + "")));
                        itemMeta.lore(lore);
                        itemStack.setItemMeta(itemMeta);
                        player.updateInventory();
                    }
                }


            }
lilac dagger
#

the lore might be a copy

#

you'll probably have to set it again

chrome beacon
#

also that's the Paper API

eternal night
#

Please do not store data in display names or lore

#

use the pdc

chrome beacon
#

You'll probably get better help in the Paper discord

cursive loom
cursive loom
chrome beacon
#

?pdc

lilac dagger
#

why not reset the lore when needed

#

also pdc ^

slender elbow
#

but, as pointed out, use pdc for storing custom data, not lore

nova quail
#

Hello! Why enchantment isn't adding to the item

    private ItemStack createEffectItem(Material material, String displayName, List<String> lore, String effect, Player player) {
        ItemStack itemStack = new ItemStack(material);
        ItemMeta meta = itemStack.getItemMeta();
        if (meta != null) {
            meta.setDisplayName(color(displayName));
            if (effect != null && effect.equals(getSelectedEffect(player))) {
                meta.setLore(lore.stream().map(Utils::color).collect(Collectors.toList()));
                itemStack.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1);
            //    meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
            }
            itemStack.setItemMeta(meta);
        }
        return itemStack;
    }
cursive loom
#

okk thx 🙂

slender elbow
#

add the ehcnantment to the meta

#

not the itemstack

nova quail
worldly ingot
#

Also, fun fact, fairly certain List has a replaceAll() method which you could use instead of a Stream

#

Obviously it mutates the List you pass in, but yeah

#

meta.setLore(lore.replaceAll(Utils::color))

remote swallow
#

im not sure thats a very fun fact

worldly ingot
#

I thought it was fun

#

I had fun writing it

slender elbow
worldly ingot
#

IT DOESN'T!?

#

that's stupid

#

java is stupid

#

i hate java

#

i'm becoming a haskell developer

slender elbow
#

based

sonic sky
#

All the homies hate Java

#

All the homies are wrong.

remote swallow
rough drift
austere cove
#

🙏

rough drift
#

you need to teach me some day how to properly use hasell

#

I have a severe skill issue

austere cove
#

imagine

color <$> lore

instead of #replaceAll(...)

worldly ingot
#

I take it back. I'm becoming a PHP dev

remote swallow
#

lore.colourme

rough drift
#

is the <$> an apply method

austere cove
#

functor application

rough drift
#

ah, is it multiple symbols or is it literally just <$>

austere cove
#

its the infix equivalent of fmap

rough drift
#

ah

#

flatmap I assume right

austere cove
#

flatmap is more like a monadic bind

rough drift
#

mhm I assumed because of fmap

#

flat map

austere cove
#

functor

rough drift
#

ah

#

I'm slow

austere cove
#
fmap :: (a -> b) -> f a -> f b

where a, b are types and f is a functor type
So for a list w elements of type a and a function a -> b, fmap returns a list w elements of type b

There are also other functors in the stdlib, like Maybe, Either etc

lean arrow
# lean arrow When instantiating a new `WorldCreator` is it possible to set a size of the worl...

I found an alternative solution if anyone else ever has a similar problem to me:

val regionAccessor = world as RegionAccessor

        val foundBiomes: MutableSet<Biome> = mutableSetOf()
        val maxBiomes = 10

        var x = world.spawnLocation.blockX / 16
        var z = world.spawnLocation.blockZ / 16
        var dx = 0
        var dz = -1

        spiralLoop@ for (i in 0..(50 * 50)) {
            if (-50 / 2 < x && x <= 50 / 2 && -50 / 2 < z && z <= 50 / 2) {
                val chunkToBlockX = x * 16
                val chunkToBlockZ = z * 16
                val chunkBiome = regionAccessor.getBiome(chunkToBlockX, world.spawnLocation.blockY, chunkToBlockZ)
                if (foundBiomes.none { it.key == chunkBiome.key }) {
                    foundBiomes.add(chunkBiome)
                }
                if (foundBiomes.size >= maxBiomes) {
                    break@spiralLoop
                }
            }
            if (x == z || (x < 0 && x == -z) || (x > 0 && x == 1 - z)) {
                val temp = dx
                dx = -dz
                dz = temp
            }
            x += dx
            z += dz
        }

Hope this helps another dev sometime eventually!

remote swallow
#

ooooo kotlin

lean arrow
#

It might not be the best approach but it works in a subsecond timeframe so I'll take it!

austere cove
#

monadic bind is similar but not quite.

Say you have an optional type in Java, and you want to apply a function that also returns an optional. fmap would essentially get u an Optional<Optional<Type>>
A monadic bind does what you're looking for:

(>>=) :: m a -> (a -> m b) -> m b
#

also functors and applicative types can be defined by monad application:

fmap f x = x >>= return . f
pure = return
mfab <*> ma = mfab >>= (\ fab -> ma >>= (return . fab))
slender elbow
#

🙏

tidal finch
#
        PotionMeta meta = (PotionMeta) customDrink.getItemMeta();
        meta.setColor(Color.LIME);
        meta.clearCustomEffects();
        customDrink.setItemMeta(meta);```
Hi, I am trying to create addon for slimefun that displays recipes for Brewery addon in Slimefun menu. Can someone please help me to remove "No Effects" lore from potions? I just couldn't find it in meta.
neon shoal
#

Yo

remote swallow
#

try give it the hide potion effects item flag

neon shoal
#

How do I send a message to a user

#

Sendmessage()?

river oracle
#

Player#sendMessage

#

Or more accurately

#

CommandSender#sendMessage

remote swallow
#

where javadoc smh

icy beacon
#

?jd

undone axleBOT
river oracle
remote swallow
#

smhj

#

go home

#

no outside

icy beacon
neon shoal
#

I have the commandsender filtered to players so

remote swallow
#

use send message still

neon shoal
#

So name#Sendmessage("message")?

remote swallow
#

no

neon shoal
#

Name = player

remote swallow
#

use a dot and ye

#

and fix the captialization

neon shoal
#

NamedotsendMessage()

#

Dot being .

remote swallow
#

ye

neon shoal
#

I was wondering wtf # was

#

Lmao

remote swallow
#

its a javadoc notation, we use it to show you need an instance

#

as it can be confused with static if a dot is used

slender elbow
#

i mean if you used javadoc notation you should use it for all methods indiscriminately :p

#

and fields

#

ruh roh

remote swallow
#

ruh roh raggy

hearty moat
#

I am trying to make a plugin that stores player stats on a YML file. The stats I want to save for now are the kill count, their bounty and their name. I want to make a separate file for each user. I have tried with the wiki entry that explains how to use custom config files, but none were generated. This is my code now, and it won't generate either when I kill my friend (for now, I only want to store kills per user):
Main: https://hastebin.skyra.pw/uxubuxisur.java
When I kill someone, no file is generated on the plugin folder, which is hosted on our server. What am I missing? I already tried three different ways before this one and none were working.

remote swallow
#

File#createNewFile iirc

dawn flower
#

how do i remove 10 raw cod named "idk" and 15 chicken named "idk" from the player's inventory, if the player doesn't have 10 raw cod then it removes nothing same with chicken (test items)

icy beacon
icy beacon
#

Everything else wrong with the code, smile seems to be currently writing about

#

I'll let him do the job

dawn flower
tidal finch
lost matrix
# hearty moat I am trying to make a plugin that stores player stats on a YML file. The stats I...

Some notes on style convention for java:

  • Variables in lower camel case: Num_veces -> numVeces
  • Generally english is the preferred language for methods and variables.
  • Dont use single letter variables like e (this goes for any programming language)
  • Dont name your class something ambiguous like Main

It is very important, that you dont run IO on the games main thread. Hard drives are very very slow compared to ram.
So if an event occurs, and you start writing data to disk, then the entire game has to wait for your IO to finish. This
will cause massive lag in absolutely no time.

Bind your data to scopes:
When a player joins -> Load the data from Disk to RAM
When the player quits -> Save the data from RAM to Disk

icy beacon
#

Nice job Smile. You should be a Discord Helper

dawn flower
#

he is

lost matrix
icy beacon
#

Thanks for pointing that out MissingReports. You'd make a really good Verified

dawn flower
#

icba to type event everything

icy beacon
icy beacon
dawn flower
#

sometimes it doesnt if i have a variable that starts with 'e'

icy beacon
#

skill issue

lost matrix
dawn flower
#

the thing is, if u don't have enough items (it's a shop plugin) i dont want it to still remove whatever u have

#

and i want it so if u have for example 10 raw cod in 1 slot and 5 cod in another slot it would still work

#

and if u have 10 cod in one slot and 6 in another it removes 10 then 5 not 10 then 6 cuz all my previous attempts did that

lost matrix
#

removeItem should be very exact with its amount. I think you used remove() before, which removes all items that match the given ItemStack

dawn flower
#

can i copy the player's inventory and set the player's inventory

lost matrix
#

That sounds expensive. Why dont you just use containsAtLeast on the Inventory to check if he has enough items

dawn flower
#

this is hard to explain, i have a rarity system that changes the color of the item name based on the rarity, i could have a common cod (white) and an uncommon cod (lime) and isSimilar iirc checks if the item name is exactly the same color included

#

containsAtLeast and removeItem as u said use isSimilar

lost matrix
#

Hmm, i really wanted to add a method which takes a Predicate<ItemStack> as an argument instead of the isSimilar check.
Well, looks like you need to write two util methods then.

dawn flower
#

cant i just copy removeItem method and change the check to be my custom check instead of writing one from zero

lost matrix
#

Sure

dawn flower
#

what implements inventory in craftbukkit

eternal night
#

CraftInventory

rough drift
eternal night
dawn flower
#

thanks

rough drift
#

Type faster

eternal night
rough drift
#

shit

hollow vessel
#

hi! Guys, do you know some good library to handle opening and get user input from writable book? I need to get a user input from each line

dawn flower
#

bro "item" and "i" are already defined in the scope and i need to define an itemstack var

#

tf do i name it

dawn flower
#

genius

rough drift
#

descriptionOfItem

#

or

#

refactor

lost matrix
# dawn flower cant i just copy removeItem method and change the check to be my custom check in...

Just an example i thought about:

public class InventoryUtils {

  public static int count(Inventory inventory, Predicate<ItemStack> predicate) {
    int count = 0;
    for (ItemStack item : inventory) {
      if (!predicate.test(item)) {
        continue;
      }
      count += item.getAmount();
    }
    return count;
  }

  public static int remove(Inventory inventory, int amount, Predicate<ItemStack> predicate) {
    int remaining = amount;
    for (ItemStack item : inventory) {
      if (!predicate.test(item)) {
        continue;
      }
      if (item.getAmount() <= remaining) {
        remaining -= item.getAmount();
        item.setAmount(0);
      } else {
        item.setAmount(item.getAmount() - remaining);
        remaining = 0;
      }
      if (remaining == 0) {
        break;
      }
    }
    return amount - remaining;
  }

}
rare rover
#

would anyone know how to use shadowJar with jitpack? Can't figure it out, i'm getting this error:

#

😡

lost matrix
#

You mean how to get mavenplublish working with jitpack? I dont see a correlation to shadowjar here.

dawn flower
lost matrix
dawn flower
#

thats literally craftinventory method

lost matrix
#

How about you write it in a more generic way so that it can be reused

rare rover
dawn flower
rare rover
#

i need to include all the dependencies in the jitpack source

oak mica
#

How can I make a warden not target specific players

dawn flower
#

uhh

#

ur remove thingi aint even taking an item as param?

lost matrix
rare rover
chrome beacon
#

You can't forcibly open a writable book

dawn flower
#

using ur code

for (ItemStack costItem : cost) {
  Predicate<ItemStack> predicate = (stack) -> stack.hasItemMeta && ChatColor.stripColor(stack.getItemMeta.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(costItem.getItemMeta.getDisplayName()));
  if (costItem.getAmount() > InventoryUtils.count(inventory, predicate)) {
    player.sendMessage("brokie");
    return;
  }
  InventoryUtils.remove(inventory, costItem.getAmount(), predicate)
}```
like dis?
oak mica
#

also i still dont understand what i can save in a chunks nbt that allows me to respawn an entity from it

#

cuz i cant save all the entity data

hollow vessel
oak mica
hollow vessel
#

i would like to use book instead

chrome beacon
#

no

oak mica
#

can i set a zombies skin

#

idk man i want it to look different

icy beacon
#

im not like other girls

oak mica
#

on god

#

hiow do i stop this warden from giving a certain player blindness :c

modern plank
#

is there any supported ways to make http requests in bukkit or do i have to use a 3rd party

slender elbow
#

I mean, bukkit isn't an http client

#

the jdk does have one however

#

in the java.net.http package iirc

modern plank
#

i was thinking if using a http would cause issues

icy beacon
#

Or if you like convenience use retrofit

lilac dagger
#

java has it all

#

if it's malicious yes

modern plank
#

but doing Bukkit.runTask should fix every threading issue

slender elbow
#

I mean, just don't block on requests on the main thread

#

runTaskAsync

lilac dagger
#

but nobody will say anything if you just use https

modern plank
#

i was thinking using okttph doing async callback then soing Bukkit.runTask to handle bukkit related stuff

slender elbow
#

and the jdk http client has built-in support for asynchronous execution anyway, returning a CompletableFuture

lilac dagger
#

just use java 😄

modern plank
#

so the asyncatcher doesnt cause an error

lilac dagger
#

you'll have to sync it back

#

if you wanna use spigot/bukkit api

modern plank
lilac dagger
#

Bukkit.runtask is pretty good

modern plank
lethal coral
#

why are these the file locations? this is not where the directory is for the server on my pc

#
    /**
     * Ensures that the provided file and its directories are created.
     *
     * @param file the file to defend
     * @return the file being defended (ignorable)
     */
    @SuppressWarnings("ResultOfMethodCallIgnored")
    public static File defendFile(File file) {
        try {
            File parent = file.getParentFile();
            if (!parent.exists()) {
                parent.mkdirs();
            }
            file.createNewFile();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return file;
    }

this is the defendfile method

remote swallow
#

. signifies current dir

#

current dir comes from location of server jar

slender elbow
#

technically

#

no

#

but generally yes

granite owl
#

do i understand the concept correct that when i pass a primitive wrapped in a Class i pass a reference, and thus i can handle it like a pointer rather than a copy(e.g modifying the value of the wrapped primitive passed as parameter)?

#

i mean is this the purpose of wrapped primitives?

tardy delta
#

defend file?

lethal coral
#

my defendFile method just wasn't doing what I was expecting

granite owl
#
public static void foo(Integer i)
    {
        i = 5;
    }

    public static void main(String[] args)
    {
        Integer i = 1;

        System.out.println(i);

        foo(i);

        System.out.println(i);
    }
```because this appears to remain 1
icy beacon
#

I may be completely wrong but I would assume that the compiler would unbox this into primitives for optimization

granite owl
#

what about strings

#

it shows the same behavior

#

and theres no primitive char* in java

icy beacon
#

Good question

#

It's something else then probably, not sure, will also wait for an answer

granite owl
#
public static void foo(String s)
    {
        s = "LOL";
    }

    public static void main(String[] args)
    {
        String s = "Hello World";

        System.out.println(s);

        foo(s);

        System.out.println(s);
    }
``` this remains hello world
#

that kinda defeats the purpose of pass by reference

slender elbow
#

java is pass by value

#

Objects are not like C++ references

granite owl
#

so it always makes copies?

slender elbow
#

it copies the "pointer"

granite owl
#

i thought it always passes a reference of objects?

granite owl
slender elbow
#

when you reassign an object you reassign the local "pointer", not the underlying object

icy beacon
#

Oh that's trueeeee

granite owl
#

so

#

i have to change it with valueof?

slender elbow
#

huh