#help-development

1 messages · Page 960 of 1

worthy yarrow
#

I may be wrong, but you might have to give every player a uuid in the context of using it persistently...

proven musk
#

how do I do that lol

#

how do I give a player a uuid without having a uuid to store it

#

should I just use their username to store it

worthy yarrow
#

the pdc link should have a snippet of how to save a uuid with pdc

proven musk
#

i wanna do something like this

#

the way the world does it

proven musk
worthy yarrow
#

Oh I guess I forgot that lol

#

eh,

proven musk
#

which is the entire reason im doing this

#

I think the getuuid command SHOULD work

#

based on what the docs say

worthy yarrow
#

It doesn't make sense that the players pdc is reset

#

The whole point of pdc is so that it persists the data...

proven musk
#

yep

#

its because the player object isn't the same

#

i assume

worthy yarrow
#

And you mean reset in context of the container still existing just being cleared of data

proven musk
#

i guess

#

the container can't go away

worthy yarrow
#

That's my point

#

is it doesn't make sense that the data is poofed

#

Ah more api advancements to look forward to ig

proven musk
#

hmm

#

well

#

honestly I dont wanna go back to pdc

#

Id rather have a class I can serialize

worthy yarrow
#

At this point I'd say save whatever playerdata you need to a flat file

young knoll
#

PDC is saved with the player

#

It is not reset when they rejoin

worthy yarrow
#

I swore that was true too, there has to be something else happening here

proven musk
#

then whats the deal

worthy yarrow
#

Also pdc is held by the server, so given the player joins/rejoins that should make no difference in the persistence

worthy yarrow
proven musk
#

code is gone

worthy yarrow
#

breh

proven musk
#

i replaced it

worthy yarrow
#

With serialization for a file?

proven musk
#

yeah

#

its annoying to manually load each pdc key into a class anyway

worthy yarrow
#

tbf you can just do that, given pdc is somehow breaking for ya

proven musk
#

dammit

#

it still isn't working

#

it worked when i rejoined finally

#

but it didn't save

#

ill get there

worthy yarrow
#

You might have to preimtively save the player data before they actually leave

#

ie: prePlayerLeave(custom)Event or something of the sort

#

^ note thats not a real method call

worthy yarrow
proven musk
#

that also sounds annoying

worthy yarrow
#

Less annoying then having to define a key in every class

proven musk
#

and was the second idea I had

proven musk
#

idk its not letting me create the file for some reason

#

im like hey write to this file! and its like that file doesn't exist

#

and im like i KNOW

worthy yarrow
#

You initialized a new file correct?

proven musk
#

idk I just copy pasted from herehttps://www.spigotmc.org/wiki/save-load-data-files/

#

imma try absolutefilepath rather than filepath

#

nope

