#help-development

1 messages · Page 89 of 1

buoyant viper
#

only time i snake in java is public static final 😎

iron glade
#

== compact, readable, works, null safe, slightly faster than equals

grim ice
#

and you straight up copied that off stack overflow btw

iron glade
#

for you

grim ice
#

i saw that post a few months ago

iron glade
#

since both can be used just let people use whatever they prefer

flint coyote
#

I already did answer it.

  1. it's not necessary
  2. no problems with null
  3. better performance (equal has an overhead)
  4. just why
grim ice
flint coyote
#

you can't say equals is the standard either. Or are you comparing two numbers with equals, too?

#

2.equals(2) lol

buoyant viper
#

enums are a special case of funk in a language full of already funky stuff

grim ice
grim ice
#

are you okay?

#

you had a small argument, you just ruined it

iron glade
#

"works" all of them work - correct, so let people use whatever they wanna use

tender shard
#

the only difference between equals and == on enums is whether it throws an NPE or not

buoyant viper
#

new Integer(2).equals(2) 😎

iron glade
#

really no difference

grim ice
flint coyote
next stratus
#

shame triumph gui doesn't work seems so cool

buoyant viper
#

so like u doin

EnumClass.ENUM_CONST.equals(getValue())

or

getValue().equals(EnumClass.ENUM_CONST)

iron glade
#

enum first

buoyant viper
#

sane method of checking i guess

#

null safety built in for one side at least, who knows what dirty checks exist in the .equals implementation of EnumClass tho, if it overrides

flint coyote
#

If you want a real reason, fine.

Each enum only exists once. While it is an object there is only one if each object. Every time you access an enum value you get the same object (the same pointer). Since that is the case you never have to use equals(). And doing it because it's standard is just weird. Yes it won't make a huge difference but why don't you just get used to == when .equals() is never needed

grim ice
buoyant viper
#

give this man a /j /srs

grim ice
#

No, just because its initialized only once doesnt make it better to use an unsafe instance comparison operator

#

it's fine in this case, but not better than .equals()

iron glade
#

cause they're equally good

buoyant viper
#

haha equally

grim ice
iron glade
#

I mean you have good points

buoyant viper
#

sry havent slept in a while

iron glade
#

And I get them

tardy delta
#

sleep for the weak

buoyant viper
#

can u increase the framerate of ur pfp

#

i want eminem to spin faster

iron glade
#

lmao

grim ice
#

you decrease the framerate

#

not increase it

#

increasing the framerate will make it slower

iron glade
#

increasing it would only make it smoother

buoyant viper
#

thats what i meant

#

woops

iron glade
#

it was hard enough getting the .gif under discords upload limit without having it look like trash

buoyant viper
#

had the word in my head but not in my hands

flint coyote
# grim ice No, just because its initialized only once doesnt make it better to use an unsaf...

Since it isn't unsafe in this case why would you not use it? In programming there's always a thousand ways to achieve your goals. Usually I'm "readability over performance". But in this case == is (atleast for me) more reasonable and readable than .equals()
I mean you can use whatever you like but idk why you try to convince people to use equals() when there's no reason for it

buoyant viper
#

up the framerate on that bitch and videos go zooooom

#

and yes i mean framerate not a speed slider

grim ice
buoyant viper
#

kdens just shit enough to not have one and is genuinely not a fun video editor but still works and is free so i use it

patent fox
#

how can i make a custom entity able to fly?

flint coyote
#

That's like those people that try to convince others that their own religion is better

grim ice
#

No, religions are social constructs and cannot be proven physically

#

unlike concepts in code

buoyant viper
#

what if i break the computer

#

no physical proof

iron glade
#

winn go sleep dude hahaha

buoyant viper
#

i gotta be up in like 4.5 hrs

grim ice
buoyant viper
#

is it even worth it

grim ice
#

no physical proof

iron glade
#

sleep is always worth it

buoyant viper
grim ice
#

lol

flint coyote
flint coyote
#

static objects that only exist once

grim ice
#

ur comparing enum values here, not enums

flint coyote
#

Yes

#

each enum value only exists once

#

that's part of the specification

grim ice
#

sigh

#

my internet is dying

flint coyote
#

So if you know the pointers will always be the same by specification it would be useless to assume they are not

#

that's like always calculating 2/2 instead of just writing 1 inside your code imo

alpine urchin
#

sometimes 2/2 can show clarify and the intention

grim ice
alpine urchin
#

just any expression

iron glade
alpine urchin
#

like why do we calculate 2*PI

flint coyote
#

As I already said: Use what you want but don't try to convince others to swap to something that you prefer while there's no benefit of doing so.

alpine urchin
#

instead of writing the value

#

right away

grim ice
#

I asked to stop recommending things, with no reason whatsoever

#

and to not stop doing things when you dont know why to stop

#

btw

buoyant viper
flint coyote
#

You are the first person I've seen that uses .equals for enums. And just because you don't like the arguments given to you that doesn't mean that .equals() is better. It's pretty much personal preference. I've just never seen anyone do it before

grim ice
#

is having a public static instance of your plugin in your main class, without a getter for it, static abuse??

for others reading this, don't reply, this question is directed to fabsi

flint coyote
#

If you make it public you will enable others to override your plugin instance.

#

Why would you do that

grim ice
#

my question began with "is" so im expecting yes or no

flint coyote
#

And don't tell me "reflection can do that anyway"

#

Define what "static abuse" is for you lol

#

i would never go with a static instance and instead pass it via DI

grim ice
#

Nope, it's not my definition

#

it's a concept that's agreed on by many developers

#

if i have my own opinion on it then im simply wrong

flint coyote
#

Your definition seems to be to use equals for enums aswell🤷‍♂️

grim ice
#

therefore having opinions is okay

buoyant viper
grim ice
#

as long as you back them up

#

now just

#

