#help-development

1 messages · Page 609 of 1

silent steeple
#

just the active thing

remote swallow
#

25565 most likely isnt open with it then

#

see if anything shows up with sudo ufw status

echo basalt
#

I wonder if linux devs say sudo-code instead of pseudo-code

silent steeple
#

i did this

#

sudo ufw allow 25565

#

and now it says

#

v

#

Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip

To Action From


25565 ALLOW IN Anywhere
25565 (v6) ALLOW IN Anywhere (v6)

remote swallow
#

sudo ufw reload

silent steeple
#

ight

#

ima run the server now

#

yesss its working

#

thanks epicebic

remote swallow
#

enjoy the port scanners btw

silent steeple
#

yeah im turning on whitelist

#

lol

agile laurel
remote swallow
silent steeple
#

ok so? they cant connect

remote swallow
#

ur console would get flooded

silent steeple
#

really bruh

#

how do i stop them

agile laurel
remote swallow
#

somethign like this

#

fail2ban would be useful in most cases

silent steeple
#

weirdos bruh how do i make it so they cant

remote swallow
#

fail2ban

silent steeple
#

whats fail2ban

#

how do i delete a world in linux

#

rmdir or rm doesnt work

#

got it 👍

river oracle
#

we say super-user-do-code

#

acronyms are bloat to the dictionary

remote swallow
#

do you still say faq

river oracle
#

no

#

just say Frequently Asked Questions

remote swallow
#

faqu then

river oracle
#

faq is bloat

dull schooner
#

hey, does anyone know how to make a player use a held item?

silent steeple
dull schooner
#

nope

#

to give some context, im trying to do an autofishing

river oracle
crystal latch
#

Hello, with custom npc how to execute a command to the player who clicks on it?

dull schooner
#

otherwise it isnt an autofishing

late sonnet
remote swallow
#

idk, havent had a reason to set it up yet lol

late sonnet
river oracle
#

thouhg I suppose you could send a packet not sure how the client would respond to that though

dull schooner
#

maybe with nms?

river oracle
eternal oxide
#

There is a swing arm method.
You can fire your own interact event and there is a method to execute a command by the player. If thats what they mean.

fluid river
#

they who

#

you are answering one guy fr

river oracle
#

Used to refer to the one previously mentioned or implied or Used to refer to the ones previously mentioned or implied

rose trail
#

can the CompletableFuture be reused?

river oracle
#

wdym by re-use

crystal latch
#

Hello, with custom npc how to execute a command to the player who clicks on it?

crystal latch
river oracle
river oracle
crystal latch
#

its custom npc for jobs reborn

river oracle
#

ask in their discord they probably have one

river oracle
#

there's no need to ever "reuse" one anyways

#

they are single operations

remote swallow
rose trail
# river oracle No

I need to get a message from the proxy server before the command completes, can you recommend something?

#

I send the player's name to the proxy server and it returns the uuid to me, but it turns out that the uuid is returned after the command

#

And I need to use it in the command

river oracle
#

?paste

undone axleBOT
river oracle
#

show me the code

#

seems like you have flawed design

#

I wanna see what you're doing it

eternal oxide
#

you can;t use it in the command, but you can send some trigger data in the request so when you get a response you can run the command you want

#

your response should contain whatever data you need to run the command

river oracle
eternal oxide
#

nope, they are using messaging channels

river oracle
#

oh Ic

river oracle
#

you're halting the main thread

#

use thenAccept or whenComplete

eternal oxide
#

I told him to use futures earlier before I saw he was using messagign channels, but he seems to have not understood about running off thread

rose trail
river oracle
rose trail
#

but they were always null because

river oracle
#

running Future#get is a death sentence for the main thread if you're running a heavy operation you're freezing the entire server for however long it takes the operation to complete

remote swallow
rose trail
#

I'm a noob in multithreading)

eternal oxide
#

what you shoudl be doing is sending the PMC requests, then listening for a response and doing whatever you need to do there. Let your command exit without taking any other action after sending the request

sullen canyon
ivory sleet
#

Dw so are many others, but yeah you should learn about callbacks and why they are so useful when you play with concurrency

sullen canyon
#

я имею ввиду о чем плагин

rose trail
rose trail
eternal oxide
#

thats fine

rose trail
#

so i need to have uuid somehow

eternal oxide
#

you do it when you get a reponse, OFF thread

#

you don't wait for a response

#

all your onCommand code should do is make sure the player is allowed to use the command and send your PMC request. Your onCommand should then exit. It's done its job.

rose trail
eternal oxide
#

in the response

#

your response should contain all the data you need to execute whatever code you want to run.

rose trail
cobalt thorn
#

most basic thing that i can do because math is not my best, im making a sort of economy and im adding buy what you can, and i need a way to sell to a player the max he can so if an item cost 100 and he has 500 in automatic the player will get 5 items and so in this way

young knoll
#

Balance / cost

#

Round down

cobalt thorn
# young knoll Balance / cost

int max = Math.round(UserManager.getTokens(player.getUniqueId()) / config.getLong(path + "cost")); so in this way?

young knoll
#

I would use Math.floor

#

To round down

river oracle
shadow owl
#

Does anyone know if BiomeProvider is supposed to be extended? Otherwise how do I control the biome generation using a worldcreator? I want to make a whole world one biome

young knoll
#

Yeah you can extend it

quaint mantle
#

Has anyone ever worked with lettuce (redis)? I need to set my charset to ASCII (I guess) but I can't find how.

For more context: It returns "\u003d" instead of "=" and It completely brokes NPC skins

eternal oxide
#

I don;t use redis but unless you misconfigured somewhere it shoudl default to utf8, which is what you need

rough ibex
#

I don't see why you would intentionally want your charset to be ASCII

#

it is returning \\u003d or \u003d

quaint mantle
rough ibex
#

\u003d and = are the same thing

#

\u003d is just an escape

eternal oxide
#

yep, thats unicode, utf8

rough ibex
#

technically its also ASCII

quaint mantle
#

I know they are same but the player skins are not loaded for some reason and I can't figure out why

eternal oxide
#

?paste some code then

undone axleBOT
quaint mantle
#

Oh I'm blind, sorry for the trouble. I forgot to wait some time before sending playerinforemove packet 🤦

crimson tinsel
#

Hello! I ran into some problems with trying to make an object of a class outside the package and when i try to use setters it doesnt work. Can somebody tell if has an interest to help thanks!

eternal oxide
#

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

tender shard
#

?notworking too

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.

crimson tinsel
#

