#help-development

1 messages · Page 759 of 1

icy beacon
#

Ooooooooooooooooo

#

Time for a massive fucking refactor

#

Lmao

#

Uh uhh uhhh does not look right

covert valve
#

nono

#

like this

#
/**
 * Tries to look up a [value] in an enum, returning null if not found.
 */
icy beacon
#

Ahh

covert valve
#

its inline

icy beacon
#

Gotcha

covert valve
#

tbh i prefer the javadoc style it seems more precise but hey thats convention

icy beacon
#

Yup, I'll look into that

uncut needle
#

I get this error when exporting a spigot project

#

The following artifacts could not be resolved: io.papermc:paperlib🫙1.0.6 (present, but unavailable): io.papermc:paperlib🫙1.0.6 was not found in https://hub.spigotmc.org/nexus/content/repositories/snapshots/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of spigotmc-repo has elapsed or updates are forced

eternal oxide
#

?whereami

icy beacon
#

In case you wonder how I approached the problem, this is what I came up with. I've ought to test it now haha

uncut needle
#

am I using paper or spigot

#

its the spigot logo on top left

#

spigot logo on this

#

I think im using spigot

icy beacon
eternal oxide
#

paperlib is paper so not in the spigot repo

icy beacon
#

And you are trying to use some paper dep

uncut needle
#

thats a thing?

icy beacon
#

What exactly

uncut needle
#

is essentialsx a paper dep

#

im using that as dep

icy beacon
#

Shouldn't be

slender elbow
#

essx casually having a transitive dep on paperlib

icy beacon
#

I mean they might be hosted at paper repo

#

I don't know how freely people can use it

#

The docs of essentialsx should tell you exactly how to add it

icy beacon
young knoll
#

Yeah its a transient dependency on paperlib

icy beacon
uncut needle
#

in basic english please

icy beacon
#

Essentials depends on paperlib and so your project also does

young knoll
#

You depend on essentials

#

Essentials depend on paperlib

uncut needle
#

ok thank you

valid burrow
#

who here got too much time and wants to go error hunting with me

#

ive been looking for like

#

3 hours

#

and i cant find it

uncut needle
#

make new a project

#

add parts of the plugin chunk by chunk

#

and see that chunk causes the error

valid burrow
#

im not gonna rewrite 2k lines of code

#

because of a simple logic error

#

there are no errors

#

its a logic error

#

i just dont know where

wooden hearth
valid burrow
#

first of all ive done this a million times before no idea why it doesnt work no

#

Im saving data to a database

#

that works

#

when i retrieve the data it doesnt exist

#

so my code trys to save it again

#

and guess what

#

SUDDENLY IT DOES EXIST AND I CANT SAVE IT

#

AND I CANT FIND THE MISTAKE

#

LIKe

#

IM GONNA GO INSANE ISTG

wooden hearth
low marlin
#

how to know if someone that has a open inventory is the same as the custom inventory I made?

#

like if 2 people has the same inventory open

wooden hearth
valid burrow
#

like

#

literally

#

i added like 500 debug statements

#

and i still cant find it

#

the connection works just fine

#

the part that annoys me the most

glad prawn
valid burrow
#

is that i used the code 100 times before

#

and it always works

valid burrow
#

its only about getting the data

#

that seems to be the only error

#

i beliebe

#

believe

#

but like

#

its 5 lines

#

and its completly correct

#

idk why it doesnt work

#

even these few lines i wrote to test it dont work

lost matrix
valid burrow
#

no its not

#

i could wait 20 seconds

#

and it say its not there

#

i could wait an hour

#

and it says

#

its not there

#

to put it simple

#

i click item

#

i put item tag in database

#

i click same item again

#

its supposed to say its already in database

#

but it doesnt

#

it trys to save it again

#

and then says its already in database as an sql error

lost matrix
#

I just came. Let me read the whole rant first

lost matrix
grand flint
#

What do I do

lost matrix
lost matrix
valid burrow
grand flint
#

is so confusing

#

when do i send packets

#

does an event fire when the person passes the config state?

lost matrix
grand flint
#

or do i have to wait for them to pass the config state

valid burrow
#

give me a sec

#

actually

#

?paste

undone axleBOT
valid burrow
lost matrix
valid burrow
#

alr :-

#

WAIT I GOT IT OMG

#

WTF

#

BUT HOW

#

THE UUIDS ARE COMPLETLY DIFFERENT IN BOTH METHODS??

zealous osprey
#

Why are you passing the uuid using a String type instead of the UUID type?

valid burrow
#

cause there is no uuid type in a database?

zealous osprey
#

.toString?

young knoll
#

there is in some

valid burrow
zealous osprey
#

Neverming, it seems you fixed the issue anyways :)

valid burrow
#

well no

#

now i gotta find out WHY

#

it is differnt

zealous osprey
#

Well, the hastebin does not have info code in it that one could assess it

valid burrow
#

i think i found hwy

zealous osprey
#

yey

quaint mantle
#

Bros codebase prob like ☠️

valid burrow
#

woooooow not i only have to remove about a million print statements

#

i error i did while turing the string back to a uuid.

zealous osprey
#

I can only strongly recommend to use the inbuilt debugger from intellij or some kind of debugger, as it really makes your life easier when you can dynamically place break points

subtle folio
#

remote testing is a thing

#

wtf

zealous osprey
#

Well "remote" as in a local development env.
I don't think you can send the data across the internet, tried that once and it failed, I might have just done it wrong though.

orchid gazelle
#