answer my question please

#

why r u taking this long to answer with yes or no lo

flint coyote
#

I already did. It wouldn't make sense to make it public static. So the answer is yes

grim ice
#

Incorrect

#

it is not static abuse

flint coyote
#

That's just a bad way of handling objects

lost matrix
grim ice
#

it's generally fine

#

as your main class is a singleton

flint coyote
#

It is a singleton but you still wouldn't need a static variable if you use DI

next stratus
iron glade
next stratus
flint coyote
#

this @lost matrix

next stratus
# lost matrix

I don't understand arrow code, I found the gradle format but thanks for pointing that out

tardy delta
#

arrow code lol

flint coyote
#

I wouldn't ever suggest using static unless it's necessary or you want to define constants.

I did that in some older plugins of mine but I swapped to not doing so

iron glade
#

7smile do you use.equals or == on enums?

empty laurel
#

Hi, I need some help, can anyone help me?

flint coyote
#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

lost matrix
#

.equals literally does a single == internally for enums. So why bother with the extra method call?

empty laurel
#

Oh.

alpine urchin
#

Benefits of == is

#

you wont run into NPEs

empty laurel
#

So my plugin doesn't want to add +1 lvl to items that are already enchanted.

alpine urchin
#

if a value is null

#

plain and simple

iron glade
#

we already mentioned that == is null safe

alpine urchin
#

ok

lost matrix
#

Having a public static instance of your JavaPlugin class isnt exactly static abuse but its very fragile design.
public static should always be final. Otherwise you have no control over access.

alpine urchin
#

so use it

empty laurel
#

but, items with no enchant, enchant.

iron glade
alpine urchin
#

eminem

reef lagoon
#

Anyone knows why this doesn't delete the file? The file is set because it broadcasted the name of it

tardy delta
#

show code @empty laurel

empty laurel
#

Ok

next stratus
iron glade
#

our friend 2hex says the null safety is no argument as you should compare from left

tardy delta
#

?paste actually