This is my explosion blockbreakevent class where i tried to initialize the TokensCommand class

#

?paste

undone axleBOT
crimson tinsel
#

And this is the TokensCommand class

#

And when i break blocks everything works except that it doesnt add anything to my tokens field

eternal oxide
#

@fluid river ^ someone here needs a few lessons

crimson tinsel
#

i havent finished my oop lessons yet

glad prawn
quaint mantle
silver robin
#

Is anyone here familiar with maven? I never really liked using it or gradle either because it is always introducing problems before even writing any code but more and more libraries are requiring it so I kind of have no option
Error: ```
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project CustomBlockDataExample: Fatal error compiling

My pom.xml : <https://paste.md-5.net/akopoyegex.xml> i'm using spigot 1.16.5 hope that's not a problem
Intellij idea doesn't give any red errors in the pom.xml, even tried invalidate caches and restart
tender shard
#

update it to 3.5.0

#

also what's all of this?

orchid gazelle
#

@tender shard what gpu do you have

tender shard
tender shard
orchid gazelle
#

What do you think about the RTX 4070? Should I get it?

tender shard
#

idk

tender shard
orchid gazelle
#

It's literally 700€, this is 2 years of saving for me

silver robin
silver robin
tender shard
#

the CustomBlockData-Example repo compiles just fine btw

tender shard
silver robin
#

I'm using this option, shouldn't it be the same?

tender shard
unique shuttle
silver robin
rose trail
#

how better to do operations with the database, asynchronously? And how to combine it with the main thread of bukkit?

tender shard
silver robin
silver robin
#

wait nvm, let me try something okay nvm I accidentally forgot to change shadedPattern in pom but it still errors

tender shard
#

click the uppermost entry in the list on the left, then you can copy/paste the full log

#

click this, then copy/paste the full log

silver robin
unique shuttle
#

💀

tender shard
silver robin
tender shard
#

You set the java version to 16.0.1

alpine cairn
#

When I write "p.sendMessage()" it gets a strikethrough and hovering over it reads "Obsolete API is used." Can anyone tell me what the issue is or what I should use instead?

tender shard
#

Not 16.0.1

alpine cairn
silver robin
# tender shard It must be 16

I didn't set it
is it in pom?

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>``` (sorry for terrible indentation)
tender shard
alpine cairn
#

Uhhh

young knoll
#

Paper deprecates all the string thing

silver robin
# tender shard In your properties

