#help-development

1 messages · Page 1098 of 1

eternal oxide
#

The client extrapolates a LOT of movement so I'd not be surprised

torn shuttle
#

that kinda sucks

drowsy helm
#

Yeah body movement is somewhat relative to a minimum head rotation threshold

pseudo hazel
#

tf are u on about

wet breach
#

says the unverified

thin frost
#

Isnt Coll sending crakced minecraft link?

pseudo hazel
#

lmao

#

maybe click the link?

slender elbow
#

lol

torn shuttle
#

mods ban this filth

young knoll
#

You should click the link for more information!

torn shuttle
#

classic twitter user brain

pseudo hazel
#

but yeah honestly I think the mods should ban coll for sending such a link /s

#

well

#

its more like if you take a bit more time to read what was actually said, and by who it would make more sense why they send that

sterile breach
#

How can I get a block NBT should I use nms?

pseudo hazel
#

blocks dont have NBT

sterile breach
#

TileEntity I mean, like a chest

young knoll
#

I mean you can use NMS

#

but

#

?xy

undone axleBOT
sterile breach
#

I am using packet events, to send a chunk data packet I need to give an array of TileEntity but TileEntity object dont really exist for spigot, there doesn't seem to be a method for builds so I have to do it myself from the nbt of the tiles entities

#

so I have to use nms?

river oracle
#

TileEntities exist for spigot

#

Check out TileState

sterile breach
#

thanks

sterile breach
# river oracle Check out TileState

Block b = e.getBlock();
TileState tileState = (TileState) b.getState();
System.out.println(tileState.getBlockData().getAsString());

I am getting minecraft:chest[facing=west,type=single,waterlogged=false]
its nbt?

worldly ingot
#

You can't get the NBT from a tile entity, nor construct one

#

You would have to do it from server internals

sterile breach
#

I see

worldly ingot
#

You can cast a TileState to a CraftBlockEntityState and call getSnapshotNBT() to get the NBTTagCompound() of the snapshot data (which is probably all you need)

#

Then there's a loadData(NBTTagCompound) which will load the snapshot

hybrid turret
#

when using the data guide, i keep getting the following error when logging in (for PlayerData)

#

?paste

undone axleBOT
hybrid turret
#

it didn't do that from the beginning

#

but now fsr it does, the event is suddenly null and i have no idea why

final ore
#

Can someone pls help me make a plugin for me to add custom end armour with recipes and a crystal and ingot cause I have tried and it doesn't work

chrome beacon
#

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

chrome beacon
#

?paste your code

undone axleBOT
rough hinge
final ore
rough hinge
#

what a complication

river oracle
rough hinge
final ore
river oracle
#

I hate when my projects have more than one file

#

you know what if something isn't working about your code. Send the stacktrace, send the related code to the stacktrace. Then we can actually help you

rough hinge
river oracle
#

No one will be making your plugin for you unless you pay them

tardy delta
wary harness
#

So I am making discord bot for my plugin
now I am thinking should each user create there own bot and add its token to config file?

#

or should I just create my own bot

#

hard coded its token in plugin

river oracle
#

you should not host your own bot. Imagine you do and your token is in the plugin

chrome beacon
#

config

wary harness
#

and each user could invite my bot

river oracle
#

I'll decompile it

#

take your token

rough hinge
river oracle
#

and boom you're token is leaked

wary harness
#

ok I see

#

but could I make it so it is using my bot some how without adding token to plugin

river oracle
#

no

#

any way you provide your token to some random call is a vulnrability

tardy delta
#

let the user add their own token

river oracle
#

make the user add their own token

tardy delta
#

if their are smart enough to use plugins, they are smart enough to make a discord bot

wary harness
#

ok thanks

#

for info

river oracle
wary harness
#

but I got slight problem

river oracle
#

but regardless you should force the user to add their own token

wary harness
#

if they use plugin on multiple server would that not create multiple instance of bot

hybrid turret
river oracle
wary harness
#

should bot be hostes on one instance

river oracle
#

that's the thing with development there are always those damn plugins

#

depends on your scenario really

#

I mean there are times where spinning up multiple bots under the same token is no big deal, it really depends what the bot is doing

wary harness
#

well just messaging one changel when players buys things in gui

#

shop

river oracle
#

yeah you'll be fine with multiple bot instances

#

I don't see how that would cause issues

wary harness
#

I was curious how whole think work

#

have no expiriance with it

#

for example if u run SocketServer instance it can only be one on same port

river oracle
#

CafeBabe is actually 2 bots under 1 token 😉 so you can do it

wary harness
#

thanks for all info

river oracle
rough hinge
#

@river oracle

river oracle
#

don't ping me

burnt oriole
rough hinge
river oracle
#

I didn't answer because I didn't feel like it

rough hinge
river oracle
#

idk didn't read seemed like an ambiguous question and I don't feel like answering

river oracle
#

is there a stacktrace?

burnt oriole
#

although it just says

#

in game opening then it dont open

river oracle
#

I don't think it says that

#

going to need a stacktrace

olive lance
#

Is there some way to have a method run in the event a runnable is cancelled?

#

from the context where you created it

river oracle
#

not sure what you mean byt his

olive lance
#

im using runnables and theres various things i am looking for and cancelling the task in certain cases. I wanted to send a message to the player when its cancelled but it would be the same for any reason it would be cancelled

river oracle
#

just make a callback

#

you can wrap BukkitRunnable to store some information on creation

#

you could also wrap BukkitTask too

#

depends how you wanna do things

olive lance
#

What would be the difference effectively between the 2? I am looking at just wrapping runnable

burnt oriole
river oracle
#

its whenever you run it

#

or if the server loads

#

depends when an error occurs

olive lance
#

does playermoveevent fire when swinging a sword

sterile breach
# worldly ingot Then there's a `loadData(NBTTagCompound)` which will load the snapshot

like this?

    @EventHandler
    public void onBreak(BlockBreakEvent e) {
        TileState tileState = (TileState) e.getBlock().getState();
        CraftBlockEntityState craftBlockEntityState = (CraftBlockEntityState) tileState;
        CompoundTag compoundTag = craftBlockEntityState.getSnapshotNBT();

        NBTCompound nbtCompound = new NBTCompound(); //packet events nbt
        for(String key: compoundTag.getAllKeys()) {
            nbtCompound.setTag(key, new NBTList(NBTType.LIST, (List) compoundTag.get(key)));
        }
    }

rough hinge
#

Bukkit.getLogger().log(Level.WARNING, e.getMessage()); is thread safe?

eternal oxide
#

depends on teh Bukkit version

#

Log4j is thread safe, but Bukkit has not always used it

#

seems SLF4j is too, so I'm going to say yes.

wary harness
#

just tired to invite my bot in discord server and it is not showing up

eternal oxide
#

Your bot obtained sentience.

wary harness
#

I should use this link

#

I guess

#

and select server

vast ledge
#

What does that have to do with spigot development tho?

hidden spade
#

Does anyone here know how exactly the custom crop plugins work, from what ive gathered they use blockentities but from what i can see i wouldnt be able to display the crop properly

