#help-development

1 messages ยท Page 248 of 1

humble tulip
#

Nice

tall dragon
#

like i guess when a player joins it will send out a message requesting the player data?

tall dragon
#

idk tbh. i just need to figure out how to make the server communicate so it always makes sure data is not lost

rotund ravine
#

Tcp?

wet breach
#

migrate can move keys from one instance to another

#

so if you use redis and have separate DB's

#

you could just migrate the key and thus now the other server has access to it ๐Ÿ™‚

tall dragon
#

right i think using redis to cache the data is best but would need to do some research on how that works exactly

#

like how would you se the amount of time it keeps it cached

#

& how would i commit back to db on expiry

wet breach
#

personally you should use replace instead of migrate

#

because replace will check to see if it exists already, and if it does deletes it and then migrates the key

wet breach
humble tulip
#

And when they log in another server, you set it to false

#

In the server they logged out of, you can run a task 10 seconds after to see if toRemove is true and of it is, remove data frm redis

#

Also on logout, you should still put whatever is cached into mongo

wet breach
tall dragon
#

yea that would be a good idea too

humble tulip
wet breach
#

sometimes not, but it really depends on ones setup

tall dragon
#

ah well thanks for the advice. i will go and try some stuff out and see if i can make it work nicely

smoky oak
#

sounds like nms incoming. Context for this question is that i want to check for certain blocks, but only under certain conditions will the chunk be loaded. I'm aware theres a chunk class that iirc is in the api, so let me rephrase a bit.
Can i somehow read chunk data in without '''activating''' the chunk - speak, without loading it?

wet breach
#

no

#

server isn't aware of the chunk unless it has been loaded even if partially because region file gets memory mapped even if a single chunk in said region is accessed

#

So the only way you could access chunk data without it being loaded is if you accessed the region file yourself

#

but, I mean it isn't an expensive operation to load a chunk and then unload it when done with it

remote swallow
#

invalid syntax

tardy delta
#

depend or softdepend

remote swallow
#

it has its own syntax checker

#

?paste config

undone axleBOT
remote swallow
#

no idea, rename the file to something no called config.yml then regen the file

wet breach
#

it is still an array

#

String ... is an array that takes a varargs as a parameter

ionic dagger
#

how do i print a debug message?

worldly ingot
#

... is just syntax sugar for a variable sized array

wet breach
#

String [] and String ... are both internally arrays

#

one takes a vararg parameter the other doesn't

#

not sure why that is so hard to understand, if you don't believe me go look at the implementation

remote swallow
#

fuck logger

tardy delta
#

unnessecary di

wet breach
#

if all you need to do is print debug messages, the logger isn't necessary for it

white root
#

Or you could be a baller and use kotlin's println() function

worldly ingot
#

For debug, logger if possible, otherwise sysout is not going to kill you

#

It's all going to the same place and you know where the messages are coming from

tardy delta
#

love it when the server complains about me using sysout

eternal oxide
#

paper

tardy delta
#

im running paper yes

tardy delta
#

stfu

#

should be working on my parser but my head hurts when i think about the debugging

remote swallow
#

i always dev again spigot api but i have always ran paper severs for some reason

tardy delta
#

only thing i could think of

candid galleon
#

Flashback to when a logging library had RCE

tardy delta
#

i always run paper cuz their reload command is faster

#

for the rest i dont give a fuck

remote swallow
#

i use plug woman

#

no need for /reload

tardy delta
#

ew

candid galleon
#

plug woman? kek

tardy delta
#

breaks even more than reloading

#

you got anything against men?

eternal oxide
#

I never reload unless testing reload itself

remote swallow
#

only on jda ive found

tardy delta
#

usually my plugin was breaking when using reload but i fixed it

remote swallow
tardy delta
#

fuck copilot cant even write correct tests for me

wet breach
#

lol

eternal oxide
#

lol

smoky oak
#

u have the money for copilot?

tardy delta
#

gh student lol

tardy delta
#

only effective way to test

smoky oak
#

why not be me and write this abonimation

#

?paste

undone axleBOT
tardy delta
#

wha

smoky oak
tardy delta
smoky oak
#

just generate your tests with more buggy code

tardy delta
#

hehh

#

did smth related but that was for a benchmark

smoky oak
#

one is cs and one is math

lavish wing
tardy delta
#

copilot sayin A: A function is a relation in which each element of the domain is paired with exactly one element of the range. A relation is a set of ordered pairs.

remote swallow
haughty idol
#

when i spawn in particles such as CLOUD, it makes them fly all over... how would i fix that

smoky oak
tardy delta
#

uh thank you

smoky oak
#

called something something total relation

#

its a part of group theory iirc

remote swallow
#

could the islandData be returning name

#

the only other option is tab is adding the player name in

#

where does it actually get added

#

before or after the money

#

on a method that can be triggered try printing the return of any player to console or something and see if its added there

#

yeah

#

the Helper.colorize

#

ye

#

if that returns a player name it would have to come from one of your methods, if not its tab being stupid

#

ig you could try and change the placeholder and see if that fixes it

#

try the placeholder change and see if its them trying to hook into player for it

#

instead of %player-something% change the player to anything else

red sedge
#

lets say I have a hashmap of hex codes, given a hex code that is not in the hashmap, how would I go about finding the colour nearest to an existing key in the hashmap

eternal oxide
#

google java colour distance

ivory sleet
#

else might wanna use a tree map

red sedge
eternal oxide
#

best I've seen (ignoring it uses sqrt) ```java
double colorDistance(final double r1, final double g1, final double b1, final double r2, final double g2, final double b2)
Return the "distance" between two colors.

double a = r2 - r1;
double b = g2 - g1;
double c = b2 - b1;
return Math.sqrt(a * a + b * b + c * c);

#

yes, lowest comparison is closest

red sedge
#

ight thanks

crimson scarab
#

how severe would the performance impact be of always loading designated "farm chunks" 24/7 to make farms always work

lavish wing
#

How i can convert String to Material?
if (player.getInventory().contains(getConfig().getString("BuyBlock"))) {}

