#help-development

1 messages · Page 1958 of 1

quaint mantle
#

thank you

sleek pond
#

Better question is, what tf is that theme

quaint mantle
#

alright sorry to be a pain for the millionth time but my loaditems method causes an error that disables my plugin if it restarts after an item is added and saved into the items.json file

#

public static void loadItems() throws IOException {
Gson gson = new Gson();
File file = new File(MagnificentMenus.getPlugin().getDataFolder().getAbsolutePath() + "/items.json");
if (file.exists()) {
Reader reader = new FileReader(file);
ItemStack[] m = gson.fromJson(reader, ItemStack[].class);
Menu.menuitems = new ArrayList<>(Arrays.asList(m));
System.out.println("Loaded Preexisting Menu Items Successfully!");
}
}

#

this is the error i get

eternal night
#

You cannot just use gson to serialize an item stack

quaint mantle
#

what would i use then, bukkitinput/outputstream?

eternal night
#

An item stack contains item meta which is a hidden server implementation

#

Yea that's one way

quaint mantle
#

ok

eternal night
#

If you goggle I think someone made a gson adapter for item stacks

#

Tho idk the quality

waxen plinth
#

My library has a method to convert an item to a string and back

storm crescent
#

Is there a way to overwrite the getUniqueId method? If so, how?

quaint mantle
vocal cloud
#

Make your own

quaint mantle
#

bruh so your saying make my own tutorial on something i dont even know how to do, thats logical

hexed hatch
worldly ingot
#

There is no possible scenario where this is necessary lol

quaint mantle
#

how could I stop a player from entering nether portal? Is there like a portal enter event or something?

quaint mantle
#

like how would i output it to a json

storm crescent
maiden thicket
warm light
#

onLoad run before onEnable?

young knoll
#

yes

warm light
#

this.getConfig().exist is not valid code. how to check if config.yml exist?

young knoll
#

saveDefaultConfig will copy the config from your jar if it doesn’t already exist

#

So you can ensure it will exist

wet breach
#

saveDefaultConfig() suggested above should be in your onEnable() and it will silently fail if a config.yml already exists so no need to add additional checks for it

#

if you still want to check if a file exists, use File API from Java to do so

warm light
#

ok

low temple
young knoll
#

You don’t really need to use file.separator

wet breach
#

only I just didn't type out the relevant code for such

low temple
young knoll
#

No but you can just use /

#

Or the other constructor that takes a file and a string

low temple
young knoll
#

Yes you can

low temple
#

I used to have that and it worked on my computer but didn’t on a host

young knoll
#

The file constructor will convert it

low temple
#

Well it’s always better to

warm light
#

I am making a auto update config.yml on plugin update.
like if I add new keys on config, it will auto generate. admin's don't need to remove old config.

also java don't support yml.

#

anyone can tell me best process to do it?

young knoll
#

Java don’t support yaml?

warm light
#

umm. I mean is it officially support by java?

young knoll
#

Define official

#

At the end of the day they are just text files

#

But java does not have any built in libraries to parse them, afaik

#

Which is why spigot uses SnakeYaml

warm light
#

alright. then ignore that part. can you tell me a best way to auto update config?

young knoll
#

Load both the one in the jar and the one in the folder

#

Copy any keys missing from the jar one to the folder one

#

And then save it

wet breach
#

snakeyaml is a library that is already geared towards the yaml spec

#

but I mean it makes use of all the java API to do what it does lol

young knoll
#

Yeah you can parse anything you want manually

wet breach
#

as far as making an auto-updating code for your config.yml that is relatively easy to do

#

I can show you an example of just how easy it is it lol

#

those lines there is all it took to do an update to a file 😛

#

feel free to browse the repo for anymore useful code

#

it is open source after all 🙂

young knoll
#

It’s basically just looping over the keys in the new file and copying any that don’t exist in the old one

#

Although I’ve never actually done it, probably because I didn’t want to yeet comments

#

But that’s not an issue now

wet breach
young knoll
#

Gotta explain things somehow

wet breach
#

generally config files should be structured in a way that it for the most part should speak for itself

young knoll
#

Easier said than done

#

Users can be... special

wet breach
#

lol

#

well can't help the PBKAC problem

storm crescent
#

Is there a way to make sure my plugin's join event fires before every other plugin?

young knoll
#

The most you can do is set it to LOWEST priority

#

But even then other plugins using LOWEST may still fire before yours

wet breach
#

because while although you could make your event fire first, that means it will have the last say in what happens

#

if this isn't what you want then instead you would want to have your plugin handle the event last

storm crescent
wet breach
#

not sure why you would need to do such things unless you are using offline mode

#

in which case such things are not supported here

#

however I suspect you are running an outdated server version as well

warm light
wet breach
#

if the config contains the section I seek, I go ahead with the object creation/assignment, otherwise if it doesn't exist no need to do anything anyways 😛

#

that specific code, moves a section from the config.yml and puts it in the data.yml

#

and then clears the section from the config.yml

#

I do need to update that plugin at some point, but anyways before it was popular most everything could fit in the config.yml

#

then the features expanded and the data it was saving didn't make sense to have in the config.yml

#

so, that bit of code moves the data for the user without any fuss 🙂

#

however, as you can see it didn't take much to update configs though

mortal hare
#

shower thought

#

lets say we restart the server whenever player clicks on the inventory slot and the item is transferred to cursor

#

what happens to cursor item after the restart

#

where does it go

young knoll
#

You’d probably have to test it

#

Imma guess it goes back to where it was

mortal hare
#

but how would it know which slot he was in

#

i can hold cursor item for hours

#

what if the cursor item is set via the method

#

so many questions

#

😄

wet breach
#

player data is written whenever players leave as well as when the world save happens

#

world save happens on normal shutdown as well or should

young knoll
#

You don’t even need a plugin to test it

#