vast ledge
worthy sable
#

hello, im developing a spigot plugin which modifies the item from fishing

vast ledge
#

Cool

worthy sable
#

but

#

i got problem

#
    public void reload() {
        this.clear();
        ConfigurationSection cfg = null;
        for (String key: getLootConfig().getKeys(false)) {
            cfg = getLootConfig().getConfigurationSection(key);
            if (cfg == null) continue;
            plugin.getLogger().info(cfg.toString());
            add(key, cfg.getItemStack("item"), cfg.getDouble("weight"));
        }
    }
vast ledge
#

What is 'getLootConfig()'

worthy sable
#

when i deserialize my config file to ItemStack, it throws my a error

[22:40:33 ERROR]: [org.bukkit.configuration.serialization.ConfigurationSerialization] Could not call method 'public static org.bukkit.inventory.ItemStack org.bukkit.inventory.ItemStack.deserialize(java.util.Map)' of class org.bukkit.inventory.ItemStack for deserialization
java.lang.IllegalArgumentException: Material cannot be null
vast ledge
#

The given material returns null

worthy sable
#
private ConfigurationSection getLootConfig() {
        return plugin.getConfig().getConfigurationSection("LootItems");
    }
vast ledge
#

Or isnt present

worthy sable
#
LootItems: 
  salmon:
    weight: 100
    item:
      ==: org.bukkit.inventory.ItemStack
      type: SALMON
#

this is my config

hidden spade
chrome beacon
worthy sable
#

yes

worthy sable
#

i dont know why it said java.lang.IllegalArgumentException: Material cannot be null

#

cuz i wrote that type

#

and SALMON did exist in my mc version

#

btw theres a thing unnormally

#

[22:40:31 WARN]: [org.bukkit.craftbukkit.v1_20_R1.legacy.CraftLegacy] Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!

#

i got this warning

burnt oriole
vast ledge
#

What symbol?

tardy delta
#

SlashEffect, what dependency?

chrome beacon
worthy sable
#

i already set

#

api-version: '1.20' in plugin.yml

chrome beacon
#

Then you have another legacy plugin installed

torn shuttle
#

I just realized something mildly interesting

worthy sable
#

the only plugin i installed is my plugin

#

theres no other plugins

torn shuttle
#

if you use ai regularly you end up slowly building up a resistance against confidence men

torn shuttle
#

because AI is always 100% confident no matter what

worthy sable
#
> plugins
[22:50:18 INFO]: Server Plugins (1):
[22:50:18 INFO]: Bukkit Plugins:
[22:50:18 INFO]:  - FishInControl
glad prawn
#

show your plugin.yml

worthy sable
#
name: FishInControl
version: '${project.version}'
main: net.fishport.fishincontrol.FishInControl
api-version: '1.20'
folia-supported: true

commands:
  fishincontrol:
    aliases: [fic]
    usage: /<command> reload
    permission: fisnincontrol.admin

permissions:
  fisnincontrol.admin:
    description: Allows reloading config file with /fisnincontrol reload.
    default: op

  fisnincontrol.bypass:
    description: Bypass item replacement.
    default: false

  fisnincontrol.forced:
    description: forced item replacement.
    default: false
rough drift
#

I like your style magic man

worthy sable
#

lol, i just forgot to add it

rough drift
#

ah wait

#

I'm sorry

#

you're using paper

torn shuttle
# rough drift confidence men?

basically charismatic people who seem 100% certain of what they're talking about no matter what even if they're wrong and bullshitting, it's somewhat of a sales / stocks term

worthy sable
rough drift
rough drift
worthy sable
#

i have to create paper-plugin.yml?

rough drift
#

?whereami

hushed spindle
#

apparently TradeSelectEvent#getMerchant() instanceof AbstractVillager always returns false, how does this work?

rough drift
#

magic

torn shuttle
worthy sable
#

omg

#

im so sorry

rough drift
#

lmao

burnt oriole
tardy delta
#

where do you expect that class to come from

chrome beacon
#

it's not really an entity

hushed spindle
#

it has abstractvillager as subinterface though

chrome beacon
#

getMerchant will return CraftMerchant

chrome beacon
#

might be an implementation oversight

#

?jira

undone axleBOT
chrome beacon
#

^^ make a report ig

#

Looks like CraftMerchant just wraps the villager

#
((Villager)((CraftMerchant) event.getMerchant()).getMerchant()).getBukkitEntity()
#

would work

#

but that's a bit hacky

hushed spindle
#

yeah right now im just avoiding using Villager or Merchant alltogether and using them as entities instead

worldly ingot
#

I want to say CompoundTag has a getter that gets things as an NBTBase and you can set those instead, or probably even a copy method to copy one tag's contents into another

#

I can't remember off hand though

worthy sable
quaint mantle
#

Bro 💀

#

Go to paper discord server

worthy sable
#

sorry, im using spigot api to develop and testing on spigot 1.20 server idk why i need to ask in paper discord now☠️

tardy delta
#

material cannot be null

worthy sable
#

but i did set it

#

ill show you my code

tardy delta
#

put in null checks then

worthy sable
#
    public void reload() {
        this.clear();
        ConfigurationSection cfg = null;
        for (String key: getLootConfig().getKeys(false)) {
            cfg = getLootConfig().getConfigurationSection(key);
            if (cfg == null) continue;
            plugin.getLogger().info(cfg.toString());
            add(key, cfg.getItemStack("item"), cfg.getDouble("weight"));
        }
    }

    private ConfigurationSection getLootConfig() {
        return plugin.getConfig().getConfigurationSection("LootItems");
    }
#

i cant because its Configuration deserialize

#
LootItems: 
  salmon:
    weight: 100
    item:
      ==: org.bukkit.inventory.ItemStack
      type: SALMON

my config

tardy delta
#

item is incorrectly serialized maybe

worthy sable
#

how

#

its internal method

tardy delta
#

idfk, thought you were running paper, ItemStack::material nullable maybe

#

im thinking thats not even the correct config

worthy sable
#

im running spigot

chrome beacon
#

otherwise it will default to legacy

worthy sable
#

oh

#

how do i do that?

chrome beacon
#

I don't recommend doing it manually

#

v: 3953

#

is what it's generating for me

worthy sable
#

omg what is this

#

is there other ways?

#

btw i did set api-version in plugin.yml

eternal oxide
#

create ItemStack in code, then getConfig().set("path", itemStack);

chrome beacon
#

^^ will add the correct version info

worthy sable
#

okay

#

ill try it

hushed spindle
#

is there like a villager trade prepare event

#

so that i can change a trade's output without changing the trade itself

chrome beacon
#

oh didn't read second part

#

Doesn't look like it

hushed spindle
#

setting item index 2 to something else doesnt seem to actually change it weirdly enough

worthy sable
chrome beacon
worthy sable
#

hold on

eternal oxide
#

legacy? you do not have a version in your plugin.yml

worthy sable
#

i have 😭

eternal oxide
#

did you save the config after you set the itemstack?

hidden spade
#