undone axleBOT
grim ice
empty laurel
#
    public void Transformar(InventoryClickEvent e) {
        Player p = (Player) e.getWhoClicked();
        ItemStack espada = new ItemStack(Material.DIAMOND_SWORD);
        ItemStack machado = new ItemStack(Material.DIAMOND_AXE);
        if (e.getClickedInventory().equals(p.getInventory())) {
            if (p.getItemOnCursor().isSimilar(runaAfiacao(p.getItemOnCursor().getAmount()))) {
                if (e.getCurrentItem().equals(espada) || e.getCurrentItem().equals(machado)) {
                    int a = (int) Math.round(Math.random() * 100); 
                    int level = e.getCurrentItem().getEnchantmentLevel(Enchantment.DAMAGE_ALL);
                    if (a <= 50) {
                        e.getCurrentItem().addUnsafeEnchantment(Enchantment.DAMAGE_ALL, level + 1);
                        p.getItemOnCursor().setAmount(p.getItemOnCursor().getAmount() - 1);
                        p.sendMessage("§eVocê conseguiu utilizar a runa em sua ferramenta.");
                        return;
                    }
                    p.getItemOnCursor().setAmount(p.getItemOnCursor().getAmount() - 1);
                    p.sendMessage("§cFalha! Você não conseguiu encantar sua ferramenta.");
                }
            }
        }
    }```
grim ice
#

you should compare constants from the left

next stratus
grim ice
#

if you dont then youre doing something wrong

iron glade
#

yes

lost matrix
iron glade
#

you can do that and still use ==

empty laurel
next stratus
undone axleBOT
alpine urchin
#

if both are null

empty laurel
#

Oh.

alpine urchin
#

cope

buoyant viper
#

iirc javac actually optimizes enum equals into == doesnt it

tardy delta
#

pff spaghetti code

buoyant viper
#

so unless u really need a deep equals check

alpine urchin
reef lagoon
alpine urchin
#

integers with a meaning

flint coyote
buoyant viper
#

does in source and at compilation ig

#

lol

grim ice
alpine urchin
#

yeah haven’t had time to look into java with its vms in the way but c++ deals with it

lost matrix
alpine urchin
#

like that

reef lagoon
buoyant viper
reef lagoon
#

im trying to delete yml files so there won't be folders

tardy delta
#

you gotta be kiddin me for not using early returns

buoyant viper
#

have u tried just file.delete()

reef lagoon
#

yeah take a look at the code xd

buoyant viper
#

not even camelCase

iron glade
flint coyote
# iron glade yes iirc

well if the compiler already changes it then I'd really say it's full personal preference. I'll stick with == tho.

grim ice
#

i like how the indents

#

with the annotation

#

and the method are different

buoyant viper
#

that part is just copy paste issue probably

tardy delta
#

dont blame me lol not my code

buoyant viper
#

probably started copy at @ instead of the start of the line

tardy delta
#

tell that the dude who made this

empty laurel
#

??

lost matrix
empty laurel
#

Fourteen, What do you mean by that? my english is so bad.

reef lagoon
flint coyote
buoyant viper
#

java concurrency

lost matrix
tardy delta
#

didnt even know return; without value existed

buoyant viper
#

literally didnt start until someone here yelled at me few months ago

flint coyote
#

My teacher told me to not declare variables in loops and I stuck with that for a long time.

empty laurel
reef lagoon
#

Pretty sure that nothing else is relevant

lost matrix
iron glade
flint coyote
patent fox
#

why do i get errors in the ide when i import other classes in the project?
the errors are only visually and do not effect the package or inside the minecraft

buoyant viper
#

probably a cache miss in ide

#

idk

lost matrix
reef lagoon
#

it is my plugin

reef lagoon
iron glade
#

do you create the inventory when running the command?

grim ice
grim ice
#

maybe he has a clue

buoyant viper
#

think id rather try to abstract the gui handler instead of run command imo

patent fox
#

i just reopend the ide and

reef lagoon
iron glade
#

well usually I have a method like openGuiX(Player p) or smth that I can call where ever I want

lost matrix
empty laurel
#

When I go to enchant an item, it doesn't enchant if it's enchanted,
but when it's out of enchantment, it enchants, WTF?

flint coyote
#

When you are writing a utils class...
Do you go full static methods since it doesn't have any variables and no state?
Or would you still pass an instance around?
Feels like every second day I change my mind and swap from one to the other because I dislike static but then again it's a wasted instance in memory

lost matrix
#

Otherwise its not a utility class

#

And should be handled differently

lost matrix
empty laurel
#

When I go to enchant an item, it doesn't enchant if it's enchanted,
but when it's out of enchantment, it enchants, someone help me?

flint coyote
reef lagoon
lost matrix
grim ice
#

yeah

#

as smile said

#

just use lombok tho!

buoyant viper
#

like maybe u want a cached Random in there or something

#

or regex

reef lagoon
#

doesn't this close it tho

grim ice
flint coyote
buoyant viper
#

bru

buoyant viper
#

same principle just easier to say Random

grim ice
#

A utility class cannot be instantiated. By marking your class with @UtilityClass, lombok will automatically generate a private constructor that throws an exception, flags as error any explicit constructors you add, and marks the class final. If the class is an inner class, the class is also marked static.

All members of a utility class are automatically marked as static. Even fields and inner classes.

reef lagoon
#

I think i found the issue, an unclosed buffered reader ty 7smile7

young knoll
#

Wow you save 2 lines

#

Totally worth it

lost matrix
buoyant viper
#

random was just an example of something that would be understandably instantiated once and reused

grim ice
lost matrix
#

Meh. Not my favourite lombok annotation

flint coyote
#

Hmm I don't know if I like the "make non static methods static" part. That kinda hides too much. That's why I sticked with the simple annotations that I mentioned before

grim ice
#

same but if ur using lombok anyways

#

might as well use it

grim ice
#

and there isnt that much boilerplate anyways

flint coyote
#

I mean I can use it and declare everything static myself but that would feel weird aswell

smoky oak
#

im trying to build the 1.19.2 server jar, but it says 'started to download https://piston-data.mojang.com/.
heres the issue.
task manager says im not sending or recieving any data

#

yes

#

well i didnt use rev --latest but it said building 1.19.2 anyways

grim ice
#

that's pretty obvious, though it doesnt require that much knowledge to "now what you're doing"

#

you can pretty much just google it

buoyant viper
#

simple, if u dont plan on ever changing it and use it in multiple places, make it static 😎

#

give examples of valid/working and valid/not working nums

smoky oak
#

wtf is var

buoyant viper
#

its javascript

#

lol

smoky oak
#

let me show you the exit lol

empty laurel
#

When I go to enchant an item, it doesn't enchant if it's enchanted,
but when it's out of enchantment, it enchants, someone help me ? (5)

young knoll
#

Java has bar now

#

Var

buoyant viper
#

yeah but not function lol

#

or typeless parameters

smoky oak
#

which is a good thing

#

ah i didnt try

#

give me a moment

sonic sky
#

4137894711755904 for example

smoky oak
#

i fucking hate windows lol

#

anyways

#

but it seemed to work

empty laurel
#

Hey, moterius

smoky oak
#

i stg if you make that joke

empty laurel
#

stg?

smoky oak
#

swear to god

#

i have REALLY had enough of people joking about my handle

#

i made my account before that movie was announced

flint coyote
#

now I'm interested. What movie and what joke?

#

I suppose the movie is named Moterius, so what's the joke?

smoky oak
#

that im such a fan i made a similar sounding name

#

and its really, really annoying

#

*morbius

flint coyote
#

Oh morbius

#

Haven't seen it but I guess you don't like it then

smoky oak
#

oh for gods sake

#

[WARNING] The requested profile "remapped" could not be activated because it does not exist.

#

scuse me

#

does that no longer exist in 1.19.2 or something

young knoll
#

I get that error

#

Still works

flint coyote
#

I get it, too

#

just ignore it

smoky oak
#

so the remapped stuff still got generated in .m2 ur saying?

flint coyote
#

yes otherwise you can't compile if your pom has the plugin

smoky oak
#

ah

#

btw wheres the script for md_5's plugin again

#

the maven remapped one

hybrid spoke
flint coyote
#

what script? You mean the pom entry?

smoky oak
#

yea the pom remap rebuild

quiet ice
hybrid spoke
flint coyote
quiet ice
flint coyote
#

found it

smoky oak
#

ah thanks

#

i never know what to google to find it

hybrid spoke
mighty pier
#

i have a string [ItemStack{MUSHROOM_SOUP x 1}, ItemStack{MUSHROOM_SOUP x 1}, ItemStack{MUSHROOM_SOUP x 1}, ItemStack{MUSHROOM_SOUP x 1}] how do i loop through all of the itemstacks? (they arent always the same)

#

like seperate them

young knoll
#

Split on ,?

mighty pier
#

yes but

#

tghere are like 20 itemstacks

quiet ice
#

If you obtained that String through ItemStack#toString - don't.

mighty pier
#

its an array in mongodb

#

and when i get it

#

i cant turn it into an arraylist

urban kernel
#

how do i get the player and way they died from a PlayerDeathEvent?

quiet ice
#

Ah, so in reality it is an array of Itemstacks and you want to turn it in an arraylist?

young knoll
#

Arrays.asList(yourString.split(“,”))

mighty pier
#

yes

#

ty

young knoll
#

Then you have to read the strings to itemstacks

grim ice
#

that wont work the waya he thinks

mighty pier
#

e

quiet ice
#

new ArrayList(Arrays.asList(array));

smoky oak
young knoll
#

getEntity

urban kernel
urban kernel
crisp steeple
#

what an interesting image hosting domain

urban kernel
#

ty

mighty pier
urban kernel
#

wtf

meager trout
mighty pier
#

ballrape

urban kernel
smoky oak
#

well if you cast it to a name ofc its a string

#

(Player) event.getentity

mighty pier
meager trout
young knoll
#

getEntity should not be a string

buoyant viper
buoyant viper
#

new ArrayList<>(Arrays.asList(new String[] {"hello"}));

hybrid spoke
quiet ice
#

And in what way does that convert an array of Itemstacks in an arraylist of itemstacks?

buoyant viper
#

it doesnt

quiet ice
buoyant viper
#

its just a wasteful line uwu

quiet ice
young knoll
#

Sometimes you gotta give the compiler a workout when optimizing

hybrid spoke
young knoll
#

Otherwise it gets lazy

buoyant viper
#

gotta keep the javac on its toes

smoky oak
#

just code the bytecode yourself if you know better

young knoll
#

I’ll just write assembly like Chris Sawyer

quiet ice
golden turret
smoky oak
#

eh fair

quiet ice
#

Unless you pass -noverify that is

smoky oak
#

whatever you do just dont do it like yanderedev

pulsar parcel
#

Hello, I am trying to make shop in my minigame. I am trying to make, if player have Itemstack "price" in his inventory, it will remove "price" form his inventory and give him "sword". But when I am testing it in minecrafft, it's playing enderman teleport sound, witch mean, I dint have enough coins. But If I will paste Material.SUNFLOWER instead of price, its working. But here is problem, I cant remove amount of items. Can someone help me with this?

Here is my code:
https://pastebin.com/fysthtDt

young knoll
#

Use containsAtLeast and removeItem

mighty pier
#

do Player p = e.getWhoClicked(); pls

young knoll
#

It’s not a player

mighty pier
#

wym

pulsar parcel
empty laurel
#

i'am with problems.

mighty pier
#

it is

golden turret
empty laurel
#

someone help?

golden turret
#

vai se fude

empty laurel
#

KKKKKKKKKK

golden turret
#

tu ta aqui tbm

empty laurel
#

kkkkkkkkk

#

vai se fuder kk

golden turret
#

aqui eu posso mandar

#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

golden turret
#

?learn-java

empty laurel
#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

young knoll
#

InventoryClickEvent#getWhoClicked is a HumanEntity

golden turret
#

?jd-s

undone axleBOT
empty laurel
#

Foda-se

#

?send

worldly ingot
# mighty pier it is

It's not. It's a HumanEntity. Which is essentially a safe cast to Player at this point, but technically speaking, it's not a Player lol

golden turret
#

?learnjava

undone axleBOT
empty laurel
#

?learnjava

#

Enfim, @golden turret , fiz com math.random, mas não adiantou nada.

#

tá a mesma coisa..

golden turret
#

ta

buoyant viper
#

bukkit api is so funny and quirky and weird sometimes

golden turret
#

gringo vai reclamar do pt

empty laurel
#

Pode ir na gdd?

buoyant viper
#

unnecessary necessary casting of event objects

golden turret
undone axleBOT
empty laurel
young knoll
#

Blame Mojang for the HumanEntity stuff

empty laurel
#

cara.

#

Bro.

buoyant viper
young knoll
#

Mojang: Let’s make HumanEntity a thing
Also Mojang: Armorstands are a living entity

jaunty cove
#

I'm using ProtocolLib to get packets being sent to the client, and some of these packets just send an integer entity ID. Is there a way to get an in-world entity by that ID?

empty laurel
#

@golden turret Dude, flirt. The error is like: items that are enchanted do not enchant.

buoyant viper
#

either protocollib or bukkit has a method to get entity by id iirc

#

dont ask me what it is though bc idk

young knoll
#

Yeah I’m trying to remember what it is

#

Eeeee

buoyant viper
#

?jd-s try looking around

undone axleBOT
jaunty cove
#

Bukkit can get an entity by UUID

#

but I don't think that's the same thing

tender shard
chrome beacon
#

You'll need nms for the int id

young knoll
#

Yeah but like

#

Why tf did they not make an equipable interface

spare prism
#

?paste

undone axleBOT
spare prism
buoyant viper
#

so what u could do is uh

#

uhm

#

loop through a worlds entities

young knoll
#

Loading chunks

buoyant viper
#

and check if getEntityId == packetEntityId

#

bc bukkit exposes that at least

hybrid spoke
quiet ice
#

Yeah, I haven't got an idea either

hybrid spoke
#

but thanks anyways

jaunty cove
young knoll
#

The NMS method does that anyway

buoyant viper
#

hmm theyre using corretto in recaf

hybrid spoke
#

GitHub Workflow

buoyant viper
#

maybe that builds with uh

#

jfx

#

havent used that in so long i forgot what it was called

chrome beacon
#

You're loading a whole bunch of chunks

#

in an unsafe way

young knoll
#

I didn’t even know you could load chunks async on spigot

chrome beacon
#

Probably an old version

#

without the warning

spare prism
spare prism
magic wigeon
#

Hello guys, i've got a question. I want to create an "obsidianjail" command, where you can add the amount how much obsidian he has to mine. When i execute the sendjail command, the database will create with the UUID + how much he has to mine. Everything works just fine. But at the remove command, the player(UUID + jailcount) should be deleted from the database... I tried but there are just errors. Can someone help me fix this?
https://paste.gg/p/anonymous/1ba3f14f6c9843a7b70d7345c88d1541

The Error: ||MrIllusion issued server command: /obsididanjailremove MrIllusion
[14:46:23 WARN]: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '* FROM obsidianjail WHERE uuid=┤929bbc61-2f89-45cd-a351-84f439842832┤' at line 1||

#

MySQL Issue

flint coyote
hazy parrot
#

Like full one

quiet ice
# spare prism Any ideas?
                x = RandomUtils.nextInt(maxCoordinateValue) - RandomUtils.nextInt(maxCoordinateValue/2);
                if(x < minCoordinateValue) x = minCoordinateValue;
                z = RandomUtils.nextInt(maxCoordinateValue) - RandomUtils.nextInt(maxCoordinateValue/2);
                if(z < minCoordinateValue) z = minCoordinateValue;

I'd assume that x < minCoordinateValue (same with the z thing) almost always applies

tender shard
#

why do you have those weird symbols in the UUID string

magic wigeon
#

Idk but i think its like that isn't it?

hazy parrot
spare prism
quiet ice
hazy parrot
quiet ice
#

new Location(world, x, y, z); at least does not load chunks

chrome beacon
#

getHighestBlockAt

magic wigeon
chrome beacon
#

I believe it loads the chunk since you're getting the block instance

young knoll
#

Not in this case

#

Just an int

#

Using the height map

quiet ice
#

Although yes, it probably just queries the highmap which should be rather fast

young knoll
#

Still may need to load the chunk to get the height map

#

Idk

spare prism
magic wigeon
#

I hope thats it, what you need

hazy parrot
magic wigeon
#

In Php? Or where

quiet ice
# spare prism ?

Assume maxCoordinateValue is 500 and minCoordinateValue is 50. Then on average x will be 250 - 125 = 125. This means that you do many computations over and over again

hazy parrot
#

Your mysq query, where you call it in code

young knoll
#

We coding spigot in php now?

magic wigeon
#

I mean in Database

#

xd

quiet ice
#

For a minCoordinateValue of -maxCoordinateValue/2 (or lower) it probably is impossible to reach a settlement

buoyant viper
magic wigeon
#

It is in there

hazy parrot
tender shard
quiet ice
hazy parrot
#

Didn't know there were two pastes

young knoll
#

Take a look at essentials /tpr

tender shard
magic wigeon
#

haha no worries xd

spare prism
young knoll
#

Iirc essentials tpr is nice and performant

#

And takes advantage of paper as well

buoyant viper
#

essentials has a rtp? must be essX addition

quiet ice
#

Myeah, then the while loop CAN be an infinite loop if I am right

young knoll
#

Yeah

#

They finally added it

quiet ice
hazy parrot
#

You doesn't seem to send that

quiet ice
#

Doesn't say too much for me

magic wigeon
#

I did wait

#

all the way to the bottom

hazy parrot
spare prism
chrome beacon
#

Yeah as mfnalex showed that loads the chunk as well

#

You're just going to have to do less checks per tick

magic wigeon
chrome beacon
#

And spread out the checks over multiple ones

hazy parrot
magic wigeon
#

And when im adding it, will create the player

buoyant viper
#

make a queue for rtps 😎

#

process one every 5s ezpz

magic wigeon
#

RemoveFromJailCommand

hazy parrot
#

It's really hard to look when you send 10 classes

magic wigeon
#

Sure

#

wait

hazy parrot
#

This is your command handler..

#

Not remove Jail method

magic wigeon
#

Ahhh

#

Sorry haha

#

Sec

young knoll
#

Essentials random location finder thingy ^

magic wigeon
#

You mean that, right

spare prism
young knoll
#

PaperLib

#

Which is what they are using

quiet ice
#

PaperLib delegates to spigot if it is on spigot

young knoll
#

Mhm

spare prism
#

ok, I'll try it, ty

hazy parrot
#

first dont save uuid as string

#

and use prepared statements

#

also this ` might be cause for sql syntax error