this? ```xml
<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
</properties>

alpine cairn
tender shard
tender shard
#

groupid org.spigotmc
artifactid spigot-api
version 1.20.1-R0.1-SNAPSHOT

alpine cairn
#

Thank you

silver robin
crimson tinsel
#

Are there something like minecraft plugin development courses where i can learn more?

tender shard
# silver robin well this was awkward but it worked, thanks ❤️ may I ask why what was with the ...

Well those were all the default values, its not needed to specify them. Your issue was that you used the old maven shade version which didnt support java 16, and then didnt run „clean“ after updating it - you also didnt specify java.version in your properties, so it used the java version environment variable, which was 16.0.1, which is not a valid option for maven.compiler.target and source

silver robin
#

eh, didn't think maven would be so tricky in intellij

tender shard
#

you can either use {java.version} and then declare that in your properties:

<properties>
  <java.version>16</java.version>

or just directly use "16" or whatever in the maven-compiler-plugin configuraiton

silver robin
#

Hard-coding it should be fine I assume

tender shard
#

in the CustomBlockData-Example pom, I used ${java.version} but I also declared it in the properties:

tender shard
# silver robin Hard-coding it should be fine I assume

yeah but you can also delete the <configuration> section as you already set it in properties through maven.compiler.target and source, so one of those is redundant - you can either remove the compiler <configuration> section, or remove the stuff from the <properties>

#

doesn't really matter which one you use

shadow owl
#

Does anyone know if there's a way to get the highest block at a point excluding certain materials (in this case, barrier blocks)?

#

Do I need to just manually search

uncut needle
#

How to type || on uk keyboard

#

I have to google the symbol and copy it everytime I want to use it

tender shard
# shadow owl Do I need to just manually search

yes. I'd just write a tiny method that takes a Predicate<Material> or sth so you can reuse it later

    /**
     * Returns the highest block at the given x/z coordinates, ignoring the given materials
     */
    public static Block getHighestBlockAt(World world, int x, int z, Predicate<Material> ignoredMaterials) {
        for(int y = world.getHighestBlockYAt(x, z); y >= world.getMinHeight(); y--) {
            Block block = world.getBlockAt(x, y, z);
            if(!ignoredMaterials.test(block.getType())) {
                return block;
            }
        }
        return null;
    }
tender shard
#

or maybe shift + that key, idk

eternal oxide
#

uk keyboard it should be right next to the left shift key, press shift + \

#

||

uncut needle
#

~

tender shard
#

what the heck is this

uncut needle
#

its a gun

tender shard
#

ah sure

#

the gun key

eternal oxide
#

¬

uncut needle
#
    • ¬
#
          • ¬
tender shard
#

show a picture of your keyboard

uncut needle
#

my keyboard is us layout

#

but I like uk layout more

#

on windows

#

only diffrence is dolllar sign

eternal oxide
#

a few keys are different

#

but minor

tender shard
#

you're gonna have a bad time if you use a different layout in windows than your keyboard is made for

uncut needle
#

I have been doing it for 2 years

#

ez

tender shard
#

yet you can't type a |

#

after 2 years

#

lol

uncut needle
#

that is the only problem

eternal oxide
#

its literally shift + the key between shift and Z

tender shard
#

US keyboards don't have a key between Z and shift

#

at least not the one shown on wikipedia

eternal oxide
#

uk do 🙂

tender shard
#

yeah but they got a US keyboard

uncut needle
#

yes

eternal oxide
#

oh I saw him ask how to do it on uk keyboard

uncut needle
#

my windows layout is uk

tender shard
eternal oxide
#

just add a US one too. you can switch in windows taskbar

tender shard
#

or with Win-Space

#

I always accidentally press that

silver robin
tender shard
silver robin
tender shard
#

using the <configuration> is probably more straightforward

eternal oxide
#

pretty sure they depricated it in properties

tender shard
eternal oxide
#

best to do it in plugin configuration

eternal oxide
#

I remember it stopped workign at some point when just in properties

tender shard
#

it's also still mentioned in the compile mojo docs

remote swallow
#

i think TAB supports 1.8

#

dont remember tho

tender shard
#

what do you wanna do?

#

spigot got API for per player header and footer, and the names can be changed with the display name

silver robin
tender shard
remote swallow
#

where is the plugin.yml

silver robin
tender shard
#

looks good. show pom.xml again pls

silver robin
tender shard
#

remove the whole includes part

unique shuttle
tender shard
# tender shard remove the whole includes part
  1. you don't need a <includes> set, you wanna include everything from the resources folder
  2. if you wanna use an includes set, then you gotta specify the full path, or use the ant style:
    Either <include>src/main/resources/plugin.yml
    or
    <include>**/plugin.yml
#

TL;DR: just do it like this

    <build>
        <resources>
            <resource>
                <filtering>true</filtering>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
#

also note that there's no starting / in the directory

#

it's a relative path

remote swallow
silver robin
#

removed the includes, ran 'package', new jar still doesn't have plugin.yml (when I view it with 7zip) okay nevermind the forwardslash

tender shard
#

anyway it's highly suspicous and I'd demand my money back lol

silver robin
remote swallow
#

the way you didnt it wont work anyway

#

you added paperclip jar, not an actual purpur server jar

unique shuttle
#

I want to make sure before doing it since in a few hours I have an event that I cannot cancel 😬

silver robin
silver robin
tender shard
remote swallow
#

paper (and its forks) distribute something call paperclip jars, they dont include any code thats on any repo, just instructions for the end server to download the patches and apply a binary patch

silver robin
orchid gazelle
#

shaded includes Libraries and Dependencies into the jar

#

If you do not have any Dependencies, it is the same

rough drift
#

Extending character limit on a scoreboard with teams.

tender shard
orchid gazelle
#

Isn'r it there to include deps?

tender shard
#

The shade plugin copies the -shaded .jar to the normal ind

remote swallow
orchid gazelle
#

Huh? Last time I used maven it did not

orchid gazelle
#

And had a second jar including everything

tender shard
remote swallow
#

yeah, they changed maven info

orchid gazelle
#

Ohh sorry for the missinformation then

shadow night
#

What is shading for again?

remote swallow
#
<dependency>
  <groupId>org.purpurmc.purpur</groupId>
  <artifactId>purpur-api</artifactId>
  <version>1.16.5-R0.1-SNAPSHOT</version>
  <scope>provided</scope>
</dependency>

<repository>
  <id>purpurmc-snapshots</id>
  <name>PurpurMC Repository</name>
  <url>https://repo.purpurmc.org/snapshots</url>
</repository>
tender shard
kind hatch
tender shard
shadow night
#

Ah right

silver robin
tender shard
#

Maven shade is like gradle‘s shadow

orchid gazelle
tender shard
#

CustomBlockData is a compile dependency - you gotta ship it yoursef

silver robin
remote swallow
#

reload maven

silver robin
remote swallow
tender shard
silver robin
remote swallow
#

add the scope provided i missed

#

i forgot that reposilite doesnt care about stuff like that

#

and then clean build

silver robin
#

I opened a ton of tabs already just from discussions here :/
now all I can hope that my pom won't break sometime in the future

#

Thanks again every one of you 😃

tender shard
#

if it breaks, just ask here again lol

silver robin
#

i was hesitant at first to use spigot discord server for such things but again if I were to ask general java people I thought they'd get as confused as me

sharp bough
#

anyone knows if this is normal? 60% on votifier? running 1.16.5 arclight

remote swallow
#

is there any reason you arent using nuvotifier

fluid river
#

?learnjava

undone axleBOT
fluid river
#

not for you guys

remote swallow
#

why not

sharp bough
#

made a profile and found that

#

im honestly not sure if thats just the normal ussage of votifier

#

but i dont think so?

#

feels like too much

remote swallow
#

idk how bad it was, check source code of both and check if nuvotifier adds something to counter it

ornate patio
#

I'm creating a custom UI using inventoryframework

#

and for some reason the library places some custom nbt data on items that i place in

#

making it non-stackable

#

how can I delete this nbt tag?

sharp bough
#

is what i use

#

i already asked the dev

ornate patio
#

hmm okay

carmine mica
#

wow that looks like not a good idea

remote swallow
#

that removes all pdc, be careful with that one

ornate patio
#

i thought there would be a better way

silver robin
carmine mica
#

just wipe all plugin's custom info on items = bad time

remote swallow
sharp bough
ornate patio
#

is that a pdc though?

carmine mica
#

yes, its all the PDC

ornate patio
#

because if so can't i just use the pdc api

carmine mica
#

yes, you don't need anything extra

ornate patio
#

to delete it

#

ok

#

yeah i'll do that then

carmine mica
#

just create a namespaced key that matches the key in the nbt you have, so new NamespacedKey("classmmo", "if-uuid");

remote swallow
#

(NamespacedKey.fromString("classmmo:if-uuid"))

tender shard
#

better use NamespacedKey.fromString

carmine mica
#

why is that better?

tender shard
#

because the constructor is deprecated and tells you to NEVER use it, with 2(!!) exclamation marks

carmine mica
#

oh yeah, forgot spigot still has that deprecated for whatever reason

#

don't really understand why

remote swallow
#

better stay the hell away from it

tender shard
#

yeah lol

carmine mica
#

fromString is nullable which is annoying. so new is better for this imo (assuming it wasn't deprecated), cause that's even more annoying from a static analyzer perspective

ornate patio
#

why would i fromstring tho

#

cant i just use the plugin instance

carmine mica
#

well is the plugin name classmmo? if they created a custom key

tender shard
#

is "classmmo" your plugin?

ornate patio
#

integer array?

ornate patio
carmine mica
#

byte array

tender shard
#

byte array

ornate patio
#

oh

#

i should use the plugin instance then huh

remote swallow
#

im just looking at a profiler of my dev server and i feel like this probably isnt good

#

i just managed to crash it trying to profile my plugin

#

thats great

worldly ingot
#

I mean that's just how memory works in Java

remote swallow
#

choco can we ban mm

#

look at his status

worthy moat
#

How can I read in Spigot 1.8.8 what color a wool is if I only have the ItemStack?

young knoll
#

It’s the damage value on the stack

#

Think it’s getData or something

worldly ingot
#

Wool MaterialData existed back then

#

but please, for the love of God, write against modern API

young knoll
#

Oh yeah you guys abstracted the magic values

#

And then they got yeeted right after

worthy moat
ornate patio
#

I want to make a command that'll open up an Anvil GUI that has custom recipes

#

Right now I'm doing this with InventoryFramework but it's really scuffed because you're not meant to be placing items into the GUI

#

is there any alternative i can do

ancient glade
#

Hey, I have been struggling with an issue for a while and found no help or useful information online regarding the issue.

Whenever I try to make a copy of a sqlite file from the resource path to the plugins datafolder it gets corrupted(Only sqlite files no other file formats, it corrupts the encoding), no matter what copy method I try no matter what encoding I set it to it always gets corrupted.

Now for the funny part. It only happens when loading it as a plugin, the code works fine without issues no corruption when just running it as java code. It also does not matter if I create the file on plugin startup or any other time during the servers lifetime. it always gets corrupted. Did anyone run into similar issues before?

eternal oxide
#

how are you copying it?

ancient glade
#

Currently using the nio Files.copy function, but I also tried manual binary copying and other methods I could find. Did not change anything, always worked on normal java and failed as a plugin

eternal oxide
#

nm, when packaging (maven) you need to turn filtering off to package compressed files.

tender shard
#

is it corrupted when you extract it with winrar etc?

eternal oxide
#

it is, he filtered

ancient glade
#

oh my god... you are a lifesaver, I tested everything under the sun but did not even think about filtering

carmine nacelle
#

Anyone know why when this is only despawning the entity for one player online?

    public void despawnHologram(Player player, Hologram hologram) throws InvocationTargetException {
        List<Integer> holoIDs = hologram.getHoloIDs();

        for (Integer holoID : holoIDs) {
            PacketContainer metadata = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY);
            metadata.getModifier().write(0, new IntArrayList(new int[]{holoID}));
            ProtocolLibrary.getProtocolManager().sendServerPacket(player, metadata);
        }
    }

I'm sending the packet to all players, but it only actually deletes the hologram for one player

#

image illustration

ornate patio
#

can i create custom smithing table recipes

worthy moat
#

How can I enchant my wool for example in 1.8?

quaint mantle
#

Hide enchants with hideflags

worthy moat
#

And how do I enchant?

quaint mantle
#

ItemMeta

worthy moat
#

ah ok thx

quaint mantle
#

I think ItemStack still allows doing enchantment operations

#

Let me ensure

#

Yeah, ItemStack itself can do it 👍🏻

#

No need to access the ItemMeta

#

But you’ll need the ItemMeta for the hideflags

cinder abyss
#

Hello, I've got this error when reloading maven : org.spigotmc:spigot-api:jar:1.20.1-R0.1-20230709.090828-26 failed to transfer from 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 spigot-repo has elapsed or updates are forced. Original error: Could not transfer artifact org.spigotmc:spigot-api:jar:1.20.1-R0.1-20230709.090828-26 from/to spigot-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/): GET request of: org/spigotmc/spigot-api/1.20.1-R0.1-SNAPSHOT/spigot-api-1.20.1-R0.1-20230709.090828-26.jar from spigot-repo failedIt's perfectly working with 1.19.4, but not with 1.20.1

#

(working with 1.20 too)

rose trail
#

it just happened to me

cinder abyss
#

LUL thanks !

rough drift
tender shard
#

-U updates snapshots

cinder abyss
ornate patio
#

Can I create custom smithing table recipes

#

And could I also create dynamic recipes, like a callback function that checks the ingredients and returns a new item

young knoll
#

Sure

tender shard
tender shard
#

normal (registered) recipes are "static"

young knoll
#

There’s also the PrepareItemSmithingEvent

tender shard
#

oh yeah right. but it's PrepareSmithingEvent*

grim ice
#

i can recognize everyone here mostly

#

cool thing, nobody really disappeared since 2022

rough drift
#

can you remove entries from a team while iterating on them?

#

I don't know if it returns a clone or not

#

and don't ?tas me

#

It's a clone

tender shard
quiet ice
#

Yeah I also recognise most of you. But it would be strange if I wasn't able to

grim ice
#

found this

#

maybe it can help

rose trail
#

?paste

undone axleBOT
grim ice
#

amazing

rose trail
quiet ice
grim ice
#

yeah

#

its nostalgic seeing this chat

#

ive learnt csharp while i was gone from discord

#

and some dart

ornate patio
tender shard
quiet ice
#

Anyways. I require some help from the spigot hivemind:
I have an array of numbers (integers) (called the test array) that is freely resizeable. At any time, any number may only present within this array once.
Upon invocation of a method I have control over, exactly one number is added or removed from that array.
Then I also have multiple arrays of numbers (the witness arrays). These arrays are relatively constant and will rarely change (and if they do the aforementioned test array is empty). I have control over the method that would change these witness arrays.

The root question here is what data structure or algorithm would return me the witness arrays that contain the test array fully - though order of elements does not matter. Furthermore, the test array may contain more values than the witness array.

noble crown
tender shard
#

I also don't think so

#

it makes absolutely no sense

rose trail
#

It stops at future.get();

quiet ice
#

Is the future ever completed?

#

Do you even know what futures do?

remote swallow
#

this is very pointless

#

this.future.whenComplete(uuid -> {
//do whatever
}

#

your uuid will be null with the way you do it currently

rose trail
#

thanks

rose trail
noble crown
#

I don't think it's the only way 🤔

rose trail
#

I can't think of anything else

quiet ice
#

AtomicReferences might be another way

rough drift
#

Quickly, if you set an objective score to 0, does it show as 1 or is it ignored

quiet ice
#

I think it is shown as 0?

rough drift
quiet ice
#

Yeah could also be that I am misremebering those

rough drift
#

only issue is that it's only showing one of em

remote swallow
#

i think you have to use packets

#

check how TAB does it

quiet ice
#

Okay yeah. It's 1 - X

rough drift
#

wdym epic

young knoll
#

Just get that resource pack that removes the numbers

rough drift
#

That's not what I want lmao

#

I am just asking because some of the text is not showing

#

I set a team's score to zero to display that, but it's not showing so I was wondering if it started at 1 or zero

remote swallow
#

oh i thought you wanted to make them all 0

rough drift
#

oh no

young knoll
#

Yeah I think 0 doesn’t show by default

rough drift
#

moving the setting to be at least 3

#

let's see if that fixes it

#

if it does then I know the issue ;)

#

I've been making simple mistakes today

#

like != instead !.equals

#

lmao

eternal oxide
#

0 displays

rough drift
#

Apparently not

compact haven
quiet ice
#

I think it just depends

compact haven
#

it's possible you have too many lines?

rough drift
#

I have 15 iirc

remote swallow
#

bad

quiet ice
#

I recall it not being a problem with Presence

compact haven
#

ur bad

remote swallow
eternal oxide
#

where are MC screenshots saved? I forget

rough drift
#

16 lines in total, going from 0 to 15, or is that too much

quiet ice
#

But I don't recall seeing 0 elsewhere either

rough drift
compact haven
#

^

#

so quick

rough drift
#

yep I got muscle mem for the mc directory

remote swallow
#

mainy bc i dont use that .minecraft

#

i love discord making me reply to random things

neon nymph
#

Hello! Is it possible to store custom enums into an item's PDC? Currently I only store the int references to my enums, but I was wondering if I could store the enum itself

eternal oxide
#

odd mines not there 😦

remote swallow
#

the entire enum?

compact haven
#

!notworking

#

lame ass bot

young knoll
#

Bad

neon nymph
rough drift
#

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

rose trail
hazy parrot
#

Who tf is using java cord

remote swallow
#

i dont see where this is, and use jda

timid hedge
#

When i use !whoIsOnline nothing is happening

hazy parrot
remote swallow
neon nymph
remote swallow
#

this is probably the wrong use for futures

#

use callbacks or something

hazy parrot
neon nymph
#

Great, thanks so much! 😄

remote swallow
#

it shouldnt?

#

i run it on mainthread

hazy parrot
#

Jda have it's own thread anyway

#

Different for websocket and events

#

Because it's executing from jda thread, just call .runTask from consumer

umbral ridge
# rough drift

1 2 3 4 5 six even eight nine 10 eleven twlve 13 14 1five

rough drift
#

Why does 1 get skipped though

umbral ridge
#

That's a scoreboard on the right side yeah?

rough drift
#

ye

umbral ridge
#

What are you doing with it

#

how is it done

rough drift
#

I generate 15 teams, set them to be an empty unique id, and set their score

#

then when I want I just change prefix/suffix for no flicker

umbral ridge
#

if you do something like bukkit.broadcastMessage(id) in the code where you create these teams, does it output 15 ids?

#

any exceptions?

#

or if you go in your console and do /scoreboard

#

and check there if there are 15 teams

rough drift
rough drift
umbral ridge
rough drift
#

nope

umbral ridge
#

have you tried testing it with different ids?
eg.
11
12
13
14
15

rough drift
#

yeah those all work

#

apart 1

umbral ridge
#

then its probably just some bullshit hardcoded thing XD

rough drift
#

What the fu-

umbral ridge
#

Yeah it would piss me off too

#

what if you do negative? XD

#

can you even do that?

rough drift
#

ye

umbral ridge
#

then use negative I guess? if it works

wet breach
#

when it comes to looping inserts you have to insure you account for the initial loop

#

otherwise you miss an insert at the beginning or sometimes at the end

#

because it doesn't loop that one last time

#

this is why ++i and i++ are a thing

tawny remnant
wet breach
#

show the error

#

please

eternal oxide
#

you are spawning a mob in the spawn event

wet breach
#

that may do it yeah

eternal oxide
#

infinite loop

rough drift
#

@wet breach When I register the team I just set text on it to debug, no further setting

#

Line 1 is just not rendered

wet breach
eternal oxide
#

yep overflow

ornate patio
#
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
    // Allow tools and weapons to be placed in the smithing table (for custom upgrades)
    if (!(event.getInventory() instanceof SmithingInventory)) {
        return;
    }

    if (event.getSlot() == 1) {
        event.setResult(Result.ALLOW);
    }
}

I'm trying to allow players to put any tool or weapon inside a smithing table

#

This doesn't work, still only allows diamond tools

tawny remnant
wet breach
#

so its infinitely running with no condition to stop

eternal oxide
#

the instant you call spawn, a new event is triggered. your event never gets to finish

#

and so on

tawny remnant
#

oooohh

wet breach
#

so you spawn the mob -> event runs your checks do its thing, removes entity, spawns another

#

and then it does it again

rough drift
# wet breach mind showing the code?
    for (int i = 0; i < 15; i++) {
        var team = scoreboard.registerNewTeam("test_team_" + i);
        var id = "§r".repeat(i);
        team.addEntry(id);
        team.setPrefix("A");
        objective.getScore(id).setScore(i);
    }
wet breach
#

how you stop it from doing that is add something to your custom entities to check for

#

so as to not remove them

#

this way, the next event is just ignored instead 😛

ornate patio
wet breach
#

try adding an else statement to set result disallow?

ornate patio
#

i want to put any tool into the second slot

#

even if its not diamond

wet breach
#

but I don't see where you check for the tools though 🤔

ornate patio
#

i havent implemented that part yet

#

right now im just trying to put any item

#

which doesnt work

wet breach
#

you might need to use a custom inventory for it, not sure. Does the smithing table typically allow any tools?

ornate patio
#

no

#

it only allows diamond tools

wet breach
#

then yeah going to need to use a custom inventory then most likely

ornate patio
#

ugh damnit

wet breach
#

because it could be a client side thing not allowing it, not necessarily the server

young knoll
#

I know when you register recipes with different items they work fine

#

Well, at least in the old table they did

ornate patio
#

well i need it to be dynamic tho

#

i need to read the properties of the tool

#

for the result item

young knoll
#

You can still do that with a registered recipe

ornate patio
#

i can do that for smithing tables?

tender shard
# tawny remnant oooohh

add a boolean field to your class

private boolean ignoreNextSpawn = false;

@EventHandler
public void onSpawn(EntitySpawnEvent event) {
  if(ignoreNextSpawn) {
    return;
  }

  // ...
  ignoreNextSpawn = true;
  event.getLocation().getWord().spawn(...);
  ignoreNextSpawn = false;
}
#

and instead of calling entity.remove(), why don't you just cancel the spawn event?

young knoll
ornate patio
#

how exactly

young knoll
#

How to register a recipe?

ornate patio
#

with a dynamic result

young knoll
#

Same way you register crafting recipes, just with smithing instead

#

Use the event to change the result

ornate patio
#

which event

#

and the issue still stands that I can't put any tool inside the smithing table

young knoll
#

PrepareSmithingEvent

ornate patio
#

when i can just set the result inside that event

young knoll
#

Like I said

#

It may only let you put the item in if there is a recipe that uses it

ornate patio
#

oh

#

ok let me try rq

wet breach
#

I am not super familiar with the smithing stuff as I haven't really messed with it lol

young knoll
#

I’m not familiar with the new smithing table

ornate patio
#

doesnt seem to work

#
Bukkit.addRecipe(
    new SmithingRecipe(new NamespacedKey(this, "custom_smithing"), new ItemStack(Material.IRON_SWORD), new RecipeChoice.MaterialChoice(Material.IRON_SWORD), new RecipeChoice.MaterialChoice(Material.IRON_INGOT))
);
#

also i just realized

#

this smithingrecipe class is outdated

#

theres now three elements inside the table

young knoll
#

Iirc there’s new classes

#

SmithingTransformRecipe and SmithingTrimRecipe

ornate patio
#

lemme try that then

young knoll
#

They both seem to require 3 items tho

#

Hm

ornate patio
#

oh shit it works

#
Bukkit.addRecipe(
    new SmithingTransformRecipe(
        new NamespacedKey(this, "custom_smithing"),
        new ItemStack(Material.IRON_SWORD),
        new RecipeChoice.MaterialChoice(Material.AIR),
        new RecipeChoice.MaterialChoice(Material.IRON_SWORD),
        new RecipeChoice.MaterialChoice(Material.IRON_INGOT)
    )
);
#

thank god

carmine mica
#

yeah, spigot doesn't tell you that SmithingRecipe constructors are useless, as instances of pure SmithingRecipe aren't recognized by the server

#

addRecipe returned false there probably

ornate patio
#

but yeah why are they 2 seperate recipes though

carmine mica
#

because there are 2 kinds of smithing recipes now

ornate patio
#

i mean

#

they both require templates anyways

carmine mica
#

they have different behaviors

ornate patio
#

i dont see why they're split

young knoll
#

Ah you can just pass air to have no third item

#

Fair enough

ornate patio
#

for the smithing template slot

carmine mica
young knoll
#

Wait can’t we just make SmithingRecipe abstract then

carmine mica
#

well if you want to break API and probably ABI

young knoll
#

I guess that would cause old plugins to explicitly throw an error, but that’s better than doing nothing imo

ornate patio
#

they're both the same recipes, one just uses armor trim templates and the other uses upgrade template

carmine mica
#

if you use the trim one, and the stacks you input DON'T match trim pattern and trim material, it won't do anything

ornate patio
#

wdym "stacks you put input"

#

what stacks

carmine mica
#

the template and addition ingredients

ornate patio
#

what needs to match

#

you can use any ore for the addition

#

and any smithing template

#

the only thing that won't work is if you use iron armor with an iron ingot addition or smthn

carmine mica
#

you also don't specify a result for trim recipes, hence it extending ComplexRecipe

ornate patio
#

hmm ok

#

i've never heard of ComplexRecipe before

#

could I perhaps use that for my own custom recipe instead too?

#

or do i have to use PrepareSmithingEvent

#

just completely out of curiosity

young knoll
#

You can’t make an instance of ComplexRecipe directly

#

It’s an interface

ornate patio
#

Oh ok

#

Should transform recipe use complexrecipe too though?

#

Because even though it always upgrades diamond to netherrite

#

It has to keep its enchants and nbt data

worthy moat
#

hey

#

I want to save a Object with SnakeYAML (the yml framework which is used in spigot)

#

But

remote swallow
#

ConfigurationSerializable

worthy moat
#

Ah there you already know the problem hahaha

#

PirateCraft: !!de.marvn.alphablock.alphawars.util.objects.Arena

remote swallow
worthy moat
#

is it this one?

#

I am using 1.8.8

remote swallow
#

that should exsit still

worthy moat
#

I dont really understand how to use this

#

Should I implement this Interface into my Object?

remote swallow
#

yeah

#

just follow its javadocs

worthy moat
#

ok wait

#

A constructor that accepts a single Map<String, Object>.

#

?

#

What should I exactly put into the constructor

carmine mica
#

a single Map<String, Object> param

#

then populate the fields from that map

worthy moat
#

yeah but can i choose a name by myself?

young knoll
#

Sure

#

Name doesn’t matter, only the type

remote swallow
#

the name doesnt matter in a constructor

worthy moat
#
        map.put("Name", name);
    }


    String name;```