Does anyone here know how to create a custom crop similar to that found in oraxen with custom models aswell?

worthy sable
#

it throws me this error

eternal oxide
#

else your config is still old

worthy sable
#

yes

#

still old

eternal oxide
#

then you have done nothing

chrome beacon
#

^^

#

As I said the version needs to be in the config

#

or it will default to legacy

worthy sable
#

wait

#

you mean plugin.yml

chrome beacon
#

no

worthy sable
#

oh

chrome beacon
#

And I don't mean api-version

eternal oxide
#

your item: in your config.yml is broken, stop using it

chrome beacon
#

Do what ElgarL said ^^

eternal oxide
#

replace it with getConfig().set

worthy sable
#

ok ill keep config.yml empty

#

and my code will be

ItemStack itemStack = new ItemStack(Material.BUCKET);
        getConfig().set("aaa", itemStack);
#

let me try

eternal oxide
#

and saveConfig()

chrome beacon
#

Could just set your actual path

worthy sable
#

okay

ItemStack itemStack = new ItemStack(Material.BUCKET);
        getConfig().set("LootItems.bucket", itemStack);
        saveConfig();
#

Material cannot be null

eternal oxide
#

you are still trying to read yoru old Item

worthy sable
#

no

#

its empty

#

wait

#

it did write

eternal oxide
#

?paste your onEnable

undone axleBOT
worthy sable
#

but why theres error

sterile breach
#

to make plugins using nms compatible with multpliqe version, I should import "all" nms version and choose it depending on the one I want to execute, is there a libs/api for that?

eternal oxide
#

because somewhere your old code is still reading junk

worthy sable
chrome beacon
#

and what's the error

worthy sable
#

how can it read the old file

eternal oxide
#

that code will not throw that error

worthy sable
#

☠️

eternal oxide
#

on Enable line 16

worthy sable
#

this is line 16

#

☠️

chrome beacon
#

getConfig would try to deserialize

eternal oxide
#

it does

#

first touch of config deserializes all objects

rough hinge
worthy sable
#

config.yml is empty before it set, i swear

eternal oxide
worthy sable
#

yes

rough hinge
worthy sable
#

maybe the problem is
Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!?

chrome beacon
#

That happens when you use getItemStack when the item stack has no version set

#

as I said it will default to legacy

eternal oxide
#

its impossible that it is empty as that error can;t try to deserialize an ItemStack from an empty config

worthy sable
#

i can send you the jar

#

and test it yourself

#

i swear nothing in it

chrome beacon
#

Delete the config entierly

eternal oxide
#

an empty config would do absolutely nothign when used with getConfig()

#

do you have a broken config in your plugin.jar?

worthy sable
#

ill replace it with a empty config file

#

empty

#

and

#

wait

#

your right

#

finally 😭

#

so i have to define this when i setting it manually?

chrome beacon
#

yes

worthy sable
#

okay

#

thankyou guys!

#

very much!

eternal oxide
#

its much easier if you create the items in code then save them. as you can do everythign without having to write it all maually

karmic falcon
#

guys, i saw a PlayerDamageEvent on a forum but i cant find it

#

was it removed or smthn?

olive lance
torn shuttle
#

what the hecc

#

I just noticed people are stealing my style in their update logs

#

I will sue for style theft

pine crest
#

lil bro you sure it was ever yours to begin with?

rough hinge
chrome beacon
#

no

pine crest
#

variables dont just become null

eternal oxide
#

Do not store Players. We've told you many times

pine crest
#

but that said the Player object is considered invalid once logged out, that is no longer in session so u should release it

rough hinge
#

GlobalPlugin.INSTANCE.getUserService().get(player.getName()).thenAccept(globalUser -> {

        if (user.getPlayer().isOnline())

        switch (user.getRadiation()) {
            case 100 ->
                    BukkitUtils.sendTitle(player, lang.getString(globalUser.getLanguageType(), "title"), lang.getString(globalUser.getLanguageType(), "subtitle1"), 20, 60, 20);
            case 300 ->
                    BukkitUtils.sendTitle(player, lang.getString(globalUser.getLanguageType(), "title"), lang.getString(globalUser.getLanguageType(), "subtitle2"), 20, 60, 20);
            case 500 ->
                    BukkitUtils.sendTitle(player, lang.getString(globalUser.getLanguageType(), "title"), lang.getString(globalUser.getLanguageType(), "subtitle3"), 20, 60, 20);
        }
    });
pine crest
#

Its really that easy lil bro

rough hinge
# pine crest Its really that easy lil bro

the player can log out until thenaccept is executed, although the user is no longer in the cache, I can still use user#getplayer and check if he is online to send the title

pine crest
#

what does user::getplayer do?

rough hinge
rough hinge
pine crest
#

Show code

#

or i dip

rough hinge
pine crest
#

alright thats poor code

#

Change it up and use UUID

#

And then you can use Bukkit.getPlayer(uuid)

#

If Bukkit.getPlayer(uuid) is null => offline

#

im dipping now, good luck and listen to my advice lil broski

rough hinge
#

If User is only in the cache if he is online, then I don't need to do this

pine crest
#

extremely needed

rough hinge
#

If User is only in the cache if he is online, then I don't need to do this

hazy parrot
#

why not just use uuid or weakref

rough hinge
#

doing BUkkit.getplayer(uuid) is just one more load every time

rough hinge
hazy parrot
#

?

pine crest
eternal oxide
#

Holding stale Player references is a memory leak

pine crest
#

Your code legitimately sucks

rough hinge
# hazy parrot ?

I don't know if you know but accessing a map always has a cost

pine crest
#

I said it

#

switch it up to uuid

hazy parrot
#

XD

pine crest
#

nobody is gonna help you otherwise

hazy parrot
#

seems like this is rude one, im out

rough hinge
rough hinge
eternal oxide
#

He argues over everything

rough hinge
pine crest
rough hinge
inner mulch
#

i dont know the context, but maps are faster than lists when trying to access somethign

pine crest
#

Not true

#

On ArrayLists that holds false

hazy parrot
#

It is

rough hinge
inner mulch
rough hinge
#

this is a context

#

no make senses storage the uuid

pine crest
#

because ur cache class sucks and u gonna shoot urself in the foot

#

uuid is legit THE PRACTICE you use

pine crest
#

The Player class is only a context api class you use to invoke behavior on players

inner mulch
eternal oxide
#

Worrying about the access time of a Map when you are holding stale Player references is asinine.

pine crest
inner mulch
#

@rough hinge just use a player reference as long as you clean it up

#

tbh i dont see the reason for the uuid debate

pine crest
#

but thats besides the point

eternal oxide
#

yep

rough hinge
pine crest
#

You just don’t hold players

pine crest
#

I don’t understand how you can sit here and have the audacity to argue when you’re shooting yourself in the foot as we speak

#

Shameless

#

im out

inner mulch
pine crest
#

There are like 10 people explaining it to them

hazy parrot
#

i dont get why ur upset if he asks why something is
not true

pine crest
#

If they cant grasp the situation, thats on them