worthy yarrow
# proven musk nope
private File dataFile;
    private FileConfiguration dataConfig;

    public DataManager(JavaPlugin plugin) {
        if (!plugin.getDataFolder().exists()) {
            plugin.getDataFolder().mkdirs();
        }

        dataFile = new File(plugin.getDataFolder(), "data.yml");
        if (!dataFile.exists()) {
            try {
                dataFile.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        dataConfig = YamlConfiguration.loadConfiguration(dataFile);
    }

    public FileConfiguration getConfig() {
        return this.dataConfig;
    }

    public void saveConfig() {
        try {
            dataConfig.save(dataFile);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void reloadDataConfig() {
        dataConfig = YamlConfiguration.loadConfiguration(dataFile);
    }

    public void setPlayerData(String playerName, String path, Object value) {
        dataConfig.set("players." + playerName + "." + path, value);
        saveConfig();
    }

    public Object getPlayerData(String playerName, String path) {
        return dataConfig.get("players." + playerName + "." + path);
    }
}```
#

So the point is to create a new file & fileconfiguration, when you create the file you define the path ie: plugin.getDataFolder, then use the fileConfiguration to edit said file

proven musk
#

hmm

#

im like 99% there on my implementation I just need to figure out

worthy yarrow
#

Usually you create a new(fileName).yml in your plugin's resources and write it out in there in order to keep it clean

young knoll
#

You can easily make a custom adapter for PDC that goes directly from/to a class

proven musk
worthy yarrow
#

He just switched from pdc to a flat file serialization and I dont think he wants to go back lol

proven musk
#

she

#

yes other methods could work but like

young knoll
#

Tbf they are about the same

#

:p

worthy yarrow
#

^ more or less it's just pdc is a bit easier

proven musk
#

sounds like I should use the one I already wrote most of then

young knoll
#

Fair

worthy yarrow
#

pdc is just better because it's basically the same thing just held by the server rather than your plugin

proven musk
#

I just wanna get this working so I can actually add features 😭

#
        try {
            BukkitObjectOutputStream out = new BukkitObjectOutputStream(new GZIPOutputStream(new FileOutputStream(filePath)));
            out.writeObject(this);
            out.close();
            return true;
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return false;
        }
    }```
#

heres my code

#

I dont really know what most of this does but in theory it should work unless that wiki is lying to me

young knoll
#

Oh

worthy yarrow
#

In the usage methods, you can obviously parse the data however you want

proven musk
#

please just help me on my actual thing

#

im gonna have a headache

worthy yarrow
young knoll
#

Well if you want to just save binary data

worthy yarrow
#

I think she probably wants to use file & fileconfiguration but thats my opinion

young knoll
#

Jesus what even is that

#

It doesn’t even use try with resources :(

worthy yarrow
worthy yarrow
proven musk
#

so you have no idea why my code isn't working

young knoll
#

The standard java serialization just requires an ObjectOutputStream

#

I would start with that

worthy yarrow
young knoll
proven musk
#

so u think it wont work

young knoll
#

Should cover the basics

proven musk
#

alr ill use ur method

worthy yarrow
#

I think it will when it's written properly, however I only ever use file & fileConfig so I probably wouldn't even be much help with base java serialization

worthy yarrow
young knoll
#

Yaml is more standard

#

Or you could do gson since spigot shades that

#

But binary serialization is certainly an option

worthy yarrow
#

yaml is easiest / mainstream so probably just do that lol

young knoll
#

Depends

#

I’d argue gson is the easiest in terms of code written

proven musk
#

how does you example work

#

so its loading on object into yaml... how?

#

also what do I put in as the path

worthy yarrow
worthy yarrow
proven musk
#

im honestly so confused

#

so I can't save my playerdata class

#

I have to save individual values

worthy yarrow
#

Meaning

Pets:
- petName
- petType
Commands:
- petCommand
- petTypeCommand

#

hold on

proven musk
#

this is what I was trying to avoid lmao

worthy yarrow
#

It's never too late to go back to pdc

proven musk
#

why would that be better

#

I was so close to having it work now I gotta start from scratch again

#

and now ur telling me ... what to start over again again

worthy yarrow
#

Because in the essence of pdc, it's essentially the same thing as serialization to a flat file rather it's held by the server instead of your plugin

proven musk
#

but id have to rewrite that again

worthy yarrow
#

So you're doing the same thing just along the lines of how pdc work, it's still saved in a file format for the server to use iirc

proven musk
#

im like this close to just crtlzing back to serialization

#

because if I did pdc like

#

I have to do so much extra work to get the values out of the container

worthy yarrow
#

So then just continue with flat files

proven musk
#

I already deleted all that to try to use your code

young knoll
#

If you want the lazy method of being able to go directly from object -> file

#

Use gson

proven musk
#

and now ur telling me NOT to use your code use pdc

worthy yarrow
#

What you had before was binary serialization

#

What I sent you is yaml serialization

proven musk
#

ok

#

sigh

#

im so exhausted dude

worthy yarrow
#

Not that it's a whole lot different

proven musk
#

all this to save whats essentially a scoreboard value

worthy yarrow
proven musk
#

is there a way to disable files in intellj

worthy yarrow
#

Wdym by disable?

#

and files tbf

proven musk
#

lmao

#

just delete a file without having it gone forever

#

i just changed the extension

worthy yarrow
#

// or \ * commenting... otherwise I don't think that's a thing

proven musk
#

ok

#

I went all the way back to pdc but better this time

#

works when I rejoin

#

works when i restart!

#

idk what was going on with that before lol

buoyant jasper
#

hello, does anyone know how do i change this from main to say Version Control i want to bring it back

#

on top left of the screen

drowsy helm
rotund ravine
#

There was one

proven musk
#

what would be the best way to have a event run exactly at sunrise every day?

rotund ravine
#

Depends

proven musk
#

on?

rotund ravine
#

Sunrise ingame?

proven musk
#

yes

#

sunrise in game

#

basically when time = 0

rotund ravine
#

I mean you could do some little math and just schedule a task for sunrise and then schedule it again in that task

proven musk
#

damn

#

does spigot not have a on tick command

rotund ravine
#

There is tasktimers

#

Not really any reason to have it run every tick though

proven musk
#

im lazy is the reason 😭

#

but alr

sullen marlin
#

A scheduled task with period=1 is 'on tick'

#

But 1 tick is overkill for this

#

Maybe every 100 ticks at most

proven musk
#

if this is depricated then what do I use

#

oh

#

it just wants a runnable not a bukkit runnable

rough ibex
#

yup

proven musk
#

ok well how do I start a runnable from the runnable

buoyant jasper
proven musk
#

( you need to be verified to send images)

proven musk
#

whats wrong with intellj

drowsy helm
#

not really that bad of a shortcut

#

all in the same corner

proven musk
#

normally its just alt up

#

im switching it to alt up

#

is time skip event run when /time is run?

#

it should

#

weird

worthy yarrow
#

Are you using a key manager?

#

Do you even have enough keys to warrent a key manager?

proven musk
#

rather than storing it in a class im just doing PlayerData.getSoulPoints(player) basically

worthy yarrow
#

you didn't do that before?

proven musk
#

no I

#

lmao

worthy yarrow
#

breh

proven musk
#

I copied the values into a class

#

well I thought pdc was going to be slow to call every time

#

but it probably isn't

worthy yarrow
#

The way it's called upon again within the ?pdc example is kinda meh, there are workarounds to make it a bit more robust

#

er robust isnt the correct word

#

easier is fine

#

Rather than having a constant itemstack, it just tells you to make another each time you want to access the custom item

proven musk
#

ok

#

sooo

#

this is weird

#

the gametime doesn't actually reflect the time of day

#

how do you get the time of day of a world

#

right

#

.getTime

worthy yarrow
#
long getTime()
Gets the relative in-game time of this world.
The relative time is analogous to hours * 1000

Returns:
The current relative time
See Also:
Returns an absolute time of this world

@proven musk

proven musk
#

pog

tranquil badger
proven musk
#
public static void load() {

        var item = new ItemStack(Material.FLINT);
        NamespacedKey key = new NamespacedKey(Main.instance, "flint_from_gravel");
        ShapelessRecipe recipe = new ShapelessRecipe(key, item);
        recipe.addIngredient(Material.GRAVEL);
        recipe.addIngredient(Material.GRAVEL);
        recipe.addIngredient(Material.GRAVEL);
        recipe.addIngredient(Material.GRAVEL);

        // Finally, add the recipe to the bukkit recipes
        Bukkit.addRecipe(recipe);

    }```
#

it just does nothing

#

idk what to troubleshoot

#

I can't craft it and theres no error

#

im pretty sure its running lol im calling .load onenable

tranquil badger
#

Any reason its static, just curious

proven musk
#

why not

tranquil badger
#

But, pretty sure for shapeless you can enter an int

proven musk
#

I just want the code in its own class

tranquil badger
#

I'm on my phone so gimme a sec to type it

proven musk
#

`` recipe.addIngredient(4,Material.GRAVEL);` u mean like this

worldly ingot
#

Yes

proven musk
#

I mean thats cool but does it matter for it working

worldly ingot
#

It does

#

addIngredient() essentially does addIngredient(1, Material)

#

which sets a value in a Map

proven musk
#

wouldn't it work if I just put one gravel in tho

#

bc it doesn't

#

trying the new way

#

doesn't work

#

no errors

vital void
#

Aren’t you adding 4 ingredients?

#

Meaning you need 4 gravel

proven musk
#

        var item = new ItemStack(Material.FLINT,1);
        NamespacedKey key = new NamespacedKey(Main.instance, "flint_from_gravel");
        ShapelessRecipe recipe = new ShapelessRecipe(key, item);
        recipe.addIngredient(4,Material.GRAVEL);

        // Finally, add the recipe to the bukkit recipes
        Bukkit.addRecipe(recipe);

    }```
proven musk
#

heres the new code that doesn't work still

vital void
#

Are you loading this in on enable?

proven musk
#

mhm

vital void
#

Show

tranquil badger
#
ItemStack item = new ItemStack(Material.FLINT, 1);
NamespacedKey key = new NamespacedKey(this, "flintGravel");
ShapelessRecipe recipe = new ShapelessRecipe(key, item);
recipe.addIngredient(4, Material.GRAVEL);
this.getServer().addRecipe(recipe);
proven musk
proven musk
#

why are the tutorials so uhm

tranquil badger
#

If its in another class

proven musk
#

bad

tranquil badger
#

Replace this

#

Or just call that class

#

As a record

proven musk
#

im confused hold on

tranquil badger
#

new Recipe(this)

And make the Recipe a record

proven musk
#

ohhh

#

ok I see what u mean

tranquil badger
#

Or you can do the other way of just saying this.plugin = plugin;

#

In constructor

vital void
#

Use an instance of the main class

proven musk
#

yes

vital void
#

You shouldn’t be accessing that with a static method either

tranquil badger
#

Also why do you use var instead of ItemStack

proven musk
#

:)

worldly ingot
#

For the record, this works just fine for me

proven musk
#

dont worry about it guys

#

lol

#

its weird how bad the spigot resources are

#

almost all the articles are outdated or have misinformation

vital void
#

Same code choco?

proven musk
#

Its hard to learn what do to do basic stuff

worldly ingot
#

Identical

proven musk
#

weird

worldly ingot
#
var item = new ItemStack(Material.FLINT,1);
NamespacedKey key = new NamespacedKey(this, "flint_from_gravel");
ShapelessRecipe recipe = new ShapelessRecipe(key, item);
recipe.addIngredient(4,Material.GRAVEL);

// Finally, add the recipe to the bukkit recipes
Bukkit.addRecipe(recipe);
#

So if it's not working, it's for some other reason

proven musk
#

it works for me now

#

chaning Bukkit to the server

tranquil badger
#

And I still have no clue the difference besides access

worldly ingot
#

No reason to at all. Plugin#getServer(), Bukkit.getServer(), Bukkit.x(), all does the same thing

#

Bukkit statically mirrors all of Server's methods for convenience

proven musk
#

then why did it do different things

worldly ingot
#

It didn't

#

Probably something else :p

vital void
#

@proven musk you sure your compiling and uploading to your server

#

And then restarting your server

proven musk
#

I would hope

vital void
#

Add a debug message on Onenable to confirm

tranquil badger
proven musk
#

I didn't change that

tranquil badger
#

O

#

Dk then

proven musk
#

it isn't casted to a var btw

#

its still an ItemStack

vital void
#

Add a debug message to on enable

#

Ensure your plugin is uploading correctly

proven musk
#

it works now

vital void
#

Didn’t upload correctly?

proven musk
#

Idk

#

is there any way to have recipes use custom items as ingredients

worldly ingot
#

Only shaped ones. Not shapeless ones

#

But yes, RecipeChoice.ExactChoice

proven musk
#

pog

#

furnaces?

worldly ingot
#

Unsure if it works for furnaces. Could always try it

proven musk
#

how would I set an ingreditant to a tag

#

like #wood_planks

worthy yarrow
#

Same thing

worldly ingot
#

MaterialChoice

worthy yarrow
#

pdc is pdc

worldly ingot
#

Lets you pass a Tag or a Collection<Material>

#

Might be a Set or List. Can't remember. The Tag constructor I added recently

worthy yarrow
#

Oh are we talking about different thing

#

Sorry i chimed in at the wrong time

proven musk
#

all it gives me is RecipeChoice.MaterialChoice

worldly ingot
#

Yeah that's the one

proven musk
#

how do I use that

worldly ingot
#

Same as the exact choice. You can create an instance of it

proven musk
#

oh

worldly ingot
#

new MaterialChoice(Tag.PLANKS)

proven musk
#

why did I think it was an enum

#

how would I remove/replace a vanilla recipe

#

I think I got it

#

it would be NamespacedKey.Minecraft

worldly ingot
#

I'm unsure if it would replace it. You may have to remove it first

#

Ideally you'd remove the Minecraft recipe and add one under your namespace instead

#

Bukkit#removeRecipe(NamespacedKey) before you ask :p

proven musk
#

ok thats what I have

#

and yeah it seems like my plugin wont always update

#

I build in intellj and then restart the server

worldly ingot
#

Best guess is that IntelliJ could be incorrectly caching your compiled code, or maybe it's refusing to replace a .jar file that's been loaded by a JVM

#

So you could stop your server, build and export, then start your server

proven musk
#

nope im stuppid its just an error

worldly ingot
#

That's also a possibility :p

vital void
#

@worldly ingot question for you

worthy yarrow
proven musk
#

this is weird

#

it uhm. doesn't?

#

is it something about how im doing like a 2x3 recipe

#

or do I have to set the shape first

vital void
#

If I export using an artifact it over writes the jar in the jvm. But if I build with maven I have to stop the server, add it then start it

worthy yarrow
worldly ingot
#

Shape first, then ingredients

proven musk
#

yep

#

ty

worldly ingot
worthy yarrow
#

Is it not possible to load the changes during runtime?

#

Or perhaps just very dangerous

worldly ingot
#

I mean some people have managed to spin up a server via IntelliJ and setup some hotswapping but it's never been officially supported, nor do I really know how to go about doing that

worthy yarrow
#

Oh right I remember seeing stuff about that haha

#

I mean it's quite annoying to get the 20s delay on outdated spigot version

worldly ingot
#

You can skip that for development purposes if you'd like

#

java -jar -DIReallyKnowWhatIAmDoingISwear server.jar nogui

#

Don't use that on a production server, obviously, because keeping the server software up to date is important. But if you're just working on a local dev server and testing things, it's fine. Skips that 20 second delay so you can boot your test server quicker

worthy yarrow
#

Never knew that haha

#

ty

proven musk
#

im honestly just gonna ask here bc google is really unhelpful

#

how would I change (and can I) change block properties like how hard it is to mine and the tool required

worthy yarrow
#

You can definitely do that

proven musk
#

how

#

the best I can figure out right now is like

#

giving haste to the player using on damage and on damage abort?

#

is there a better way

worthy yarrow
#

PlayerInteractEvent

proven musk
#

then what

worthy yarrow
#

I’m about to sleep so hopefully someone will help you more with that, but go through the javadocs on playerInteractEvent to gather what you need

proven musk
#

rip

worthy yarrow
#

You can get the block, and modify from player interact event iirc

proven musk
#

gn!

worthy yarrow
#

Goodnight good luck with the project!

proven musk
#

yeah I have no idea what they were trying to tell me

#

idk how I would actually change the mining speed

worldly ice
#

iirc the way hypixel (and other servers) do it is they give the player haste -1 to prevent breaking blocks, then just listen to on damage and damage abort events like you said

proven musk
#

alright

#

hmmm

worldly ice
#

depending on how long they break the block, you change it's damage or like crackedness

#

i know there's a spigot method for that but i cant remember it off the top of my head

proven musk
#

the issue is it interfiering with existing haste

#

sigh

worldly ice
#

you would have to handle haste differently, yeah

proven musk
#

ill figure something out

#

thankfully it should be alright

#

maybe ill just not do it if the player already has haste because it shouldn't really matter past that

worldly ice
#

yeah that would work

stiff sonnet
#

does anyone know how you'd register a command? I'm very confused. The wiki sais one thing, doesn't mention the registration progress though, my IDE sais that the CommandExecutor class doesn't exist and cannot be imported, and I'm really confused what I'm supposed to be using.
So I have a class ready that extens Command - what now?

proven musk
#

it should extend CommandExecutor

stiff sonnet
#

yeah that just does not exist

proven musk
#

can you import it

#

because it does

stiff sonnet
#

no as I said I cannot

agile anvil
#

Do you use maven or graddle ?

stiff sonnet
#

are you serious

#

now it worked

#

I hate java development

proven musk
#

what ide are you using

stiff sonnet
#

well anyway, now I have a CommandExecutor extending class, what now, how do I register taht?

stiff sonnet
proven musk
#

the wiki should tell you

stiff sonnet
#

the wiki just tells you how to create the class and not how to register it that's why I'm here

proven musk
#

this has every step

stiff sonnet
#

the spigot wiki is meh

#

why are there 500 different wiki pagse for the same thing

#

I was on a different wiki page that just didn't have the registration part -.-

agile anvil
#

I think you are meh if you cannot find the information and struggle with java development

#

Just fight and trust yourself

#

you can do it

stiff sonnet
#

I've tried fabric, I've tried kubejs, I've tried spigot all to get the same project working and I've not had a successful start yet

#

in any of those

stiff sonnet
proven musk
#

I mean

#

tbf all I looked up what "spigot custom command"

#

idk how you didn't find it

stiff sonnet
#

I searched the same thing and all I found were wiki pages talking about the same thing but without the registration part

#

and the search bar in the wiki just searches posts not the wiki

proven musk
#

r u using like

#

duckduckgo

stiff sonnet
#

no

proven musk
#

bc thats weird

stiff sonnet
#

I'm using everything at once, literally

warm pine
#

skill issue

proven musk
#

what shows up when u type spigot custom commands into google

#

im curious

stiff sonnet
#

the wiki is definitely not SEOd

#

bro I hate imgur

#

why are image uploads not enabled here

#

whatever, anyway just a bunch of random plugins and libraries

agile anvil
#

?img

undone axleBOT
#

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

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

proven musk
#
var itemMeta = event.getItemInHand().getItemMeta();
if(!itemMeta.hasEnchant(Enchantment.DIG_SPEED)) {
    itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
    itemMeta.addEnchant(Enchantment.DIG_SPEED,3,true);
    setPdcValue(itemMeta,PersistentDataType.BOOLEAN,"copper_wooden_pick",true);
}
event.getItemInHand().setItemMeta(itemMeta);

this doesn't hide the glint. Isn't there a way to hide the glint? I could've sworn theres a way to do it with commands normally

stiff sonnet
#

I cannot even use that properly

proven musk
#

I mean suit yourself

stiff sonnet
#

oh well then just no screenshots here

#

they could just use a normal verification system

agile anvil
#

You seem so unhappy

proven musk
#

I think you need to take a walk dude

#

just like go outside and smell the air

stiff sonnet
agile anvil
proven musk
#

development aint easy

stiff sonnet
#

any other programming language is the easiest to setup, and then there's java with maven, gradle, and all that garbage

worthy yarrow
#

It took me 15 minutes to setup eclipse, 20 minutes to setup IntelliJ so idk

stiff sonnet
#

and I cannot use vim because the language servers are all having issues

agile anvil
#

You should clearly take a walk

proven musk
#

talk a walk get some water

stiff sonnet
#

been at this for several hours because nothing works

#

I just want to get this over with

worthy yarrow
#

Describe nothing

#

Is the issue the ide?

stiff sonnet
#

the issue is always the ide

proven musk
stiff sonnet
#

but if the best ide doesn't work then no idea

worthy yarrow
#

What is the issue with the ide? Which are you using

#

intellij?

stiff sonnet
#

intellij as I said

agile anvil
proven musk
#

yep

worthy yarrow
proven musk
#

and its hidden

#

but it keeps the glint

agile anvil
#

Ahhh

proven musk
#

oh

stiff sonnet
# worthy yarrow And the issue is that?

on fabric it wasn't picking up like half of the fabric libraries, and on spigot it's also struggling to find the most basic libraries on the first attempt

proven musk
#

weird

#

I coulda sworn there was a way to hide the glint

#

but ig not

#

thats frusterating

#

whats the point of hiding enchantments then 💀

stiff sonnet
#

the glint is done client side when used with enchants afaiik

shadow night
agile anvil
#

I think the glint is client side. That means you need to remove the enchant from the packet

proven musk
shadow night
proven musk
#

yeah

stiff sonnet
agile anvil
worthy yarrow
agile anvil
#

but for the dig speed yeah

proven musk
stiff sonnet
#

McDev plugin

worthy yarrow
#

Jut checking

stiff sonnet
proven musk
#

literally it doesn't matter lmao

shadow night
proven musk
#

im just trying to make it so certain blocks are easier to mine than normal

#

but whenever ur mining it it adds a glint

#

idk how to remove that but ig its not a huge deal

agile anvil
#

@proven musk for the dig speed there is no work around. You can however change the client attribute (maybe) when he holds this item, but the render wouldn't be that great

worthy yarrow
#

Just get the ide to a "usable" state as it were?

proven musk
#

anyway its fine

#

its not worth fucking around with packets

worthy yarrow
#

It's def worth

#

Packets are fun

proven musk
#

I dont beleive you

worthy yarrow
#

You called my bluff

proven musk
#

is there an event for like

#

switching the item ur mining a block with

#

or just switching ur hotbar item

agile anvil
worthy yarrow
#

It wouldn’t fall under that sort of system

#

The event would have to be custom

agile anvil
#

Only workaround is to apply HASTE effect on the client

#

And this is kinda shit

proven musk
#

haste doesn't work

stiff sonnet
proven musk
#

it needs like haste 5 to have an effect

#

and that ruins the animation

proven musk
shadow night
#

I wonder if you can remove the glint with coreshaders

agile anvil
#

Or you can apply your own block break packet (don't do that)

#

Just keep the glint, it's not a big deal ahah

proven musk
#

yeah

worthy yarrow
# proven musk wdym

You'd have to describe what that event looks like ie: when a player is mining a block and if they change items while minging it

agile anvil
proven musk
#

I need to remove the enchantment when that happens also

shadow night
proven musk
#

bc you can swap items and keep breaking it and keep the enchantment

worthy yarrow
proven musk
#

idk how that would change anything

#

i already know the block that the player is breaking

worthy yarrow
#

Then you can just trigger your logic from the interaction of that block

proven musk
#

again tho

#

that doesn't change the issue

#

when you switch what item ur using to break it

#

unless im misunderstanding

worthy yarrow
#

You have to detect the fact the player switched items and then handle that interaction as it were accordingly

proven musk
#

I mean

#

I know that

#

thats what I asked about in the first place

#

I need more info idk what ur trying to tell me

worthy yarrow
#

I’m pretty sure if you use playerInteractEvent, you can get the necessary information to listen for the player switching their currently active item whilst that interaction is occurring, I don’t have any examples of this

proven musk
#

so it would fire if they switch the active item

worthy yarrow
#

You just need an event to occur ie: player switching items while breaking a block

proven musk
#

thats what im asking

#

what event would that be

#

how do I detect when that happens

worthy yarrow
#

Mmm

#

Give me a minute to think about that

proven musk
#

its this

worthy yarrow
#

Idk how you’re gonna get the block from that

proven musk
#

i dont really need to honestly

worthy yarrow
#

Oh well then

#

You’re just gaslighting me 😦

proven musk
#

what

worthy yarrow
#

I thought you needed the block the whole time

proven musk
#

ur good

#

but thats what I said in the first place

#

hmm

worthy yarrow
#

I was trying to help the other guy with the ide issue I hadn't read that

proven musk
#

nw

stiff sonnet
#

any idea how you make intellij rescan the maven dependencies? Now it's not able to find anything about the worldedit libraries I just added

#

why is everything so annoying

radiant laurel
#

lol xd

#

🤣

#

my humour is good right?

proven musk
#

leave the server

stiff sonnet
#

🚱 this is literally is the most useless emoji

worthy yarrow
radiant laurel
stiff sonnet
#

there is no lifecycle tab

worthy yarrow
#

I meant to say maven

#

/gradle

#

click the maven button

stiff sonnet
#

there is no maven button

worthy yarrow
#

then theres that refresh button in that ui

proven musk
#

how would I make block drop when it shouldn't normally (ei: broken with the wrong tool)

worthy yarrow
#

The right side of the ide

proven musk
#

I tried to setDrops to true

#

but no dice

stiff sonnet
proven musk
#

do I just have to manually do the drops

stiff sonnet
#

I'm not used to complex uis anymore

worthy yarrow
#

Yes ofc, that's prolly the issue you've been having with the libs... just click that and usually it starts working

tall dragon
proven musk
#

damn

stiff sonnet
proven musk
#

can I just drop from a loottable

tall dragon
#

i mean. u can pretty easily get a block's default drops

worthy yarrow
stiff sonnet
#

yeah fabric was causing me issues, and taht was probably the solution too

#

same issues on spigot and it's all just this tiny button

proven musk
#

theres no such thing as default drops with ores

worthy yarrow
#

yep

proven musk
#

it depends on the tool

#

I could just say I dont want fortune to matter but I also plan on editing the loot tables

worthy yarrow
#

A lot of times the ide just needs a lil refresh... that's not to say 95% of the times I've put a dependency into the build path and it just works but yk

#

stuff happens

proven musk
#

so id rather just have it drop the loottable

tall dragon
#

last time i did that stuff i just calculated the fortune myself

proven musk
#

theres gotta be a better way

#

at least datapacks have /loot

worthy yarrow
#

Better way sure but thats for later optimizations, you just have to get it working first!

proven musk
#

it would be easier just to get what would drop

#

ok its just getDrops from the block ig

worthy yarrow
#
getDrops
@NotNull
Collection<ItemStack> getDrops()
Returns a list of items which would drop by destroying this block
Returns:
a list of dropped items for this type of block```
worthy yarrow
#

One thing you'll learn from asking questions here is that a lot of the time it can be answered by a (thorough) search through the jdocs... given you want to put the time into that

proven musk
#

the answers on google for spigot are kinda ass

worthy yarrow
#

Thats why you use the jdocs

proven musk
#

those dont super help when the question is how do I do x

worthy yarrow
#

How new are you to programming?

proven musk
#

not new at all

#

but im very new to spigot programming

worthy yarrow
#

Then docs will be your best friend, you'll just have to put a bit more time into searching / testing

proven musk
#

so i never know the best way to do x

#

since most of my questions should be really basic stuff I assume people would know here when google doesn't give me what I want

worthy yarrow
#

The best way to do x is hard to determine as theres a lot of ways to achieve x

#

So imo the best way to do something comes down to like 2 factors: speed / efficiency

proven musk
#

the most important factor to me is stability

worthy yarrow
#

Stability is important but that should be saved for optimizations mostly,

proven musk
#

theres alot going on in this game and doing something the first way that seems possible usually has side effects

worthy yarrow
#

so long as the foundation is solid, then just save the premature optimization for a better time

#

Just get it working first then improve

#

Are you an experienced mc player?

proven musk
#

yeah

#

for the most part

#

theres still alot of little mechanics that I dont remember tho

worthy yarrow
#

I mean a lot of what you can take from that experience can be applied to the spigot dev work, that's how I learned

proven musk
#

I know alot about datapacks

worthy yarrow
#

But as programming is virtual there are limitless possibilities, and with the freedoms of minecraft I mean that's a pretty cool environment to learn in

proven musk
#

ill be honest the main reason the jdocs aren't super helpful is the descriptions aren't very helpful

#

like

worthy yarrow
#

You're not wrong

proven musk
#

.getHealthScale = this gets the health scale

#

ok?? wtf is a health scale

worthy yarrow
#

The amount of health an entity has iirc

#

total amount

#

Or wait no that changed, I'm pretty sure it relates current health

tall dragon
#

the number by which health gets scaled e.g multiplied

worthy yarrow
#

nope im wrong

proven musk
#

why would it be multiplied

tall dragon
#

cuz its a scale

worthy yarrow
#

Hearts in minecraft = 10, scale in code = 20

#

for a player (normally)

proven musk
#

so you can change each heart to be more than 2 points?

tall dragon
#

here

#

this one is more informative

worthy yarrow
#

I think you can change the size of the scale

proven musk
#

weird

#

didn't know u could do that

tall dragon
#

so its health / max health * scale

tall dragon
worthy yarrow
#

Tbf it just comes with time like most things, you'll pick up some good tips and tricks here that's for sure

lilac dagger
#

it's finally done 😄

lost matrix
#

Noice

#

Now add comments 🙂

lilac dagger
#

done

lost matrix
#

What does your @Setting annotation do?

echo basalt
#

ew annotation based settings

lilac dagger
#

it marks the field to be processed and also carries the id that has to be put in config

lost matrix
#

The id...

lilac dagger
lost matrix
#

You mean the path

lilac dagger
#

yeah

#

the key of the section

lost matrix
#

Alright, what is your generall approach to serialization?

lilac dagger
#

i made this

#

i have a type registry where you can add your custom type

#

this is for map for example

#

i'm gonna attempt to deyamlify it eventually

#

but for now yml is all i need

#

oh yeah, it supports recursion, which took me the most time

#

as in map inside map

lost matrix
#

Hard coding a HashMap is probably fine for configs

lilac dagger
#

it is for yaml

lost matrix
#

But it might mess up the ordering of your config every time you throw it back into yaml

lilac dagger
#

afterall yml is just a fancy hashmap

lost matrix
#

May i suggest a LinkedHashMap

lilac dagger
#

hmm

#

not a bad idea

#

thank you

lost matrix
#

How did you handle ConfigurationSerializable? Becaus the deserialization needs to infer the runtime type

lilac dagger
#

i don't

#

i use mostly MemorySection get and set

#

and the extra is configuration section

#

the problem with my approach is that you have to parse it

#

i'll try to add itemstack as well, it can't get more complicated than that

lost matrix
#

You might also try serializing any ConfigurationSerializable as they all end up with a Map<String, Object>

lilac dagger
#

ohh

#

yeah, i can just serialize that

#

this is for my custom interface

#

like how events has Listener

#

classes have to implement it in order to be considered a section

#

or node

#

overall, i'm really happy with this

#

there's a problem with configuration serializable, i can't see how to deserialize all of them

trail estuary
#

can anyone help me,
i need that if a player is holding a candle in offhand and u have 64 off a block u get a commpressed block

on rightclick:
if player off hand is holding a '%candle%':
loop items in player inventory:
loop-item is a block
if player has 64 of loop-item:
remove 64 of loop-item from player inventory
give player 1 of loop-item named "&{#E8E64A}&lCompressed %loop-item%"
set {_compresseditems} to true
if {_compresseditems} is set:
send "&eCompressed Blocks!" to player
else:
send "&aCouldn't find anything to compress!" to player

can anyone fix this for me

lilac dagger
#

itemstack has it like this

trail estuary
#

yes

tall dragon
#

this channel/server is for java plugin help

trail estuary
#

yes

echo basalt
#

Yeah this isn't the place to ask for skript help

#

shoo

trail estuary
#

oh

echo basalt
#

anyways my 15 year old copy of effective java just arrived

#

it's slightly modern

#

I can't bother spending more than 5$ on a book :)

twin venture
#

Hi , about making code in a better design , so i have a question so iam trying to make a multi user - table system , so :

  • UserStats : uuid , kills , ...
  • UserData : uuid , name , color
  • UserPrestige : uuid , prestige
    .. etc
#

what would be the best aproch?

#

and i tried ormlite before it didn't really work for me fine , allot of bugs ..

tall dragon
#

not sure what ur asking

#

what database schema u should use?

twin venture
#

for example :

tall dragon
#

yea seems fine to me no?

twin venture
#

but i didn't finish it , this is only the starting ..

lilac dagger
#

yo, i think i have configurationserializable working

twin venture
#

how would i load the PortalUser , and User inside the SkyUser? like i want to make a refrence for them

lilac dagger
#

i'mma test it

twin venture
#

like inside SkyUser , i will have privite User , and privite PortalUser

#

but idk how would that can work :0

#

and iam using mysql , but can use other database too

tall dragon
#

why not put it all in 1 user object

twin venture
#

well it does not looks nice to have all things in there ,-,

#

or is it oky?

tall dragon
#

but it is convenient

#

ur aproach with multiple different classes like that is not going to save u space. its just going to quickly get very annoying to work with

#

as u add more of them

#

i would keep all the data in 1 user object

#

a friend of mine took exactly that approach ur taking now

#

now they have over 60 user classes 😂

twin venture
#

daam xD

tall dragon
#

and its pain to work with

echo basalt
#

Well yes and no

#

you end up having a single god class

twin venture
#

but does not other big servers use this aproch?

echo basalt
#

it's bad design

#

The big servers I worked at worked with modules

#

Each module had its own user class

tall dragon
#

well yea they have a big server

tall dragon
#

but its a mess

twin venture
tall dragon
#

i dont rlly see the advantage

#

technically all data will still be in a single object

twin venture
#

i just wana learn more aproches , not only 1 .. xD

#

so what i mean is this

#

but , how would i load them in therE?

#

i was thinking about something like this , but not sure!

tall dragon
#

for example u prolly woulnt need to store uuid there

#

since thats stored in user

echo basalt
#

Yeah so

#

At this project we just made our own little ORM with mongo and some gson and annotation magic

#

And I ended up making codecs on top of codecs on top of codecs

tall dragon
#

💀

echo basalt
#

Having it all in a single class is a bad idea and let's start with that o_o

lost matrix
twin venture
echo basalt
echo basalt
#

Because you need to have some separation of concerns

#

It also takes forever to encode and decode

tall dragon
#

i mean both approaches would take just as long

lost matrix
#

If you separate it into several classes then it takes even longer

tall dragon
#

yea

echo basalt
#

Well if you need fine grained data you aren't loading all of it

lost matrix
#

Its just a question about your design strat. Is your data relational or not.

echo basalt
#

If you're encoding maps and metadata all in the same big object then you need to load all of the maps into memory for a map list menu

#

If you keep metadata separate from the map contents themselves you get the benefit of only picking the data you'd like to read

lost matrix
#

You can allways do that with a query

echo basalt
#

Correct

#

But what if it's all just in one big mongo object or whatever

echo basalt
#

For fine grained individual plugins it's whatever

twin venture
#

so i want to have 1 global user , that i can get the UserStats , UserPortal .. etc from

echo basalt
#

But for monolithic cores you want things separated

#

The server I worked at had prison and skyblock

#

If I loaded your skyblock island while you were afk in the lobby because it happened to be in the same pojo as your stats it'd be a concern

lost matrix
worthy yarrow
#

One day all the spigot wizards gotta get in a call so I can take notes

echo basalt
#

Unless half the fields are nulled

#

Which is extremely degenerate

lost matrix
#

You can have a monolothic user class in mongodb, with a ton of filled fields and only get a single field from mongodb.
Why do the others need to be "nulled". You can just get a single field.

#

Type safe even.

echo basalt
#

I mean the way you represent it in ram

#

whatever you toss at the db is whatever

twin venture
#

for example :
and i can later set this 2 fields

#

is this a bad design?

echo basalt
#

The whole argument is like

#

A big user class with data for each gamemode or individual user classes for each gamemode

#

Not how many tables you have

twin venture
#

etc

tall dragon
#

was about to say pretty sure its 1 gamemode

lost matrix
#

You could have

{
  _id: ...
  kills: 20
  deaths: 30
  a ton of other props
}

In your DB. And then just get the kills without loading the entire object into memory.
And if the player joins, then you load the entire object into memory.

lilac dagger
#

@lost matrix i've implemented configuration serializable too 😄

echo basalt
#

Yeah that's a whole diff argument

lilac dagger
#

actually this way is better

lost matrix
#
K key = ...;
String property = "kills";
int kills = mongoCollection.distinct(property, Filters.eq(key), int.class);

Gets your the "kills" property for the given object key, as int. As an example.

echo basalt
#

I'm aware smile

lost matrix
echo basalt
#

the whole fight is big class vs lots of small ones imo

tall dragon
#

they are talking about having a big pojo class with everying nulled but the kills field

#

iirc

lost matrix
#

Aj

#

Ok

#

In that case a lot of small ones

lost matrix
tall dragon
#

but i still think its fine to have 1 user data class per gamemode

#

cross gamemode is dif story

worthy yarrow
#

When is spigot gonna release a book

lost matrix
lilac dagger
#

oh yeah sorry

lost matrix
#

Show me what you did. Bc it can get messy af with the deserialization

lilac dagger
#

this

lost matrix
#

Wait, you just delegated to spigots FileConfiguration, didnt you

lilac dagger
#

yeah

#

and in case there's no element, it'll pull it up

#

wait, i think i have a bug actually

lost matrix
#

field.getType() ?

lilac dagger
#

it's the current field type

twin venture
#

this is my idea so far but i think its wrong?

#

and in SkyUser i have this :

lilac dagger
lost matrix
#

Ah

tall dragon
#

do u realize the pain that is :<>

twin venture
#

why is it pain? is there a better way?

echo basalt
lost matrix
tall dragon
lost matrix
#

Could use a facade class

echo basalt
#

why does googje shopping suck so much

lilac dagger
#

it's a facade class yeah

#

it has some other stuff other than field

#

just use List

#

abstractlist has only internal methods

inner mulch
lilac dagger
#

yeah

#

but it's not as hard as you believe

inner mulch
#

gg bro

#

is this possible without writing one?

lilac dagger
#

no

#

you can get the annotation from the Field class

#

it's really nothing special

inner mulch
#

maybe configregistry and when registered the annotations are processed?

#

instead of an annotation processor

echo basalt
#

It's just basic reflections

lilac dagger
#

it's processed at runtime

inner mulch
#

but anotation processor :(

lilac dagger
#

i don't generate configs on compile time

#

the harder part was writing the serializer

inner mulch
#

does it serialize everything

#

or just stuff that you alr thought about

lilac dagger
#

everything i could think of

#

but you can add your types in the registry

inner mulch
#

nice

lilac dagger
#

or you can make your object implement ConfigurationSerializable

inner mulch
#

imagine serializing to byte and your customer has to define config values in byte arrays

lilac dagger
#

well, you only put in configs what you want your customer to see

#

i can't think of a reason why you'd need a byte array, but you can do it if you really want to

lilac dagger
#

ah lol

trim lake
#

Im thinking about how to make plugin witch will add weight (material based for now) to every item and inventory. So that will add weight limit for iventories as well. Would be big problem if I will recalculate actual weight of inventory on every inventory click?
I will use this code:

  public double getInventoryWeight(Inventory inventory) {
        double weight = 0;
        for (ItemStack item : inventory.getContents()) {
            if (item == null) continue;
            Material material = item.getType();
            if (material.equals(Material.AIR)) continue;
            weight += this.getItemWeight(material)*item.getAmount();
        }
        return weight;
    }
echo basalt
#

Uh

#

That isn't that heavy

#

36 iterations at most

#

Or whatever

#

41

lilac dagger
#

which for yml it's just fancy lists

inner mulch
lost matrix
quaint mantle
echo basalt
#

gl detecting that

#

Just do it like once a second it's fine

inner mulch
lilac dagger
inner mulch
#

every time inv closes

#

check

#

on drop

echo basalt
#

item pickups

inner mulch
#

check

echo basalt
#

api?

lost matrix
#

The fork has an event for intrinsically detecting when slots in a players inventory change

inner mulch
#

which fork?

#

paper?

quaint mantle
#

Shmaper

echo basalt
#

he's a mod he can't say the word

inner mulch
#

really? is that against the rules

echo basalt
#

lol no

quaint mantle
#

I have literally never used a spigot server

#

I just run paper

#

Im here cuz the support is essentially the same

#

Because im doing very low level shit

remote swallow
#

?whereami

inner mulch
#

no

quaint mantle
#

Facts

inner mulch
#

paper kinda the same as spigot

quaint mantle
#

It is

inner mulch
#

paper has just a little bit more api in some cases

lost matrix
#

But sometimes they introduce scuffed features that feel experimental

trim lake
quaint mantle
inner mulch
#

you need to track 3 things

#

picking up

#

dropping

#

and changes when the player closes and inv

lost matrix
#

What about death?

inner mulch
#

death too ig

lost matrix
#

What about plugins removing items?

quaint mantle
echo basalt
#

what about data corruption?

quaint mantle
#

And you have no problems anymore

quaint mantle
lost matrix
#

What about interacting with an item in your hand (like placing a block)

#

What about an ItemStack breaking because of durability?

inner mulch
#

its over

#

its impossibel

#

ble

trim lake
inner mulch
lost matrix
#

PlayerInventorySlotChangeEvent

inner mulch
#

marek

trim lake
#

I mean detecting inventory changes would be probably better but... So should be rly bigg issue to itarate, if yes fck it, there is no better solution lol

inner mulch
echo basalt
#

On today's episode of Illusion's scuffed past work

lost matrix
#

Even if your iterate over all players every tick and sum up their inventory weight, you will probably be fine.
Even with 20 players thats below 0.1ms

echo basalt
#

Did you know I made my own slot change event by legit just having a task running every tick and comparing?

lost matrix
#

classic

rotund ravine
inner mulch
#

prob every 2 seconds is fine

rotund ravine
#

Be a menace and iterate async

trim lake
#

I expect it will be heavier for performance so thanks, I will keep that. but there are more possibilities that can change the inventory than I thought lmao. I was thinking I will just update on every inventory click and when player close inventory and just adjust player speed or some effect to player based on weight... Looks like not I will just check all players inventory every seconds or something like that. Thanks guys

lost matrix
#

Yeah create 5 buckets and split your 20 players into them. 4 players per bucket.
Then tick one bucket each tick and repeat in a round-robin fashion.
Each player will be checked every 4 ticks. That 200ms and barely noticable.

wet breach
wet breach
#

you don't even need to do the whole bucket thing either, with object comparison you can iterate a list super fast that for you to notice your iteration being slow you would need to be in the hundred thousands or so

trim lake
inner mulch
#

yeah you can compare and only when changes where made you recalc

wet breach
#

then its comparing inventory objects

#

if the before object doesn't equal the now object

#

it changed

trim lake
#

I mean I can still try to make system witch will perfectly reflect any remove, pickup, drop, broke or what ever.... I can do it that the task way for now and in future develop system what would count with every possibility of inventory change and then base on that change weight of that inventory. To check if system is correct just use Task method and I will know what I didnt handle, but thats probably long time project lol

#

But while this is not heavy for performance I will do it this way then, Thanks

wet breach
#

well, even if it was heavy

#

you still wouldn't notice unless you were doing some extreme complex task

#

or doing something that would halt the main thread for some long period of time

#

modern cpus are extremely fast that many simply don't understand lol

#

you can easily run unoptimal code that you wouldn't notice any issues until you hit something like a thousand players

trim lake
#

I would only check if item can fit the weight limit of inventory. Probably PickupEvent, InventoryClickEvent, DragEvent would be enought so.

wet breach
#

point is, don't worry too much on the optimizing or performance until its actually an issue 😛

trim lake
#

I mostly care about that... bcs idk if u trow item away basicly... You will be "punished" for caring too much items with slow or something.

trim lake
#

Im trying to learn and do the best lol

wet breach
#

as you should uwu

twin venture
#

i was thinking about making something like this :
and then i use this and implement it where i have my sql code :

rotund ravine
#

save should return a transaction or smth

stiff sonnet
lost matrix
#

Did you specify that you are using a custom generator in your spigot.yml?

echo basalt
stiff sonnet
#

I'm trying to override all chunk generation code with just empty methods so it shouln't generate anything. I however still don't see the plugin enable early enough even though I set it to STARTUP in the plugin yml

echo basalt
#

I do like that you're experimenting

#

That's p much how I learned as well

stiff sonnet
rotund ravine
echo basalt
#

maybe

#

prob not

slender elbow
#

you need to tell the server to use your world generator

#

in bukkit.yml