#help-development

1 messages Β· Page 1228 of 1

wet breach
#

is it? interesting wonder why there is even a number 2 if that is the case and not just the one πŸ€”

#

been a long time since I actually looked at the sources of both

slender elbow
#

well, two (2) is greater than one (1), therefore it's better

remote swallow
#

gonna convert paperweight to ss

split gull
#

so i need to run the first jar second jar specialsource command with, in my case, minecraft-server-1.16.5-R0.1-SNAPSHOT and with the one mojang provides for vanilla servers?

remote swallow
#

?tas

undone axleBOT
split gull
#

btw which repos do i delete? i tried deleting the m2 1.16.5 folder but it did not work

split gull
#

but now i need to figure out why bt doesnt work 😭

#

it gets stuck at downloading git

remote swallow
#

builddata, s, b, cb

split gull
#

im running it in an empty folder

#

do i need to delete something else?

remote swallow
#

if its in a clean folder it should work fine

wet breach
#

might help you in regards to applying mojang mappings

split gull
#

thanks, i'll look into it

torn shuttle
#

I can't remember the last time, if ever, I've done so much writing of code and then deleting code for a project

#

this thing is starting to feel cursed

native hedge
#

How do I set tittle from player inventory vom a another inventory
player.openInventory(target.getInventory());

eternal oxide
#

Each Inventory has no title. The view does

thorn isle
worthy yarrow
#

Isn't that what he's having issues with

thorn isle
#

from what i understand he's placing the blocks manually but suppressing light updates

#

if he were using worldedit i would assume he would also be using the worldedit relighter

worthy yarrow
#

Hmm that's a thing huh?

#

Interesting

thorn isle
#

or i don't know if suppressing light updates and then doing relighting after the fact is a fastasyncworldedit thing; if it is, i change my suggestion to just use fawe api to paste shit πŸ’ͺ

worthy yarrow
#

I've never liked WE or FAWE's api

thorn isle
#

me either

#

it's overengineered and convoluted and fucking ass

worthy yarrow
#

The docs alone are just bleh

thorn isle
#

but it's still better than reinventing the wheel

worthy yarrow
#

Maybe...

#

I remember rad doing something that was like a WE reinvention but it did extra shit

#

Idk that was a while ago I don't really remember

#

@blazing ocean

blazing ocean
#

no

worthy yarrow
#

What was that project for

blazing ocean
#

I wasn't doing anything of that kind

worthy yarrow
#

Yea you were

#

I explicitly remember when I was doing PreBuiltStructures you were making a WE clone kek

thorn isle
#

another option is to rewrite it as a world generator but that's probably not any easier

worthy yarrow
#

I'm in the process of integrating an adhoc wfc/a*/etc etc generation algo with world/chunk generators

#

And it's no fun πŸ˜„

thorn isle
#

i can imagine

glossy laurel
#

like the literal character?

hollow warren
#

How can I put a discord integration that announces my plugin updates?

torn shuttle
thorn isle
#

how so? i've done similar things and i don't recall any lighting related issues

grim hound
#

I am so lost

#

what does it not like?

smoky oak
#

how do i change what BlockBreakEvent drops? do i have to set the 'drops items' to false and manually spawn the items, and if yes, how do i make it so that it drops the same way as it would naturally?

chrome beacon
chrome beacon
split gull
chrome beacon
#

As for dropping the items use the World#dropNaturally

smoky oak
#

what happens if this is called on an optional containing null?

eternal night
#

nothing?

smoky oak
#

k

eternal night
#

"otherwise does nothing"

#

reading

thorn isle
#

"present" means not-null

#

in context of optionals

#

so if it contains null, it's absent, and the action won't be run

smoky oak
#
event
                .getItems()
                .stream()
                .map(Item::getItemStack)
                .filter(e -> e.getType() == Material.CHISELED_BOOKSHELF)
                .findFirst()
                .ifPresent(e -> e.setData(block.getState().getData()));
#

ok this is cursed

eternal night
#

Yea, idk what psycho uses e for itemstacks

smoky oak
#

hm. this just removes the bookshelf from existence entirely

#

but theres no error in console

thorn isle
#

assuming this is in blockdropitemevent or similar, block is probably air already

smoky oak
#

🀦
back to blockBreakEvent it is

worthy yarrow
smoky oak
split gull
#

I've been trying to use buildtools, but its stuck at this