hazy parrot
#

he is rude

inner mulch
#

oh

rough hinge
inner mulch
#

i didnt see that

pine crest
#

I am rude

eternal oxide
inner mulch
#

if he is rude you can be mad ofc

#

okay in this case i didnt have enough context

pine crest
#

Its alright

#

skibidi gooblers forgive you

rough hinge
vast ledge
#

yes

pine crest
#

Well either way you’re storing it like a potato

pine crest
vast ledge
eternal oxide
#

You already said earlier you are on 1.8 using player names as keys, fetching a user object which holds a Player reference

vast ledge
#

And use UUIDs instead of names

rough hinge
hazy parrot
#

i bet he is using cracked mc

#

XD

eternal oxide
#

he is

pine crest
#

ola I still cant grasp you out of touch with reality you are when Elgar, Goksi, Bedless and Salvation is legit giving you free knowledge and improvements

#

its beyond shameful

pseudo hazel
#

you are lucky that you receive help in the first place haha

pine crest
#

bye

chrome beacon
#

Yeah just block him and move on

#

Just like I did days ago

eternal oxide
#

he was arguing with 7Smile7 earlier about async 🙂

slender elbow
#

a tale as old as time (since 01/01/1970)

pseudo hazel
#

yeah

eternal oxide
#

lol, I get teh reference 🙂

pseudo hazel
#

before that time didnt exist

eternal oxide
#

when time equals zero

torn shuttle
#

it must be because they're all dated from 01/01/1970

#

and it was good 😎

dull schooner
#

hey guys
im trying to detect when a player middle clicks an inventory, but the event.getClick() never returns a middle click, only left and right

eternal oxide
#

it will probably only fire for a creative inventory

#

if it does at all

dull schooner
#

is there a way for me to check it on survival?

eternal oxide
#

does the event trigger at all for middle?

#

what does middle click do in an Inventory?

dull schooner
#

hm

#

if the player has an item on the cursor it triggers

dense falcon
#

I would like to know, how can I tp to a player on another server, imagine this:

  • bungeecord
  • lobby-01
  • lobby-02
    I am from lobb-01, I want to be TPed to a player on lobby-02, how may I do? 🤔
eternal oxide
#

transfer using PMC

#

where you turn up will be upto the server you are going to

#

?pmc

onyx fjord
#

why is javadoc rendering popup so poor and weird with kotlin libraries?

#

i dont even know what exception would throw

chrome beacon
#

Try downloading docs 🤷‍♂️

chrome beacon
#

might give better description

onyx fjord
#

i did

remote swallow
#

that looks correct to me

#

that is just how kotlin looks

onyx fjord
#

theres no way

remote swallow
#

public fun myMethod(myInput: String) : String { return myInput + " hello!" }

#

public String myMethod(String myInput) { return myInput = " hello!"; }

rough hinge
#

I can do a completablefuture and then use the value returned with thenaccept and keep checking how the player executed the command, for example if he only executed /money it shows his balance (his balance based on the value returned by the future), if he typed /money <nick> it returns the balance by the value returned by the future, but for example if nickOfflinePlayer#hasPlayedBefore returns false, I will not use the value returned by the future. Do the developers choose to do a completablefuture in the entire command even in some cases not using the returned value, or do they make a separate completable future if there is a case that will not use this returned value?

blazing ocean
onyx fjord
#

So kotlin people don't write proper docs?

sterile breach
#

its possible to load a chunk who's in another world?

#

than the player

worthy yarrow
#

Yeah

#

Pretty sure that method is contained within world not player

sterile breach
#

I have to do it with packets so its okay

worthy yarrow
#

Uh

#

I mean I’d imagine its handled the same way so it should be fine

eternal oxide
#

what?

#

you want to load a Chunk in a different world to the player using packets?

sterile breach
#

yes

#

its a long history

eternal oxide
#

can't be done

#

chunks exist on the server. They are sent to the client

sterile breach
#

and a great deal of distress in the same world?

sterile breach
eternal oxide
#

that makes no sense

sterile breach
#

im making a repaly system who restore old chunks To avoid problems, it's easier to send them in advance.

eternal oxide
#

the client (as far as I know) does not understand worlds.

#

it can;t hold a chunk in memory for a world its not in

sterile breach
#

it seems to me that because, for example, when you change world there is a screen, whereas when you change world there is a screen

#

but you have reason

eternal oxide
#

as far as I know teh client only references the current world at a time

sterile breach
#

packet just contain X and Z nothing about world

eternal oxide
#

yes

#

so if you send a chunk for a different world, it will not understand it is a different world. it will take it as the current world

worthy yarrow
#

Can you not send packets as if you’re the server? Or am I misunderstanding something about mc protocol

torn badge
#

What even is the point of this

eternal oxide
#

quite

worthy yarrow
#

Oh I think I’m just dumb

#

Who’s gonna receive the packet from the server kek

sterile breach
sterile breach
eternal oxide
#

I've no idea what you are doign either

sterile breach
#

I like to feel mysterious

worthy yarrow
#

I think I was just being dumb

sterile breach
#

no seriously, for replay I want to restore old blocks and chuks so I send the old chunk to the client

sterile breach
eternal oxide
#

I see what you are doing

#

but any interaction by the client will cause issues on teh server if the current world is not updated with the new data

worthy yarrow
eternal oxide
#

his "other" world is a backup

worthy yarrow
#

Oh right

eternal oxide
#

the worlds original state

sterile breach
eternal oxide
#

generally they just replace any changed blocks to reset the chunk

sterile breach
#

yes

#

the worry is that if all the chunk has been changed it will send more or less 70 000 packets block update (its a really bad idea)
most plugins require you to define a "camera" zone in advance, so it's easier to modify blocks in this case.

worthy yarrow
#

Why differ from other implementations then?

rough hinge
tardy delta
#

what

rough hinge
# rough hinge https://imgur.com/a/RiLNPc7

The code is always executed in the same thread, correct? The code inside the task? If you just modify the hashmap, there is no need for it to be concurrenthashmap, right?

rough hinge
tardy delta
#

getRanking is subject to race conditions

rough hinge
torn shuttle
#

everyone's racing for the ranking

rough hinge
rough hinge
worthy yarrow
#

Concurrent just means only a single thread can access it at a time iirc

tardy delta
#

imagine a reallocation happens due to a put

worthy yarrow
#

please enlighten me con

ivory sleet
#

In this case it means it supports concurrent operations, like put, get and compute (read-modify-write) at the same time on multiple threads

tardy delta
ivory sleet
worthy yarrow
#

Wait so there are differences of the definition based on the usecase

tardy delta
#

ofcourse?

ivory sleet
#

I mean there is no harm in using a CHM in a single threaded environment, but its slower

tardy delta
#

differences of the definition on the usecase
what

worthy yarrow
#

Con confused me with the "in this case"

#

Is this how the concurrent map works always?

tardy delta
#

concurrent hashmap partially locks itself

ivory sleet
#

I described its semantic reassurance

#