#

Like that?

carmine mica
#

well that's not constructing the object. you need to populate the feidl from the map

#

you create a map from the fields in the serialize() method that interface has you implement

remote swallow
#

?learnjava moment

undone axleBOT
worthy moat
remote swallow
#

the list will have whatever contents you add in the serialize method

worthy moat
young knoll
#

Anything you need to serialize, yes

#

And then you read it from the map in the constructor

remote swallow
#

public class MyCustomDataClass implements ConfigurationSerializable {

    private final String name;

    public MyCustomDataClass(String name) {
      this.name = name;
    }


    public MyCustomDataClass(Map<String, Object> map) {
      this.name = map.get("name");
    }

    public static MyCustomDataClass deserialize(Map<String, Object> map) {
        return new MyCustomDataClass(map):
    }

    public static MyCustomDataClass valueOf(Map<String, Object> map) {
        return new MyCustomDataClass(map):
    }

    @Override
    public Map<String,Object> serialize() {
        Map<String, Object> map = new HashMap<>();
        map.put("name", name);
        return map;
    }
}
worthy moat
#

yes thats what I meant with the serialize method

#

yes

#

Thats why its a map

young knoll
#

Yeah idk why you have a valueOf method there

#

Smh epic

worthy moat
#

The question is...If I try to read my stuff...Why Do I need a deserialize and a valueOf if I get the Object with #get