Just pick up an item and then run stop in the console

mortal hare
#

what if you set the cursor via player.getOpenInventory() tho

wet breach
#

that just moves the cursor to the spot

#

doesn't force click for the client

mortal hare
#

now thats impressive

neon minnow
#

@mortal hare do you need spigot help? If not, then dont spam youtube links

neon minnow
#

dont give me that attitude

#

go to general

lost matrix
neon minnow
#

who are you

lost matrix
neon minnow
#

this is spigot help

#

if you dont need help

#

go

mortal hare
#

breh is correct

#

i shouldnt post things like this here

neon minnow
#

dont know how they made it

lost matrix
neon minnow
#

Why did you delete your message ?

lost matrix
#

Dont know what you mean clown

neon minnow
#

You are a server booster so act like one

#

Instead of helping you are just being really immature

mortal hare
#

stop

#

both of you

lost matrix
neon minnow
#

No. I do not play fortnite, and i do not write plugins in skript.

#

You know nothing about me

lost matrix
#

That is right. Im just making assumptions.

#

Ok come on... im just going for the memz. Its simply a burden for the community when people hang on older versions.

ivory sleet
#

Another 1.8 debate?

lavish hemlock
#

I'm pretty sure it's not "another" debate, it's just the same debate that's been prolonged for years.

lost matrix
warm light
#

%%__USER__%% will replace with username where I will add this in my code?

#

how spigot will know where is the placeholder?

lost matrix
#

You can add it wherever

warm light
#

alright

#

oh also if I add this in my plugin, user can't download without login?

ivory sleet
#

There’s this one gradle plugin called blossom if you want to replace %%USER%% to something else when compiling

lavish hemlock
#

Oh yeah

#

Blossom is p'good!

lost matrix
lavish hemlock
#

It's by Kyori (Adventure devs) and it works very well.

#

I use it pretty often for replacing a "version" token.

ivory sleet
#

Yeah same

warm light
lost matrix
warm light
#

oh ;-;

lost matrix
neon minnow
#

Hi all

quaint mantle
#

salutations

lost matrix
#

Then reply[sender] might have been null

#

aka its not in the map

grim ice
#

7smile7 is very immature, and he doesn't help?

#

Not sure about that bud

ivory sleet
#

just drop it

neon minnow
# grim ice 😀

He was not helping -- instead talking about 1.8 for no reason and making unnecessary rude comments that then he removed afterwards, plus talking about off topic things in this channel

ivory sleet
#

?kick @neon minnow stop already

undone axleBOT
#

Done. That felt good.

ivory sleet
#

For people who might read this, just block the user if you can't be in the same channel as them without starting a fight

maiden thicket
#

😦 i didnt get to witness the drama

ivory sleet
#

didnt miss anything important probably :]

maiden thicket
#

😔

#

maybe there should be a showcase channel

#

for youtube links like that

neon minnow
#

why you kicking me

#

when i havent even done shit

maiden thicket
#

oh hes already back

ivory sleet
#

I said stop

#

Drop it now....

maiden thicket
#

conclure could there be a future showcase channel in the future

#

would be cool

vivid cave
#