#

Thx

quaint mantle
#

I cant find GameProfile at all in my external libraries and cant get a custom skull.

#

Its as if GameProfile doesnt even exist in the first place, even though I used it in the past.

remote swallow
#

?bootstrap

undone axleBOT
#

Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.

Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163

lavish wing
#

๐Ÿฅฒ
https://paste.md-5.net/mamujacixi.bash
Line 45:if (api.utils.checkItem(player, Material.matchMaterial(getConfig().getString("Clans.BuyBlock")), getConfig().getInt("Clans.BuyAmount")))

checkItem method in API: public boolean checkItem (Player user, Material id, int amount) { if (user.getInventory().contains(new ItemStack(id, amount))) { return true; } return false; } }

quaint mantle
lavish wing
quaint mantle
#
<repositories>
        <repository>
            <id>spigotmc-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.19.2-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

Im building it as package shade:shade
Why wont it show GameProfile?

smoky oak
#

uh

#

isnt it 1.19-R0.1

quaint mantle
smoky oak
#

lmc my pom

quaint mantle
#

Wait.. do I need to run buildtools?

smoky oak
#

well

#

yes

#

it uses ur local .m2

#

so for every new version ur gonna need to run bt for that or somehow get the shaded jar file

quaint mantle
#

the shading isnt an issue

#

how do i run bt

smoky oak
#

download it

#

then just call --version latest on it from console

glossy venture
#

when printing the 1d slot it calculated its 0, how the fuck does that make sense
if you fill it in it should be 0 * 9 + 5 = 5 right

quaint mantle
#

i assume i place the file inside of External Libraries

#

or

smoky oak
#

no

#

you dont do anything after running buildtools apart from rebooting ur computer

#

maven ONLY works correctly if u touch neither the m2 folder nor ur import folder

quaint mantle
#

@smoky oak so as soon as its done just restart my pc right

smoky oak
#

essentially yes

#

might work if you just restart ur ide

#

but i wouldnt guarantee it

echo basalt
#

like

#

there are multiple ways to compare colors

#

there's the euclidean distance, but some algorithms cater to the human eye

smoky oak
#

well u could convert it to color wheel and calc the angle

#

but i recon thatd take more cycles to do since its sinus math

echo basalt
#

I mean like

#

there are multiple ways to determine how "close they are"

#

one is based on pure rgb values

#

but that might not always be "accurate" among a population because we have more red? receptors

#

so there's this secondary comparator

smoky oak
#

bah
i write the library to use color
not the library to adjust it

echo basalt
#

I use this in my imageboard system

#

this weighted euclidean check tends to boost yellows more

smoky oak
#

well its not like im a graphic designer. the stuff i work with is usually much lower or much higher in abstraction tbf

echo basalt
#

same

smoky oak
#

id probably just subtract the values and add up the differences

echo basalt
#

I just happen to have obsessed over maps & itemframes

smoky oak
#

ah

echo basalt
#

and couldn't go to sleep without making this extremely performant

#

worked tirelessly for like 3 days straight

#

and even setup graphs for it

smoky oak
#

bah i only care for performance if its me whos going to use the code

#

lol

quaint mantle
#

@smoky oak Didnt work: I installed it into my downloads, restarted my PC and nothing happened

smoky oak
#

um 1 sec

echo basalt
#

so is the traditional raytracing route

#

but then you start going into advanced routes and have to account for stuff like lens distortion

wet breach
quaint mantle
#

I had 0 clue why my gameprofile wont work lol

echo basalt
#

not the client part itself

wet breach
#

oh

smoky oak
echo basalt
#

it was taking like 60ms to draw an image

wet breach
#

1.3 ticks isn't all that bad

quaint mantle
echo basalt
#

for 1 frame

#

now, go render a 1000x1000 image into a grid made from frames that can only render 128x128

#

so 64 frames

#

sure you can multithread it

#

that's still more than 0.1ms :)

wet breach
#

well I mean you are not going to get lower then 50ms in mc

echo basalt
#

I know

#

but you can process more things

smoky oak
#

well considerimg mc runs at 20 internal fps anyways couldnt u do that frame smearing they use in vr

echo basalt
#

uhh

#

I might be tripping but don't packets send instantly?

wet breach
#

they get put into the queue

echo basalt
#

grr

#

time to bypass the queue :)

quaint mantle
#

my brain hurts

smoky oak
#

tldr: we likely all have, or are working on, cs degrees

echo basalt
#

I'm finishing up my associate's in programming

smoky oak
#

theres a reason i only ever poke opengl with a 10 foot pole

#

also ofc its implementation in javas crap so im sitting here staring at c++ pointers and wondering why tf its not working

wet breach
smoky oak
#

and then i learn that for some dumb reason it put my massive array onto the STACK

#

like

#

think 3000000 values

echo basalt
#

I mean

#

I didn't learn jackshit at school either

wet breach
#

just increase the size of the stack ๐Ÿ˜„

#

it be fine

echo basalt
#

I've been making plugins for 6 years :)

smoky oak
#

yea i did then i did it properly @wet breach

quaint mantle
#

am i doing something wrong?
ive shaded my jar
ive installed buildtools on my pc

#

now what

smoky oak
#

ie without fucking over my computer

wet breach
#

lol

smoky oak
#

okay this is dumb

#

i just ran bt myself and cant find the folder its generating in

wet breach
#

o.O

#

what are we looking for?

smoky oak
#

im looking for where my .m2 folder is

#

hes looking for help

wet breach
#

${user.home}/.m2/repository/

smoky oak
#

who the fuck moved that

#

it was in appdata

alpine narwhal
#

you??

wet breach
#

oh whats it doing there lmao

smoky oak
#

like the .m2 folder was buried into appdata for a long while for me

#

and now its in home

#

wtf

#

aaanyways, @quaint mantle, do you have a $home/.m2/repository/org/spigotmc folder

smoky oak
#

like

#

ur user home

#

the folder that contains ur desktop ur downloads ur pictures etc

quaint mantle
#

yes

#

i have that

#