young knoll
#

Oh there are several options

worthy moat
#

ahh

remote swallow
young knoll
#

Didn’t know that

remote swallow
#

use eyes

young knoll
#

Neat

remote swallow
#

i didnt see the one

#

i thought it wanted all of them

young knoll
#

Also hush I’ve never used ConfigurationSerializable

echo basalt
#

man just did all 3

young knoll
#

Kek

echo basalt
#

ConfigurationSerializable is a bit gimmicky

#

looks ugly on yml

#

So I just make a constructor that takes a config section

young knoll
#

Yeah it has the weird !!class to identify it

worthy moat
#

Yeah....Cant do anything...Need to save it somehow

echo basalt
#

And simply never have to impl a write method because all my YMLs are read-only :p

young knoll
#

My cursed reflection config lib takes care of everything

worthy moat
#

Uhhh what if I have a List of Objects in my Object xD

#

same thing for them?

#

map.put("teams", teams);

compact haven
#

my configs are kinda scuffed, I have an interface, then a class YamlWhatsverConfig that accepts a ConfigurationSection in the constructor, then the interface returns the values of ConfigurationSection#get…

young knoll
#

Make sure the items in the list are ConfigurationSerializable

worthy moat
#

Just like that?

young knoll
#

List itself is already serializable so ur good on that part