Well you could sync up your target directory with a remote online server and fire it up via SSH, im sure you'll somehow be able to write a script for that for IntelliJ

#

But for breakpoints and shit, nah

wooden hearth
wooden hearth
lost matrix
#

Not really a script needed. You can connect intellij with your host and remote debug it

valid burrow
#

therefor it saved the data under the wrong uuid

wooden hearth
#

Ah

valid burrow
#

cause it saved under my playername but i tried revieving it from my uuid

lost matrix
#

So it was something with your DB methods smileybolb

valid burrow
#

nope

#

it was in my model

#

someone here yesterday begged me to turn the uuid into a string and other way around inside my model

#

so i did

#

i made an error there though

#

but i completly forgot i even mde it

wooden hearth
lost matrix
#

Or you could use a DB that supports UUIDs.

valid burrow
#

what db supports uuids

wooden hearth
#

I was talking when I use configs tho

valid burrow
lost matrix
#

MySQL for example

valid burrow
wooden hearth
#

Yeah they support loads

valid burrow
#

mysql supports uuids?????

lost matrix
#

Or Postgres

wooden hearth
#

Yeah

lost matrix
#

Wait let me double check

pseudo hazel
lost matrix
#

I see, they use a binary format for that

pseudo hazel
#

yeah there is just the uuid helper function

#

but thats still pretty useful

#

no need to use strings

valid burrow
#

well aready did so no point changing it now

#

next time ill know better

lost matrix
#

Well, shows that Postgres is just the better DB imo. It has a dedicated uuid type.

slender elbow
#

there are tons of db engines that support uuid type lol

pseudo hazel
#

strings are still not the end of the world

#

everything better than saving player objects into your db 💀

lost matrix
pseudo hazel
#

oh well

lost matrix
#

MariaDB has one as well

slender elbow
#

yeah mysql is just bleh

valid burrow
#

i like mysql

slender elbow
#

iirc even msft sql server supports it lmao

lost matrix
#

Its very... basic

valid burrow
#

how can you look at this cute doflin and not like it

valid burrow
#

necessarily

wooden hearth
#

I'm trying to create a player message util do you think it's too much to keep recalling a new class should I just make an instance of that class to make ```java
public class MessageUtil {

private final String message;

public MessageUtil(String message) {
    this.message = message;
}

public static MessageUtil message(String message) {
    return new MessageUtil(message);
}


public MessageUtil setPlaceholders(Player player) {
    String raw = PlaceholderAPI.setPlaceholders(player, message);

    return new MessageUtil(raw);
}

public MessageUtil color() {
    return new MessageUtil(ChatColor.translateAlternateColorCodes('&', message));
}

public  void send(Player player) {
    player.sendMessage(message);
}

}```

lost matrix
#

I would def rename this class because its not a util class but a wrapper

wooden hearth
lost matrix
#

But keeping it immutable and creating a new instance is fine

wooden hearth
echo basalt
#

Not sure how I feel about it

#

string wrapper ehh

wooden hearth
#

why nt

#

not*

torn shuttle
#

I really wish java would only error when attempting to run code from a package that is not present instead of erroring at the moment it accesses the class

wooden hearth
heady grove
#

Command is not run and usage message is given

lilac dagger
#

?mappings

undone axleBOT
fluid river
#

?notworking

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

fluid river
#

that's for me guys no worries

river oracle
#

What how dare you insult me

#

No I get it fuck you too ig

lost matrix
smoky oak
#

are the != and == operators faster, or just as fast as the <,>,... operators when used on integers?

#

tryina kill a runnable on player death

lost matrix
#

Smelling premature optimizations

smoky oak
#

im using death count statistic

fallen lily
#

🥸

smoky oak
smoky oak
#

wait im dumb

#

thats not what im supposed to do here

warm mica
grim ice
#

what hes tryna make is a util

#

he just ended up making a wrapper

grim ice
#

and remove the constructor

lost matrix
#

I think his approach is perfectly valid. His class clearly has states, which makes it pretty infeasible for static usage.

grim ice
#

how does it have any state?

#

It's just a bunch of utility string methodsas an object for some reason

dry hazel
grim ice
#
public class MessageUtil {

    public static String setPlaceholders(Player player, String message) {
        return PlaceholderAPI.setPlaceholders(player, message);
    }

    public static String color(String message) {
        return ChatColor.translateAlternateColorCodes('&', message);
    }
}
#

could be simplified to this lol

smoky oak
#

anyone here worked with PAPI? i want to know if i can just enable the remote debugging like normal for extensions or not

#

it's just showing the placeholder text when calling the parse me command

grim ice
#

there is arguably no reason to make this class anyways

#

but whatever

dry hazel
scenic onyx
grim ice
#

this case doesnt require a wrapper

scenic onyx
wooden hearth
grim ice
#

youre trying to make a message builder?

scenic onyx
smoky oak
grim ice
#

then you should make a builder

#

not a wrapper

shadow night
grim ice
#

The builder pattern is a design pattern designed to provide a flexible solution to various object creation problems in object-oriented programming. The intent of the builder design pattern is to separate the construction of a complex object from its representation. It is one of the Gang of Four design patterns.

#

read this

scenic onyx
lost matrix
scenic onyx
slender elbow
#

no

scenic onyx
#

is normal

lost matrix
#

Do you run unit tests?

#

Then ignore it

smoky oak
#

hey smile do u have papi xp?

lost matrix
#

Sure

smoky oak
#

so tldr

#

upper point stops

#