Much like you need to use AtomicReference if u want to read, write and read-modify-write to variables that may be operated on with the aforementioned operations on multiple threads

#

or well not need, you can hop over AtomicReference, but you lose atomicity and memory visibility (unless you use other tools like volatile, synchronized or VarHandle etc)

worthy yarrow
#

Hmm alright

slender elbow
#

that's why I use AtomicReference of an ImmutableMap :sunglas:

ivory sleet
worthy yarrow
#

Other than performance as an example, what other benefits are there from doing stuff from multiple threads?

ivory sleet
#

but yea good thing Emily points out sort of, immutable is free thread safety

tardy delta
worthy yarrow
#

kek

slender elbow
#

especially when it involves networking and such

#

for example, the game has a tick loop, but it also has to wait for connections to read them

worthy yarrow
#

So in terms of spigot, when running an "async" task, is this task actually ran on another thread? And how is this new thread (if any) handled before, during, and after said operations

slender elbow
#

tasks dispatched through the scheduler (runTaskAsync) do run on a separate thread

torn badge
#

Yes, spigot is using a thread pool internally to run your tasks

worthy yarrow
#

So then what does "async" actually mean?

slender elbow
#

it's basically just a thread pool that waits for tasks in a queue to run them, then once you queue a task the thread runs them, and once it's finished it becomes free and waits for a new task

slender elbow
worthy yarrow
#

Ah ok gotcha

slender elbow
#

"sequential" might be a word you could think of

worthy yarrow
#

Concurrency is hard man D:

slender elbow
#

println("1")
runTask(() -> println("2"))
println("3")

1 and 3 are synchronous, but 2 is asynchronous as it doesn't run with the current flow of execution, although it runs on the main thread

slender elbow
torn shuttle
#

is there a spigot way to make a mob not quite not have ai but not do any movement including turning around

#

I know I could probably lobotomize it via nms

worthy yarrow
#

Yeah I always thought the concurrent map meant only a single thread can read/write/read-write-modify at a time

torn shuttle
#

I don't want to go that high effort either

viscid carbon
#

Question:

Should homes be an object?

public class Home {

    private final Home home;
    private final Location location;
    private final double x, y, z;
    private final World world;

    public Home(Home home, Location location) {
        this.home = home;
        this.location = location;
        this.x = location.getX();
        this.y = location.getY();
        this.z = location.getZ();
        this.world = location.getWorld();
    }

    public Location getLocation() {
        return location;
    }

    public Home getHome() {
        return home;
    }

    public World getWorld() {
        return world;
    }
    
    public double getX() {
        return x;
    }

    public double getY() {
        return y;
    }

    public double getZ() {
        return z;
    }
}```
lost matrix
#

I think a home should def be an object. But why do you pass a Home to the constructor of a Home?

viscid carbon
#

instead of a string?

lost matrix
#

Also x,y,z and world are redundant

torn badge
#

How do you even create a Home instance if it requires another home instance lol

slender elbow
lost matrix
#

-.-

slender elbow
#

doll houses

tardy delta
#

Location already stores a world

lost matrix
#

Yeah almost checks out

viscid carbon
#

So instead of passing Home it should just be a String?

tardy delta
#

new Home(new Home(new Home(null, loc), loc), loc) lol

worthy yarrow
#

Think about in game

#

They run the command /home create “name” usually right?

lost matrix
#

Yes, a String makes more sense

viscid carbon
#

i just need to remember k.i.s.s

#
public class Home {

    private final String home;
    private final Location location;

    public Home(String home, Location location) {
        this.home = home;
        this.location = location;
    }

    public Location getLocation() {
        return location;
    }

    public String getHome() {
        return home;
    }
}```
lost matrix
#

rename your home field to something better fitting like name or homeName

eternal oxide
#

getName

lost matrix
#

Because the string is not actually your home. Its just its name.

tardy delta
#
record Home(String name, Location loc)
#

sad that you need a whole file for that

sterile token
#

hii, how would you fix the issue with color codes support on components? I really need a solution to that issue, for some reasons when applying color codes

tardy delta
#

lemme guess? there is no support?

sterile token
#

Its an issue which has been there for years and years, and im not sure why they havent already fixed

tardy delta
#

not sure if you can solve that with a component builder

sterile token
#

what i was thinking is to clone the component which has color codes, replace each color by hand and map it into ChatColor.COLOR and finally put all into a new component

worthy yarrow
# viscid carbon you make sense lol

Well reverse engineer a little bit, what is your end goal. And tbf just a bit simpler to think about when it comes to all the lingo you probably come across

sterile token
#
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.style.Style;

Component component = new TextComponent("first line").setStyle(Style.EMPTY.withColor(Formatting.RED));
Component secondLine = new TextComponent("second line").setStyle(Style.EMPTY.withColor(Formatting.BLUE));

Component combined = component.append("\n").append(secondLine);

player.sendMessage(combined, player.getUUID());

What the hex is that, thats not mc for sure

tardy delta
#

nms

sterile token
#

oh conclure

#

you know about the issue right? explain me please why spigot didnt fix till

#

Issue
When you use direct color codes (&c or any color code) on text that spans multiple lines, the color is applied only to the first few lines and then not to the following lines. This occurs because the conversion between text formats may not handle line changes correctly, causing the color to be "lost" in the process.

Cause
This may be due to how the processing and conversion of multi-line text is done. Color codes & may not be handled correctly in texts that include line breaks, and this may lead to formatting only being applied to the initial part of the text.

Here is the issue with good english described @tardy delta

#

that only happens in components

tardy delta
#

what happens when you do new componentbuilder().append(line 1).color(x).append(\n line 2).color(y)

sterile token
#

let me try it and seem what happens

#

thanks for being kinfull and not getting mad cause of tagging

tardy delta
#

variables my man

viscid carbon
#

i got told not to store getX, etc

#

i dont know the reason behind it

eternal oxide
#

you don;t need it

#

its a Home so you will be teleporting (I assume) so you only need the location

#

the Location itself has getX etc

viscid carbon
#

i store the world, x, y, z in the file not the whole location

karmic falcon
#

hi,i have a uick question, am i supposed to unregister my listeners in onDisable() ?

viscid carbon
#

nope

karmic falcon
#

alr ty

lost matrix
#

They get unregistered automatically

viscid carbon
#

unless you're saving stuff then theres no reason

sterile token
viscid carbon
#

i know its easier to do and get and set

tardy delta
#

getLocation() buddy

sterile token
#

you can use the approach and use that time to build your goals

viscid carbon
#

good point, i just like to make things harder on myself i guess. lol

sterile token
viscid carbon
#

Yeah, i've spent like a week working on a player data object and @river oracle is like stop being stupid lol.