inside it is minecraft-server

#

spigot

#

spigot-api

#

spigot-parent

smoky oak
#

do u have a spigot/1.19.2.... folder

quaint mantle
#

yep

#

i have the 1.19.2-R0.1-SNAPSHOT

#

im using spigot-api and not spigot however

#

i changed that a while ago

smoky oak
#

uh

#

pom please

quaint mantle
glossy venture
#

how would i turn a legacy string into a minecraft chat component

smoky oak
#

try this

        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.19.2-R0.1-SNAPSHOT</version>
            <type>jar</type>
            <scope>provided</scope>
        </dependency>
#

it also might be ur repo

#

try spigot-repo instead of spigotmc-repo as identifier

quaint mantle
#

first thing didnt work

#

trying spigot-repo

#

building

#

@smoky oak Nope

#

none of those worked

smoky oak
#

?paste

undone axleBOT
quaint mantle
#

paste my pom?

wet breach
#

what error are you getting?

quaint mantle
#

no error; just that gameprofile doesnt exist

wet breach
#

using intelliJ?

quaint mantle
#

yes

#

IntelliJ Idea community

wet breach
#

tried clearing caches?

quaint mantle
wet breach
#

idk, I don't use intelliJ

#

but that usually resolves the problem

smoky oak
#

and for the love of god make a copy of it first

wet breach
#

maybe Moterius can guide you to clear caches

#

I really doubt its maven

quaint mantle
#

ok cleared caches

#

testing

wet breach
#

may or may not need to restart IDE after that don't remember

quaint mantle
#

i did

#

nope didnt work

wet breach
#

o.O

smoky oak
#

whats ur build args

wet breach
smoky oak
#

on ur maven build button

wet breach
#

gameprofile doesn't exist in the API

#

PlayerProfile does however

smoky oak
#

is it a nms thing?

quaint mantle
wet breach
smoky oak
#

ah

#

then just copy paste ur dependency and change spigot-api to spigot

tardy delta
#

mojang authlib

wet breach
#

you can be happy to know you are not going crazy yet

smoky oak
#

that imports nms

undone axleBOT
#

Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.

Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163

smoky oak
#

idk it works for me

wet breach
#

depends on the version

quaint mantle
#

Okay so then how do I create a PlayerProfile

wet breach
#

starting from 1.17 you need to use the method described in the post above

quaint mantle
#

with a random UUID

smoky oak
#

it works for me in 1.19

quaint mantle
#

wait ill send my code

#
public static ItemStack getCustomSkull(String url) {
        ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1);
        if (url.isEmpty()) return head;

        SkullMeta skullMeta = (SkullMeta) head.getItemMeta();

        GameProfile profile = new GameProfile(UUID.randomUUID(), null);

        profile.getProperties().put("textures", new Property("textures", url));

        try {
            Method mtd = skullMeta.getClass().getDeclaredMethod("setProfile", GameProfile.class);
            mtd.setAccessible(true);
            mtd.invoke(skullMeta, profile);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) {
            ex.printStackTrace();
        }
        head.setItemMeta(skullMeta);
        return head;
    }
#

I was attempting to create a skull

#

this is some code I made ~ a year ago

#

So im unsure if it still works correctly

wet breach
#

oh wait that is for items, not a skull block

smoky oak
#

wasnt there something new for 1.18 skull skins

quaint mantle
#

no i mean the skull block itself

wet breach
quaint mantle
#

i wanna create a skull w/ a texture inside of a gui

wet breach
#

anyways the skull api has setOwner()

#

and setOwnerProfile()

#

no longer do you have to do it that old way ๐Ÿ™‚

smoky oak
#

no like

#

string to texture

quaint mantle
#

^^^

wet breach
quaint mantle
#

ah

smoky oak
#

im a dumbass
i thought u wanted a create skull texture gui

quaint mantle
#

all g

#

@wet breach so i can create the skull using setowner and setownerprofile

#

using these strings

#