hey guys, i'm struggling big time with papermc/purpur, okay here is the issue
I have an Advancement, i need to get its title description and type
(Also please lemme know if I can do that without spigot because i searched spigot docs i really didn't find any methods for Advancement)
As a start, I made Advancement.getDisplay(), but then i'm kinda stuck on what to do
.title() and .description() of it are Component class; i'm really a retard but i can't get this class convert to string (didn't test the .toString() but idk im kinda sure it wont work)

ivory sleet
#

If you really have an issue with someone, first and foremost block them, secondly DM us about it, do not publicly shame them.

maiden thicket
#

you would do

#

Component.text("text here")

#

to add color you would do

lost matrix
maiden thicket
#

Component.text("text here").color(NamedTextColor.COLOR_HERE)

#

etc

vivid cave
maiden thicket
#

oh

#

ohh

#

i see

lavish hemlock
maiden thicket
#

you'd use a

#

hold on let me get the naem again

maiden thicket
vivid cave
#

sure thank you 🙂

maiden thicket
#

PlainTextComponentSerializer

lost matrix
ivory sleet
#

paper has some serializers of its own iirc

#

(hint the PaperSerializer class)

maiden thicket
#

:peepoShake:

ivory sleet
#

might be PaperComponents idr

maiden thicket
#

isn't it

#

PaperAdventure

#

oh u mean this

vivid cave
#

Thank you guys for your answers, am I the only one to find these kind of changes useless irritating & toxic btw?
I feel like devs looove to rename their classes and keep adding abstraction but in the end it breaks our code

ivory sleet
#

myeah

maiden thicket
vivid cave
#

hm okay

maiden thicket
#

i believe kyori is also able to retrieve nbt data and stuff as well so it's more like advanced in a way

#

it's tedious and annoying i agree

#

but it's not too hard to get used to once u use it

vivid cave
#

i see

maiden thicket
#

si

ivory sleet
#

Alexis well I find it disturbing that they deprecated the existing stuff

maiden thicket
#

yeah 😔

ivory sleet
#

Because honestly, It would have been just that easy to not put @Deprecated and just delegate a serializer call

maiden thicket
#

yeah coulda easily switched it

#

i probably can see a future deprecated ChatColor

ivory sleet
#

mye

#

anyhow the new system isnt too bad

maiden thicket
#

yeah just tedious asf

ivory sleet
maiden thicket
#

wat

#

oo

ivory sleet
#

(assume you staticlly import stuff) something quite succinct is still possible to write

maiden thicket
#

why did i not know of this 😢

ivory sleet
#

linear(GREEN, BOLD, text("Hello"),RED,text(" there!"))

#

yeah

#

&a&lHello &cthere!

#

basically

#

🙂

vivid cave
ivory sleet
#

ye

#

I don't see why just having some quick string methods would harm anyone at all

#

like sure its not the most convenient way to represent the way mojang is dealing with their shit

#

but at least it makes it easier for users if they just want to send something simple

maiden thicket
#

pov @Deprecated ChatColor

vivid cave
#

PlainTextComponentSerializer.plainText().serialize(some Component object)
does that look good to you?
And also I assume I could create only one instance of a Serializer instead of calling .text() everytime right?

maiden thicket
#

instead use NamedTextColor

ivory sleet
#

🙄

maiden thicket
#

😔

ivory sleet
#

yes alexis

ivory sleet
#

iirc the plainText() is a singleton

vivid cave
#

oki

#

thanks guys!

ivory sleet
#

gl

maiden thicket
#

glhf

#

i like kyori for its hover and click events more

#

i feel they did it better than mojang

#

sorry

#

not mojang

#

wait yes it is mojang

#

wait no its bungeecord's api

#

right

ivory sleet
#

depends on what you class as better

#

but its somewhat more sophisticated Ig

maiden thicket
#

it's more simple i feel because u can just one line that shi

#

compared to bungeecord

ivory sleet
#

hmm yeah probably

#

I don't find them too different imo

maiden thicket
#

yeah in the end it depends on the user

ivory sleet
#

indeed

maiden thicket
#

but i was told u dont need NMS to get NBT data from certain things using kyori now

#

or smthn

#

by paper devs

ivory sleet
#

yeah thats true

#

and then we got pdc api

maiden thicket
#

whats PDC

#

oh

ivory sleet
#

PersistentDataContainer

#

ye

maiden thicket
#

yeah i have no idea how to use that

#

💀

ivory sleet
#

Hmm its simple kind of

maiden thicket
#

theres probably like a forum post for it but i dont really go in depth into nbt a lot

#

in kyori

ivory sleet
#

certain existing interfaces such as Entity, ItemMeta now derives PersistentDataHolder which has the method PersistentDataHolder#getPersistentDataContainer which gives you a PersistentDataContainer instance (that basically acts like a map [which persist any change made to it])

maiden thicket
#

hmmm interesting... but is it modifiable

ivory sleet
#

yeah

maiden thicket
#

ah

#

epic

ivory sleet
#

entire purpose is for devs to just store custom key:value things to entities, tile entities, chunks and some other stuff

#

without exposing nbt

#

as thats too close to implementation in some devs' view

maiden thicket
#

ahh i see

#

i was having a discussion w these other people the other day on how "spigot is outdated api" or whatever and that fabric is superior

#

and im like 😕

#

dont understand what u can do w fabric that u cant w spigot + nms besides mixins

ivory sleet
#

depends on what you call outdated

#

yeah

chrome beacon
#

You can even use Mixins with spigot if you want

ivory sleet
#

well people are kinda overreacting to spigot not taking advantage of some of the newer java features and design principles

maiden thicket
#

me giving up on my mc server java implementation as soon as i saw that chunk data packet xD

maiden thicket
ivory sleet
lavish hemlock
#

md_5 says you shouldn't use NMS, so don't use it 😉

chrome beacon
maiden thicket
#

well nms isnt as much of a pain to break now since we have mappings

lavish hemlock
#

Nah Fabric encourages mixins in some places

#

Like with events

ivory sleet
#

Yeah, well they don't make as many promises in terms of an api with a set of interfaces as opposed to spigot Olivo

maiden thicket
#

fabric encourages it but u'll see modders telling u to not use it because it can have api changes

chrome beacon
#

True

lavish hemlock
#

Well

maiden thicket
#

conclure, do u understand the chunk data packet actually?

lavish hemlock
#

I don't concern myself with the opinions of the Fabric community

maiden thicket
lavish hemlock
#

Considering they're all fucking retarded anyway

maiden thicket
#

and how it's written

ivory sleet
#

I am enjoying the abstractions way too much

maiden thicket
#

i was writing a java implementation (it's my most recent github project if u wanna look) of the protocol and bro

#

i was so lost

#

looking at that packet

ivory sleet
#

lol

chrome beacon
lavish hemlock
#

Uhh SJWs

#

Mainly

maiden thicket
#

yessir

lavish hemlock
#

That is a lot of folders

maiden thicket
#

bro i was getting people on my ass the other day for using forge over fabric

#

i was like

#

man

#

give me a break 😭

ivory sleet
#

yeah

#

losts of people are just being assholes

maiden thicket
#

i hate modding purely cus they dont have any documentation

#

but i still like learning it bc its fun

#

but so annoying

maiden thicket
#

xd

chrome beacon
#

They do have documentation on their apis

maiden thicket
#

yeah but it's quite little

lavish hemlock
#

Not the best documentation though

#

I must say

chrome beacon
#

Mojangs code not so much

maiden thicket
#

wish mojang came out w javadocs 😩

#

is it still considered mojang's mappings if the game is owned by microsoft

#

or is it still a mojang game

lavish hemlock
#

Well Mojang develops it

maiden thicket
#

or did microsoft buy mojang

#

i forget

lavish hemlock
#

Microsoft just (technically) owns it

maiden thicket
#

ah

lavish hemlock
#

So yes it is Mojang's mappings

#

They are the devs

#

But yeah the reason why they likely don't have javadoc mappings

maiden thicket
#

oh microsoft bought mojang not mc specifically

lavish hemlock
#

Is due to the ProGuard format being shit

#

Aaaand also

#

They likely just don't value writing docs

#

Since Mojang does not care about the modding community

chrome beacon
#

They do actually

lavish hemlock
#

"No they do"

#

Expected it

chrome beacon
#

;)

ivory sleet
#

Datapacks!

lavish hemlock
#

If they did care, they'd do more to help

maiden thicket
#

if only they were as kind as among us devs

#

😔

ivory sleet
#

among us :]

lavish hemlock
#

among us :]