#
    public void setHome(String name, Location location) {
        Home home = new Home(name, location);
        fileHandler.getConfig().set("Location", home.getLocation());
    }```
sterile token
sterile token
viscid carbon
#

fileHandler.getConfig().set(String.format("Homes.%s.Location", home), home.getLocation());

#

my bad

#

lol

sterile token
#

be carefull

#

im still seeing it wrong

#

because a player can have many homes

#

or what you doing exactly? give more context

#

Shouldnt be saved like?

Homes:
 playe-uuid-one:
  home-uuid-1:
   name: "" 
   location: bla bla
  home-uuid-2:
   name: "" 
   location: bla bla
 playe-uuid-two:
  home-uuid-1:
   name: "" 
   location: bla bla
  home-uuid-2:
   name: "" 
   location: bla bla
...
viscid carbon
#

No the files are saved seperately.

sterile token
viscid carbon
#

Yeah sorry, that would be confusing lol

sterile token
#

i seen smile typing too much, i wish i could know what he is typing

viscid carbon
#

hes crying looking at my code

#

😂

lost matrix
#

You should separate your persistence handling from your data.
First set up the data structure containing your data in memory, then tinker with persisting it to configs etc.
Write a manager class:

public class HomeManager {
  private final Map<UUID, List<Home>> loadedHomes;

  public void loadHomes(UUID playerId)...
  public void saveHomes(UUID playerId)...
}

or

public class HomeManager {
  private final Map<UUID, Map<String, Home>> loadedHomes;
}

And then come back.
When a player joins -> load his homes
When a player quits -> save his homes

While a player is online, you only interact with your manager class.

viscid carbon
#

My UserManager does just that. my User class saves lol

#

private final HashMap<UUID, User> playerData = new HashMap<>();

lost matrix
#

So does a User have a List<Home> in it?

sterile token
tardy delta
#

(extend ConfigurationSerializable)

lost matrix
#

*implements

#

Anyways, if you want to truly not care about your serialization, you can throw your objects at Gson and see what sticks.

sterile token
#
public class PlayerData implements ConfigurationSerializable {
    
  private String playerName;

    public PlayerData(String playerName) {
        this.playerName = playerName;
    }

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

    @Override
    public Map<String, Object> serialize() {
        Map<String, Object> data = new HashMap<>();
        data.put("playerName", playerName);
        return data;
    }

    public String getPlayerName() {
        return playerName;
    }

    public void setPlayerName(String playerName) {
        this.playerName = playerName;
    }

}```
And then just use Config$set() and Config#get() by using object casting
#

smile, are you free? if you would want to read the issue i would like to know if spigot will fix or not?

lost matrix
#

Hmm...

raw epoch
#

I don't know why, but this recipe isn't working (the recipe exist but the result slot is empty if i don't fill the "*" items) :

@Override
    public ShapedRecipe getRecipe() {
        ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(HekaCite.getPlugin(), "decapitator"), this.build());

        recipe.shape("*d*","*D*","*N*");
        recipe.setIngredient('d', Material.DIAMOND);
        recipe.setIngredient('D', Material.DIAMOND_BLOCK);
        recipe.setIngredient('N', Material.NETHERITE_INGOT);

        return recipe;
    }

(cause of undefined items)

But, this one works and it has undefined items:

@Override
    public ShapedRecipe getRecipe() {
        ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(HekaCite.getPlugin(), "crab_rune"), this.build());

        recipe.shape("aia","imi","aia");
        recipe.setIngredient('m', Material.EMERALD);
        recipe.setIngredient('i', Material.ARMADILLO_SCUTE);
        return recipe;
    }

Can someone help me 🙏 ?

echo basalt
#

I've been avoiding nesting maps :)

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.

lost matrix
sterile token
#

what do you mean exactly by not working? describe in "deep" what happens

echo basalt
#

detail not deep

lost matrix
echo basalt
#

smh

#

and ?paste instead of making a mess

#

?paste

undone axleBOT
sterile token
raw epoch
#

thx a lot GL !

lost matrix
#

And if you want to enforce empty slots, use spaces

echo basalt
#

🤔 gotta make a tournament system for a minigame network

#

should I make template vs instanced classes or just have empty entries

lost matrix
#

"d", "D", "N"
Works for

d## | #d# | ##d
D## | #D# | ##D
N## | #N# | ##N

but " d ", " D ", " N "
only works for

#d#
#D#
#N#
raw epoch
#

yeahh i see

viscid carbon
river oracle
#

Already better than before

viscid carbon
#

Thank you y2k for showing me. I didnt understand how to save till i thought about it and thats all User does lol

slate siren
#

Guys, I recently made a plugin with Kotlin, I get the head from the Minecraft-heads section with the command block. And when I said /addhead, I was saving this head. The server I set up via Windows was also fine, but I rented a server at Apex hosting and when I said /addhead there, it gives this error.l

#

An error occurred while saving the skull: null value in entry skull-owner-null

#

What's this?

#

There is absolutely no problem with the code, because I can download the head plugin and save any head

#

I don't only get things from the Minecraft-heads website.

ivory sleet
# worthy yarrow Other than performance as an example, what other benefits are there from doing s...

Well there is the io part, like file downloading, file operations, database calls etc, things that may take an arbitrarily long time to compute. Here concurrency is key, the fact that we can download a file and at the same time continue to run our app.

Then there’s the parallel part, that is often if you compute let’s say a very big mathematical task, such as multiplying a series of colossally large numbers (stupid example). This won’t take an arbitrarily long time, but heck does it take a long time. Here since multiplication is commutative by definition (=order does not matter), we can divide this into smaller problems, and then we can compute these smaller problems on different cores on the cpu at the same time (in parallel) if we have hardware that allows us to, this is far faster than to only let one core do all the work.

viscid carbon
#

How often do you guys think PlayerData should save?

#

5 minutes?

shadow night
#

Every WorldSaveEvent maybe? Or whatever it was called

#

Or was that forge

olive lance
#

when i push a commit to github through intellij for some reason it says BuildTools is the author of the commit. But Im logged into my account in settings

ivory sleet
#

you can save it after doing something with it

#

assuming you do it asynchronously

#

you can also save it optimistically

ivory sleet
#

meaning that you only save it if its currently not saving

viscid carbon
#

I do, but should i have a timer that saves it every x minutes?

ivory sleet
#

na

#

Sync buffering is usually not needed

olive lance
echo basalt
#

It depends

#

If it's a highly uh

#

volatile?

#

environment

#

where data changes a lot

#

Then saving once in a while is aite

shadow night
ivory sleet
# viscid carbon I do, but should i have a timer that saves it every x minutes?

The only time you realistically would wanna stick with running a buffer that syncs and saves all the data is if you for example don’t wanna bother the database constantly or ur file system, which is understandable if you aim to horizontally scale where you can compromise on high real time data availability lets say

olive lance
olive lance
#

ty

slate siren
blazing ocean
lost matrix
#

That seems excessive

blazing ocean
#

well you'll never have data losses

lost matrix
#

But you hammer your persistent storage medium

blazing ocean
#

it does deserve a little beating

#

and was this not for a db? i thought it was

tardy delta
#

you definitely deserve a little beating

blazing ocean
#

i love beating my postgres

lost matrix
#

Lets say you want to track the distance a player has traveled via a certain mount.
For this you use the PlayerMoveEvent with a delta. Imagine now starting a query for 20 players in the PlayerMoveEvent.