worthy moat
#

So I wouldnt have to serialize that? HashMap<String, Team> teams = new HashMap<>();

remote swallow
#

just make sure its vaulues are (configuration)Serializable

worthy moat
remote swallow
#

team is gonna need serializing

worthy moat
#

ah ok

#

thx

ivory sleet
compact haven
#

It is

ivory sleet
#

Sounds like everything but scuffed

worthy moat
#

Otherwise I would juist use valueOf

remote swallow
#

turns out you only need 1 of them

#

pick your favourit

#

e]

compact haven
#

kek thank you for that

worthy moat
compact haven
#

You

ivory sleet
#

Yeah but fr tho, if I read code like that my eyes would be shining

remote swallow
#

whoevers listening

young knoll
#

I can make your eyes bleed if you want

#

Kek

ivory sleet
#

🥹

remote swallow
worthy moat
#

I mean the IDE would have a probl

remote swallow
#

cast it

compact haven
ivory sleet
#

I remember this faction code base where all their data was grabbed from debugging logs, oh god, dont think code can get any worse than that

worthy moat
#

hmm ok

compact haven
#

debugging logs cat_what

#

logs as input is actually crazy

remote swallow
#

@young knoll wheres my eye blood

young knoll
#

Logs as input

#

Wtf

worthy moat
#