maiden thicket
#

sus :]

lavish hemlock
#

among sus :}

maiden thicket
#

when the imposter makes a spigot plugin ;]

lavish hemlock
#

susgot >:]

ivory sleet
#

lol

maiden thicket
#

org.susgotmc ?

opal juniper
#

stop

lavish hemlock
#

No

#

olisussers0n

restive tangle
lost matrix
restive tangle
#

Still sounds cooler

#

So it's better, I speak only the truth

quaint mantle
#

Is it possible to change the name of the anvil?

#

Repair & Name

#

On 1.12.2, the name is not visible, but on 1.16.5 it is visible. Is it possible to somehow change the name to 1.12.2?

maiden thicket
maiden thicket
rough drift
#

what's the name of the § symbol

rough drift
chrome beacon
#

Forge is quite easy too and has better intermod compatability

#

Personally I prefer Forge for most things but if I want a clientside only mod I use Fabric

tender shard
#

client mods always suck

#

and not in the good way

maiden thicket
#

@ voodoo and @ olivo ah ic

#

isnt fabric like newer so it doesnt have everything that forge does

rough drift
#

allowing you to edit code of other classes

chrome beacon
#

Forge has mixins too

tender shard
rough drift
#

xD

tender shard
#

yeah that's the german word

#

never knew it was section in english

maiden thicket
#

kyori taught me

#

xD

#

adventure api

#

always using that damn legacy component serializer

#

legacyAmpersand and legacySection

lost matrix
maiden thicket
#

😔

#

i thought & was called

#

the and symbol

#

but no

#

it's called aMPerSAND

tender shard
gritty mist
#

I can't run maven build I don't understand why

neon nymph
#

Could we store enums in PDCs?

quaint mantle
lost matrix
quaint mantle
#

And valueOf

#

Oh

neon nymph
lost matrix
gritty mist
#

well as you can see on the screen I can't maven build

drowsy helm
lost matrix
halcyon mica
#

Question, is it possible to use brigadier over the standard spigot command system

#

Because nesting subcommands and optional arguments is just a pain

lost matrix
#

With over do you mean prioritize or 'via'

halcyon mica
#

Prioritize

#

Or via, either works

#

As long as I can use brigadier for my commands

#

I've seen that there have been plenty of prs and feature requests since 1.13 but nothing ever came of it

lost matrix
#
  1. Use brigadier directly without API support
halcyon mica
#

Well that‘s annoying

#

Home come there is no support for it, if it's right there

lost matrix
#

Because it all has to be abstracted. And making this backwards compatible is quite difficult.

halcyon mica
#

The old backwards compatibility trap

#

It‘s a shame

#

But even so, brigadier is a fully standalone library, all that would be needed is a event during command registration that passes the dispatcher

#

And aside from that, it is fully isolated minus commands registered by the vanilla server

#

So what else is there to be abstracted

#

And I'd argue making a feature require 1.13+ is not unreasonable

lost matrix
#

Never looked into that. But spigot grows with every PR :D. Maybe with version 1.21 people will be fed up with spigots command system and
write write a proper PR that can be merged.

#

I personally didnt use spigots command system for ages now

halcyon mica
#

Considering that there are 2 prs since 2020 which are very much „proper“ and have gone completely ignored since despite constant upvotes, I don‘t think that is really a option

#

Not to mention the multiple feature requests for it

lost matrix
#

🤷

neon nymph
#

How do you make GUI button operations o(1)? Currently, my implementation is to store a string in the item's pdc and when that item is clicked, it'll get the string and run it on a switch statement to find it's designated effect. How would you guys make it so that it doesn't affect performance and take constant time?

opal juniper
#

there are libs for guis, i think redlib has one

neon nymph
#

Hmm I'd prefer creating my own, but sure I'll look into those. What are some you suggest?

worn tundra
#

Perhaps having your own wrapper object for the inventory, with a map that maps items to slots?

#

Then have a separate class for "buttons" or clickable items, that would be looked up from that map, and actions stored inside would be executed.

loud haven
worn tundra
#

More OOP than having a large switch statement.

neon nymph
neon nymph
worn tundra
#

I mean that is kinda what you already have to do, to check what inventory a player clicked, so why not store data inside of that object as well?

gritty mist
#

I added Vault API in my plugin but when I compile it doesn't find the Vault package

worn tundra
worn tundra
#

And it does?

gritty mist
#

depend: [Vault]

#

I put that in my plugin.yml

neon nymph
#

I've been playing around with callables too, and my idea is to create a HashMap<Enum, Callable<Object>> and load it on startup with various callables, and now all I have to do is set the appropriate enum in an item's PDC and when it's clicked, it'll get the enum and get the callable from the hashmap using it as key. Seemed to work, but I'm kinda worried about the memory this would take up as the hashmap gets bigger and bigger

gritty mist
#

don't roast me I am beginner

worn tundra
# gritty mist depend: [Vault]

When you look in console, does Vault actually load before your plugin? Do you really have Vault installed in your plugins folder?

gritty mist
#

yes

#

I added it in my project libraries

worn tundra
gritty mist
loud haven
#

It would be better to make a class that holds an array of Slot classes, and delegate click events to the Slot class that was clicked on. That way you can get the class of the clicked slot quickly and have better control over how the slot should respond to the click.

worn tundra
neon nymph
gritty mist
worn tundra
#

Also as far as I remember, when initializing Economy object of Vault, you have to load it first from the bukkit's service manager

gritty mist
#

if(!setupEconomy()){ System.out.println(ChatColor.RED + "Vault n'est pas installé !"); getServer().getPluginManager().disablePlugin(this); return; }

#

private boolean setupEconomy(){ RegisteredServiceProvider<Economy> economy = getServer().getServicesManager().getRegistration(Economy.class); if(economy != null){ eco = economy.getProvider(); } return (eco != null); }