kindred valley
#

How can i prevent a player to drop something in their inventory

#

which event

magic wigeon
#

PlayerDropEvent

#

e.setCancelled(true)

kindred valley
#

It does not work at inventory

magic wigeon
#

You mean cant move items?

young knoll
#

Probably the InventoryClickEvent

magic wigeon
#

Then its InventoryClickEvent

kindred valley
#
@EventHandler
    public void onDrag(InventoryClickEvent e) {
        CustomStacks.addingComponents();
        if(e.getCursor() == null) {
            System.out.println("AAAAAAAAAAAA");
            return;
        }
        for(CustomStack stack: CustomStacks.list) {
            if(e.getCursor().isSimilar(stack.getItemStack())) {
                System.out.println("BBBBBBBBBBBBBB");
                e.setCancelled(true);
            }
        }
    }
smoky oak
#

uh what was groupid again? io.github.<name> or <name>.github.io?

magic wigeon
#

Adde@EventHandler

#

Bruh

reef lagoon
#

ur @EventHandler is off

#

u should add a tab there

hazy parrot
#

probably inventory move item event

quiet ice
#

Spigot has slf4j-api shaded in, right?

magic wigeon
kindred valley
#
    @EventHandler
    public void onDrag(InventoryMoveItemEvent e) {
        e.setCancelled(true);
    }```
#

its on man

magic wigeon
#

The @ need to be above the p

kindred valley
#

it is man

quiet ice
undone axleBOT
young knoll
#

InventoryMoveItemEvent is for hoppers

tender shard
kindred valley
hazy parrot
#

cant you do just click event and cancel it ?

#

shouldn't that work ?

tender shard
#

ClickEvent and DragEvent, yeah

grim ice
#

anyoone has concepts to learn about?

reef lagoon
grim ice
#

ngl

#

cant there be a platform with all internet users on

hazy parrot
grim ice
#

like one social media that everyone uses

reef lagoon
amber vale
#

I am attempting to send actionbar messages using spigot 1.18.2 using:

player.sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("This message will be in the Action Bar"));

But there is no such thing as ChatMessageType

reef lagoon
hazy parrot
#

that method doesn't exist

reef lagoon
#

yeah..

#

there's fromRGB but i don't know how that could help me

hazy parrot
#

nah, looks like you would to do switch/case yourself

grim ice
#

OHHH ITS NOT AN ENUM

#

LOL

grim ice
#

its a static variable

grim ice
#

give me the class import

hazy parrot
reef lagoon
#

import org.bukkit.Color;

grim ice
tender shard
hazy parrot
#

for what reason ?

grim ice
#

cuz i said so

reef lagoon
#

inefficient and boringg

hazy parrot
#

¯_(ツ)_/¯

hazy parrot
#

or look trough all vars and match toString

reef lagoon
#

nah bs there must be a way

grim ice
#

hm u can use reflection thats for sure

#

but

#

that sucks ass

#

a second

hazy parrot
amber vale
grim ice
#

no, there is a better way

#

map them

#

or make ur own enum

reef lagoon
#

What's reflection

grim ice
#

an enum like this

hazy parrot
smoky oak
tender shard
#
        int r = ChatColor.valueOf("RED").asBungee().getColor().getRed();
        int g = ...;
        int b = ...;
        Color bukkitCOlor = Color.fromRGB(r,g,b);
#

but that's deprecated

reef lagoon
#

not chatcolor

#

Color

#

oh wiat

#

nvm

hazy parrot
#

this is how i do it

#

it should work

grim ice
#

actually no

#

mfnalex thats a pain to do

#

u will have to get the green and blue of each color

#

and theyre constatns anyways so

#

anyways

#

just make an enum 🧠

amber vale
tender shard
# grim ice mfnalex thats a pain to do

I know, the Color class is weird. One liner would be using reflection

    public static Color fromName(String name) throws ReflectiveOperationException {
        return (Color) Color.class.getDeclaredField(name).get(null);
    }
grim ice
#

yeah

#

or u can make an enum

#

which is faster than reflection

#

but longer to write

hazy parrot
amber vale
hazy parrot
#

nice 👍

amber vale
#

Spigot uses some parts of the bungeecoord api.

grim ice
#

@hazy parrot ur website dude

#

its so fucking

#

amazing

#

god

#

how did u make that?? this makes me want to learn front end

tender shard
# grim ice or u can make an enum

I'd probably do it like this

public class MyColor {

    private static final Map<String, Color> COLORS = new HashMap<>();

    static {
        for(Field field : Color.class.getDeclaredFields()) {
            if(field.getType() == Color.class) {
                try {
                    COLORS.put(field.getName(), (Color) field.get(null));
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    
    public static Color getColor(String name) {
        return COLORS.get(name);
    }
}

hazy parrot
#

particlesjs or something along those lines

#

but thanks 😄

grim ice
tender shard
#

so that it will also work when new stuff gets added or stuff gets renamed or whatever

#

I mean it only gets the values once

#

and then saves it to a map

amber vale
grim ice
#

it wasnt updated in like

#

8 months

#

and the latest updates didnt add much

#

just changed some internal stuff

reef lagoon
#

no fucking way

#

ty mfnalex

grim ice
#

man this is so annoying

quaint mantle
grim ice
#

i really wanna play 1.19

vocal cloud
#

I hate particlejs

hazy parrot
#

why, its cool

reef lagoon
#

the math behind it isn't cool at all

vocal cloud
#

Lag

#

It's overused

hazy parrot
#

its not laggnig ?

vocal cloud
#

People abuse it

hazy parrot
#

Everything being abused isn't good, right 😄

vocal cloud
#

Gotta write your own impl that's 10x slower and looks ugly

hybrid spoke
#

let them lag out themself

#

also 1.16+ the particles should be only clientside anymore

grim ice
#

anyone?

#

this is pain

tardy delta
#

lol

vocal cloud
hybrid spoke
#

oh

#

it made sense to me

grim ice
#

6 ppl in the thread

#

and no one could fix it

#

aaa

scarlet creek
sullen wharf
#

is there any particular reason for why the InventoryClickEvent sometimes doesn't make anything, when i left click a bit fast?

grim ice
#

yeah

tender shard
#

if you move the mouse a little while clicking, it's considered a DragEvent, even if you only touch one slot

sullen wharf
#

bruh

#

thank you 🙂

tender shard
#

np

#

I use this to detect whether the drag affects the upper inventory or not

#

just in case you need that

sullen wharf
#

i'm updating an item whenever it gets moved from a chest to player's inventory

#

so that should be useful

young knoll
#

I hate that that fires the drag event

sullen wharf
tender shard
#

yeah it sucks

vale veldt
#
tasks {
    assemble {
        dependsOn(shadowJar)
    }
    java {
        toolchain {
            languageVersion.set(JavaLanguageVersion.of(8))
        }
    }
    withType<JavaCompile> {
        options.encoding = "UTF-8"
    }
    shadowJar {
        val relocate = "net.shibacraft.simpleblockregen.libs"
        relocate("net.shibacraft.api", "$relocate.shibacraftAPI") // this
        minimize()
    }
}```