SkullOwner:{Id:[I;384364079,607340060,-1248642982,2089600727],Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmZhZmUwNmZlMzI4YTI1YjViZGM3ZjA3OGJmOTM1OGViYWQyNWQ5MTQ5NTkxMTM4MmZjNDMyNWVkODg0MjhkMiJ9fX0="}]}

smoky oak
#

yea sound about right

#

idk the syntax here tho

#

someone posted an example here like 4 months ago but i aint being bothered to find it

wet breach
#

you would need the playerprofile, from there you can get the PlayerTexture

chrome beacon
smoky oak
#

it should be the encoded texture

wet breach
#

PlayerTexture lets you set a url to the texture to be used

chrome beacon
#

^ decode the base64 and extract the url

#

then use the url with the api

quaint mantle
#

so

#

String url = Base64.getUrlDecoder().decode(txr);

#

txr = the texture value

chrome beacon
#

Almost it's a piece of json containing the url

smoky oak
#

found it

wet breach
#

wooo

#

we are saved

quaint mantle
#

Oh wow

quaint mantle
#

i shall use this but credit them

#

tysm

wet breach
smoky oak
wet breach
#

lol

quaint mantle
#

i didnt think it was THAT outdated lol

smoky oak
quaint mantle
#

for this:

PlayerProfile profile = Bukkit.getServer().createPlayerProfile(id, name);
s

#

should I just make it a random id and a blank name

#

as custom skulls dont use them

tardy delta
#

same thing as Bukkit.createPlayerProfile tho

smoky oak
#

oh on that topic

#

who am i kidding this is a logic leap but

#

does anyone know if different worlds run on different threads?

echo basalt
#

they all run on the same thread

flint coyote
#

They do not afaik. Since some things have to be in sync (like time and teleportation)

smoky oak
#

uh

#

world times desync

flint coyote
#

Well but what about plugins?

#

They would need their own instance for each thread/world

smoky oak
#

ah

#

point

quaint mantle
#

how do I check if something doesnt exist in a hashmap?

#

do i just compair it to null or

smoky oak
#

iirc u can just call contains

#

O(1) too

quaint mantle
#

ty

wet breach
#

to be specific

#

if you want to check for a key

#

containsValue() if you want to check values

smoky oak
#

shouldnt that be getEntrySet().contains()

#

oh wait

wet breach
#

If you want to grab it as a set

smoky oak
#

no like

#

i was doing the same thing with extra steps

wet breach
#

ah lol

quaint mantle
#

okay yay my stuff works

wet breach
ivory sleet
#

since yk, given a really bad hashCode

#

but thats rarely the case

smoky oak
#

well isnt it scaled so that it's considered o(1) by saying that extra cost is part of some other part of that

#

a bit

#

why

ivory sleet
#

yea

tardy delta
#

yes?

smoky oak
#

what were trying to say is

#

?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!

tardy delta
#

smells like a new T[] issue

#

nvm lol

#

how would that cause bugs tho

wet breach
#

all I see you doing is initializing the size of the array + 1

neat harbor
#

This line of code is creating a NPE -> item1_meta.setDisplayName(config.getString("GUIItems.item1.name"));, I have NO IDEA why it would do this. ```logFreezes: true
logReFreezes: true
GUIItems:
item1:
type: !!org.bukkit.Material 'PAPER'
name: You have been frozen by staff, please look at your discord!
amount: 1

gray merlin
#

Heya!
I keep getting this issue, and I've done a lot to try and fix it, to no avail. It also doesn't seem to have been encountered much, so no luck googling... Have you guys ever encountered it? If so, how'd you fix it?

[21:35:47 WARN]: Entity ChestBoat['x2 ยงiChestBoat'/491, uuid='cb7d6a7f-684d-4eba-be46-41bd09ed97a0', l='ServerLevel[world]', x=-36.22, y=176.00, z=-99.36, cpos=[-3, -7], tl=128, v=false, removed=DISCARDED] is currently prevented from being added/removed to world since it is processing section status updates```
gray merlin
#

Also I'm not sure if you can set the display for a name that long

#

I might be wrong, I'm really not sure

neat harbor
#

The name does

gray merlin
#

ah mb

neat harbor
#

Ok, so I was using an int in the ItemStack which is depreciated, but I am unsure if that would make it null? I am unsure on that. However I am unsure how I would go about making it not that and just having the material

#

But also making it readable

undone axleBOT
neat harbor
remote swallow
#

whats line 18 of FreezeFunc and line 27 of FeezeCommand

neat harbor
#

Line 18 of FreezeFunc is the one I sent and line 27 in the command is just Freeze.Freeze(p, true, false); (Calling FreezeFunc)

rotund ravine
neat harbor
#

Or how I could take a string and use it in a material name

remote swallow
#

Material.valueOf(configString)

neat harbor
#

Oh thanks

#

sorry?

#

Do I need to change what I have already put there? Or just change what is after Material.?

#

Also, this is my plugin.yml -> ```logFreezes: true
logReFreezes: true
GUIItems:
item1:
type: Paper
name: You have been frozen by staff, please look at your discord!
amount: 1

#

Cheers

#

I just want to know if it passes an array

#

Ok, will that return an array?

#

hm ok

spring minnow
#

Anyone knows how to do a "loading screen" like that?

#

i'm currently using bossbars to do that but this would look way better

#

i know how to send the titles but idk how to make the loading thing

#

it is

orchid gazelle
#

Action bar

spring minnow
#

its a title

orchid gazelle
#

Looks like Actionbar tbr

spring minnow
#

i know difference between title and actionbar

orchid gazelle
#

Ohhh sorry my bad I did not see the crosshair

#

Yeah it is title then

spring minnow
#

don't worry, i know how to send them but i don't know how to make the plugin know where to start coloring green

neat harbor
#

Wait so I put this in ConfigurationSection GUIItemsSection = config.getConfigurationSection("GUIItems");, do I just use something like GUIItemsSection.getKeys()?

orchid gazelle
spring minnow
orchid gazelle
#

But you would just do a for clause to loop it

neat harbor
#

kk thanks

spring minnow
neat harbor
#

GUIItemsKeys = GUIItemsSection.getKeys(); what should I put before this

#

Like String?

#

It wanted me to use a Set so it wrapped it into a String List List<String> GUIItemsKeys = (List<String>) GUIItemsSection.getKeys(false);

orchid gazelle
neat harbor
#
    E element = list.get(i);
}``` Would something like this work for iterating through the list and then using the element to get the values ofc
neat harbor
#

Nicec

#

What would I use in the config.getString? -> for (String guiItemsKey : GUIItemsKeys) { config.getString() } Would I just add GUIItemsKeys +"path to value" or something?

#

Nice

#

This error is occuring when it is called

#
            ItemStack item1 = new ItemStack((Material.matchMaterial(((config.getString(GUIItemsKeys+".type").toUpperCase())))), (config.getInt(GUIItemsKeys+".amount")));
            ItemMeta item1_meta = item1.getItemMeta();
            item1_meta.setDisplayName(config.getString(GUIItemsKeys+".name"));
            item1.setItemMeta(item1_meta);
            GUI.setItem(Integer.parseInt((GUIItemsKeys+".placeInGUI")), item1);
        }``` That is the loop
#

oh ok

#

kk

orchid gazelle
#

Oh

#

Nvm

#

Sry

#

Use the method morice said, forget mine

spring minnow
#

never heard of that

#

gonna check some tutorial xD

orchid gazelle
#

You gotta String#repeat the amount of green chars, then subtract the green chars from the total chars to get how many gray chars you gotta repeat after that

#

If you know what I mean

spring minnow
#

there is no such method

#

intellij doesn't find it in the String class

desert loom
#

repeat doesn't exist in Java 8 iirc

#

if you're using java 8

spring minnow
#

ohh

#

that's why it doesn't work

#

found it

wet breach
#

people need to move away from java 8

spring minnow
desert loom
# neat harbor ``` for (String guiItemsKey : GUIItemsKeys) { ItemStack item1...

you should use ConfigurationSections for this

        final ConfigurationSection guiItemSection = config.getConfigurationSection("GUIItems");

        for (String key : guiItemSection.getKeys(false)) {

            final ConfigurationSection currentSection = guiItemSection.getConfigurationSection(key);
            
            final String name = currentSection.getString("name"); // equivalent to GUIItems.<key>.name

        }

example

spring minnow
wet breach
#

Java 17 is the latest LTS

#

yes but it isn't an LTS

spring minnow
wet breach
#

not sure what link you clicked

spring minnow
#

in the official java site, 8 is the first thing that comes out

orchid gazelle
#

Well use the right Java Version depending on your mc version

spring minnow
wet breach
orchid gazelle
#

If you are developing a minecraft 1.12.2 plugin, do not use Java 17

sonic cosmos
#

?paste

undone axleBOT
spring minnow
orchid gazelle
#

Yeah then you cannot use repeat

spring minnow
#

still that link you gave me gives a dev kit

spring minnow
#

it uses java 8 compatible code

orchid gazelle
#

You gotta use my complicated method then I guess

wet breach
#

link I provided is the official oracle download

#

and it shows 19 and 17

orchid gazelle
#

Or maybe there is a method for repeat user-made online

#

frostalf that does not change the fact that he needs to use J8

spring minnow
sonic cosmos
spring minnow
#

the code used by the repeat method

#

It works in java 8

#

its just that wasn't included

orchid gazelle
#

Aight

#

That should work too

warm mica
vocal cloud
#

If you compile your plugin for 17 and the server isn't running 17 then it's not going to work.

crude estuary
#

or Java 19

#

The Server Just Needs to have a Higher or Same Java Version as the Plugin

#

Java is Backwards Compatible

humble tulip
#

I have a class that acts as a middleman between my database and my plugin and also caches stuff from the database, what should i call that class?

hybrid spoke
#

sounds like a service to me

#

otherwise dao

prisma sedge
#

Does anybody know how one would add a delay to a command?

hybrid spoke
#

fuck

#

?scheduling

undone axleBOT
prisma sedge
#

uh i looked at that but i ment more like

#

like cant move for 10 seconds when you execute it

#

and if you do it cancels

hybrid spoke
#

well, then you would have to keep track of the player and the timestamp and check for it

prisma sedge
#

i guess i can try that

prisma sedge
#

one more thing though how would i kill someone while bypassing their titem

#

totem

smoky oak
#

calling kill on something should kill it even with totem

tall dragon
#

whenever i remotely interact with the class "Material" my entire ide just freezes...

#

any1 know why that could be happening?

#

never had that issue before

desert loom
#

that started happening to me a while back while using eclipse

#

I don't think I was able to fix it

tall dragon
#

Im using intellij. But like my pc is pretty strong it normally handles it fine

#

I also have plenty ram allocated to intellij so i dont rlly understand

warm mica
#

In fact, I'd never use Java 8 for any personal project nowadays

#

There is just no reason

vocal cloud
#

My point would be that if someone downloaded a plugin built for 17 and their server used 8 it would error resulting in the plugin being removed usually.

warm mica
#

That's true, if he's developing it for the public then it can make sense

#

But my only reason in doing that would be to have some calm from people who contact you because the plugin isn't working on their relic server

dry forum
#
        Metrics metrics = new Metrics(this, pluginId);``` bstats isnt recording the data from my plugin
hybrid spoke
sullen sierra
#

I was wandering if anyone had any YouTube tutorials for velocity?

trim creek
#

Velocity not maintained by Spigot.

sullen sierra
#

I know I was just seeing if anyone knew of any tutorials

trim creek
#

Afaik config is almost the same. Althouhg. Testing and self-taughting is a thing as well. But any seaches also should give a good result.

summer scroll
#

Oh, it's already up now.

humble tulip
#

can someone walk me through creating a multi module project with maven?

#

i always mess it up and end up throwing all the files in 1 module

#

currently this is my layout

remote swallow
#

iirc intellij has module creating built in

humble tulip
#

yeah but the project structure looks weird sometimes

remote swallow
#

from what ive seen and that, its

FolderMain
pom.xml
module
--pom.xml
--src

humble tulip
#

now that looks wrong doesnt it

remote swallow
#

delete the src folder not in API

humble tulip
#

that contains all my current code

remote swallow
#

if you want that kind of module's people normally just put it in a separate folder after me.name.something or something like that, so you would have src.main.java.me.epic.epicplugin.api.APISTUFF and src.main.java.me.epic.epicplugin.core.MAINPLUGIN

#

main class only existing in core

humble tulip
#

fuck

#

i messed it up

#

now servercore has no pom

remote swallow
#

that looks correct to me

remote swallow
#

right click server core and new file

#

but the .gitignore should most likely be in server core too

humble tulip
#

should packaging be pom or jar?

#

for the main module

remote swallow
humble tulip
#

it's pom

#

ty

humble tulip
#
        <dependency>
            <groupId>me.saif</groupId>
            <artifactId>API</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
#

i have that in my Spigot module since it depends on the api

#

ohhh

#

wait ik

#

i dont have a build config for API

#

works ๐Ÿ™‚

#

now time to make this a template

fierce whale
#

does anyone know about import MagicSpell lib to maven project?
I couldn't find dependency of MagicSpell ๐Ÿ˜ฆ

remote swallow
#

do you have their repo

fierce whale
#

do you mean repository?

remote swallow
#

repo is short for repository

fierce whale
#

In this site I could find only gradlew build

jagged monolith
fierce whale
humble tulip
#

is there any way to do something like this so i dont need to go to each pom to change the version?

delicate lynx
#

you can, I do not remember how to off the top of my head

river oracle
#

I mark up my versions with a comment

#

this is my current project

#

multi-moduled

unreal willow
#

can i use this plugin in 1.19.2

#

?

delicate lynx
#

try it

river oracle
#

?paste

undone axleBOT
earnest forum
#

?tryitandsee

#

not a thing nvm

river oracle
#

?tas

undone axleBOT
river oracle
#

I swear to god I have my pom setup correctly

#

nvm I see I'm not getting specific errors reported for some odd reason

#

which still doesn't make sense

#

I forgor /java ๐Ÿ’€

river oracle
#
Exception in thread "main" java.lang.IllegalArgumentException
        at java.base/jdk.internal.misc.Unsafe.objectFieldOffset0(Native Method)
        at java.base/jdk.internal.misc.Unsafe.objectFieldOffset(Unknown Source)
        at jdk.unsupported/sun.misc.Unsafe.objectFieldOffset(Unknown Source)
        at sh.miles.test.Test.main(Test.java:12)

does anyone have an idea why this is causing an error?


    private static final String TEST = "test";

    public static void main(String[] args) throws NoSuchFieldException, SecurityException {
        final sun.misc.Unsafe unsafe = getUnsafe();
        Field field = Test.class.getDeclaredField("TEST");
        unsafe.putObject(null, unsafe.objectFieldOffset(field), "Changed"); // line 12
        System.out.println(TEST);
    }   

    public static sun.misc.Unsafe getUnsafe() {
        try {
            java.lang.reflect.Field f = sun.misc.Unsafe.class.getDeclaredField("theUnsafe");
            f.setAccessible(true);
            return (sun.misc.Unsafe) f.get(null);
        } catch (Exception e) {
            return null;
        }
    }``` I'm pretty sure I invoked it correctly
primal goblet
#

i'm making a system plugin that manage 90% of my server.
but the bungee messaging must have atleast one player in the spigot instance
and i wanna make it with websockets, i have a websocket server in nodejs.
and the websocket is secure (https).
but what should i put the uri the websocket client in java?
i tried a lot ..

vast kelp
river oracle
#

test isn't an object

river oracle
#

I figured it is unsafe.staticFieldOffset

#

though I get a jvm dump for doing that lol

#

first time running unsafe and It crashes how fitting

tender shard
tender shard
#

why do you need unsafe to change a field?

#

why can't you just do field.set(...)

river oracle
#

๐Ÿ˜ข

#

blame mojang

#

and openjdk for patching a bug that allowed you to change private static final with reflection

tender shard
#

you do not need Unsafe

river oracle
#

the standard method for doing so prior was removed post JDK12

#

the ability itself was removed all together in JDK18

#

to ensure platform compatability unsafe is a better option

#

you may ask? How do you know are you sure? I've dumped too many hours into this in research

river oracle
tender shard
#

that sucks

tender shard
#
String version = System.getProperty("java.version");
river oracle
tender shard
river oracle
#

like the reflection thing

tender shard
#

fuck the security manager, I hate this thing

river oracle
#

fuck security Unsafe time ๐Ÿ˜ˆ

tender shard
#

I also love putAddress

#

you can crash the JVM without even getting a stacktrace lol

quaint mantle
#

So I was attempting to create a lottery system for my server...

#

And it doesnt work with more than 1 person.

#

Ill paste my code, I have 0 idea why its not working correctly

tender shard
#

?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.

quaint mantle
#

It refuses to run EventHandlers (and yes I tested them they are active)

#

?paste

undone axleBOT
quaint mantle
#

Here is the code, can anybody identify why it wont run the events properly? and if you guys see any way to improve it lmk

#

Better question: Is inventory holder a better way to run this

tender shard
#

hm well I would add a ton of debug statements, e.g. like this

    @EventHandler
    public void onInventoryClick(final InventoryDragEvent e) {
        System.out.println("InventoryDragEvent");
        final Player p = (Player) e.getWhoClicked();
        System.out.println("Player == " + p.getName());
        if(inv == null || !(inv.getHolder() instanceof Player) || !p.equals(inv.getHolder())) {
            System.out.println("inv is null or the holder is not the player");
            return;
        }
        
        ...
    }
#

then see where it stops executing

quaint mantle
#

For 0 reason

tender shard
#

inv is null where?

#

you listen to three events

quaint mantle
#

Yes i listened to all 3

#

In all 3 it reports that inv == null equals true

delicate lynx
#

are you creating 1 shared inventory or is each one per player?

tender shard
#

ooh inv is a field

tender shard
#

I didnt see that

#

you should not just save one "inv" field, but rather use a Map<UUID,Inventory>

#

so you can store one inventory per player

#

do you know how maps work?

quaint mantle
#

I see, but my better question is if it may be better to move this over to as a InventoryHolder, from what I can tell, your supposed to use inventoryholder for this stuff

quaint mantle
#

I mainly use hashmaps

tender shard
orchid gazelle
#

Good man

#

I love HashMaps

quaint mantle
tender shard
#

while you can technically do that, it's disallowed as stated in the javadocs

tender shard
#

(creating a custom inv holder)

quaint mantle
#

so its better to do it the way I am them technically

orchid gazelle
#

Yes

tender shard
#

you should just use a Map<UUID, Inventory>

orchid gazelle
#

Yeah

quaint mantle
#

alr lettme try that

orchid gazelle
#

Am I the only one that is always parsing UUIDs to Strings to store them? Lol

quaint mantle
#

should i keep its owner as the player

#

for the ui

#

or set it to null

quaint mantle
#

not as strings

kind hatch
quaint mantle
#

idk about others tho

orchid gazelle
#

I always either use JSON or MariaDB to store data

tender shard
quaint mantle
#

import java.net.io.*;
trynna make a damn http request but it says Cannot resolve symbol 'java'

kind hatch
quaint mantle
remote swallow
#

what would be the best way to store a location in a database

tender shard
orchid gazelle
#

But Strings

tender shard
tardy delta
#

Separate columns for world id x y z yaw and pitch

tender shard
#

yeah I'd also do it like this

remote swallow
#

i was thinking that, but wanted to check there wasnt a better way

quaint mantle
remote swallow
#

ill use that, thanks

tender shard
#

although I mean... it already implements ConfigurationSerializalbe

delicate lynx
#

File > Project Structure > set the Java SDK

quaint mantle
#

o k

tender shard
remote swallow
#

(#FuckJson)

orchid gazelle
#

No

tender shard
orchid gazelle
#

Json is good

remote swallow
#

gson json is shit

#

i hate it

orchid gazelle
#

No

#

I heavily disagree, I love it lol

tender shard
#

you should set your JDK to either 8 if you wanna support ancient mc versions, or 17 if you are using a proper version

quaint mantle
remote swallow
#

what jvm does 1.16 use

quaint mantle
#

im using maven btw

tender shard
kind hatch
tender shard
#

it's compiled for java 8

orchid gazelle
quaint mantle
#

wiat i needa use jdk 8?

tender shard
#

no, you should use JDK 17

quaint mantle
#

oh oka

delicate lynx
#

what MC are you looking to support

quaint mantle
#

lemme install it rq

quaint mantle
remote swallow
#

smh i was planning on support 1.16 too

quaint mantle
#

I shud use jdk 17 for latest relaeses of mc?

orchid gazelle
#

Yes

tender shard
orchid gazelle
#

Since it is LTS

remote swallow
#

now we drop the support of 1.16

quaint mantle
#

K

tender shard
#

should look like this

orchid gazelle
#

I began switching to new minecraft versions, and I gotta admit it really sucks in some ways

tender shard
quaint mantle
#

its downloading correto 17

tender shard
#

I still was together with a girl haha

remote swallow
#

i wonder if mc will swap to 20/21 the one thats lts next

orchid gazelle
#

For modding with forge new versions are just absolute garbage, for servers it is fine

quaint mantle
remote swallow
#

are you registering them

tender shard
quaint mantle
#

does my vendor matter?

#

yep, in createInventory

#

invList.put(key, in);

tender shard
#

If it still doesn't work:

quaint mantle
#

aight imma just use the default

remote swallow
tender shard
#

File -> Invalidate Caches -> Check every box and click "Invalidate & Restart"

quaint mantle
#

the events are registered

orchid gazelle
#

Hmm

quaint mantle
#

Wait a minute.

delicate lynx
#

you're using the same key for all the inventories?

quaint mantle
#

OH WAIT I SEE WHATS WRONG A

orchid gazelle
#

lol

tender shard
#

because you only store one key, that makes absolutely no sense

quaint mantle
#

les go I think tghat worked

#

Okay so, the events get called.
The list key returns as nil for an unknown reason.
Upon the openInventory event being called, it creates the inventory and puts the data in the hashmap. Unsure why it wont work further.
https://paste.md-5.net/wagovetatu.java

#

To access the list: invList.get(p.getUniqueId())

#

List contents: invList.put(p.getUniqueId(), new HashMap<String, Object>(){{ put("ClicksR", 3); put("Inv", in); put("AllowC", false); }});

#

yessir that worked

#

tysm

chrome beacon
quaint mantle
#

Doesnt that do the same thing

#

Anyone have an idea of the issue

tender shard
#

wdym*

#

oh you are talking about the code block they sent

#

I only looked at the link

quaint mantle
#

is something wrong with that codeblock

tender shard
#

it's fine but a bit unusual

#

you do new HashMap() { ... }

#

usually you do not use the { ... } part

#

usually you do it like this;

#
Map<String,Integer> myMap = new HashMap<>();
myMap.put("mfnalex", 27);
quaint mantle
tender shard
#

if it works, it's okay lol

quaint mantle
#

thats my philosophy lol

#

anyways: did you detect the issue?

#

Also: the ui is initialized like so:

new LotteryGui().openInventory(p);
tender shard
#

as I already mentioned twice . add a ton of debug System.out.println()'s and you'll find the issue

#

print out the result of every if(...) check you do

#

I have no clue what's wrong, I am too tired to check your code line by line

#

but printing everything out will tell you what's wrong

quaint mantle
#

alr

#

It creates it, than disappears

#

what

tender shard
#

"it" creates "what"?

quaint mantle
#

It creates thhe new userid hashmap

#

and after the createinventory function gets to the end

#

it just ceases to exist

tender shard
#

the hashmap gets set to null, you mean?

quaint mantle
#

yea

#
05.12 06:54:25 [Server] Server thread/INFO {193ff4d4-68cd-4f4b-8877-a31f41f88aa2={Inv=org.bukkit.craftbukkit.v1_19_R1.inventory.CraftInventoryCustom@1db9732, ClicksR=3, AllowC=false}}
05.12 06:54:26 [Server] Server thread/INFO {}
#

the first one is on opening the ui

#

the second one is an event

tender shard
#

it's not null, it's just empty

quaint mantle
#

why

tender shard
#

idk but first of all, I would suggest you to use descriptive variable names, that helps everyone else who looks at your code to debug it

#

please do not use variable names like "in", "bg", "bg_x" etc

#

rather call them "inventory", "itemstack", etc

#

e.g. I have no clue what "bg_x" is

quaint mantle
#

alr lettme rework the names

tender shard
#

I think it's control+shift+F6 in intellij

#

then it automatically renames it everywhere

#

it's just Shift+F6

quaint mantle
#

ale ty

river oracle
#

I have just observed very weird behavior and I'm curious for an explanation

        Gson before = ReflectionUtils.getStaticField(ClientboundStatusResponsePacket.class, "a");
        new StatusApplier().injectJson();
  public void injectJson() {
        UnsafeUtils.changeStaticFinalField(ClientboundStatusResponsePacket.class, "a", GSON);
    }

I am working with Gson formatting in NMS, I am injection my custom GSON formatting, but to start I'm just copying impl nms to make sure the fields replacing. Oddly enough if I observe the before value than inject my GSON the code errors out

[00:58:27] [Netty Epoll Server IO #1/ERROR]: Packet encoding of packet ID 0 threw (skippable? false)
java.lang.StackOverflowError: null
``` with an overflow as well
however if I remove the observation no error occurs, but no changes occur when I switch over to my custom system as intended. The only think of is some weird optimizations by the jvm have caused the field to not actually be changed properly or something along those lines
quaint mantle
#

heres a nicer view for stuff

primal goblet
#
player.setAllowFlight(true);
player.setFlying(true);
``` is not working! why?
#

i'm using imanity spigot but is not the issue

river oracle
#

?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.

primal goblet
#

hmm

#
public static void playerJoin(Player player) {
        playerClear(player);
        LocationUtils.safeTeleport(player, Major.spawn);

        if(topOnline != null) {
            try {
                topOnline.display(player);
            } catch (Exception ignored) {}
        }

        if(topClans != null) {
            try {
                topClans.display(player);
            } catch (Exception ignored) {}
        }

        player.getInventory().setItem(1, generateItemStack(
                Material.BLAZE_ROD,
                Major.C("&6Fun&eGun"),
                Major.C("&8"),
                Major.C("&7Wooho")
        ));
        player.getInventory().setItem(0, generateItemStack(
                Material.COMPASS,
                Major.C("&9Game Menu"),
                Major.C("&8"),
                Major.C("&9Browse our games")
        ));
        player.getInventory().setItem(8, generateItemStack(
                Material.ENCHANTED_BOOK,
                Major.C("&eShop"),
                Major.C("&8"),
                Major.C("&eOur store"),
                Major.C("&cWe are no longer selling on the site")
        ));

        boolean has = hasPerm(player, "pgxpo.fly");
        player.setAllowFlight(has);
        player.setFlying(has);

        ScoreBoard.toPlayer(player);
    }
``` is that good for you? and the `has` var is true i'm checked that
#

and this function executed from the join event

#

and for no reason the player cannot fly

river oracle
#

I mean playerJoin quite literally does nothing

#

so

#

who knows

tender shard
#

idk if that helps

primal goblet
remote swallow
#

are you calling that method on a player join event

quaint mantle
#

okay yea i cant figure out the issue

primal goblet
tender shard
river oracle
#

those conventions tho lol, but I'm not sure tbh\

tender shard
#

e.g. Essentials automatically removes fly if they don't have essentials.fly perm IIRC

primal goblet
tender shard
#

then see if it now works

quaint mantle
#

Do hashmaps clear after calling get on them

tender shard
#

if yes, it's another plugin causing this

tender shard
quaint mantle
#

Im like 99% sure they dont

tender shard
#

it definitely stays

river oracle
#

why would they clear that seems so random

tender shard
#

100%

quaint mantle
quaint mantle
#

For 0 reason

primal goblet
#

hmm ima try to remove some plugins

tender shard
quaint mantle
tender shard
#

and in createInventory, you call invList.put(..., new HashMap)

river oracle
tender shard
#

I don't even know what your hashmap is supposed to contain, your variable names are really a bit weird

primal goblet
#

lmfao

quaint mantle
#

Mine is a HashMap<UUID, HashMap<String, Object>>

primal goblet
#

the issue from the multiverse core! wow

tender shard
quaint mantle
river oracle
remote swallow
tender shard
#

imho yes

remote swallow
#

link it

tender shard
#

simplejson basically always just turns a json doc into a Map<String,Object>

tender shard
remote swallow
#

it is?

quaint mantle
#

updated

river oracle
#

it just confuses me since the GSON i injected only causes errors when the old GSON is observed prior to injection, but if its not observed nothing occurs. this is like some quantum physics hsit

tender shard
quaint mantle
#

im gunna go to the store to see if maybe my brain is just fuzzy

#

ill brb

#
Object authenticatedUsers = getAuthenticatedUsers();
``` getAuthenticatedUsers() returns a JSONParser. this json/object/thing is a list. how do I loop over it???
tender shard
quaint mantle
#

how do I even get a element from dis

quaint mantle
quaint mantle
river oracle
#

my favorite json library org.json.simple.JSONParser lmao

quaint mantle
tender shard
quaint mantle
#

wat

#

but when I do JSONParser.parse(mystring) it returns a Object

#

java is weird bro

river oracle
#

not really

#

Java is awesome

quaint mantle
river oracle
#

spotted the JavaScript dev

quaint mantle
tender shard
#

oh I see, I checked the wrong javadocs

river oracle
#

oh lord

hazy parrot
quaint mantle
#

troll

tender shard
#

you can usually cast your "Object" to JSONObject or JSONArray, or String, or Number, or Boolean

#

how does your json string look like?

quaint mantle
#

[[0],[1],[2]]

#

something like that

tender shard
#

then it's a JSONArray

quaint mantle
#

ohhhhhhhhhhhhhhhhhh

#

thanku

tender shard
#
JSONArray myArray = (JSONArray) JSONParser.parse(...);
#

sth like this should do

tender shard
primal goblet
tender shard
#

Gson has TypeAdaptors and stuff. that's only useful if you have complicated data

primal goblet
quaint mantle
#

i have simple data

tender shard
#

if you just have a simple array, then you just cast your stuff to JsonArray and that's it

quaint mantle
#

yas

primal goblet
quaint mantle
tender shard
primal goblet
tender shard
#

he's talking about primates, not primitives, lol

primal goblet
quaint mantle
tender shard
#

?learnjava

undone axleBOT
primal goblet
quaint mantle
#

is it a weird java thing

tender shard
#

String are NOT primitives

tender shard
#

int, float, double etc are

#

or boolean

#

a String is an object

quaint mantle
#

ohhhh

#

you mean TYPES

#

what

primal goblet
primal goblet
#

byte and chars is primitive too

quaint mantle
#

i refuse to commit cardinal sin ๐Ÿ™

tender shard
#

well

#

if you mean char[] by using the word "chars", then they are arrays, which indeed are objects lol

#

it's a bit confusing

#

if you talk about a single char, then you are right

primal goblet
#

mb

tender shard
#

java indeed is weird, I never understood why primitives even exist

quaint mantle
#

@tender shard it says that the hashmaps may be final

#

is that the possible issue

tender shard
#

everything should be an object, like in lua or in python

tender shard
primal goblet
tender shard
#

that doesn't change anything

river oracle
#

it could be final, but its just a small optimization

tender shard
#

yeah but it won't fix their problem

hazy parrot
tender shard
#

it returns an object because JsonObject and Number do not share the same superclass

#

you simply cannot know what you get when you parse json

#

because obv it could be anything