#

This will lead to problems in no time

blazing ocean
#

well that's what you cache stuff for

lost matrix
#

Caching writes?

blazing ocean
#

starting a query
writes

slate siren
#

Guys, I recently made a plugin with Kotlin, I get the head from the Minecraft-heads section with the command block. And when I said /addhead, I was saving this head. The server I set up via Windows was also fine, but I rented a server at Apex hosting and when I said /addhead there, it gives this error.l
An error occurred while saving the skull: null value in entry skull-owner-null
What's this?
There is absolutely no problem with the code, because I can download the head plugin and save any head
I don't only get things from the Minecraft-heads website

lost matrix
#

How about you dont start a query every time your data changes. 🙂

blazing ocean
#

by query do you mean a write or read operation

lost matrix
#

Persisting in any way

#

The proper way would be to flag your data as dirty and only persist it every few minutes, if it changed.

slate siren
lost matrix
blazing ocean
#

1.8
glhf

lost matrix
#

Support for that version was dropped half a decade ago

slate siren
#

I don't think it has anything to do with the version.

#

Because I have installed many heads plugins so far and they worked successfully.

lost matrix
#

Could be, we will never know

echo basalt
#

any language is a configuration language if you twist reality enough

onyx fjord
#

how do i make gson throw an exception when deserialized object has null fields instead of just leaving them null?

#

i wanna make sure that my object never has any null field

ivory sleet
#

i think it by default should omit null fields

onyx fjord
#

it does yeah

#

i need it to throw instead or just make the whole deserialized object null

#

so i can easily validate

grand magnet
#

I program a 1.20 minecraft plugin and want to use sendBlockChange but ist doesnt work

ivory sleet
#

but idk

#

You could validate the nullness in the class itself

#

like whatever class/type u deserialize, in its constructor

grand magnet
#

Can someone help me with that

pliant kite
#

can i please get help with this

#

im lost

viscid carbon
#

Okay im stuck, whats a good way to ignore a configurationSection thats null?