how do I relocate a dependency? if I run with shadowJar it would be like this, but I'm compiling this project as a library in jitpack and it doesn't relocate, what should I do to relocate the package that is inside shadowJar?
young knoll
#

Was such a pain making a custom inventory due to that

tender shard
#

does your shadowJar task run at all?

vale veldt
tender shard
tender shard
vale veldt
#
plugins {
    id("java")
    id("maven-publish")
    id("com.github.johnrengelman.shadow") version ("7.1.2")
}

group = "${project.property("group")}"
version = "${project.property("version")}"

plugins.apply("maven-publish")
plugins.apply("com.github.johnrengelman.shadow")

publishing {
    publications {
        create<MavenPublication>("maven") {
            groupId = "${project.group}"
            artifactId = project.name
            version = "${project.version}"

            from(components["java"])
        }
    }
}

repositories {
    mavenCentral()
    maven("https://jitpack.io")
    maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
}

dependencies {
    implementation(libs.shibacraftApi)
    compileOnly(libs.spigot)
    compileOnly(libs.lombok)
    annotationProcessor(libs.lombok)
}

tasks {
    assemble {
        dependsOn(shadowJar)
    }
    java {
        toolchain {
            languageVersion.set(JavaLanguageVersion.of(8))
        }
    }
    withType<JavaCompile> {
        options.encoding = "UTF-8"
    }
    shadowJar {
        val relocate = "net.shibacraft.simpleblockregen.libs"
        relocate("net.shibacraft.api", "$relocate.shibacraftAPI")
        minimize()
    }
}```I have it like this right now, if I put it outside, it gives an error
tender shard
#

hm then I have no idea

#

gradle is much too complicated for simple things lol

vale veldt
hybrid spoke
#

whats the issue

tender shard
#

in their FAQ they tell you to open an issue if you have a any question

tender shard
hybrid spoke
#

tried a JavaExec task?

vale veldt
#

JavaExec? i don't know what it is

hybrid spoke
#

and from in there you can run shadowJar stuff

vale veldt
mighty pier
#

how do i turn string "ItemStack{MUSHROOM_SOUP x 1}" into an itemstack

agile anvil
#

Format the string to remove the unnecessary strings, split it to grab the material name, then the amount

#

Might differ if you have also itemmeta on it

mighty pier
#

yes

#

its gonna have itemmeta

#

but like

agile anvil
#

But the thing I recommend is to serialize properly the itemstack

#

So you can properly deserialize

mighty pier
#

what is serialize

agile anvil
#

Transform an itemstack to string

#

But properly with all info

#

And in a properly way to quickly deserialize

vital sandal
#

Add fly controller to him

#

hava a look at entityBat class
also Leash event for smoother movement

smoky oak
#

is it possible to cast a object to a certain version of bukket, then its current version?

vital sandal
smoky oak
#

thatd probably do it

vital sandal
#

just came across it

#

they can all fly and blaze seem not to have a fly controller

#

if you leash a cow u are a leash holder

old cloud
#

Why do some spigot versions only work "up to" specific java versions and is there any workaround?

tender shard
#

I know that you can skip the buildtools check, but I dont think you can easily skip the check when running the actual server

#

but tbh if you have java 8 and java 17 installed, you can basically run EVERYTHING

#

there is no spigot version that wouldn't run on either 8 or 17

grim ice
#

just install every java version

#

ez

tender shard
#

yeah java 10, best version ever lol

#

i think on my macbook I got 6 different versions

#

I have at least java 8, 11, 14, 15, 16, 17 and 18 there

#

java 11 is what macOS came with

grim ice
#

how do i write something on the boss barbtw

tender shard
#

menawhile they don't include java anymore and link you to the java 8 download

tender shard
tender shard
#

bossbar

#

you have to create one

#

Bukkit.createBossbar

#

then add the player

#

I usually keep a Map<UUID,Bossbar> of all bossbars if I need to change the text later on

old cloud
tender shard
#

quick mnemonic: 1.17+ works on java 17+, everything else works on java 8

tardy delta
#

so much easier to handle playerdata if you create a player wrapper

vivid skiff
#

How can i make a player ride a clicked armorstand?

sage dragon
#

I wonder what happens if you try to set entries in the PersistenDataContainer on a different thread.

Does it work? Or does it throw an error?

smoky oak
sterile token
#

Because a friend is arguing about that a plugin compiled with Java 8 can work on 1.19

sterile token
#

Hmn

smoky oak
#

thats because java mostly only adds stuff, so its almost 100% backwards compatible

#

the server itself has to run on the corresponding java though

#

and you cant comiple a 1.12 plugin using java 17

sage dragon
# sterile token Hmn

I have a few plugins on spigotmc which are compiled with Java 8, but work for 1.8.8 - 1.19

sturdy frigate
#

how do I change the pitch and yaw of the default spawn point?

sterile token
#

Weird

smoky oak
sterile token
#

How litch

tardy delta
#

is there smth as Bukkit.setSpawnLocation?

smoky oak
#

theres a command yes

sturdy frigate
sterile token
#

Or smth line that

smoky oak
#

maybe its exclusive to the teleport command

tender shard
sage dragon
smoky oak
#

really?

#

huh

sturdy frigate
sturdy frigate
tender shard
sterile token
sage dragon
smoky oak
#

you CAN set rotation

quaint mantle
#

the only reason it wouldn't work is if you have a Java 8 server trying to run a Java 17 plugin

sturdy frigate
#

Oh I see thanks

smoky oak
#

ah yes thats why i said it wouldnt work

tender shard
tardy delta
#

retrieve the spawn loc, change yaw and pitch and set it back

smoky oak
#

my server host says 'select version' which forces me to select java 8, 16 or 17 for the corresponding server jar

tender shard
#

I am 100% sure that everything between 1.8 and 1.16 works fine on java 8 while everything 1.17+ works fine on java 17+

tender shard
#

1.17 required java 16+ but also works fine on java 17

#

(and java 16 is EOL anyway)

patent fox
#

how can i make a custom entity fly?
using path find

smoky oak
#

im guessing here but

#

make a flying entity path find

#

then try to force the entity to follow that path

spare prism
patent fox
smoky oak
old cloud
#

Is it possible to compile java 17 code to a java 8 jar while using stuff from > java 8 versions?

smoky oak
#

i dont think so

quaint mantle
#

no

smoky oak
#

java compiles to jvm bytecode

tender shard
old cloud
#

sucks

tender shard
#

however there isn't really anything in java 17 you couldnt do with java 8 code

#

it's just a bit more writing

old cloud
#

ofc but now i have to change everything

patent fox
old cloud
#

What an epic idea to clamp java versions for spigot

#

But a java 17 jvm will be able to run a java 8 jar right?

quaint mantle
#

yes

old cloud
#

yea ok, just wanted to be sure before wasting another couple hours

tender shard
#

there are VERY VERY FEW things that are not possible with higher version JVMs that were previously possible

#

e.g. accessing Unsafe without reflection IIRC

patent fox
smoky oak
#

is my install botched or am i being an idiot again

tender shard
#

what are you trying to override?

smoky oak
tender shard
#

OnEnable

#

!= onEnable

smoky oak
#

right

tender shard
#

methodsAreAlwaysLowerCamelCase

#

orRatherShouldBe*

#

why the fuck did I write my own plugin name in lower case

smoky oak
#

lol

jaunty cove
#

Is it possible to check if any part of a player's bounding box is visible to another player without sending out multiple ray traces? I was thinking about sending one for each corner of the BB but didn't know if there was a better way.

waxen plinth
#

That's not guaranteed to work either

#

If only the center of the player is visible that would fail

jaunty cove
#

True 😅

smoky oak
#

to be fair

#

tnt just throws 1000 rays

#

its not THAT hard for a modern computer to do something similar

#

just spread those 1000 rays over the bounding box of the player youre trying to check for

waxen plinth
#

🤔

#

That sounds like a bad idea

smoky oak
#

why do you think a minecraft boom looks like this if exaggerated?

sterile token
#

So i can compile spigot plugins from 1.13 up to 1.19 using java 8?

#

And what about the error from spigot which told you on 1.19 that you are compiling it with old versión

jaunty cove
#

This runs way too often for 1000 rays 😂 I could probably just use a few dozen rays and see how much of a performance hit that gives.

smoky oak
#

maybe you can do it on a separate thread off the main thread

spare prism
#

Hello. Why does my code causes the server to lag for 4 seconds every time it executes?: https://paste.md-5.net/anaxiguqen.cpp
The line that causes this problem (I don't understand why, cause I've already loaded that chunk asynchronously, so there shouldn't be any problems): int y = world.getHighestBlockYAt(x.get(), z.get()) + 1;

I'm using PaperMC 1.18.2

jaunty cove
sterile token
#

Ditto

#

You can make a cooldown to thst player

#

Something like Map<UUID, Long>

smoky oak
#

store activation time in that

#

plus cooldown time

#

then if its tried again check against that

#

system gettimemilis

#

plus cooldown in seconds times 1000

#

thats your bar

sterile token
#

Ditto i can help you

#

But wait some minutes I need to turn on pc

#

But more or less could you understand?

#

Ok

#

1 first question

#

Please tell that you know how works java atleast and the learnt the lang before

#

Because if not its like talking to you in chinese

#

You wont understand anything

#

Not wondering to sound rude

#

Are you spanishP

#

Because im also Spanish and i can help you vía dm in spa ish

#

Because here we must speak english

#

Ok

#

Perfect I will dm you

#

Your welcome

shut field
#

how do I set the progress of a bosses bossbar

#

like a bosses natural bossbar not one of my own bossbars

#

I tried boss.getBossbar().setProgress() but that doesn't actually change the progress of it

smoky oak
#

try changing their health

shut field
shut field
#

so I want the wither to spawn with the shield (they have to spawn with half their max health) but I want the bossbar to not show that they have half health

#

and I also want them to have a bossbar

smoky oak
#

cant u hide their bossbar and make a custom one and link that bossbar to their healt

jaunty cove
#

You might be able to hide their bossbar and create/link your own

shut field
#

I guess I can do that

tender shard
#

i dont think there's an easy way to get existing bossbars of a player

sterile token
smoky oak
#

tf are you doing with player bossbars in the first place anyways

tender shard
#

although since 1.16 or so, Bossbars are Keyed

#

and you can even do Bukkit.getBossBars()

#

this definitely wasnt possible a few versions prior

brittle loom
#

Hello, does anyone know what version the Consumer class was introduced in? I think it was 1.11 but I'm not sure.

ivory sleet
#

8

hazy parrot
ivory sleet
#

Well certain classes like Runnable was introduced earlier

#

but yeah java.util.function is all java 8

tardy delta
#

spigot has its own consumer class smh

brittle loom
ivory sleet
#

oh been there since a very long time

brittle loom
#

I tried using it for 1.8 but I've been getting noclassDefFoundError

young knoll
#

Yeah it wasn’t in 1.8

grim ice
#

anyone has an idea?

grim ice
tardy delta
#

reinstall mc smh

hazy parrot
spare prism
hazy parrot
#

Which method return compfuture

desert frigate
#

what do i use for player#canSee(Entity) since its deprecated

young knoll
#

It’s deprecated since it’s draft api

brittle loom
#

Yeah ok Consumer appeared in version 1.11

tender shard
#

it's draft api, meaning "it's new and might change"

#

but 99% sure it will not change

desert frigate
#

is it possible to kill a entity with a given itemstack? exactly like Block#breakNaturally(ItemStack)

#

like imagine a sword with sharpness or looting.

ashen quest
#

how do i calculate the armor points

more info, you see the armor icon above the hearts, i want to calculate that.

grim ice
#

well idk how to do that but i found a guy that made a method to calculate the damage reduced with the user's armor

ashen quest
#

doesnt help 😢

tropic ingot
#

Hi, I tried to complete the plugin build but it gives me this error (I think it's about "OnEnable" and "OnDisable")

How can I solve?

smoky oak
#

same typo i made

#

small first letter on method

#

onEnable

tardy delta
#

OnEnable -> onEnable

#

just ctrl + o and select methods to override

tropic ingot
#

Thank you! ❤️

tender shard
#

looks like someone released a shitty tutorial in the last days

#

methodNamesAreAlwaysLowerCamelCase

flint coyote
#

thatsAPrettyLongNameForAMethodButAtleastItDescribesItWell

tender shard
#

oh you havent seen my exception names