ok so

#
    @Override
    public Map<String, Object> serialize() {
        Map<String, Object> map = new HashMap<>();
        map.put("name", name);
        map.put("maxPlayers", maxPlayers);
        map.put("teams", teams);

        map.put("bronzeSpawner", bronzeSpawner);
        map.put("silverSpawner", silverSpawner);
        map.put("goldSpawner", goldSpawner);
        map.put("diamondSpawner", diamondSpawner);
        map.put("emeraldSpawner", emeraldSpawner);
        return map;
    }```
#

Does this look good?

#

Is that how they want that?

remote swallow
#

as long as its a a map string object its happy

worthy moat
#

nice

#
    public Arena(Map<String, Object> map) {
        this.name = (String) map.get("name");
        this.maxPlayers = (Integer) map.get("maxPlayers");
        this.teams = (HashMap<String, Team>) map.get("teams");

        this.bronzeSpawner = (List<Location>) map.get("bronzeSpawner");
        this.silverSpawner = (List<Location>) map.get("silverSpawner");
        this.goldSpawner = (List<Location>) map.get("goldSpawner");
        this.diamondSpawner = (List<Location>) map.get("diamondSpawner");
        this.emeraldSpawner = (List<Location>) map.get("emeraldSpawner");
    }``` and this is my constructor
#

Looks good?

compact haven
#

yep

worthy moat
#

ok and if i read that correctly I have to serialize it in my onEnable?

remote swallow
#

ConfigurationSerialization.registerClass(Arena.class)

worthy moat
#

Wait

#

I first have to make Team serializable

compact haven
#

probably

#

also you don't necessarily need to register it in onEnable I don't believe

#

if you find it better to stick it in a static block in the same class, that probably will work

static {
  ConfigurationSerialization.registerClass(Arena.class)
}
rough drift
#

I need to split a string, whilst keeping color codes intact, is there a known way to do this?

compact haven
rough drift
#

Just using length right now, that's why it's happening

ivory sleet
#

Like with String::split and pass a pattern?

rough drift
#
var left = text.substring(0, Math.min(text.length(), 64));
var right = text.length() >= 64 ? text.substring(64) : "";
compact haven
#

you could probably use indexOf, then loop all characters from then to indexOf, and build a new translatable string color code?

#

I mean instead of indexof you'd just use the second parameter of substring, but same idea

rough drift
compact haven
#

well I'm thinking if you have a string like &aHello &cWorld &b&lHahahahah &r&6Test (split) &cmwhaha, you'd end up with &a&c&b&l&r&6&cmwhahaha, and that should just apply the right ones, I think?

rough drift
#

I figured

  1. if the last char is a color code, move it to right
  2. if two characters behind is a color code, move the last two chars to right
  3. try repeat two
ivory sleet
#

You’d just wanna make sure the character after § is together with the § if its a valid chatcolor code character?

rough drift
#

Oh shit yeah domi

ivory sleet
#

Or is it important to have consecutive § pairs not split up?

remote swallow
#

coll

#

wheres my eye blood

worthy moat
#

Ah fuck it still shows that: " ==: de.marvn.alphablock.alphawars.util.objects.Arena"

rough drift
#

I could just

indexOf('§r') (if it returns -1 I just use indexOf('§')) and just apply all existing color codes forward, thanks

ivory sleet
#

Dw coll is cooking

compact haven
#

it's the worst API in existance

worthy moat
#

But how should I then save my stuff?

compact haven
#

manually write to ConfigurationSection

worthy moat
#

what should I use instead

remote swallow
#

database

worthy moat
#

any guide?

young knoll
remote swallow
#

i hav?e

young knoll
#

And my unfreezing registries

compact haven
#

but you most definitely have done this before

remote swallow
compact haven
#

it's literally just section.setInt("maxPlayers", team.maxPlayers) and so-forth

#

and note that YamlConfiguration is also an instance of ConfigurationSection so if your data is at the root, it'll still work fine

worthy moat
#

So the interface holds the data types?

ivory sleet
#

Switch Map<String,Object> to ConfigurationSection lmao

remote swallow
#

josh does ur config work off gson type adapters

ivory sleet
#

Thats all

compact haven
#

in my case yes, but you don't necessarily have to inplement it like that

#

you'd just change your constructor like Conclube said

young knoll
#

Not my fault Mojang freezes the registries smh

remote swallow
#

why not

worthy moat
compact haven
#

no do not implement that

#

and u can remove the method

ivory sleet
#

^

worthy moat
#

ok

ivory sleet
#

or just change it to
public ConfigurationSection serialize() {

}

compact haven
#

just from when you attempt to build the object it's not like this:
(Arena) config.get("arena"), it's like this: new Arena(config.getSection("arena"))

worthy moat
#

ConfigurationSerialization.registerClass(Team.class);

#

This also out?

ivory sleet
#

Yeah

compact haven
#

kind of like this:

public class Arena {
    protected int maxPlayers;
    
    public Arena(int maxPlayers) {
        this.maxPlayers = maxPlayers;
    }
    
    public Arena(ConfigurationSection section) {
        super(
            section.getInt("maxPlayers")
        );
    }

    public Arena(ConfigurationSection config, String key) {
        return super(config.getSection(key)); /* even can do this, so getting becomes new Arena(config, "arena") */
    }
    