#
    public Set<String> getPlayerHomes() {
        if (fileHandler.getConfig().getConfigurationSection("Homes").getKeys(false) == null) {
            return null;
        }
        return fileHandler.getConfig().getConfigurationSection("Homes").getKeys(false);
    }```
tardy delta
#

variables

#

neither of these functions are pure so please

viscid carbon
#

.contains...... lol

grim ice
#

Is it possible to add a "[Click to Copy]" button?

#

in chat

blazing ocean
#

?components

undone axleBOT
grim ice
#

but

#

that does not answer my question

#

actually it does

blazing ocean
#

For hoverable, clickable ...

grim ice
#

COPY_TO_CLIPBOARD

#

yes

restive mango
#

A basic java question: suppose you have a class which takes a boolean as a parameter, and it contains a while loop, and this while loop will do some math, and then based on the boolean, will do one of two sets of math, before ultimately returning a value. I want to avoid re-checking the boolean inside the while loop again and again and again -- isn't there like some kind of consumer thing to avoid having basically two classes that are almost exactly the same except for the chunks of code related to the boolean? Anyone know a resource for this?

worthy yarrow
dull schooner
#

hey guys

#

is there an event for when the players dismounts?

dense falcon
blazing ocean
#

.kotlin
it's java
hastebin moment

remote swallow
#

they like to give it any possible extension

#

could be .sql

junior bough
#

Hello, I created a plugin that allows you to make holograms and I would like to know how to add different lines such as displaying the player's name, the only track I have is protocolib

eternal oxide
#

what bukkit version?

restive mango
#

idk

#

just something that would do that

ivory sleet
#

Wait dou have the actual code at hand?

sly topaz
#

why is the boolean checked inside the while loop, is it supposed to dynamially change what kind of operation it is doing mid-computation?

restive mango
#

it's not

#

i'm just

#

trying to figure out a way to not have two classes all with almost the same code

#

except

#

one is like

#

while (fartloving = true) {
x = x+10;
if (farteater) {
x = x +1;
} else {
x = x*2;
}

if (x > 100) {
fartloving = false;
}

print("I love farts!");
}

sly topaz
#

if you have two classes whose code share a good chunk of logic, the common way to deal with that is parametizing whatever logic is shared

ivory sleet
#

love the variable names

restive mango
#

farteater being the boolean

daring moat
#

Hi is there any where I can request commissions in spigot discord or the website?? would the forums work?

restive mango
undone axleBOT
daring moat
#

thanks!

restive mango
#

i'd like to do something like

class void FartMaster(Codechunk codechunk) {
while (fartloving = true) {
x = x+10;

codechunk(x);

if (x > 100) {
fartloving = false;
}

print("I love farts!");
}
}

#

i just dunno how to do that

#

just cant remmeber what that is

ivory sleet
#

I mean one way is to pass a single abstract method interface

#

aka functional interface

#

Consumer perhaps

restive mango
#

well

#

if you have a resource for this lmk 😮

sly topaz
#

well, in this case rather, a Supplier since you'd need to mutate x

ivory sleet
# restive mango if you have a resource for this lmk 😮

Just google around about “Java functional interfaces” its basically the equivalent of passing around functions, since java doesn’t really support that semantic like other languages we need to create classes with a single method instead

sly topaz
#

here I was thinking they were trying to convert the branch into a bitmask lol

ivory sleet
#

Yea well the original issue was somewhat poorly worded

sly topaz
#

This usually indicates that they have missed some fundamental aspects of learning the language; they are aware it's possible but lack the knowledge of how to proceed. I would take a basics course to serve as both a refresher and to reaffirm my foundations if I were you

#

@restive mango ^

ivory sleet
dense falcon
#

I am checking if it's done or no.

#

In the constructor.

restive mango
#

lol

#

i love how superior you sound

sly topaz
#

I tried to phrase it in a non-condescending way but I lack the writing skills to do that apparently lol

restive mango
#

nah no worries

#

i kinda dig it

dense falcon
ivory sleet
dense falcon
#

xd dw :).

ivory sleet
#

@dense falcon I dont remember correctly

#

but iirc I think "bungeecord" channel consumes messages and whitelists the special subchannels like ConnectOther

#

i havent fiddled with it in ages

#

but either,
use "BungeeCord" + bungee sub channel specification
or use custom channel all along

#

id advice former

dense falcon
#

?

#

Did not understand :(.

ivory sleet
worthy yarrow
#

Hey @ivory sleet if you remember that registry system I posted in the mega thread, all I did was remove the abstract modifier from the class, does this pretty much clear up the design?

#

I think the only reason it was abstract was because I wanted to implement some abstract methods but never did so it ended up just being used as the base impl for other registry classes

worthy yarrow
#

Ok cool yeah I think I was probably stoned or something lol

ivory sleet
worthy yarrow
#

Forgive the naming, I changed it like 3 days ago or wtv and haven’t touched it since

#

I was also gonna put it a clearAllEntries method but not sure anything else beyond that

ivory sleet
#

the register method may wanna reject duplicates

#

else its fine

#

I think at least

#

:)

worthy yarrow
#

I was expecting to override a lot of entries with the other registry implementations so I think that’s alright

ivory sleet
#

I'd probably have more methods

#

like getOrThrow

worthy yarrow
#

More edge case stuff?

ivory sleet
#

just in general

#

like else u'd have to do sth like
get(x) == null -> throw blah every time

worthy yarrow
#

Right right

#

Is what I’m doing with this system somewhat common? I feel like the fact that all you have to do for the actual implementations is define the generics and then it’s good to go

#

Well rather smart I guess

worthy yarrow
#

I just feel weird having a visually empty class

ivory sleet
#

not sure why GUIRegistry needs to be a class still

#

I mean the Registry impl is reusable on its own

worthy yarrow
#

To define the generics right?

ivory sleet
#

na

worthy yarrow
#

Go ahead

ivory sleet
#

IRegistry<String,Item> items = new RegistryImpl<>();

#

in ur case

worthy yarrow
#

You just blew my mind kek

ivory sleet
#

:,)

sly topaz
#

what is this supposed to be for

worthy yarrow
#

Idk why it never occurred to me

sly topaz
#

right now with that it just looks like a wrapper around a Map

ivory sleet
worthy yarrow
#

Originally it was just practice with interfaces and abstraction

ivory sleet
#

ye makes sense

#

anyway, u should look at mojangs registry impl

#

its a bit more complicated due to that they care about ownership of values significantly

#

but it has some good stuff u could yoink

worthy yarrow
#

I hate yoinking code! D:

ivory sleet
#

inspiration

worthy yarrow
#

Kek

ivory sleet
#

:,)

worthy yarrow
#

Even when I’m using something as “reference” I feel it ends up being too similar and no longer follows my use case anyway

#

So I guess I just have to learn more about implementation practices

ivory sleet
#

yeah sure, but at some point reading others' solutions can be quite helpful

worthy yarrow
#

Well solutions sure, but I mean currently it does what it’s supposed to, ie: no solution is needed, there’s only room for improvement

#

Which I guess you could consider a solution

#

Eh fair enough

ivory sleet
#

yea well solutions/improvements/inspirations w/e

worthy yarrow
#

Yeah

ivory sleet
#

whenever I implement something I am always super curious to see how others have done it

#

that said ofc its not always I have the time to look into such stuff

#

but ye

worthy yarrow
#

Well I’ll certainly have to look at mojangs implementation

#

Do you know where I find this?

river oracle
#

Some are just more complex glorified map wrappers

sly topaz
#

for example, Mojang's is supposed to be a replacement for enums and facilitating their serialization framework on top

worthy yarrow
#

So in other words basically what I have with extra methods kek

ivory sleet
#

yea another example is inverse mapping, w a value to key identity map ^^

worthy yarrow
#

Sorry didn’t mean to cut ya off con

ivory sleet
#

lol allg

worthy yarrow
#

So this is probably a question that I just go look for an answer but I’m lazy, how does mojang freeze their registries during runtime?

ivory sleet
#

a freeze() method

#

and a freeze variable

worthy yarrow
#

I assume this is called after all the entries are submitted as it were?

ivory sleet
#

yes mojang buffers a set of consumers that populate the registries

#

thats also when the registries get frozen

#

iirc on fabric and/or forge they inject and change it up somewhat

sly topaz
#

the registry, when frozen, will bound all keys to their respective value

#

you can only reference the value of a key by their Holder.Reference and if a value is changed at runtime, it'll throw an IllegalStateException

young knoll
#

Unless of course you just

#

Unfreeze it

#

:)

sly topaz
#

well yeah, but that'll most likely break things that expect the registries to be frozen and whatnot

ivory sleet
#

it for sure will

young knoll
#

Meh, not really

#

Just do it when no one is online and things work fine

ivory sleet
#

😭

young knoll
#

Hey if Mojang didn’t want me to add stuff to the registries

#

They shouldn’t have made them registries

worthy yarrow
#

Fair enough kek

sly topaz
#

as if people weren't adding things to enums before registries were a thing lmao

young knoll
#

Well yeah but that’s even more jank

ivory sleet
#

its a pity there's still enums around

#

in mojangs code

#

like hey, i wanna be able to add new item rarities

young knoll
#

Tbf they don’t do much

ivory sleet
#

yea well in my mod I had to do some quirky goofy mixins injecting the backing enum array etc

#

:c

young knoll
#

Isn’t it just the item name color

ivory sleet
#

yea

#

well it still has to abide by dfu w codecs and shit since its being shipped through item components

#

would be nice if it were a registry just :/

young knoll
#

Just uhh

ivory sleet
#

or not dfu

#

wtf am I talking about

#

serialization just

young knoll
#

Force the item to always have a custom name with the color

ivory sleet
young knoll
#

Although that would get janky in anvils

worthy yarrow
#

So then when are enums actually useful?

river oracle
#

they're useful if you don't need things to be data driven

#

also short things like Results etc registries or interfaces for that would be overkill

worthy yarrow
#

I consider an enum basically a list of static constants, is this correct thinking?

river oracle
#

e.g. Imagine a simple transaction system

public enum TransactionResult {
  SUCCESS,
  FAIL,
  TIMED_OUT,
}
ivory sleet
#

or rather set, but w/e

worthy yarrow
#

Right yeah

#

But there’s still ways around this isn’t there?

#

As in making dynamic changes to said enum?

river oracle
#

uhm with bytecode sure

#

but you can do anything with bytecode

#

so that's not really a good argument for enums

worthy yarrow
#

Hmm alright

ivory sleet
#

idk I mean a lot of systems that do end up relying heavily on enums eventually come to regret it, for example ChatColor, and other enums in the api has over time had to be changed into classes partly because mojang changes its code

#

and then as y2k said, bytecode, lovely commodore is needed

worthy yarrow
#

I wish I could be around you nerds irl, I feel like I’d retain so much more sigh

ivory sleet
#

aren't you a nerd as well? :>

sly topaz
#

just go to college

river oracle
# worthy yarrow Hmm alright

in my own code here are examples of registries vs enums

enum Measurement // measurements don't change :P unless metric system blows up
class CollectorMetaRegistry extends Registry // We can arbitrarily register CollectorMeta at runtime to support additions via other plugins
enum Operator // We don't just magically add math operators safe to say this is a safe enum
class ItemRegistry extends Registry // we can just register items at runtime
worthy yarrow
#

I’ve only read like 6 books since January I don’t think that’s nerd level yet

sly topaz
#

bunch of compsci nerds to get sniped

river oracle
#

most compsci students are idiots

worthy yarrow
river oracle
#

I've only met a few who actually know whats going on

sly topaz
#

those are the actual nerds

river oracle
#

I'd go for a masters, but its way too expensive lol not gonna drop another 100k I'm good with 2 years of college for my Bachelors

#

maybe if a company payed for it

#

but no way out of my own pocket

worthy yarrow
#

Well that’s why I want to go to a boot camp

river oracle
#

boot camps kinda suck lowkey you're better of spending time just obsessively coding projects you enjoy]