lower doesnt

lost matrix
smoky oak
#

im calling /papi parse me %placeholder%

#

any clue? It clearly packaged correctly or it wouldnt spit out it's version on the papi info thing

lost matrix
#

Isnt getVersion called way earlier already?

smoky oak
#

uh... I'm not sure. but how could that be the issue

lost matrix
#

Show how you register your placeholder

smoky oak
#

register?

#

wym

glad prawn
scenic onyx
smoky oak
glad prawn
#

i know

lost matrix
#

You should read that

smoky oak
#

like seriously why is it not calling the onRequest method lol

wooden hearth
frank kettle
#

is there a way to run a task sync inside an async task?

#

right now im running 2 different ones, one sync and one async, the async one gets the data for the sync one to put out there to the server. but cause of server latecy, the sync one is happening after the async and not doing the thing I want anymore.

lost matrix
#

This explains how to load data async and use it sync

frank kettle
#

it's not just get data, apply data.

#

it does a check every 2 seconds

lost matrix
#

So you have 2 tasks, one async and one sync. And each task runs every 40 ticks?

frank kettle
#

yeah

lost matrix
#

How about you still do what i posted and just let the async task start a sync task which applies the data.

frank kettle
#

i made the async to check the data and make every verifications/updates on it, and then the sync to update what the player gets

lost matrix
#

Unless you need to sync task to run independently on a different rate.

frank kettle
frank kettle
#

oh i thought your tutorial was to not repeating async tasks

lost matrix
#

It was for async IO in general

frank kettle
#

oh ok, i checked it qucikly and saw just normal tasks.

#

sorry about that

#

thanks, i will check it out

quiet ice
#

This is a typical case of "oooo, but security!" even though the bug cannot be reproduced under the conditions whatsoever

solar mortar
#

Hey, can someone help me setup HikariCP? I can't get intelji to import the libraries after adding the decency into my pom

solar mortar
#

I've done that!

#

Can I share code with intelji so you can see it yourself?

lost matrix
#

Dont know what that means. But you can send your pom and the code you are writing which doesnt "get imported"

#

?paste

undone axleBOT
solar mortar
lost matrix
#

Those look like Hikari imports to me...

solar mortar
#

yeah, I know, but the import isn't tho

lost matrix
#

I dont understand this sentence...

#

The import isnt what?

solar mortar
lost matrix
#

Ah i see. Show your project explorer pls

#

This

#

i mean

solar mortar
lost matrix
#

Alright, how do you compile the project?

solar mortar
#

through the build/run

kind hatch
#

You should be using the maven tab.

lost matrix
#

Do a maven clean and then install

#

install or package

#

after clean

#

And always build your projects like that. I have no idea whats in your current run configuration but im suspecting that it doesnt use maven.

solar mortar
#

that worked!

#

nvm

#

it did not work xD

#

and it works

#

buggy, but it worked, thank you so much

tall saffron
#

Anyone can tell me a tutorial video for making sub commands appear as a suggestion in minecraft? plss

young shell
#

How does one extract a Folder from a JarFile at Runtime

worldly ingot
#

Are you wanting to recursively copy the files from your plugin into its config directory?

lilac dagger
#