worn tundra
#

Isn't that an IDE error and not a server error?

gritty mist
#

yes

#

IDE

neon nymph
worn tundra
#

Does it work on the server?

#

Or does it not compile xd

gritty mist
#

IDK I can't make it in a jar

#

yes I can't compile

worn tundra
#

I don't unfortunately know much about IntelliJ

#

But you should have errors before compilation

#

If you try to use a library that you do not have

#

Afaik

gritty mist
#

Well I'll double check on Google for plugin Maven Build with IntelliJ

#

but thanks again

tender shard
#

you are using maven

#

so add your dependency to pom.xml

#

NEVER EVER use intelliJ directly to add libraries

#

you are using maven, so use pom.xml

#

otherwise your IDE sees your libraries but of course maven won't see them

loud haven
#

Iirc IF API has similar structure, so I'd suggest taking a look at its source code.

neon nymph
#

Yep, I'm looking at it now. Thanks for the ideas

loud haven
#

NP

tender shard
#

I'm still looking for people to improve my discord quizbot

#

anyone bored right now?

quaint mantle
#

Anvil inventory mozgi ebet

#

Anvil inventory bug

desert tinsel
#

i have set and save my custom .yml files and they have a lot of text, but when i load the plugin, my custom .yml files are empty, why?

gritty mist
#

Hi I still have compiling errors , the API that I use is still not recognized

#

package net.milkbowl.vault.economy does not exist

elfin atlas
#

Is there a way to have 2 action bars?

#

Like sending 2 different texts at the same time

young knoll
#

Subtitle I guess

gritty mist
#

I found the solution to my problem : I added the jitpack repo and VaultAPI dependency

#

in my pom.xml

warm light
#

anyone can tell me how can I add world list?

young knoll
#

getStringList

#

Then run each string through Bukkit.getWorld

warm light
#

okay. thanks ;)

opal juniper
#

can we normalise using TabExecutor :)

#

lol

#

i have never seen people use it but its <3

opal kernel
#

Hi

halcyon mica
#

What's the best way to parse a yml map?

#

i.e. the yml's structure is

whatever:
  item1:
    data: defq
  item2:
    data: eughf0wu```
#

I only need the actual keys of the map, so item1, item2 etc

sleek pond
#

Get configuration section("whatever").getKeys(false)

halcyon mica
#

Many thanks

warm light
#

I can't make the loop🥲
my brain is so small to get it. anyone can help me pls?

tall dragon
#

Just type worlds.for and it will autocomplete for you

warm light
#

I did. but can't understand what I need to type ;-;

tall dragon
#

Huh

#

I just told you

warm light
#

world.forEach?

tall dragon
#

U could do that too, but a normal for loop is probs better for u

#

What are you trying to achieve

warm light
#

this worlds

tall dragon
#

Oh you are trying to get a list of worlds

warm light
#

yes

tall dragon
#

From the config

warm light
#

yes

tall dragon
#

So you loop through worldList and put them in worlds using Bukkit.getWorld

warm light
#

I already told you I can't understand use of loop in spigot. ;-;

#

1st time using loop in my plugin ;-;

#

can you give me what will be in ()? and explain it?

#

pls

quaint mantle
#

?learnjava

undone axleBOT
quaint mantle
#

more like java general question then

warm light
#

🤦

tall dragon
#

Yea im not here to teach you java, il happily answer api questions

latent galleon
#

i know how shitty i am right now but im desperate

hollow bluff
#

its basic java, learn

faint aspen
#

Has anyone an idea how to update multiple values in mongodb?
My current code looks like this

                Document original = (Document) param;
                Document updated = new Document("uuid", uuid.toString());
                updated.put("trashAmount", trashAmount);
                updated.put("fishAmount", fishAmount);
                updated.put("treasureAmount", treasureAmount);
                updated.put("mendingAmount", mendingAmount);
                Bukkit.getScheduler().runTaskAsynchronously(instance, () -> {
           -------->   collection.updateOne(original, updated);```
But i receive an java.lang.IllegalArgumentException: Invalid BSON field name uuid 
in the line marked by the arrow
warm light
#

what's wrong here?

quaint mantle
#

is there a way to just stop an event? Like telling it that you dont have to check if this event is happening anymore?

odd thicket
#

You probably want to get them using Bukkit#getWorld(String)

twin sapphire
#

How can i include some additional data in a messaging channel request (for example with getServer and i want to get back a integer i sent with)

Its important for my project that i can differentiata between the requests

naive bolt
#

anyone know a good free way to obfuscate plugin

visual viper
#

Hello, could someone explain to me how to obtain the name of the inventory that I am clicking on?

atomic niche
visual viper
warm light
#

no error in console

#

but not working

peak depot
#

is the list not null?

halcyon mica
#

OK, going back to my previous question:

#
whatever:
  item1:
    data: defq
  item2:
    data: eughf0wu```
How would I get a map of whatever, so that I can iterate through them as a key value pair
#

(yml parsing)

odd thicket
warm light
#

yes. the list was null first. thats why it didn't work 1st time

#

thanks for help SCHLAUBI & CuzImPhilipp <3

odd thicket
neon nymph
#

Might I ask if hack clients are capable of reading an inventory's title and automatically clicking a slot in an inventory?

#

They're like built-in mods in the launcher, right? I'm fairly certain they're capable of doing so, but I just want confirmation

glossy venture
#

yeah

#

mods are also able to do it

warm light
mortal hare
#

can someone help me a bit with concurrency logic

#

lets say i have a single core machine

patent horizon
#

how laggy does using an event listener like on any move have on the server by itself?

mortal hare
#

running minecraft server

mortal hare
#

code inside it can be

patent horizon
#

ah

mortal hare
#

but when you dig down deep into NMS

#

you can see minecraft catches thousands of packets via netty

#

at the same second

#

sent from the client to the server

#

that means if the movement packets are being processed so fast, event calling shouldnt be that costly either

#

but its a speculation

quaint mantle
#

Uhmm

#

What did you try to ask

mortal hare
#

ok moving on

#

Lets say i have a single core machine with minecraft server one it

#

and i run heavy operations on the separate thread

#

would that impact minecraft server's performance

#

even if the task is async

quaint mantle
#

?tryandee

#

?tryitandsee

mortal hare
#

hehe

#

i get it

quaint mantle
#

?tryitsee

#

?tryit

mortal hare
#

😂

chrome beacon
mortal hare
#

no but really from technical standpoint

quaint mantle
#

Nooooooooooo @hasty prawn this is still not the day :(

mortal hare
#

it should lag, since threads are only an illusion from code's perspective

#

if you dont have more than 1 core

#

you cant do "real" concurrency

#

right?

worn tundra
#

😳

brave sparrow
#

it may have a slight impact but it likely won't be that noticeable

quaint mantle
#

it still lag

mortal hare
#

well if i have 8 core processor

#

it should split the job

#

into multiple cores

brave sparrow
#

it seems like you know the answer to your question already lol

mortal hare
#

im just clarifying

#

if im correct or not

brave sparrow
#

but i mean if you have a single core machine then it's not like you can avoid running other stuff on that core

#

yes, in a single core machine all the threads have to share time and therefore the more tasks you have running the less time each will get

warm light
brave sparrow
#

but where are you finding a single core machine these days

warm light
brave sparrow
#

you'll get a NullPointerException

mortal hare
#

Null is literally none

#

zero

#

empty

#

void

#

that's like trying to setup new graphics card, but its null because scrapers selling it for 3k

brave sparrow
#

why would it be null

#

lmao

#

the card still exists

mortal hare
#

you dont have it

brave sparrow
#

but it exists

mortal hare
#

reference is null

#

in memory yes

#

but you cant access it

brave sparrow
#

also tbf i bought mine at a scalped price

#

the scalped price is irrelevant

#

it's just trying to set up a graphics card that doesn't exist

mortal hare
#

gosh i hate nfts more than scalpers

#

these days

brave sparrow
#

not trying to set up a graphics card that exists but isn't in the place you expect

mortal hare
#

whoever thought that its a good idea to sell png's

#

should burn to hell

brave sparrow
#

honestly i'm not going to get into NFTs but i understand the idea

#

i don't think it's terrible

mortal hare
#

it would be ok if you would buy copyright ownership to that picture

brave sparrow
#

it's just like buying any art in the real world, sure anyone can get a copy of it but only I can own the actual thing

warm light
#

getDataFolder() return server dir or plugins dir?

brave sparrow
#

i don't get copyright to the mona lisa if i buy a copy of it but if i bought the mona lisa i would still be the owner of the real mona lisa

#

but if i bought the real one you could still buy a copy

maiden thicket
mortal hare
#

also i have mixed bag of opinions about cryptocurrencies

#

looks how they're inefficient

#

7-8 transactions a second

#

yet they use Terrawatts of power

#

sure decentralization is good

#

but it hurts environment more than it does good

#

for comparison:

#

1 Bitcoin transaction costs 2264 kWh of power

#

while 100,000 VISA transactions cost around 148 kWh of power

#

thats a huge difference

visual tide
#

is there a built-in method to fill an inventory with n items, seperating them into stacks? cuz im pretty sure just adding a new itemstack with amount n would put them all in one slot

mortal hare
#

.setItem(int slot, ItemStack itemstack)?

quiet ice
#

well, if you have an itemstack over max size it may not behave as wished, but idk

visual tide
#

so that wouldnt work

hasty prawn
#

Why wouldn't that work

visual tide
#

wouldnt that just cram everything in one slot

hasty prawn
#

setItem? No

#

addItem will

brave sparrow
hasty prawn
#

Ah yes, not caring about the environment, that seems like an intelligent thing to do.

worldly ingot
#

Floor, add a stack of that size to each slot, get modulo of same product, handle that however you so choose. Either add one to each stack sequentially or just throw the remaining into the first stack

mortal hare
worldly ingot
mortal hare
#

i dont get his question

#

does he want to replicate dragging

#

or what

chilly haven
#

How do i remove the item that player is holding

worldly ingot
#

PlayerInventory has a setItemInMainHand() method

#

or OffHand() if that's what you want

quaint mantle
#

how do i correctly DEserialize ItemStack without getting an error on restart

river oracle
#

Can itemstacks be serialized?

quaint mantle
#

i used gson and i got a nice serialized json

river oracle
#

Oh it is what error ate you getting

quaint mantle
#

just a sec ill make a hastebin

mortal hare
#

use BukkitObjectOutputStream

#

and encode to base64 (optional)

quaint mantle
#

public static ItemStack[] itemStackArrayFromBase64(String data) throws IOException {
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
ItemStack[] items = new ItemStack[dataInput.readInt()];

        // Read the serialized inventory
        for (int i = 0; i < items.length; i++) {
            items[i] = (ItemStack) dataInput.readObject();
        }
        
        dataInput.close();
        return items;
    } catch (ClassNotFoundException e) {
        throw new IOException("Unable to decode class type.", e);
    }
}
mortal hare
#

yes

#

Arrays and lists

#

are serializable

river oracle
#

Will I get an error serializing itemstack in a hashmap not using BukkitOutpit stream but rather ObjectOutputStream

quaint mantle
#

so how would i implement this into my loaditems method?

#

public static void loadItems() throws IOException{
Gson gson = new Gson();
File file = new File(MagnificentMenus.getPlugin().getDataFolder().getAbsolutePath() + "/items.json");
if (file.exists()) {
Reader reader = new FileReader(file);
ItemStack[] m = gson.fromJson(reader, ItemStack[].class);
Menu.menuitems = new ArrayList<>(Arrays.asList(m));
System.out.println("Loaded Preexisting Menu Items Successfully!");
}
}

tardy delta
#

dont make te method static

terse panther
#

there is a way to change the 'Sky' on a world?
For example the overworld has like a nether sky without the nethere biome

mortal hare
#

since ItemStacks dont implement Serializable interface

tardy delta
#

it has a serialize method

mortal hare
#

it implements ConfigurationSerializable

#

not Serializable

tardy delta
#

mhm ye

mortal hare
#

BukkitObjectOutputStream internally wraps these objects

#

in order to serialize to bytes of data

#

BukkitObjectOutputStream = Bukkit object serialization + any other object serialization

blazing scarab
blazing scarab
opal juniper
#

mmm not necessarily

#

you can just read the object map

#

and then ItemStack.deserialize is a thing

#

but you are right bout not just being able to directly doing it

hazy garnet
#

Hi there, I am trying to create a small plugin that justs stops tnt from creating block damage, atm I have this code :

@EventHandler(priority=EventPriority.LOWEST)
public void onExplosion(EntityExplodeEvent e) {
  if (e.getEntity().getType() == EntityType.PRIMED_TNT){
    e.setCancelled(true);
    Location l = e.getEntity().getLocation();
    l.getWorld().createExplosion(l.getX(), l.getY(), l.getZ(), 0F, false, false);

However I can't get this working, if someone could tell whats the issue I would be very happy so that I can change it, thanks, btw no errors in console

sleek pond
#

What specifically isn't working

#

Which one of the statements

tardy delta
#

is the explosion which you made, creating the damage?

hazy garnet
#

I tried adding a broadcast before the new explosion to test if the first part was working, no message

#

so the first part

sleek pond
#

So the e.getEntity.gettype.

#

?

#

If so, add a sysout before the if

hazy garnet
#

Theres prob somthing wrong with the first line or the second line, after that it should work

sleek pond
#

Add a debug before the if statement

hazy garnet
quaint mantle
#

would this work

#

it also deseralizes it

sleek pond
#

Alexis is typing...

chilly haven
vivid cave
# vivid cave PlainTextComponentSerializer.plainText().serialize(some Component object) does t...

ok here's what it gives me:

io.papermc.paper.advancement.AdvancementDisplay display = event.getAdvancement().getDisplay();

PlainTextComponentSerializer serializer = PlainTextComponentSerializer.plainText();

String title = serializer.serialize(display.title());
String description = serializer.serialize(display.description());
title outputs "advancements.adventure.kill_a_mob.title"
description outputs
"advancements.adventure.kill_a_mob.description"

@ivory sleet @maiden thicket do you guys know if I can turn these strings to sth readable?
Those are keys, but where can i find the human readable description and title?

worldly ingot
#

I mean, it works. So if it doesn't work you didn't use it right or it's not being called 😛

blazing scarab
worldly ingot
#

If setItemInMainHand() doesn't work, we'd have a lot of angry developers on our hands lol

hazy garnet
sleek pond
hazy garnet
#
@EventHandler(priority=EventPriority.LOWEST)
public void onExplosion(EntityExplodeEvent e) {
worldly ingot
#

This is not Paper

#

Paper has their own Discord

river oracle
blazing scarab
#

it will translate keys to server's default locale: english

#

But.. In what case you need that>

maiden thicket
vivid cave
blazing scarab
#

What are you trying to do alexis

vivid cave
# worldly ingot You're using Paper API

So sorry, actually I talked about it earlier this morning no one complained so i didn't know it was really offtopic here, i pinged those guys cuz they very nicely helped me this morning

elfin atlas
#

Does someone know how I can get the a angle between to Y points?

elfin atlas
sleek pond
#

Trigonometry

maiden thicket
sleek pond
#

It's stuff to do with triangles

elfin atlas
maiden thicket
#

sorry wait no it may not be that

#

actually no i think it is

#

TranslatableComponent.key(string)

ivory sleet
sleek pond
ivory sleet
#

(iirc)

sleek pond
#

No

elfin atlas
#

Oof

sleek pond
#

As far as I know, anyways

#

You could also take a google

#

Or you could use cos

#

Or sin

mortal hare
#

?paste

undone axleBOT
quaint mantle
#

i get this error when my plugin enables

quaint mantle
#

my method:

#

public static void loadItems() throws IOException{
File file = new File(MagnificentMenus.getPlugin().getDataFolder().getAbsolutePath() + "/items.json");
if (file.exists()) {
ItemStack m = JsonItemStack.fromJson(String.valueOf(file));
Menu.menuitems = new ArrayList<>(Arrays.asList(m));
System.out.println("Loaded Preexisting Menu Items Successfully!");
}
}

#

ItemStack m = JsonItemStack.fromJson(String.valueOf(file)); this line supposedly causes the error

mortal hare
#

here's my item serialization class

#

its not fancy but it works

#

it serializes items in nbt form to Map object

maiden thicket
#

wtf is string valueof file

#

return

quaint mantle
quaint mantle
#

this

mortal hare
#

it needs remapping

#

if you're using spigot mappings

#

this is for mojang's mappings

quaint mantle
#

oof

mortal hare
#

serialized chest (old photo, there's new keys for specifying data type, to make it compatible with any configuration format)

quaint mantle
mortal hare
#

here's the accurate representation of serialization

#

you dont need to specify dataType for int and list data types

quaint mantle
#

nvm i think i got it

stuck flax
#

How do you check if the players inventory is full/they cant hold an item

mortal hare
#

iirc there's a a search method

#

inside inventory interface

#

that lets you search items through the inventory

tardy delta
#

is there an isEmpty method?

#

ye there is

young knoll
#

There’s a firstEmpty method

grim ice
tardy delta
#

doesnt look like vsc

brittle loom
#

Hello, when I spawn an armour stand and setVisible(false), I can still see the armour stand for a split second, does anyone know how to prevent this?

grim ice
#

Probably is, just windows 11

mortal hare
young knoll
grim ice
#

oh cool

#

btw the best ide for c++

#

is supposed to be vsc

#

right?

mortal hare
#

idk

#

i use codeblocks

tardy delta
#

CLion?

mortal hare
#

Visual Studio

#

is only for windows

grim ice
mortal hare
#

Codeblocks is free

#

and multiplatform

grim ice
tardy delta
#

i have it for free (maybe a trial)

young knoll
#

Visual studio CODE for C++?

#

Sounds painful

tardy delta
#

lemme open it

grim ice
#

i thought code blocks was outdated

brittle loom
grim ice
#

Join the Discord: https://discord.gg/4tHeAkxNg7

In this episode I describe what this series will go over. I explain that I assume you are familiar with several different programming concepts (if you are familiar with C# or Java, you should be good), then I discuss installing MSVC, coding your first C++ program, compiling/linking your first C++ ...

▶ Play video
tardy delta
grim ice
#

he is using vsc

tardy delta
#

first cpp program

mortal hare
#

std::endl or endl

tardy delta
#

idk

#

im bad

#

just import std namespace

mortal hare
#

i always use std::

#

since it makes clear

mortal hare
#

but if you add using namespace std

#

it is optional

young knoll
#

That looks very javay

#

Where’s the memory management

grim ice
#

or is that better

maiden thicket
#

c++ :booo:

grim ice
#

if that's what you're talking about

young knoll
#

Idk I don’t know C++

tardy delta
#

dont think it matters

young knoll
#

Seems like import vs FQDN in java

tardy delta
#

fqdn?

young knoll
#

FQCN*

#

Fully qualified class name

mortal hare
#

if you allocate memory

#

you need to delete it by yourself

young knoll
#

Right

tardy delta
young knoll
#

Does an int not allocate memory

mortal hare
#

well you can use smart pointers

tardy delta
#

instead of using imports

young knoll
mortal hare
#

stack memory you dont need to clean up

young knoll
#

After compiling its all FQCN

#

Imports are just for our sake

mortal hare
#

heap memory

young knoll
#

I see

mortal hare
#

new int[50] would require delete var[];

young knoll
#

I was told to just learn rust instead :p

quiet ice
mortal hare
#

eh i prefer to mark namespaces

#

its just so much readable

#

for me

#

its like declaring this.var and super.var in java for me

quiet ice
#

Agreed, but it isn't that bad if you omit it

mortal hare
#

it makes declaration easier to read

quiet ice
#

However in header files it may lead to chaos from what I heard

young knoll
#

I try to always use this.var

#

But I sometimes forget D:

mortal hare
#

also primitive arrays do not hold array length values

quiet ice
#

I just use whatever makes more sense

mortal hare
#

in c/c++

#

unless you use std::vector, etc.

quiet ice
#

is std::vector as stupid as java.util.Vector?

mortal hare
#
int var[] = {0,1,2,3,4};
int size = sizeof(var)/sizeof(var[0]);
mortal hare
#

it is a dynamic array

quiet ice
#

Cool, seems like they don't repeat the same mistake as the java people

mortal hare
#

btw sizeof() returns the byte size of the value/reference

#

usually you wouldnt need to use primitive arrays

#

since those are used for c compatibility

young knoll
#

Is it really repeating a mistake if C++ came first :p

mortal hare
#

also you can do some funky stuff with c++

#

like declare function as variable

tardy delta
#

C -> C+ -> C++

mortal hare
#

like in js

quiet ice
#

I mean, with lambdas we also have this to some degree

mortal hare
#

you can literally execute functions by only having memory adress of the function

young knoll
#

Woo consumer

mortal hare
#

that's how hackers execute game functions

#

they get the memory address via some dissasembler

#

and execute it

quiet ice
#

so java is safer?

young knoll
#

Not really

#

Reflection exists

mortal hare
#

that's a bad comparison

quiet ice
mortal hare
#

java is used for general purpose programming

young knoll
#

Aren’t those deprecated

quiet ice
#

*deprecated for removal

mortal hare
#

while c++ is only used today to support legacy programs or have performance first programs

maiden thicket
#

or used for game dev

mortal hare
#

performance first

#

just like i said

young knoll
#

C# + IL2Cpp

#

:p

maiden thicket
#

i hate hytale for making their server software java

mortal hare
#

hytale is out?

young knoll
#

They have a bunch of java devs

maiden thicket
#

hopefully someone replicates the server softwate in c# 🤞

young knoll
#

Makes sense

maiden thicket
#

nah

#

its not

young knoll
#

Not until 2076

mortal hare
#

its a dead project

maiden thicket
#

but their client is c# and server will be java

mortal hare
#

it supposed to be in beta since 2017

maiden thicket
#

which is dumdum

mortal hare
#

iirc

young knoll
#

It’s not dead

maiden thicket
#

jus do a server in c# cus if u know java u practically know c#

#

💀

mortal hare
#

why client is in c#

maiden thicket
#

idk ask their custom game engine

mortal hare
#

while server is in java

young knoll
#

It’s supposed to come out in 2023

mortal hare
#

that's just stupid

grim ice
#

is it possible to store an entity inside an item

maiden thicket
#

then last year

#

now its next year

young knoll
#

At least it isn’t being super rushed

#

Like cyberpunk

mortal hare
maiden thicket
#

cyberpunk took like

#

7 years

#

didnt it

young knoll
#

¯_(ツ)_/¯

tardy delta
#

if i execute a method after an CompleteableFuture#whenComplete, will it get called after that method?

grim ice
#

Ic but ik 0 shit about nbt

#

so very epic