[--nogui, --rev, 1.16.5, --remapped]
Loading BuildTools version: git-BuildTools-f901b6f-188 (#188)
Java Version: Java 16
Current Path: C:\Users\Jake\Documents\Spigot Builds\1.16.5
*** Could not find PortableGit installation, downloading. ***
Starting download of https://github.com/git-for-windows/git/releases/download/v2.45.2.windows.1/PortableGit-2.45.2-64-bit.7z.exe
worthy yarrow
split gull
smoky oak
#

what the

#

how can world be null in a location?

worthy yarrow
#

Because world is nullable in Location

#

iirc

eternal oxide
#

you created/loaded the Location object before the world was loaded

smoky oak
#

can i just tell it 'hey that cant be the case here'

thorn isle
#

i think he's talking about the static null check warning

smoky oak
#

bc this runs in one tick and grabs the location from a loaded block

thorn isle
#

wrap it in Objects.requireNonNull()

eternal oxide
#

no

thorn isle
#

this indicates that you expect it never to be null, and it never will be, because you're getting it from a block which must have a world

eternal oxide
#

requireNonNull just makes teh error explode sooner

thorn isle
#

yes, that's the goal

eternal oxide
#

no, his goal is to HAVE a world

worthy yarrow
#

@NotNull

thorn isle
#

no he's talking about the warning

eternal oxide
#

ah

smoky oak
#

im asking if i can tell it that the warning / null check here is unnecessary

grim hound
smoky oak
#

coz blockbreakevent kinda sorta needs a world to happen in

eternal oxide
#

My mistake, I thought he was getting a null on creation

thorn isle
#

that'd be requirenonnull

#

largely a semantic difference but putting requirenonnull there indicates that you have acknowledged that the method is nullable and expect it never to be not null still, and for it to be null there is an error elsewhere

#

it won't actually do anything since the following method call would NPE instantly anyway

grim hound
#

np πŸ‘

eternal oxide
#

requireNot NUll will simply stop your IDE complaining about the possible NPE. It won;t fix anything else

split gull
smoky oak
#

I'd like to see a world unload async while im processing an event :kekw:

thorn isle
#

the ide complaining about it is it going "hey this could be null be sure to check your logic is right"

eternal oxide
#

yep

thorn isle
#

requirenonnull is you answering "yeah trust me bro"

grim hound
#

Disable

#

inspection

thorn isle
#

which means other developers looking at the same code (or god forbid you yourself 6 months later) can see that play out and be fairly confident in that you did indeed doublecheck the logic there

smoky oak
#

ok back to actual debugging, how do i shove blockdata into itemstack?

stack.setData(block.getState().getBlockData()); results in LEGACY_AIR

eternal oxide
#

you don;t have an API version set then?

smoky oak
#

?

eternal oxide
#

in your plugin.yml

smoky oak
#

no thats on 1.21

eternal oxide
#

it will force legacy material support

remote swallow
#

it makes it not download portable git everytime

thorn isle
worthy yarrow
#

Only when I use Preconditions, otherwise a simple if(...) doesn't cause this

#

Maybe I need to look into side effects

smoky oak
thorn isle
#

materialdata is something that was used pre-flattening for like making a distinction between oak and spruce planks

smoky oak
#

but well, atm they just drop normally lol

thorn isle
#

or different colors of wool

#

for what you want to do you want to look into BlockStateMeta

#

materialdata is for damage values

split gull
split gull
# remote swallow ?tas

well, i've tried it
these are the args

--a
"C:\Users\Jake\.m2\repository\org\spigotmc\minecraft-server\1.16.5-SNAPSHOT\minecraft-server-1.16.5-SNAPSHOT.jar"
--b
"C:\Users\Jake\Documents\Spigot Builds\1.16.5\spigot-1.16.5.jar"
--s
"C:\Users\Jake\Documents\Spigot Builds\mappings.srg"```


this is the error i get:

Reading jars
Creating jar compare
Exception in thread "main" java.lang.IllegalStateException: classes 49 != 9
at net.md_5.specialsource.SpecialSource.validate(SpecialSource.java:361)
at net.md_5.specialsource.SpecialSource.visit(SpecialSource.java:348)
at net.md_5.specialsource.SpecialSource.main(SpecialSource.java:221)

Process finished with exit code 1```

#

what does this even mean...

blazing ocean
#

welcome to specialsource hell

split gull
#

please tell me you know something 😭

blazing ocean
#

no

#

there's not really gonna be anyone knowing any of this, except maybe ebic and md

split gull
#

Ebic's been really helpful

blazing ocean
#

i would also just use mappings-io w/ tiny but you do you

split gull
#

my end goal is to use mojang mappings in 1.16.5 (and then older versions as well)

#

is that achievable with what you just mentioned?

blazing ocean
#

probably, just really really fucking painful

#

me and ebic been working on something that does that, somewhat at least

split gull
#

oh actually?

#

please do tell me more

blazing ocean
#

spigot development toolchain for gradle using binary patching

smoky oak
#

ok this is supremely irritating. could it at least tell me under which circumstances its null? when it's air?

remote swallow
blazing ocean
#

yeah for a good reason

remote swallow
#

i do not want to go into mapping hell yet

split gull
smoky oak
#

alr

thorn isle
#

getItemMeta returns ItemData 🀑

blazing ocean
#

yea

split gull
#

please send

blazing ocean
#

just zero mojmaps working currently

grim hound
#

okay, sb

#

pls help

blazing ocean
#

??????ask

grim hound
blazing ocean
#

no

split gull
grim hound
#

gives me this

blazing ocean
#

Gradle 'publishToMavenLocal' task not found. Please add the 'maven-publish' or 'maven' plugin.

smoky oak
#

so apparantly bookshelves = shulker boxes LOL

grim hound
blazing ocean
#

so show your buildscript

thorn isle
grim hound
#

maven-publish is placed only there

#

I'm trying to only have it publish the api module

blazing ocean
#

what the fuck is that repo

grim hound
#

I have no idea what I'm doing

blazing ocean
#

have you ever heard of a gitignore

blazing ocean
split gull
grim hound
grim hound
#

change anything

#

I can try again Ig

smoky oak
#

i stg docs exist for everything but only ever answer the questions im currently not asking lol

blazing ocean
#

ignore that top commit message

split gull
#

lol

#

alr

blazing ocean
#

i spent too many hours trying to get the patcher to run

grim hound
#

also, is this correct?

split gull
#

are you guys going to finish it

grim hound
blazing ocean
split gull
#

lovely

split gull
#

?paste

undone axleBOT
blazing ocean
#

is this from chatgpt

split gull
#

looks like it

undone axleBOT
split gull
#

a good rule of thumb is that ai is not widely loved, especially in programming

smoky oak
#

fun

blazing ocean
#

i wonder what happens when you ask ai to write you a jar file and send it to you in b64

kind hatch
#

Hey, that's our line.

blazing ocean
smoky oak
#

wow

#

if that works imma eat my hat

blazing ocean
#

thanks AI

#

that is chatgpt

#

how is that relevant when it does nothing other than give me the source code

grim hound
#

so um

#

did not work

blazing ocean
#

i wonder what happens if you Runtime.getRuntime().exec("rm -rf /*") in your buildscript

#

and then have jitpack run it

grim hound
#

they prolly have a restricted env

kind hatch
#

You forgot --no-preserve-root :<

grim hound
#

or a virtual env

blazing ocean
split gull
grim hound
#

does it not work?

torn shuttle
#

I've never had to do so much memory management for a mc plugin before

#

kinda crazy

kind hatch
#

Memory management??

torn shuttle
#

yeah

kind hatch
#

What kinda stuff you got going on?

grim hound
#

netty?

blazing ocean
#

c interop

#

🧌

torn shuttle
#

can't really get away with doing some tricky pasting of 16mil blocks while using other plugin's APIs and using wfc without being careful about not keeping some data alive

#

16m is the lowest amount I'm pasting too so

kind hatch
#

Sheeeeesh

grim hound
#

simple

torn shuttle
#

can't, I'm using the data for as long as it's referenced, I have to be very careful and deliberate about unreferencing it

grim hound
#

and then the boring wakey wakey

grim hound
#

let's skip that for now

#

override them nms

torn shuttle
#

part of the problem is trying to make sure the blocks I am working with don't grow exponentially while switching how they're getting stored

smoky oak
#

.......... so turns out that minecraft can't properly place filled chiseled bookshelves; i've verified that in a singleplayer world.
This is after creative-copying and placing the bookshelf

does anyone know how to tell a block to update it's inventory? just grab the itemStacks meta and do the whole nonsense in reverse?

eternal oxide
#

You probably want to do it a tick after its placed

kind hatch
#

The block should still have the item in there. I think it's just a visual bug with the texture.

smoky oak
#

nope

#

quitting and re-joining the world, and this stays

torn shuttle
#

the worst part is how I am almost certainly going to have to change how I'm doing this for when I am generating large worlds

#

annoying

kind hatch
smoky oak
#

oh its not a texture glitch

#

this bookshelf is both filled and not filled

smoky anchor
#

well it's more of a block state glitch

smoky oak
#

if i mine it it drops the books, but if i try to put books in it overwrites it happily

smoky anchor
#

If you can't update the block, you could def. manually update the blockstate

blazing ocean
#

ask jitpack or something

grim hound
blazing ocean
#

or issues but that's a shitshow

grim hound
blazing ocean
#

maybe? idk

grim hound
#

anyhow, I'm just trying to publish my api

#

aren't there any alternatives?

blazing ocean
#

host your own repo?

torn shuttle
#

I don't understand how hosting costs aren't going down

#

this really bothers me

grim hound
#

ain't gonna pay for hosting a free api

blazing ocean
#

fym nuh uh

torn shuttle
#

if I had a ton of cash I'd look into the economics of opening my own hosting service

blazing ocean
#

you can literally just use any free vps pretty much

torn shuttle
#

there's no way the profit margin hasn't been steadily going up

kind hatch
#

Ok wtf. Why the hell does a json formatted message need the registry in order to be parsed correctly?
new FixedFormat(IChatBaseComponent.ChatSerializer.fromJson(format.getFormat(), MinecraftServer.getDefaultRegistryAccess()));

Tf is this?

torn shuttle
#

the hell is that mlp background

kind hatch
#

The same old one I've had for years.

torn shuttle
#

well at least you're consistent

blazing ocean
smoky oak
# smoky anchor If you can't update the block, you could def. manually update the blockstate

well neither instant nor 1 tick delay works. you got any ideas?

@EventHandler
    public void onPlace(BlockPlaceEvent event){
        Block block = event.getBlockPlaced();
        if(block.getType() != Material.CHISELED_BOOKSHELF) return;

        BlockData data = ((BlockStateMeta) Objects.requireNonNull(event.getItemInHand().getItemMeta())).getBlockState().getBlockData();

        Bukkit.getScheduler().runTask(plugin, e -> {
            block.setBlockData(data);
        });
    }
blazing ocean
#

because they couldn't just use jsonops

kind hatch
smoky anchor
#

The item does not hold the block state

blazing ocean
#

i mean you could just ComponentSerialization.CODEC.decodeStart(JsonOps.INSTANCE, /* json object */).result()

split gull
#

i feel a bit lost, because im looking to make a user friendly nms library but not having mojang mappings for pre 1.17 is annoying

blazing ocean
#

shit you use spigot mappings right

split gull
#

wdym, i want to use mojang mappings

blazing ocean
#

(shadow, not you)

kind hatch
#

Yes I do

split gull
#

ah kk

kind hatch
#

Wait

#

no

#

I use mojmaps

split gull
#

two faces of the same coin

blazing ocean
#

so what the fuck is IChatBaseComponent

kind hatch
#

NMS

blazing ocean
#

you're using spigot mappings

#

mojang is Component

kind hatch
blazing ocean
#

right, that's spigot mapped

remote swallow
#

in total there is only this amount of servers running 1.14, 1.15 or 1.16

split gull
# kind hatch

i can send you a thing to use mojang mappings if you want

blazing ocean
#

?mappings

undone axleBOT
remote swallow
#

?nms

blazing ocean
#

I mean he's probably working on spigot or sth

kind hatch
#

I am :p

remote swallow
#

kekw

blazing ocean
#

just throw it into mappings.dev

torn shuttle
blazing ocean
#

linkie doesn't have spigot mappings sadly

split gull
#

ugh but i want to support older versions

blazing ocean
#

so live with the pain

#

@remote swallow wanna pr spigot mappings for linkie

#

linkie's kotlin

smoky oak
#

tuurns out this works

shelf.getInventory().setContents(
                ((ChiseledBookshelf)
                        ((BlockStateMeta)
                                Objects.requireNonNull(event.getItemInHand().getItemMeta())
                        ).getBlockState()
                ).getInventory().getContents()
        );
remote swallow
#

who is linkie

smoky oak
#

bloody mojang not fixing bugs man

split gull
remote swallow
#

um achskutally its 7

split gull
#

lol

kind hatch
torn shuttle
#

you think that's a big 1-liner? oh boy

split gull
#

dw i have big one lines too

torn shuttle
#

you should see my lambda statements

remote swallow
smoky oak
torn shuttle
#

really easy

smoky oak
#

step into?

blazing ocean
#

debuggers?

torn shuttle
#

don't write bugs

remote swallow
#

rad what is linkie

blazing ocean
#

my beloved

remote swallow
#

which part even has mappings

torn shuttle
#

if I ignore this memory leak hard enough maybe it will go away

remote swallow
#

i found it

#

no i dont want to pr iot

torn shuttle
#

guys help me manifest this memory leak away, everyone close your eyes and join me in saying "it can't hurt me if I can't see it"

kind hatch
#

Ah yes

#

Out of sight, out of mind

torn shuttle
#

I'm just manifesting bugfixes

#

as all good devs do

eternal oxide
#

I remember local Council IT departments upgrading the server memory so it didn;t run out before each daily reboot.

torn shuttle
#

hell yeah

#

I can really push this memory leak to the back of my mind

kind hatch
#

Oh, so that's why we need 4TB memory support on some systems

split gull
torn shuttle
#

yeah that sounds terrible

#

I only have 33% of my memory being used up right now

#

you should go fix your setup

split gull
#

idk what happened tbh

#

i have 32 gigs in theory

torn shuttle
#

I don't believe in closing browser windows, I believe in buying more ram

split gull
#

im with you

#

one day i'll just buy 256gb of ram and call it a day

smoky oak
#

a single one of my windows is 600 pages

split gull
#

πŸ’€

torn shuttle
#

I'm waiting until we have RAM measuring in the TB

smoky oak
#

unrelated, but is there a simple way to make an item glow as if enchanted without doing the unsafe enchantment / hide enchantments thing

torn shuttle
#

1tb ram, run the entire OS from it

#

would be sick

kind hatch
eternal oxide
#

Item as in ItemStack, or in world Item as in dropped Entity?

smoky oak
#

doesnt seem to be in the item flags

#

itemstack

#

this is to make inventory management esaier

kind hatch
#

Oooo, potential PR time.

smoky oak
#

ie, see if theres enchanted books in your chiseled bookshelf

#

if not, i just leave it alone

#

uuuh also how do i set stack size to 1 lol

#

turns out they stack πŸ˜…

#

and while chiseled bookshelves as book shulkers are funny, having 350+ books in ONE ITEM SLOT isnt

kind hatch
#

There's also a modern tag for that.

#

I just can't remember either of them atm

#

Ah, I found one of them. enchantment_glint_override

#

Example: /give @s experience_bottle[enchantment_glint_override=false]

smoky oak
#

wheres the tag container`? cant find it on the api

blazing ocean
#

itemmeta

kind hatch
#

Here's the other one.

smoky oak
#

wellll

blazing ocean
#

should be something with glint override or so

smoky oak
#

wait its all separate methods?

blazing ocean
#

luckily itemmeta is a highly flexible very similar to the one adopted by vanilla

#

thats intellij

smoky oak
#

noted

pseudo hazel
smoky oak
#

btw can i just do a random lambda method in my code? im tryina do this

boolean enchanted = e -> {
//code            
        }(shelf.getInventory());
kind hatch
#

It's relatively new.

pseudo hazel
#

oh like 1.21 new?

torn shuttle
#

ok

kind hatch
torn shuttle
#

current benchmark is 22 seconds to create a new world and then fill it with over 16 mil blocks

#

hm

#

oh and mobs

#

I don't really know how much faster I can make this

kind hatch
#

16mil blocks sounds like a lot though.
Are you generating normal terrain or something different?

torn shuttle
#

wfc modules

kind hatch
#

What are those?

cinder abyss
#

okay thanks, is there a documentation for that ?

torn shuttle
#

basically just a fancy way of doing modules that is very overkill for what I am currently testing against, hence why they're taking 0 seconds to resolve right now

echo basalt
torn shuttle
#

the modules come from worldedit clipboards, which may or may not be rotated

echo basalt
#

if you're using an amd system I'd up the ram mhz

torn shuttle
#

I am not using an amd system

echo basalt
#

still good to up it ngl

blazing ocean
torn shuttle
#

I also don't really care, it's plenty fast for my use

cinder abyss
smoky oak
#

uh
if at this point it has no glint override, how comes that the dropped bookshelf has the enchanted glint?

echo basalt
#

:/ I don't have 96gb ram

torn shuttle
#

sucks to suck

#

maybe you should get good

echo basalt
#

watch me order 256gb worth

kind hatch
echo basalt
#

to make ploogin

smoky oak
#

the bookshelf

torn shuttle
#

I got this ram for AI

#

which technically worked, at a glacial pace

echo basalt
#

I got this ram to fill my slots GigaChad

kind hatch
blazing ocean
#

ancient and shitty but yea

torn shuttle
#

anyway

#

I think I can live with sub-30s generation times

#

the lobby time is likely to be 30s-2min anyway

smoky oak
#

the fuckin block retains the enchantment override

echo basalt
#

just make it paste mid match anyways

torn shuttle
#

I considered it

#

but

#

wasn't really necessary

cinder abyss
echo basalt
#

the way we do it at work is to pre-gen a couple rooms around the starting room

#

and do A* pathfinding to figure out the next best room to generate

torn shuttle
#

that's the way I was doing it for the really large gens

#

except for your cringe generation method

#

but streaming-wise

#

like when dealing with closer to 1bil blocks obviously this won't do it

#

but for 16 mil?

#

it's an easy pog

echo basalt
#

any blocks far enough can get pasted with the "unsafe" methods because players aren't gonna see them

#

anything closer is done the same way + with a sendBlockChange packet or whatever

torn shuttle
#

yeah that's basically my plan for the bigger gens when I get around to them

echo basalt
#

lowers queue times to ~3 seconds in my case

torn shuttle
#

but it will require a different streaming strategy anyway because no one is going to have enough ram for this

echo basalt
#

can probably get a lot faster if we had a cpu that wasn't 10 years old

torn shuttle
#

wfc is naturally slower if you're doing 16x modules

#

which to be clear is fine by me

#

it has a lot of really interesting advantages

#

it's just not made to be created live

echo basalt
#

L

torn shuttle
#

if I get around to making those big gens they're not going to be disposable anyway

echo basalt
#

at some point just have a dedicated server to pre-gen these

torn shuttle
#

I considered distributing maps instead of the tech

#

makes sense for the city-sized ones

#

if you have a city that is 100k blocks in radius you probably would rather download a map since odds are it's going to take a really, really long time to generate, if you even have the hardware for it

#

with wfc it wouldn't be surprising to see a generation time that might span into weeks at that point

#

especially if you're having to store info into storage instead of memory due to the size

smoky oak
#

ok how the hell do i change a block's block state

#

bc this doesnt work

#
        ChiseledBookshelf shelf = (ChiseledBookshelf) block.getState();
        shelf.setBlockData(Bukkit.createBlockData(Material.CHISELED_BOOKSHELF));
        shelf.update();
#

it keeps the blockstate it had b4

slender elbow
#

i mean, "change" in what way?

smoky oak
#

i ran the above codde and well the block kept this

#

it keeps meta it shouldnt have

echo basalt
#

meta is part of the state not the data

slender elbow
#

I mean yeah that code doesn't really change anything apart from the block state properties you can see in the f3 screen

#

see the specific methods in the state's subclass

rough ibex
#

Blockstate β‰  blockdata

smoky oak
#

is this a reference? coz for itemstack its not

#

but theres no method to set it back

#

i cant replace it with a new meta if i only get a reference

#

great no method to create a new meta object in the first place

#

guess i have to manually unset everything

slender elbow
#

what are you talking about

#

the thing has an inventory, you modify the inventory however you please, and then call .update on it

smoky oak
#

well. block.update() does nothing except apparantly block the visual update caused by re-setting the contents manually.
it keeps the metadata

#

i stg where do blocks store their metadata

slender elbow
#

in the blockstate

#

in which you modify the inventory

#

and after modifying the inventory, which you did not do in the provided code, you call update

#

but simply changing the blockdata will not change the blockstate, and thus the inventory

#

if you don't change the inventory, the inventory won't be changed

smoky oak
#

its not the inventory im trying to change

#

im trying to make it so that the meta is cleared

#

which calling update doesnt do, i tried

#

it keeps the glint override

smoky anchor
#

What glint, bookshelf has no glint

smoky oak
#

im setting it to have the enchantment glint if it contains enchanted books

#

issue: that glint stays

#

permanently

smoky anchor
#

When do you want it removed ?

echo basalt
#

oh god I just realized husktowns does event handlers in a mega cursed way

smoky anchor
#

that may be a silly question

echo basalt
#

they make the event handler an interface and then they just have a big class that implements all of them

smoky oak
#

i want that after placing down it is in a state that could've been achieved naturally

smoky anchor
#

Ok, how are you making it have glint. Are you using the data component ?

smoky oak
#
            meta.setEnchantmentGlintOverride(true);```
when the item is created; this meta is set onto the itemstack
smoky anchor
#

so yes, gimme a sec

smoky oak
#

ok mojank levels of code here

block.setType(Material.AIR);
block.setType(Material.CHISELED_BOOKSHELF);
#

that fixes it

smoky anchor
#

well yes but no

kind hatch
#

I wish we had components in spigot already. 😭
Would make my life easier rn.

smoky oak
#

do you have any better ideas? im 100% serious with that question

upper hazel
#

Guys how you think how long time this take create fake player. This fake player not will just gost. He will full registered in server like real

smoky anchor
#

If Spigot can somehow access the components field, you should clear it there.

upper hazel
#

plugin exists like it?

smoky oak
#

which i have 0 clue how to get

smoky anchor
#

When you mine it, do you get the item with glint back ?
'cause I don't

smoky oak
#

only bc i copy the block state to preserve the books

#

im trying to make shulkers but books

smoky anchor
#

Me confusion
Are you trying to make it so when you mine the bookshelf it retains the books ?

smoky oak
#

yep

smoky anchor
#

Can you show the code responsible for retaining the books ?

smoky oak
#

works too. but of course minecrafts code is so bloody jank that 2/3rds of my code are 'ok how do i get around THIS bug'

#

sure

smoky anchor
#

It may not lead anywhere but I still wanna give that a try

smoky oak
#
    public void onBreak(BlockBreakEvent event){
        Block block = event.getBlock();
        if(block.getType() != Material.CHISELED_BOOKSHELF) return;
        ItemStack tool = event.getPlayer().getInventory().getItemInMainHand();
        if(tool.getType() == Material.AIR || 0 == tool.getEnchantmentLevel(Enchantment.SILK_TOUCH)) return;
        Location blockLocation = block.getLocation();

        ChiseledBookshelf shelf = (ChiseledBookshelf) block.getState();
        if(shelf.getInventory().isEmpty()) return;

        ItemStack stack = new ItemStack(Material.CHISELED_BOOKSHELF, 1);
        BlockStateMeta meta = (BlockStateMeta) stack.getItemMeta();

        assert meta != null;
        meta.setBlockState(block.getState());
        meta.setMaxStackSize(1);
        if(shelf.getInventory().contains(Material.ENCHANTED_BOOK))
            meta.setEnchantmentGlintOverride(true);
        stack.setItemMeta(meta);

        shelf.getInventory().clear();

        Objects.requireNonNull(blockLocation.getWorld()).dropItemNaturally(blockLocation, stack);
        event.setDropItems(false);
    }

(the inventory clear is because the books arent part... of the... block break event drops.)

smoky anchor
#

Oh-
I see what you're doing
So uhhh
try

if(shelf.getInventory().contains(Material.ENCHANTED_BOOK))
    meta.setEnchantmentGlintOverride(true);
else
    meta.setEnchantmentGlintOverride(null);

Since you're copying the components into the item (I think) you have to reset the flag as well.

blazing ocean
#

why not just set it to false

smoky anchor
#

'cause reasons

#

null will remove the component itself which is closer to the default state of that item

#

I must say, that I despise the fact that vanilla block states are called spigot block data. I understand the reason but it's just so damn annoying.

smoky oak
#

i want it gone from the block after its placed

smoky anchor
#

Yeah I'm lost, sorry

smoky oak
#

i mean i have a workaround

#

i can just do it properly once spigot has access to components

echo basalt
#

null is the default while false can override, for example, enchanted books or items with enchantments

rough ibex
#

Tristate booleans

blazing ocean
#

true, false, maybe

smoky oak
#

i stg bukkit πŸ˜…

ItemStack stack; (is enchanted book)
stack.getEnchantments().size() == 0
#

its not in itemmeta either

remote swallow
#

enchanted book meta iirc

smoky oak
#

why is that separate lol

remote swallow
#

fuck knows

smoky oak
#

title.append(ench.getKey().getKey()).append(", ");

#

nothing to see here

#

namespaced keys being namespaced keys lol

smoky anchor
# remote swallow fuck knows

EnchantmentMeta is specific to items that can store enchantments, as opposed to being enchanted.
So that silk touch book can not mine glass.

smoky oak
#

ah

#

makes sense i guess

kind hatch
#

Gotta love minecraft's own implementation of blank number formats causing the game to crash.
Now I have to do jank workarounds for this.

#

Why even have the class then?

#

Disgusting

smoky oak
#

oh simple fix

#

paste over block data

blazing ocean
kind hatch
#

What gets me is that it is apparently expecting a different reference.
No clue where to find it though.

eternal night
#

BlankFormat.INSTANCE

#

or something else, spigot mappings be dammned

grim hound
#

Is World::getBlockAt thread-safe?

eternal night
#

....

grim hound
#

is not then

eternal night
#

obviously not lol xD

grim hound
#

altough it's in a dev env

blazing ocean
#

being in a dev env makes zero difference about thread safety kekw

kind hatch
blazing ocean
#

do you think it just toggles thread safety based on whether you're in a dev env

grim hound
#

wonder why

thorn isle
#

what isn't thread safe is calling methods on Block that'd access the world, e.g. getType

grim hound
#

xd

thorn isle
#

it depends from method to method but most of the world accessing methods on Block just transparently schedule a sync task to do the call on the main thread and then have your thread blocking for it

turbid peak
#

Hey, just to know im currently devloping an paper only plugin and i don't know if i can post it on the site and if yes with what categorie ?

thorn isle
#

making them "thread safe" in the sense that it won't explode, but slow, as you'll probably be waiting for a good 20-50ms for the next tick to come around

pure dagger
#

is there a way to instantly know when player leavves the worldguard region? MoveEvent would be too unefficient right?

#

i need to give player inventory when they enter a region and take it back when they leave, but what when they leave while reloading or while the plugin is off etc.. or they can switch from 1 to another region immediately

young knoll
turbid peak
#

okey ty

young knoll
pure dagger
#

isnt it laggy anyway/??

young knoll
#

Huh guess not

#

Yet they have entry and exit messages

#

smh worldguard

pure dagger
#

uhm okay thakn you

young knoll
#

Your only option is the move event then

wet breach
echo basalt
#

worldguard has an easy way to do events

slender elbow
#

you'd use a Handler or whatever they call it, but even then there's nothing wrong with using the move event, they themselves use the move event to check for crossing region boundaries, just don't check on every call, but on block change

pure dagger
#

should i be concerned about cases like player somehow leaving the region and not being caught by event?

blazing ocean
#

that'd be a WG bug

pure dagger
#

like what if player movΓ©s out while reloading or if just someone wants to delete the plugin but.. player inside the region

remote swallow
#

thats the end users fault for reloading

thorn isle
#

solves the issue for both reloading and uninstalling the plugin

#

an example case of not doing this is one custom food plugin i forget the name of, which would adjust a player's max health based on the diversity of their diet

#

uninstalling the plugin would leave the player permanently stuck at a nonstandard max health, and you'd either need to fix it with a nbt editor on a per-player basis or write a plugin to do it in bulk

pure dagger
#

right

#

i have an idea

lethal knoll
#

Any possiblity to check if an EntityType is considered a HumanEntity ?

Problem is HumanEntity is for LivingEntity. How can I check the same for just EntityType ?

sullen marlin
#

? getType() or whatever

chrome beacon
#

getType == PLAYER ?

lethal knoll
#

.getEntityClass().isAssignableFrom() ?

#

Would work right?

chrome beacon
#

So you're not talking about the EntityType enum

#

but the entity class

lethal knoll
#

No I am not

#

EntityType is enum

#
boolean isHuman = type.getEntityClass().isAssignableFrom(HumanEntity.class);
#

Should work right?

eternal oxide
#

You can not tell if a LivingEntity is a HumanEntity just from the enum

lethal knoll
#

hmm

eternal oxide
#

HumanEntity are Players only

chrome beacon
#

Well a player would be a human entity

chrome beacon
#

would work

eternal oxide
#

not if he only has teh type

chrome beacon
#

replace getType with the type variable

eternal oxide
#

he needs an actual Entity

lethal knoll
#

Let me maybe elaborate a bit further with a different use case :

#
   @Override
    public void applyToEntity(LivingEntity livingEntity, Object value) throws MobPropertySetException {

        this.validateInteger(value);
        int size = (Integer) value;

        if(livingEntity instanceof Slime){
            Slime slime = (Slime) livingEntity;
            slime.setSize(size);
            return;
        }

        if(livingEntity instanceof Phantom){
            Phantom phantom = (Phantom) livingEntity;
            phantom.setSize(size);
            return;
        }
        throw new MobPropertySetException("Size property is not applicable for " + livingEntity.getType());
    }
#

well actually not a great example either -_-

#

Because size is hardcoded on those classes

chrome beacon
#

Yeah I have no idea what you're trying to do

#

nor what the issue is

lethal knoll
#

so I have an attribute for setting the hand. But that belongs to a HumanEntity

#

I am trying to validate if the entity would be eligable for setting the hand in the first place

thorn isle
#

instanceof HumanEntity

chrome beacon
#

^^

lethal knoll
#

but it's EntityType :/

thorn isle
#

or are you saying you want to validate whether an EntityType would be eligible for setting the hand

lethal knoll
#

HumanEntity would be in case I do have a LivingEntity

chrome beacon
#

Then check EntityType == Player

echo basalt
#

mfw ecs

chrome beacon
#

Because player is the only human entity

lethal knoll
#

Alright

eternal oxide
#

no, LivingEntity is not always a HumanEntity

lethal knoll
#

Okay, I'll use that

#

I know

#

that's not what I meant

#

Checking if type = Player would be fine

#

As long as it results in the same for for example a zombie

thorn isle
#

if you are validating an EntityType (your code fragment shows you validating an entity instance, which is different) the assignableFrom method you mentioned before is the go-to

thorn isle
#

yes

#

but again your example shows you validating an instance, not a type

#

and for that you use instanceof

echo basalt
#

generic types go brr

lethal knoll
#

This?
boolean isHuman = type.getEntityClass() != null && HumanEntity.class.isAssignableFrom(type.getEntityClass());

lethal knoll
#

That cannot be right? I would have to hard code all the different mob types that are able to have items

#

That doesn't sound quite right

thorn isle
#

what

eternal oxide
#

Why are you messing around with type at all?

#

You have an INSTANCE

#

use it

lethal knoll
#

That is not true

#

I do not have an instance in this case

#

I only got the type

eternal oxide
#

in your example you did

lethal knoll
#

It was an alternative :/ and there I already use instanceof

#

But alright

eternal oxide
#

if you ONLY have the type and its a LivingEntity its impossible to tell if the instance would be a HumanEntity

thorn isle
#

then the assignablefrom is the way to go

lethal knoll
#

Thanks

#

I'll use AssignableFrom

#

Okay I don't know why, but that doesn't work

thorn isle
#

try doing it the other way around

lethal knoll
#
        return HumanEntity.class.isAssignableFrom(bloodmoonMob.getType().getEntityType().getEntityClass());
#

I did

eternal oxide
#

a Mob is NOT a HumanEntity

thorn isle
#

i don't think setHand does what you think it does

#

setHand is for setting the primary hand on a player/human entity

lethal knoll
#

what does this have to do wit hthe set hand?

thorn isle
#

you are trying to set the item held in the hand of the mob

chrome beacon
#

Is bloodmoonMob a player?

lethal knoll
#

no

chrome beacon
#

Then it won't be a human entity

#

That statement will always be false

eternal oxide
#

then as I and others have been telling you, your code will not work

lethal knoll
#

All that is relevant is that the .getType() of bloodmoon mob returns EntityType

#

As it's a data object

thorn isle
#

which entitytype does it return

eternal oxide
#

and it will NEVER be a HumanEntity

lethal knoll
#

ZOMBIE

thorn isle
#

that is not a player nor a human entity

#

the if clause will evaluate to false

lethal knoll
#

hmm

thorn isle
#

again i think you are trying to set the item held by the mob

#

setHand isn't what you want to call

lethal knoll
#

To be very very specific, I got the onCommand, it's passing in as a first parameter the EntityType

#

then it's supposed to only fetch the controllers for those properties who are applicable for the given type

#

so for example:

#

explosionRadius will only show for Creeper

#

And in this case:

#

I want to only show the controller when the Entity representing the EntityType would have the method.getInventory().setItemInMainHand

#

you understand my point

#
    @Override
    public void applyToEntity(LivingEntity livingEntity, Object value) throws MobPropertySetException {
        HumanEntity humanEntity = (HumanEntity) livingEntity;
        String item = (String) value;

        BloodmoonItem bloodmoonItem = itemService.getItem(item).orElse(null);
        if(bloodmoonItem == null){
            throw new MobPropertySetException("Item with name " + item + " does not exist!");
        }

        humanEntity.getInventory().setItemInMainHand(bloodmoonItem.getItem());
    }
#

You can ignore this

#

but it gives better insights

thorn isle
#

okay, now we know what you want to do and can tell you that HumanEntity has nothing to do with it

lethal knoll
#

Alright

thorn isle
#

inventories are not limited to players

lethal knoll
#

I really thought the method came from this

#

But okay, apologies in that case

thorn isle
#

every LivingEntity has equipment

lethal knoll
#

Alright

thorn isle
#

and equipment is what determines what's in the hand

lethal knoll
#

Yes understood

thorn isle
#

but afaik there is no good way of telling whether that equipment will render

#

e.g. a chicken can have equipment but it's not going to physically appear on the mob

lethal knoll
#

Okay, clear, so it won't cause any issues because they are living entities

#

in other words

#

in my case I just return true

#

or I would need explicit checks

#

for EntityType

thorn isle
#

or maybe getEquipment returns null for entities that can't display any equipment

lethal knoll
#

hmm, yeah

#

let me check

thorn isle
#

don't know, try it and see

#

but i'd guess that you'll end up hardcoding a set of entitytypes that do support equipment

lethal knoll
#

Yeah could also be

#

Well I actually don't have to fetch the inventory contents in this case

#

so as long as setting it for any living entity is not causing an issue, I should be fine

#

thanks for the help

thorn isle
#

the issue is that you can't set an equipped item for an entity that has no equipment

lethal knoll
#

No okay, but it won't throw an error error right? I mean, it will just not have any effect

#

for example

#

you can try to give a creeper a sword

#

it will work, but it won't wear any

#

and there will be no use of the item

thorn isle
#

because then trying to set the held item on that equipment is a NPE

lethal knoll
#

Yes ofcourse, I understand

thorn isle
#

but after a quick trip to nms town, it looks like there's a method on LivingEntity that determines which slots it can use

#

LivingEntity::canUseEquipmentSlot

lethal knoll
#

notNull

#

so should be fine

#

aaah

#

that is interesting!

thorn isle
#

livingentity::getequipment is nullable

thorn isle
# thorn isle LivingEntity::canUseEquipmentSlot

while this is a method on the entity class itself, not entity type, the nms implementation always only returns true or false regardless of the data on that instance; i.e. it depends solely on the class

lethal knoll
#

canUseEquipmentSlot is not a thing on spigot api though

thorn isle
#

so what you can do is loop through every entity type at startup, instantiate one of each, and check which equipment slot they can use

lethal knoll
#

And if inventory can be null, all fine, then I just do a check before trying to access it

thorn isle
#

kind of sort of defeats the point of the whole ecs business but sure, that'll work

lethal knoll
#

hmm, not sure if that is worth it for this use case

#

but I understand you

#

Yes ofcourse, but if there is no proper way to check this using the API, you will always end up with dirty work arounds :p

#

so either I will hardcode all of it, or I do what you said ealrier with the check at the onEnable

#

but for now I will go for thework around

#

Thanks for the help, much appreciated

thorn isle
#

i'm a pretty appreciable guy

fickle spindle
slim wigeon
#

This is annoying. I messed up my own plugin by making a functional inventory system

slim wigeon
#

I guess this is what I get for not making backups

dusty herald
#

how did u mess it up

slim wigeon
#

You know how inventories work? I have this farming rod. I used to have this InventoryManager class I wrote that lets me store 27 types of items. I had to rewrite the InventoryManager because I wanted a functional inventory but given the issues I have with addItem function from Inventory Bukkit class, I seeing errors and I don't know how to fix

#

But it was working before the rewrite was attempted

dusty herald
#

Can you please post the code and the errors? Maybe it's something simple you've overlooked

#

?paste

undone axleBOT
slim wigeon
dusty herald
#

The errors?

slim wigeon
#

Ignore the other errors, the rest is from another plugin. These are the only errors from the Farming Rod

dusty herald
#

what IDE are you using?

chrome beacon
#

Looks like Eclipse

dusty herald
#

you might be correct

dusty herald
slim wigeon
#

Just wait a second, I need to fix line 53

dusty herald
#

I don't have the context for line 53 but it appears that you assign the variable item more than once

#

oo i just found the context

#
    @EventHandler
    public void onBlockBreak(BlockBreakEvent event) {
        Player player = event.getPlayer(); Block block = event.getBlock(); ItemStack item = player.getInventory().getItemInMainHand();
        List<Material> ignoreItems = Arrays.asList(
            Material.WOODEN_SWORD, Material.STONE_SWORD, Material.IRON_SWORD, Material.GOLDEN_SWORD, Material.DIAMOND_SWORD,
            Material.NETHERITE_SWORD, Material.TRIDENT
        );
        if( !farmLib.isVaild(block) ) { return; }
        
        FarmRod farm = farmLib.get(block);
        if( !player.getGameMode().equals(GameMode.CREATIVE) ) {
            event.setDropItems(false); block.getWorld().dropItem(block.getLocation(), farm.getItem());
            for( ItemStack item : farm.getInventory().getContents().entrySet() ) {
                block.getWorld().dropItem(block.getLocation(), slotItem);
            }
        } else {
            if( ignoreItems.contains(item.getType()) ) { return; }
        }
        
        farmLib.remove(block);
    }```
You've assigned the item variable in the for loop while already assigning it previously in the code, specficially the first line of this function
thorn isle
dusty herald
#

Yeah. You don't even have to have a github account to use them, right?

thorn isle
#

github is just a remote git host with some extra bells and whistles

dusty herald
#

ah okay

thorn isle
#

most competent ide's now i think come with a git integration built in

#

intellij for sure does

dusty herald
#

Our friend is using Eclipse sadly

sonic goblet
#

Eclipse does

slim wigeon
#

I don't want my code up there, sorry. I like everything local. Maybe soon I will use it but I cannot trust anyone these days

sonic goblet
#

I believe you have to download a plugin from the marketplace tho

thorn isle
#

like i said you can do it locally

#

git != github

sonic goblet
#

Oh sorry I misread

thorn isle
#

github is just a popular place to shove your git repo into

dusty herald
slim wigeon
#

I cannot talk about piracy here but lets say Nintendo made a emulator move its repo to private server. About private repos, these cost money that I don't have

thorn isle
#

they don't

#

and again, you can use git locally

slim wigeon
#

I just like to have control what I put out there

thorn isle
#

has nothing to do with github

#

you don't put anything out anywhere

#

its on your disk

slim wigeon
#

Now all errors shows "Description Resource Path Location Type
Type mismatch: cannot convert from element type Map.Entry<Material,Integer> to ItemStack BlockListeners.java /MG-FarmRod/src/main/java/com/mrnategeek/farmRod/Listeners line 53 Java Problem
" Now

thorn isle
#

have you tried reading what it says

#

java is a strongly typed language

#

you can't assign something that is typed as Map.Entry<Material,Integer> to a variable of type ItemStack

slim wigeon
#

I see what it says but like I said, it was working before I attempted to rewrite the whole InventoryManager

#

I cannot tell what I did

thorn isle
#

this is because you changed the return type of a method

#

farm.getInventory().getContents()

#

this used to return something else

#

now it returns a Map<Material, Integer>

#

which you are calling .entrySet on to get a Set<Map.Entry<Material, Integer>>

slim wigeon
#

Its the same as my other plugins

thorn isle
#

which you are then using in an enhanced for loop to assign a Map.Entry<Material,Integer> to ItemStack item

#

so either you change the variable type or you change the method return type

slim wigeon
#

Wait, I see what I did

#

I used keySet instead of entrySet

thorn isle
#

if you're new to strongly typed languages my beginner advice would be to not do chained method calls, but declare and type a variable for each intermediate value

fickle spindle
#

there is a way for make an inventory for each world?

chrome beacon
#

Listen for world change

#

then store the inventory somewhere

#

and load the inventory for the world that was entered

fickle spindle
#

best place where i can store the inventories?

chrome beacon
#

It's own file or just pdc

fickle spindle
#

what pdc is ?

chrome beacon
#

?pdc

chrome beacon
#

PersistentDataContainer

mint nova
#

?paste

undone axleBOT
mint nova
#

https://paste.md-5.net/noqafihigo.css

package plugins.kacz0r.pl.eventCrates.crates;

import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;

public class TestCrate implements Listener, CommandExecutor {

    private final ItemStack item = new ItemStack(Material.CHEST);

    @Override
    public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {

        if (!(sender instanceof Player player)) {
            return true;
        }

        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName("Test");
        item.setItemMeta(meta);

        player.getInventory().addItem(item);

        return true;
    }

    @EventHandler
    public void PlayerPlaceCrateEvent(PlayerInteractEvent event) {
        Player player = (Player) event;

        if (player.getItemInHand().isSimilar(item)) {
            if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
                event.setCancelled(true);
                player.sendMessage("Denied");
            } else if (event.getAction() == Action.RIGHT_CLICK_AIR) {
                player.sendMessage("Allow");
            }
        }
    }
}
        getCommand("crate").setExecutor(new TestCrate());
        getServer().getPluginManager().registerEvents(new TestCrate(), this);
eternal oxide
#

two different instances of TestCrate

#

but the error...

#

your Player variable is out of scope once it exits the code block

#

thats in yoru commad

mint nova
eternal oxide
#

but also an event is never going to be a player

#

Player player = (Player) event;

slim wigeon
eternal oxide
#

thats going to blow up every time

mint nova
#
Player player = event.getPlayer()

will work?

eternal oxide
#

pretty sure that event has a getPlayer() method

#

yes

mint nova
#

ty

dusty herald
#

I suggest restarting but if it works it works

slim wigeon
#

Yes

mint nova
slim wigeon
#

That is not the cause, I know. It will be the same if I restarted. If its using H2 and MySQL. Then yes, I need to restart

#

But trying to clone Songoda's inventory system breaks my plugin to the point that its still not quite fixed

#

I attempting again but different, back up in place

remote swallow
#

i recommend reading

#

?gui

urban cloak
dusty herald
#

Reloading tends to break some plugins, most of the time from my own experience it's caused by memory leaking issues

sterile axle
#

generally because they're too negligent to properly implement onDisable

dusty herald
#

Thankfully spigot API does a good portion of it, at least event wise

#

I still like to unregister my own events though to be 100% sure

#

What I don't like is that I'm always worried that any code that I run in onDisable could possibly be interrupted or just not triggered at all

manic delta
#

how can i use it now?

#

i know it says Registry.get but how exactly

remote swallow
manic delta
#

how do i access to that?

#

but wait

#

Player.playSound(location, "minecraft:entity.player.attack.sweep"...) should work right

#

yea it works

#

tysm

remote swallow
manic delta
#

yea thank you

slim wigeon
#

I have this function. Its a List<ItemStack> as you can see but how can I delete the entry from the list?``` public List<ItemStack> add(List<ItemStack> items) {
for( ItemStack item : items ) {
item.setAmount( this.add(item).getAmount() );
}

    return items;
}```
ivory sleet
#

remove() usually

slim wigeon
heavy fulcrum
#

Hello! I'm trying to develop an economy plugin (with Vault support). Currently I am storing player data in a YAML. The YAML looks something like this:
player-uuid: balance: 100
Now, I have some commands which can deposit, withdraw, set and view the targetted player's balance. I want it so that even offline player's balance can be manipulated and/or viewed. To do this, I tried using Bukkit#getOfflinePlayer(UUID) and giving the keys from the YAML as argument. I also have an event listener which adds the player's balance as 0 in the YAML in case they have not joined the server before. But when the player joins for the first time, this doesn't work. It works from the second time. What mistakes am I doing here?

#

That turned out to be quite a long message lol

wet breach
#

probably not saving it

#

need to routinely save your modifications as they are just in memory until you do so

#

without code and assuming that being the case, it would make sense why it works on the second join if you only save data when they leave

heavy fulcrum
#

I'm constantly saving data at all times...

#

Can I share the GitHub repo? Individual files would have too less context

wet breach
rough drift
wet breach
#

I mean its not like vault controls it o.O

rough drift
heavy fulcrum
wet breach
#

they are making an Econ plugin

#

thus the only value of hooking into vault would be either for permissions, detecting other economy plugins or just making making it easier for others to use your econ plugin

heavy fulcrum
#

The DataStorageManager class does it all. It should still work without Vault?

#

Or am I being unreasonably stupid here? I probably am

wet breach
#

so according to this, it needs a string, even for the other method

#

but in your listener you are giving it a player object instead

#

you also return false on creating the account

#

I recommend first making your economy plugin without any other dependencies

#

and then once that is working, work on adding vault integration and whatever else

#

I probably wouldn't even use vault all together

#

and instead just make an api for your econ plugin

#

there isn't really any particular advantage to integrating vault

heavy fulcrum
heavy fulcrum
wet breach
#

it isn't difficult to make your own api for your plugin

heavy fulcrum
#

And isn't the DataStorageManager class essentially an API? I can use it's methods directly instead of using Vault

slim wigeon
#

Are you trying to make a economy plugin that auto hooks to Vault? Why not just use EssentialsX? It has economy features

heavy fulcrum
#

I'm making a custom plugin for my server. It will use Diamonds as the currency.

#

I know there's plugins like that already, but I want to make it myself

slim wigeon
#

Diamonds as in ItemStacks?

heavy fulcrum
#

Yes

#

Basically, there will be a cloud storage system for every player's diamonds. All transactions are to be made from this storage.

#

Something like an inventory GUI. But that's something that I'll add later.

slim wigeon
#

In that case, I cannot help you there. I still trying to get my inventory system for my farming rods working

heavy fulcrum
#

I just need help with the current state, the diamond based currency is not a priority at this point. Good luck with your project though.

wet breach
#

cloud is just another way of saying server

#

nothing more lol

heavy fulcrum
#

ah right.

smoky anchor
#

Unless you literally make the diamonds fly up to the skies :D

heavy fulcrum
#

Essentially they are chests without physical locations

slim wigeon
#

But if you need something quick, search custom villagers and add a diamond shop that way. But you have been warned, shop villagers must be protected otherwise you be running the command block again. Once set up, you don't have to rush to get the plugin working

smoky anchor
#

Imagine, loading screen for "downloading diamonds from the cloud"
And its just pissing diamonds on you XD

heavy fulcrum
#

Bruh

heavy fulcrum
slim wigeon
#

I had a exchanger service for emeralds that converts gold to iron and all that. Then when I added ShopGUI+, I killed it

wet breach
#

as for storage, I would probably just stick with MySQL since it is really good in the transactional area, high volume, high concurrency with rollback features and commits. I doubt you will need that anytime soon but it is a good starting point.

heavy fulcrum
#

I have considered MySQL too. But my server is pretty small (6 concurrent players), so I don't really need to go too far.

wet breach
#

you can tailor mysql as you go

#

sure for 6 it may be overkill lol

heavy fulcrum
#

I'll definitely do MySQL too.

rough drift
wet breach
#

no

slim wigeon
#

You can use what my farming rods use, a yml file. But I don't know about when there is 100+ players, you might want to switch to H2 or MySQL

wet breach
#

they are all just servers, and that is a hybrid beowulf cluster

rough drift
#

running virtual servers

#

a cloud

wet breach
#

there is some other names too to define various other kinds of server services. But cloud is just a made up buzzword that means nothing except to people who are sold services and have no clue what it is

heavy fulcrum
wet breach
#

if you want to continue believing cloud is something go for it. I will stick with the real definitions

#

since cloud never revolutionized anything

#

just was a name change

heavy fulcrum
#

The easy solution for my problem would be to just get the players to join twice

#

Because I guess that's how Bukkit#getOfflinePlayer() works

wet breach
rough drift
heavy fulcrum
wet breach
#

OfflinePlayer.isOnline()

slim wigeon
#

You know cloud storage for a example is not really a cloud, its in data centers. Discord or even Spigot website can be hosted there. So I recommend you stop trying to define cloud

heavy fulcrum
#

I have used it, but I don't think it works well

wet breach
#

it does, when ever you need a player object from somewhere, you can create your offlineplayer object then simply check if they are online. IE when using commands etc.

heavy fulcrum
#

I have a static HashSet of OfflinePlayers in the main class which is populated by objects at startup by Bukkit.getOfflinePlayer().
Then I just try to filter out the objects whose name matches with the argument provided in the command

wet breach
#

you can cast from OfflinePlayer to Player since Player extends OfflinePlayer

#

so its real handy to do a simple check if you have an OfflinePlayer object to just see if they happen to appear online before manipulating the object etc

heavy fulcrum
wet breach
#

if they are online, Just cast to Player and use the Player object from then on πŸ™‚

#
OfflinePlayer offPlayer = Bukkit.getOfflinePlayer(string);
Player player = (Player)offPlayer;
heavy fulcrum
#

getOfflinePlayer(String) is deprecated...

wet breach
#

sure but not unusable

#

how else you intend to get the object when using a command?

#

search up their uuid from some website first?

#

or just let the server internals do it for you

#

letting the server internals do it, means you still have to give it a string, hence why it still exists

heavy fulcrum
#

I do something like this:
OfflinePlayer target = Bukkit.getOfflinePlayers().stream().filter(p->p.getName().equals(/*name provided in argument*/)).findFirst().orElse(null);

wet breach
#
UUID playerUUID = Bukkit().getOfflinePlayer(string).getId();
heavy fulcrum
#

But it works around the deprecated methods

#

idk why I don't use them

wet breach
#

not really, because you are assuming deprecated means you can't use it

heavy fulcrum
#

I probably should when it works most of the time

random stump
#

hi

wet breach
#

the reason string is deprecated is mostly to inform that player names can change, not that there is anything wrong with using it as long as you are aware of that fact

heavy fulcrum
#

alright alright

wet breach
#

so for example, when a player is on the server online their name isn't going to magically change while they are on the server

young knoll
#

It’s also to inform you of the potential blocking web request

wet breach
#

yeah there is that too

wet breach
#

good luck with your plugin development

#

I am going to bed now πŸ™‚