CodeSource src = plugin.getClass().getProtectionDomain().getCodeSource();
if (src != null) {
try {
ZipInputStream zip = new ZipInputStream(src.getLocation().openStream());

#

and this way you have access to the folder

#

oh

#

there's getFile?

#

nice

worldly ingot
#

Yeah, protected under JavaPlugin

slender elbow
#

is it well protected?

worldly ingot
#

I sure hope so

#

You should be able to write protected, but also PROTECTED to let Java know that you're being very serious PES_AngeryDiamondSword

slender elbow
#

final and sealed are very real at runtime lol

dry hazel
#

me when unsafe

#

not that it will work in every jvm implementation

slender elbow
#

if you mean fields sure, if you mean classes and methods that takes a bit more effort

#

you know what else is fake? the entirety of the os kernel

molten hearth
#

entityId is just a server-wide integer counter for entities right? its not something special?

#

yeah well I was actually going to replace entity IDs with UUIDs till I realised they're built into the mc protocol

#

i guess ill add both

thin iris
#

id say it's entities version of uuid

molten hearth
#

alright so its just a numerical id tx

echo basalt
#

it's the entity id in the protocol

thin iris
young shell
#

Dont ask why, its a long story

echo basalt
#

because it's much easier to just write an integer and the UUID is only used for serialization type deal

molten hearth
#

skill issue ong 💯

#

its all good im not using java tx

echo basalt
#

you'll never have enough entries to hit the flag bit so who cares

slender elbow
#

as a byte

#

works every time

thin iris
molten hearth
#

even better

#

even better

echo basalt
#

uh sure who needs more than 256 entities

molten hearth
#

yeah

#

i talk binary

thin iris
slender elbow
#

omg I can use the default cringe stickers

#

omw to choco's

subtle folio
#

💀

round hemlock
#

Hello i can't use EntityPlayer import import net.minecraft.server.level.EntityPlayer; but i can use import net.minecraft.server.level.ServerPlayer; why thats happning

#

😂

echo basalt
#

something something mappings

round hemlock
#

i've cried 2 times today

#

i imported everything

glad prawn
#

import everything;

round hemlock
ivory sleet
#

💀

lilac dagger
#

holy

#

basically using namespace std;

#

wait nvm

#

what did static do exactly in imports?

young knoll
#

Means you can call static methods without the class name

smoky oak
#

namespace std indeed

lilac dagger
#

oh

#

so it is that kind of

slender elbow
#

import **.*

worldly ingot
#

Stop it

#

That hurts

lilac dagger
#

so much power!

#

i just wanna try it just to see how long it takes to find a missing class

quiet ice
#
*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 876

now that is an error I haven't seen yet.

#

Seems like it was caused by a stack overflow though

smoky oak
#

dafuq

#

unrelated topic: hey geol got any PAPI experience

#

cuz im going insane here

quiet ice
#

Very minor experience

smoky oak
#

let me put it this way

#

did the code you wrote run

#

cuz that damn function aint getting called

young knoll
#

“Hey is your code running?”

#

“Well you better go catch it”

pseudo hazel
#

nice one dad

smoky oak
# smoky oak

hey stop laughing i genuinely have no idea why it's not catching the 2nd breakpoint

#

its just printing back out whatever i put into papi parse

quiet ice
#

As far as I know yeah

young knoll
#

What are you putting into parse

slender elbow
#

something something ?nocode

smoky oak
#

no the parse isnt getting called

#

the METHOD isnt running

#

idk about parse CONTENT

quiet ice
young knoll
#

Are you parsing the right thing

quiet ice
#

Did you register your expansion?

smoky oak
#

probably yes and yes in that order

young knoll
#

your placeholders will be under the name of your expansion

wet breach
quiet ice
#

Yeah figured it out

thin iris
#

then i columbine these hoes

#

whats the assert keyword for

young knoll
#

So it’s not just %poop% its %myexpansion_poop%

smoky oak
#

hm interesting

wet breach
quiet ice
#

A recursive algorithm but I forgot the part where it returns

smoky oak
#

wouldnt that cause a stackoverflow error outright

wet breach
#

ah that would do it too lol

quiet ice
#

Yes but I was in my debugger so it also caused another fancy error

smoky oak
#

oh interesting

#

so debuggers make stack overflow into mystery box

wet breach
#

catching stackoverflow exceptions is interesting to do

#

you can inadvertently cause more threads to be created lol

young knoll
#

I once did that

smoky oak
young knoll
#

It was a treefeller plugin, if it recursed too much I caught it and then said the tree was too big

#

Kek

wet breach
#

lol

pseudo hazel
#

lmao

lilac dagger
#

is there a uncatchableexception for this thing?

pseudo hazel
#

wdym

quiet ice
#

No

#

In theory there is Error for this, but even then you can still catch that one

pseudo hazel
#

just catch Exception, much easier

slender elbow
#

catch Object

#

works every time

quiet ice
#

You should never catch Error though, as some subclasses like ThreadDeath are actually not to be caught as-is.

quaint mantle
#

i have it added in maven

#

and it's just the vector class

quiet ice
#

Paper?

young knoll
#

Catching error will catch oom

quaint mantle
#

nah spigot

young knoll
#

At which point idk what you’d do xd

quiet ice
#

actually what the hell...

quaint mantle
#

r u talking to me or

quiet ice
#

Yes but actually no

edgy oak
#

how would i go about making my /ban command take priority over the vanilla one?

quaint mantle
#

hm

#

how do dependencies work

quiet ice
#

@quaint mantle Do you have bukkit on your runtime classpath?

young knoll
#

Is the a main method

quaint mantle
#

wdym

young knoll
#

Tf are you doin

quaint mantle
#

im just making a bunch of vector and location utils

#

I dont need the server to be running for this

wet breach
quaint mantle
#

cause the location and vector classes are like data classes

#

they are only primitives

young knoll
#

Yeah just catch the out of memory and then call system.GC

#

Easy

wet breach
#

Lol

quiet ice
#

Or could you just give us your pom or build.gradle in conjunction with the script you use to start the main method up (sorry, I don't use IJ so I cannot be more specific than that)

quaint mantle
quiet ice
#

That looks right

wet breach
#

I forget geol is one of the few that uses Eclipse

#

like Choco does XD

quiet ice
#

Don't forget Elgar either!

wet breach
#

he uses it too?

young knoll
#

There are literally dozens of us!

wet breach
#

well better then IJ I suppose 😛

quiet ice
# quaint mantle

I know that this screen is actually hiding some important detail from you, could you expand everything there?

young knoll
#

Meanwhile md on netbeans

quaint mantle
quiet ice
#

I basically need a poke at the actual runtime classpath

quaint mantle
#
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>me.skinnynoonie.bukkit.locationutils</groupId>
    <artifactId>BukkitLocationUtils</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <repositories>
        <repository>
            <id>spigot-repo</id>
            <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.20.2-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jetbrains</groupId>
            <artifactId>annotations</artifactId>
            <version>24.0.0</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>

</project>```
#

oh

quiet ice
#

The de-jure the classpath should be right as per your pom - however you don't run your project like you should so idk

quaint mantle
#

idk bukkit uses them

#

so i am too

quiet ice
# quaint mantle

As I said, the runtime classpath will be hidden deep within this screen

quaint mantle
#

k

quiet ice
#

How you can access this I cannot say

wet breach
# quaint mantle ?

did you ensure that your import is for the Bukkit vector and not the JDK vector?

quiet ice
#

There should be enough people out there that use IJ according to all people that make fun of eclipse's userbase size

quaint mantle
quiet ice
#

But alas that is really not the case

quaint mantle
#

where do you need me to go

quiet ice
#

I don't fucking know

#

Modify options? Or the cogwheel? Idk.

#

Running a maven project from within the IDE

wet breach
quaint mantle
wet breach
#

are you sure? Beecause the way you are defining 17 is no longer supported if I remember right and need to define the maven plugin to set the jdk version explicitly

quaint mantle
#

uh

#

it says missing class

#

not some version error

wet breach
#

yes that can happen when you don't use the right JDK version

quiet ice
#

I mean really you should be using unit tests and run them from within maven but whatever

quaint mantle
#

idk what any of that means lol

quiet ice
#

Make sure to have that checked

#

As I said, IJ is big stupid

#

Worst IDE I have ever touched - and I have only touched two so far.

quaint mantle
#

am I supposed to click something after that

quiet ice
#

Do you have this -cp <no module> thing next to module not specified?

quaint mantle
#

cause it's not saving

quiet ice
#

You need to check use classpath of module

quaint mantle
#

I have this

quiet ice
#

Oh - and add dependencies with provided scope to classpath

quaint mantle
#

yay it works

quiet ice
#

That is off by default for whatever reason

quaint mantle
#

sounds important

quiet ice
#

Basically by definging a test framework via https://github.com/Geolykt/Presence/blob/main/pom.xml#L90-L96 and then defining the surefire plugin via https://github.com/Geolykt/Presence/blob/main/pom.xml#L109-L113 you can run unit tests via maven (or more specifically, mvn test - although they are also executed with mvn install and mvn deploy).

Unit tests can look like https://github.com/Geolykt/Presence/tree/main/src/test/java/de/geolykt/presence/test in practice - they are always within the src/test/java folder (as opposed to src/main/java)

#

Unit tests are frequently used to test out small parts of your code and verify that everything runs as intended

#

Also I really like that it has to be an eclipse user of all people that helps people with IJ problems.

quaint mantle
#

bro it's just an ide

#

chill out

quiet ice
#

Nah, it's just a bunch of people that say that noone will help with eclipse issues 😆

quaint mantle
#

are you just copy and pasting the methods into a test

wet breach
#

or their cache is faulty

#

and need to get rid of it

smoky oak
wet breach
#

which ironically I don't understand what is up with that cache if so many people end up having issues with it

echo basalt
#

thinkW should I impl unit tests on my skyblock stuff

quiet ice
smoky oak
#

huh

#

if i use unit tests

#

big if

wet breach
#

there is all kinds of stuff you can test for

quiet ice
#

Yeah revolutionary - you can change source code!

smoky oak
#

i do it after writing some code, not after writing a lot of it

echo basalt
#

I'm only at ~150 classes and ~9k lines of code and I want to add a bunch more before I actually add real content

wet breach
#

You can also use tests to not test for stuff too

echo basalt
#

I'd need to make a whole mock platform

#

and it's annoying

#

but it's a great way to add ~5k lines of code without doing anything meaningful

quaint mantle
#

@quiet ice how long have u been coding?

wet breach
#

too long

echo basalt
#

either this or I merge this current test branch and work on a platform-agnostic menu system

#

which prob means platform-agnostic itemstack system too

quiet ice
#

4 years? Maybe even 5 by now

echo basalt
#

ahh pain

#

need to fix this tho

quaint mantle
#

how long did it take you to learn stuff like

#

maven unit tests

river oracle
#

unit tests took like 10 minutes

#

sit down figure out how to properly setup JUNIT and you're good to go

wet breach
#

the only downside with junit tests is that they are only as good as you code them

river oracle
#

unless you're doing something fairly common I can't see any other way to do it

#

etc if you're working on sockets you can test by just throwing random ass data at it to make sure it fails gracefully or whatever

#

be harder to find something less common like did my item get put in my minecraft chest

thin iris
#

what are unit tests 😭

river oracle
#

its just a check to see if you're code works as expected

#

if you use maven surefire plugin the tests are run at c ompile time

#

and your build will fail if your tests fail

#

generally they are good for ensuring if changes occur to a system or you're writing a system no matter the implementation you recieve the desired result

quaint mantle
#

Hey, anyone got an accurate server sided onGround check?

smoky oak
#

iirc if player y velocity is a very specific double

#

like -0.0725 or smth

quaint mantle
#

Full tutorial on creating Unit Tests in Java with JUnit!

Do you write Java code that you're just not confident is 100% right? You can create unit tests using the JUnit testing framework to verify your Java code, and I'll show you exactly how to do it.

Many beginners don't know there's a great way to test their code with simple, fast tests and...

▶ Play video
#

this is a good video right

slender elbow
#

it has complete authority

quaint mantle
#

im getting this error in the console:
Caused by: java.lang.ClassCastException: class org.json.simple.JSONObject cannot be cast to class org.json.simple.JSONArray (org.json.simple.JSONObject and org.json.simple.JSONArray are in unnamed module of loader java.net.URLClassLoader @2b71fc7e)
and this is the line its screaming at:
JSONArray ja2 = (JSONArray) jo2.get("textures");

lost matrix
quaint mantle
smoky oak
#

so can onGround :kekw:

#

take their location, check if its %0.5 = 0, check if block below em is solid

#

ur only getting an approx anyway

#

and remember to check the adjacent blocks if player on edge

young knoll
#

take location, move down a tiny amount and check if you are inside a blocks hitbox

smoky oak
#

oh right precise collision exists

#

i forgot about that

quaint mantle
#

Ok thx

lost matrix
slender elbow
#

i mean that's still flawed

#

slabs, edges etc

quaint mantle
young knoll
#

What about slabs

#

Edges yes, that could be an issue

#

You can combat that by checking each corner of their bounding box

lost matrix
quaint mantle
#

there is another array in textures tho

lost matrix
quaint mantle
#

how did you know lmao

lost matrix
#

There is not a single array in this

quaint mantle
#

texturs to skin

#

then url??

smoky oak
#

alternatively just store the serialized skin lol

quaint mantle
#

If you're on ladders does the client send it's on ground?

lost matrix
# quaint mantle then url??
{
  "textures": {
    "SKIN": {
      "url": "http://textures.minecraft.net/texture/46cf412fb0bf1934da4eaf29d9079653d3d20b29e23d0f037bb043491e25af01"
    }
  }
}

I would usually just use Gson for this:

    Gson gson = new GsonBuilder().create();
    String json = ...;
    String url = gson.fromJson(json, JsonObject.class)
        .getAsJsonObject("textures")
        .getAsJsonObject("SKIN")
        .get("url")
        .getAsString();
quaint mantle
#

oh

#

i dont use gson

#

i use json-simple

lost matrix
#

Yeah with json-simply its hella ugly in a single line

    JSONObject jo = ...;
    String url = ((String) ((JSONObject) ((JSONObject) jo.get("textures")).get("SKIN")).get("url"));
#
    JSONObject jo = ...;
    JSONObject textures = (JSONObject) jo.get("textures");
    JSONObject skin = (JSONObject) textures.get("SKIN");
    String url = (String) skin.get("url");

This is cleaner

quaint mantle
#

thank you

lost matrix
quaint mantle
#

idk im just bored

#

im trying to get the image and transport it as a text

lost matrix
#

Its... already on the internet. You could just get the image from the url and not transport it XD

quaint mantle
#

yeah ik

#

thats boring tho

lost matrix
#

I see

river oracle
#

the code is falling of my screen 😭

lost matrix
#

Thats where you know that you need to replace your lambda with an actual method reference

river oracle
#

I mean I could make a method for each type but that'd get cluttered

#

like for this one making a method was good enough

weak meteor
#

ExplosionPrimeEvent includes tnt explosion?

lost matrix
weak meteor
#

k

#

thanks

echo basalt
glad prawn
echo basalt
#

yeah

#

MenuType.GENERIC_9X + index

rotund ravine
#

If it’s weird ass fields reflection can also do it 👀

#

Essy for loop

river oracle
#

probably gonna switch over now

rotund ravine
#

Reflection really is quite easy

echo basalt
#

testing my new database abstraction system

#

forgot that I need to copy builtin config files

rotund ravine
echo basalt
#

why is intellij deciding to explode with my cpu

rotund ravine
#

It’s working

lost matrix
rotund ravine
#

I wouldn’t even be mad

#

If it used very little cpu time

#

Letting them take 20% sure

echo basalt
#

using 90% cpu and 14gb ram

lost matrix
#

Its a java app so its very lenient with the resources it is given 🙂

echo basalt
#

and copilot making sure to break because intellij released a new major version where they fixed aws and kubernetes support and that one bit of text in a nested menu

#

ok my logic is broken

#

.. how

glad prawn
#

only u know

worldly ingot
#

I'm begging you lol

#

If you're going to loop that, at least just make an array of the menu types and iterate with an index

river oracle
#

I scared you tho :P

rotund ravine
#

Smh

river oracle
#

you'd have to make some insane fucking reflection for it to be anywhere near as effective as using a map

rotund ravine
#

It’d be funny

frank kettle
#

:Kappa:

rotund ravine
#

It does not do the same

#

Smh

edgy oak
#

how come i have to relog to see the changes to this block?

newBlock.setType(Material.STONE);```
rotund ravine
#

Do you have other addons?

#

I think there is a second parameter in settype you can try. It shouldn’t be needed though

plain plaza
#

What's the best approach to reduce Protection Level Programatically?
I'd like to keep the respected Protection Level on an armor piece, but in the code, half it.

edgy oak
#

the second parameter you can add is applyPhysics

#

but i dont think that will help lol

#

also i have tried updating the block state which also didnt work

Block newBlock = world.getBlockAt((int) coordsx, (int) coordsy, (int) coordsz);
blockState = newBlock.getState();
.setType(Material.STONE);
blockState.update();
halcyon hemlock
#

Oh nice, I'm also trying to make one using rust

drowsy helm
edgy oak
rotund ravine
#

Smh

edgy oak
#

yep 🤦‍♂️

echo basalt
#

mm still struggling with my cyclic dependencies code (I have no clue why, it should work)

#

maybe sets should be replaced with lists think3d

#

grr I fucking hate this

lost matrix
#

How do you get cyclic dependencies in your code?

echo basalt
#

not in my code

#

doing an inheritance thing

lost matrix
#

?

#

So its in your code

echo basalt
#

config based

lost matrix
#

config based inheritance thing

#

You lost me

echo basalt
#

sigh

lost matrix
#

Ah

echo basalt
#

and I want to check for cyclic dependencies but chatgpt's algorithm doesn't work

#

so imma write my own :)

#

should just be as simple as making a linkedlist of strings

#

and if I find a duplicate element it's cyclic

lost matrix
#

Write something else. A join message plugin for example.

echo basalt
#

lmao

#

nah this is a passion project

#

yay it loads

#

now let's try cyclic

#

ah, yeah

#

okay I revamped the config

#

a lot ismpler now

quaint mantle
#

whys this happening:
Caused by: java.lang.ClassCastException: class java.lang.Long cannot be cast to class java.lang.Integer (java.lang.Long and java.lang.Integer are in module java.base of loader 'bootstrap')

#

this is the code that is being bad:

            if (layer == true){
                return new BufferedImage[] {PlayerFace.get(Objects.requireNonNull(player.getSingle(event)).getUniqueId(), size.getSingle(event), true)};
            }
            else{
                return new BufferedImage[] {PlayerFace.get(Objects.requireNonNull(player.getSingle(event)).getUniqueId(), size.getSingle(event), false)};
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }```
echo basalt
torn oyster
#

is there something wrong with calling events e

candid galleon
#

no

#

you can if you want

#

some people are against naming variables single letters

#

if you're working with a group ask your group what they prefer

torn oyster
#

what about player p

candid galleon
#

same logic

#

if it's only going to be you working on it do whatever you want

#

if you think you might someday want others to help it wouldnt hurt to be a bit more descriptive with your names

#

especially if you're dealing with multiple players in the same context

#

like an entitydamagebyentity event

#

having your vars be p1 and p2 is more confusing vs attacker and victim

shadow night
#

Or damager vs target

torn oyster
#
    @EventHandler
    public void onTabComplete(TabCompleteEvent e) {
        if (e.getSender().hasPermission("admin.colon-commands")) return;
        if (e.getBuffer().contains(" ")) return;

        e.getCompletions().removeIf((s) -> s.contains(":"));
    }
#

why doesn't this work?

#

no errors, just nothing happens (colon commands are still tab completed)

#

it's 100% registered as other events in the same class work too

onyx fjord
#

There is something wrong with e especially

#

Exceptions have e

#

Use verbose names normally, a bit less verbose in functions

torn oyster
#

yeah thanks, i'm more concerned about how it doesn't work right now though

onyx fjord
#

Put a debug log before each if

#

Sout or something

halcyon hemlock
torn oyster
#

Found out event isnt even running

#

The asyncchatevent is in the same class and it works fine

#
    @EventHandler
    public void onTabComplete(TabCompleteEvent e) {
        System.out.println("1");
        if (e.getSender().hasPermission("admin.colon-commands")) return;
        System.out.println("2");
        if (e.getBuffer().contains(" ")) return;
        System.out.println("3");

        e.getCompletions().removeIf((s) -> s.contains(":"));
    }```

nothing gets printed at all
halcyon hemlock
#

I've done that before

#

Yes

#

It happens when you type in a command

#

And then you try to auto complete

#

with tab

#

It only runs after you type the command I think

#

Yeah pretty much

torn oyster
#

even if I press tab

#

on anything

halcyon hemlock
#

Does it not even print 1?

torn oyster
#

nope

halcyon hemlock
#

Did you register event?

halcyon hemlock
#

1-150

undone axleBOT
halcyon hemlock
#

yeah boi code leak time 🔥 🔥

torn oyster
#

This fixed it

#

Thank you

#

I just changed it into that

#

That event must be broken or something

halcyon hemlock
#

You're probably using it the wrong way

#

It works fine for me

#

I use it for auto completion

valid burrow
#

how complicated is it to edit a villagers prices

low marlin
#

how to check if 2 players are viewing the same inventory? I try to use InventoryClickEvent with getViewers but it doesn't work

cinder abyss
#

Hello, do you know a good tree blocks finder algorithm ?

hybrid spoke
cinder abyss
halcyon hemlock
#

recursion

hybrid spoke
#

not sure if there is a universal algorithm for that case

#

but you could look up other treechoper plugins

cinder abyss
#

I just want the way to a good tree blocks finder algorithm

cinder abyss
halcyon hemlock
#

You could use recursion, find all the adjacent faces/blocks, add them to some universal list I suppose and stop when none are found. And you could add limit etc

cinder abyss
halcyon hemlock
halcyon hemlock
cinder abyss
halcyon hemlock
#

That's the problem or

#

do you want to detect a wood house

hybrid spoke
#

i mean you could use recursion and additionally check for a leaf sphere at the end of the tree

halcyon hemlock
halcyon hemlock
#

If you want to detect it

#

recursion basically like repeats itself

#

search it up

cinder abyss
halcyon hemlock
#

I think it'll solve your problem

hybrid spoke
cinder abyss
#

okay thanks

#

ah

halcyon hemlock
halcyon hemlock
#

@cinder abyss Could you explain what you're exactly trying to do?

cinder abyss
hybrid spoke
#

thats what he doesn't want

cinder abyss
halcyon hemlock
hybrid spoke
halcyon hemlock
#

Tree capacitator

cinder abyss
#

because a house is not a tree

#

(like a house is not a motel)

halcyon hemlock
#

tf is a motel

#

in that case, you could write some logic

cinder abyss
#

(private joke)

cinder abyss
cinder abyss
#

I want something light and fast

#

an algorithm

halcyon hemlock
#

By any chance,

hybrid spoke
#

you could.. just cache it to a hashmap?

#

light and fast

halcyon hemlock
#

If a player places a building shape of a tree

#

do you want that to be detected

hybrid spoke
cinder abyss
halcyon hemlock
#

or just natural trees

cinder abyss
#

natural trees

hybrid spoke
halcyon hemlock
#

if a player makes a tree it doesn't detect?

#

same shape

cinder abyss
halcyon hemlock
#

cause if you want that, you can just check if the block is naturally spawned

cinder abyss
halcyon hemlock
#

save every block human place or what

cinder abyss
#

but it will correctly work on newly generated block

hybrid spoke
#

or more like flag the block as human placed

cinder abyss
#

hummm

halcyon hemlock
#

or

halcyon hemlock
#

I heard you can access biome / world generator

halcyon hemlock
#

You can get the block at that location placed by world generator

hybrid spoke
halcyon hemlock
#

and no need to check if it's a house

cinder abyss
#

Well, I'll just try thank you!

halcyon hemlock
#

or if you just want a simple solution use PDC

hybrid spoke
halcyon hemlock
#

unless you're saying there is no supposed method to check that

#

cause I remember vividly someone asked that here before as well

eternal oxide
#

There is no method in worldgenerator to tell if a block was placed by it.

hybrid spoke
#

i doubt that this is possible without listening to the generation

#

exactly

halcyon hemlock
#

I must've been hallucinating

#

well good luck

#

o7'

eternal oxide
#

?blockpdc

undone axleBOT
shadow night
#

Can't you just give each block that is placed not by worldgen a pdc

eternal oxide
#

yes, as linked above ^

#

as normal blocks don;t have an actual PDC

short raptor
#

Yo I've got this stringlist in my config yml (assume that the nulls are actually populated with uuids). It'll always be the same length (8 items), is there a way that I can set a specific index individually or must I set the whole stringlist at once?

thin iris
lost matrix
short raptor
#

Should I do that way instead?

lost matrix
#

If you have exactly N elements then this is probably better.
But what speaks against just loading the whole list and keeping it in memory?

short raptor
#

I'll do that instead

lost matrix
echo basalt
#

I wonder how wedit handles cross-platform items thinkW

lost matrix
#

Dont they have a huge abstraction which would allow WE to be used in pretty much any voxel game?

echo basalt
#

maybe thinkies

#

thinking of making a whole menu engine for my skyblock shenanigans

#

needs to work across spigot and minestom

#

they both have their own itemstack api

#

Spigot's is mutable, minestom's is not

lost matrix
echo basalt
#

Should be as simple as making a cross-platform itemstack and inventory api and then just porting all my layer and selection stuff from my existing menu stuff

#

but that's the problem..

#

what if I make an nbt api

#

but then I have to deal with nms

#

ffs

#

I guess worldedit's item api is simple enough

valid burrow
echo basalt
#

think3d should I take the minestom approach of immutable discrete item metas

#

or the bukkit approach where all meta types extend a common point

#

think I'm going with the bukkit approach

#

I guess I'm early enough

#

watch me about to reimpl half of bukkit

#

bim bim bam bam

#

Yeah the minestom approach won't work because I don't have a huge nbt file

#

I could do it with a map think3d

#

converting these to a bukkit itemstack is going to be really monke

lilac dagger
#

yeah, i don't think it's worth the platform agnostic stuff

shadow night
#

I want to remake craftbukkit in forge

eternal night
#

famous last words

shadow night
#

Like everything and always!

#

My reason is: yes

#

Fabric is cool

#

But forge <:(

#

;(*

#

:(*

quaint mantle
#

forge = visitor pattern everywere

cinder abyss
#

why is fabric better than forge ?

rough drift
#

I am going to abuse the everloving shit out of the JVM

#

but I actually have an idea to put spigot w/ fabric (stable)

shadow night
rough drift
#

My friend is doing the 2nd and is almost done

#

I am doing the first so you get plugins in single player

shadow night
rough drift
#

When did I specify plural

shadow night
rough drift
#

technically

shadow night
cinder abyss
rough drift
#

Fabric supports it

#

you just need to tell it how to support it

#

it's weird

shadow night
#

Fabric has been put into like every java app in existance

rough drift
#

Because it just works

shadow night
#

Wait, why haven't we injected fabric into forge yet

young knoll
#

Okay gaben

rough drift
#

@shadow night it has been done before afaik

#

Turns out

#

it really doesn't work

shadow night
#

expectes

molten hearth
#

Currently I'm implementing the final steps of the login sequence

granite owl
#

how am i supposed to write junit tests for a bukkit plugin i mean it doesnt even have a proper entry point and the whole codebase makes 0 sense without its observer that is the server

lost matrix
granite owl
ivory sleet
cinder abyss
#

Hello, what is the default potion amplifier for PotionEffect?

lost matrix
#

0

cinder abyss
#

it's for the first level?

lost matrix
#

Yes

cinder abyss
#

okay thanks

timid hedge
#

Does anyone know why i get 309 errors in my mcp? all my com.google, com.mojang,authlib and org.apache, org.lwjgl isnt working

lost matrix
#

The heck is 309?

remote swallow
#

probably 309 errors

timid hedge
#

309 errors

lost matrix
#

Ah i thought http status

lost matrix
vale robin
#

Hey,
I have this
final Block block = player.getLocation().getBlock().getLocation().add(0, -1, 0).getBlock();
When I check block.getType().equals(Material.AIR), non-solid blocks return true. How do I fix it?

timid hedge
#

?img

undone axleBOT
#

Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.

Here's some screenshot utilities that can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org

ancient plank
#

meow

hushed spindle
#

also, checking for air only is inconsistent because there's also CAVE_AIR and VOID_AIR

#

in caves your method would return false

#

and check enums with == instead of .equals() plox

slender elbow
remote swallow
#

why arent you using maven or gradle

vale robin
timid hedge
hushed spindle
#

well what do you mean with checking if a block is there

#

do you consider tall grass a block

vale robin
#

like

#

yes

#

everything with hitbox

hushed spindle
#

so you only want to exclude air