    public void write(ConfigurationSection section) {
        section.setInt("maxPlayers", maxPlayers);
    }
}
young knoll
remote swallow
#

its a superset

#

anyway im going to bed

#

josh thing of things i can do tomorrow

#

and dm them me

#

now im out

worthy moat
#

Cant i just save?

compact haven
#

wdym

rough drift
#

(though going from last §r to not add too much, char limit is 64)

worthy moat
#

I currently save like this;
I prepare an Arena after some setup things and then i put it in my yml like this
getConfig().set(Cache.arena.getName(), Cache.arena);

ivory sleet
compact haven
#

instead you'd save like Cache.arena.write(getConfig().getSection(Cache.arena.getName()))

worthy moat
#

I want to push the whole object containing everything

compact haven
#

you're pushing the whole object

#
    public void write(ConfigurationSection section) {
        section.setInt("maxPlayers", maxPlayers);
    }

that's what this does

#

you're giving it a new "section" in your config, like

data.yml

arenas:
  nameOfArena: # getConfig().getSection(Cache.arena.getName()
    maxPlayers: 5

and you'd write to that section using Cache.arena.write(getConfig().getSection(Cache.arena.getName()))

worthy moat
compact haven
#

ah yeah it's that

#

sorry I forget they don't short-hand it

worthy moat
compact haven
#

why would you have an empty constructor

#

please don't tell me you're filling in the fields manually like this is C

#

technically yes you can have an empty constructor and access new Arena().maxPlayers = 5;, but that's a huge anti-pattern

worthy moat
compact haven
#

there's probably a better design, but yes you can

worthy moat
#

ok

compact haven
#

though you need to replace super with this.maxPlayers

ivory sleet
# worthy moat Is it also possible to have an empyy constructor instead of the first one?

Marvin there are to designs you can have.

Either:
class Boo{
Boo(ConfigSection …){

}

ConfigSection …() {

}
}

or

class Doo {
void read(ConfigSection …){

}

void write(ConfigSection …){

}
}

One has 2 void methods, one has 0 void methods, choose one (the first one is if ur fields/variables in Boo.java can be re-assigned, the second one if they cant) mutability vs immutability.

glad prawn
ivory sleet
#

Since I don’t know how ur data transfer (ur class that u wanna serialize) is used it is hard to say what would he the best choice here

worthy moat
ivory sleet
ivory sleet
#

getSerializable("path",Location.class)

#

I think

glad prawn
#

Call another constructor use the this keyword?

worthy moat
#

So like this currently if I dont have a constructer with all fields? java public Team (ConfigurationSection map) { this.spawnPoint = (Location) map.get("spawnPoint"); this.spawnBlock = (Location) map.get("spawnBlock"); }

ivory sleet
glad prawn
#

Yes i'm talking about it

ivory sleet
#

Constructors and overriding them works similar to methods and when you override them

#

In fact almost identical

#

super. goes up to the superclass above, if the superclass did not do anything with the methods, it chains to the superclass of the superclass

#

same with constructors

#

Only difference is when you override a constructor you must call its super

#

Otherwise you’d get a lot null pointer exceptions

worthy moat
#

Thats too much info...Slowly please....My class currently looks like this:

#
public class Team {

    public Team(){

    }

    public Team (ConfigurationSection map) {
        this.spawnPoint = (Location) map.get("spawnPoint");
        this.spawnBlock = (Location) map.get("spawnBlock");
    }

    protected Location spawnPoint;
    protected Location spawnBlock;

    public Location getSpawnPoint() {
        return spawnPoint;
    }

    public void setSpawnPoint(Location spawnPoint) {
        this.spawnPoint = spawnPoint;
    }

    public Location getSpawnBlock() {
        return spawnBlock;
    }

    public void setSpawnBlock(Location spawnBlock) {
        this.spawnBlock = spawnBlock;
    }

    public void write(ConfigurationSection section) {
        section.set("spawnPoint", spawnPoint);
        section.set("spawnBlock", spawnBlock);
    }

}```
#

does that work?

ivory sleet
#

Its bad

worthy moat
#

yes but it would work?

ivory sleet
#

Yes

worthy moat
#

ok

#

so now to the optimization part

#

What exactly should I change

ivory sleet
#

The constructor

compact haven
#

why don't you use a builder pattern

worthy moat
compact haven
#

though that one is a bit weird, I don't think I've ever seen a class accept a builder as a constructor parameter

#

typically the builder returns the constructor invocation

worthy moat
#

Ah you mean that

ivory sleet
worthy moat
#

Yeah I will build them like that afterwards...Thanks for remembering me..Havent thought of it

worthy moat
ornate patio
#

I'm trying to increment a weapon's attack damage

private void enhanceGear(ItemMeta meta, Attribute attribute, int level) {
    Collection<AttributeModifier> modifiers = meta.getAttributeModifiers(attribute);

    if (modifiers != null) {
        for (AttributeModifier modifier : modifiers) {
            if (modifier.getName().equals("smithingEnhancement")) {
                meta.removeAttributeModifier(attribute, modifier);
            }
        }
    }

    meta.addAttributeModifier(attribute, new AttributeModifier("smithingEnhancement", level, AttributeModifier.Operation.ADD_NUMBER));
}
...
enhanceGear(meta, Attribute.GENERIC_ATTACK_DAMAGE, level);
ivory sleet
#

Well you know how you hav setters

ornate patio
#

but then all of this shows up

ivory sleet
#

Because of that, there is no real need to actually do anything in ur constructor

#

Instead I would go with another void method that reads from a configuration section

worthy moat
ivory sleet
#

I want u to delete ur constructor in that class

#

Instead use a method to set the values of the fields from ur config

worthy moat
#

the empty one? probably not the one with the COnfiguration map

compact haven
#

the empty one, yes

#

oh but wait pepeThink

#

conclube if he deletes that one then he can't do his weird design

#

oh I understand what you mean now

worthy moat
#

but first i want to try and see if it works

ivory sleet
#

Yeah, I just thought that since the class itself is mutable by nature, the reads and writes should follow the pattern he chose initially

compact haven
worthy moat
#

wait so as far as I understood

#

I just have my setter which gives the value to my var....And in my write method I manually do Config.set(Something.spawnPoint, spawnPoint) and this for each value?

#

I ve never worked with Serializing...I just wanted to write a MinecraftPlugin and save something....This is so complicated if you never done something with yml

ivory sleet
#

Let me write a sample

ornate patio
#

i thought an attribute modifier would MODIFY the existing value

worthy moat
#

thanks a lot man

magic glacier
#

how to get the uuid of the player if he is offline