#help-development

1 messages · Page 1427 of 1

wraith rapids
#

store a tag in the PDC

#

compare the tag

severe folio
#

this should be pinned imo

eternal oxide
#

md_5 needs to add a ?pdc

severe folio
#

^ or that

wraith rapids
#

pinning shit is too much work for the maintainers to handle

severe folio
#

i guess

wraith rapids
#

it involves like clicking stuff and shit

worldly ingot
#

but... why don't you just return Collections.emptyList()?

quaint mantle
paper viper
#

what

worldly ingot
#

oh, are you trying to output the result of the evaluation as the tab completion?

quaint mantle
#

no

worldly ingot
#

then i'm confused lol

quaint mantle
#

you know like the <args> thing

#

in commands

#

im doing that

#

but as <expr>

worldly ingot
#

o.O So just return that. I don't understand the cancelling in the event part

wraith rapids
#

that needs brigadier though

quaint mantle
#

so you dont tabcomplete <expr>

worldly ingot
#

Ohhhh but you don't want them to actually hit tab to auto complete <expr>

wraith rapids
#

or. well. i guess that works

quaint mantle
worldly ingot
#

okay okay, i gotcha now lol

#

ngl I thought that event was called when a plugin returned its tab completion results

quaint mantle
#

yikes

vestal dome
#

uhhh

#

I have a produce Method in an object, and it has to be executed sync, but when I have lots of objects on my world, it starts to lag, is there a way to make it "async" somehow?

paper viper
#

well show us what this produce method is

#

and also

#

how many times will it be executed?

#

and also what does it do

#

if it does something like world modifications, dont do that async

vestal dome
#

exactly.

#

that's what I should do.

paper viper
#

is this world modification?

vestal dome
#

yes

#

it modifies the world

paper viper
#

yeah no

vestal dome
#

spawns an item

paper viper
#

cant do anything

#

oh

#

i meant more like

#

getting rid of blocks

#

that type of stuff

glossy scroll
#

What is the code

#

show

vestal dome
paper viper
#

holy

glossy scroll
#

Is there a reason why you dont cache those config values?

vestal dome
#

yes

#

don't have to change much code

#

🤣

#

and further more, these objects are like... not static...

quaint mantle
#

wow

vestal dome
#

they can change

#

at any time..

quaint mantle
#

this code is the example of a mess

young knoll
#

To be fair configs are already cached

vestal dome
#

I would disagree..

dusk flicker
#

holy shit that code

vestal dome
#

if you say it is a mess.. well then idk what to say.

glossy scroll
#

Im not a fan of the one-line if statements

vestal dome
#

because for me it is very readable.

paper viper
#

you think that is... readable?

dusk flicker
#

thats not readable lmao

vestal dome
#

how would you make it better?

quaint mantle
#

where do we start

paper viper
#

have you ever heard of oop

#

or delegation

#

or just in general, writing code that does not repeat your self

wraith rapids
#

lots of repetition going on

vestal dome
#

how would you make it better.

#

tell me

glossy scroll
#

Instead of all that magic

paper viper
#

holy jesus.. the more i look at it the more i realize

#

i will make a list if you want.

vestal dome
#

you know that for me it isn't that much of a mess.

#

don't exagerate

paper viper
#

No, I am not exaggerating

vestal dome
#

checking booleans and then doing something is not a mess

#

at least it is devided.

paper viper
#

this is legit a fuckmess

vestal dome
#

then do me a list then

paper viper
#

Alright

glossy scroll
#

I feel like all of those config calls should be cached when the machine object is created

#

Its very hard to read

wraith rapids
#

what is this plugin again?

glossy scroll
#

Idk

wraith rapids
#

looks like slimefun

#

but worse

vestal dome
#

😂

wraith rapids
#

which is an achievement

vestal dome
#

nice

glossy scroll
#

I think its fine

vestal dome
#

thanks for the achievement

glossy scroll
#

Its just the extreme amount of config calls

wraith rapids
#

mostly that

paper viper
#
  1. Use better delegation/separate some of the logic in actual methods so you can actually see the logic better. To anyone else reading that code that is not anywhere readable.
  2. Start naming your damn methods better. What the hell does "produce" mean. It could mean produceItemStack, or some other shit. and also don't name your method simply "data()". Yeah that's a big no no.
  3. The biggest one. Use your damn variables. Store your instance, the config, as one variable instead of using like some getter method 1 quadrillion items.
  4. You are repeating a ton of code. And I mean a ton. Store some shit like the config reading in some methods.
  5. As what Martoph said, cache the config values such that you will use those instead of retreiving from the config. The ton of hashing shit going on... That is why it's causing a ton of lag. Instead, make some schedualed task to automatically update the values when necessary.
  6. You should be using dependency injection here. It avoids situations like these such that it creates too much coupling. But at least store it in a damn variable man.
#

the last one, is kinda optional

#

and is debated

glossy scroll
#

5th one

#

You dont read from file every time lol

#

Its not I/O

wraith rapids
#

myeah, though it's still pretty slow

paper viper
#

Yeah

glossy scroll
#

Its just a lot of hashing going on

wraith rapids
#

as it does map lookups for every .

paper viper
#

still pretty slow

vestal dome
#

I disagree

#

it only starts to lag when the count of objects reaches an abnormal amount

#

like 1k

paper viper
#

??

wraith rapids
#

this is false

paper viper
#

^

#

that is absolutely false

dusk flicker
#

lmao

paper viper
#

you should be already conserving resources

glossy scroll
#

Slow doesnt mean lag immediately

wraith rapids
#

a map's performance doesn't depend on its size

#

that is the whole point of a hash backed map

paper viper
#

thats only the memory

#

the memory is only affected from the size of the map

wraith rapids
#

the map performs consistently regardless of the number of entries in it, as long as the hash function is good enough

paper viper
#

Regardless, just rewrite this whole segment lmao

wraith rapids
#

which means it performs just as slow with 3 entries in it as it would with 3,000,000

glossy scroll
#

someone explain what dependency injection is i never understood that concept lol

vestal dome
#

as far as I know.... Bukkit uses SnakeYAML and you cannot retrieve something from the io directly.

#

it stores into a map with the values etc etc etc.

paper viper
#

I meant hashing

wraith rapids
#

myes

#

which is exactly what we're talking about

paper viper
#

but that is still slow if you do that like a quadrillion times

#

like what you are doing

#

lmao

wraith rapids
#

dozens of map lookups is slow

#

every . is a new map lookup

ivory sleet
#

IdentityHashMap tho fast as fuck

wraith rapids
#

and you are querying keys with several .'s like three dozen times

#

that adds up to like two hundred fucking map queries

glossy scroll
#

Your machine object needs more fields

vestal dome
#

as I said, the object itself does not mean anything, the object is a representation of the data on my other file.

dusk flicker
#

🤦

paper viper
#

omfg

glossy scroll
#

get the variables from the config before its created and pass it to the object

paper viper
#

Okay listen to us

dusk flicker
#

WE ARE TELLING YOU WHAT YOU WANTED but you wont listen to us and just argue about it

paper viper
#

We are developers. You come to ask and now you just come to argue with us?

#

I gave you a full list of improvements that can be done

wraith rapids
#

as I said, you are doing several hundreds of map lookups just to get some values that could 100% be cached

paper viper
#

now go apply them, or rewrite that code segment with those 6 things in mind

wraith rapids
#

several fucking hundreds

#

not "just a few"

#

not "just a few dozen"

#

several fucking hundreds

vestal dome
#

yeah I'm leaving this chat like a rocket launching to orbit

dusk flicker
#

thats nice

ivory sleet
#

have fun

glossy scroll
#

We tried lol

dusk flicker
#

you may come back if you are a Chinese rocket

paper viper
#

lmao

#

go fly away to mars

glossy scroll
#

A classic “i need help”

#

we help

#

“Not like that”

paper viper
#

code will remain bad

#

lol

eternal oxide
#

Must be a woman 😛

dusk flicker
#

LOL

paper viper
#

Aiyo

#

chill lmao

vestal dome
#

kthxbay

ivory sleet
#

so like women are smart tho

dusk flicker
#

how long have you been doing java Jadss

paper viper
#

women are prolly like 5x more mature than men

ivory sleet
#

they play dumb but they're smart lowkey

paper viper
#

mhm

eternal oxide
paper viper
#

yea

ivory sleet
#

lol

paper viper
#

they know what a dick looks like at 7th grade. We don't even know what their thingmabob look like until sex

#

/s

ivory sleet
#

sus

paper viper
#

nope im a virgin

glossy scroll
#

realy loving the sexism happening

paper viper
#

conclure im a virgin

dusk flicker
#

how long have all of you been doing Java I want to get a total time here lol

ivory sleet
#

why

#

just unvirgin urself

paper viper
#

lmao

#

but if unvirgin myself

glossy scroll
#

6 years idk

paper viper
#

how do

#

virgin myself

ivory sleet
#

uh revirgination

paper viper
#

ive been doing java for like 2-3 years?

#

around that

#

also my first actual enterprise language

dusk flicker
#

16 years so far

paper viper
#

i take seriously

dusk flicker
#

lmao

paper viper
#

lol

ivory sleet
#

I have been doing java for 1 year

#

pog

dusk flicker
#

17

paper viper
#

you come from kotlin?

ivory sleet
#

from javascript

paper viper
#

ah

#

better than coming from python

#

lmao

ivory sleet
#

lol ye

severe folio
#

6 years and I'm still shit at it lol

ivory sleet
#

same

paper viper
#

same

dusk flicker
#

23 years

#

same but 7 years

ivory sleet
#

still stuck with yucky leaky abstraction

paper viper
#

really shows how complex a language is

ivory sleet
#

yeah

severe folio
#

I only learnt how to use lambdas like 3 months ago

paper viper
#

Lambdas were in java 8 i think

severe folio
#

Yea

dusk flicker
#

ye

paper viper
#

They dont usually teach it in school

dusk flicker
#

ive been doing lambdas since march 18th, 2014

paper viper
#

its faster than anonymous classes tho from what i heard

ivory sleet
paper viper
#

prolly intentional

#

dont wanna confuse students

#

cause the weird syntax

ivory sleet
#

ye

severe folio
#

My school's i.t teaches basic python and that's it

paper viper
#

and it doesnt make sense cause it doesnt use new

ivory sleet
#

same

paper viper
#

and you are like declaring smthing

#

you know

ivory sleet
#

my teacher says python is by definition the best language

dusk flicker
#

🗡️

#

time

ivory sleet
#

yeah

#

his argument, everyone understands it

glossy scroll
#

Python overrated

#

Severely

paper viper
#

mhm

#

ive used it before

#

nothing special

ivory sleet
#

lambda:

paper viper
#

their lambdas are absolutely disgusting

severe folio
glossy scroll
#

I wish lamdas were faster

paper viper
#

hm?

#

arent they already super fast

ivory sleet
#

aren't they dynamically invoked or smtng

paper viper
#

they are faster than anonymous classes

glossy scroll
#

Oh i didnt mean lambdas

#

Mb

#

Streams

paper viper
#

Ah

ivory sleet
#

yeah imagine if they were

paper viper
#

I only use streams for stuff that i do once

wraith rapids
#

pretty sure there is like an ide plugin that converts streams to imperative for loops

paper viper
#

😬

ivory sleet
#

oo nice

paper viper
#

idk if that would be accurate tho

#

i mean its nice

#

but how good is it

wraith rapids
#

yeah it kind of trips over the same pitfalls as lombok

paper viper
#

and also doing stuff like parallel shit would be hard

wraith rapids
#

it kinda just does stuff and 🤷🏿‍♀️

paper viper
#

lmao

#

parallel be like making 4 classes extend Thread

#

lol

#

/s

ivory sleet
#

if we would only have 1 cpu, technically parallel streams wouldn't be parallel just concurrent, amirite?

paper viper
#

1 cpu? or 1 cpu core

ivory sleet
#

1 cpu

#

nothing else then

severe folio
#

Speaking of school btw, I hate being that one kid that "knows computers so they can fix everything"

gaunt eagle
#

Is it possible to rename @EventHandler?

naive spindle
#

I want to create warps with undying totem animation, i created items with custom model data
when player teleports to warp i want it to trigger Totem Of Undying with Custom Model Data: 2
with PacketPlayOutEntityStatus packet how can i do it?

young knoll
#

The annotation? no

gaunt eagle
#

Because one is for the team, the other is for the kit gui

young knoll
#

The method? sure

#

Just use the same method for each though?

gaunt eagle
#

thanks

#

For a moment I was afraid it would work like an override

ivory sleet
#

like the annot

naive spindle
wraith rapids
#

yes, you can rename the event handler

#

the method name does not matter

#

nobody is forcing your click event handler to be called "onClick"

#

that is just a convention

#

you can call it "onClickThisShit" or "onScrewedYourMom"

#

or just "fuck"

#

the only two things that matter are

  • the EventHandler annotation
  • exactly one parameter that extends Event
sharp bough
#

player.sendMessage(String.valueOf(e.getClass())); returns the error name

#

like null

#

not the name

young knoll
#

You know class.getName exists?

sullen marlin
#

you want this.getClass, e.getClass would be the exception class

torn shuttle
#

hey, what's the correct way of setting the contents of an inventory holder going from a Block object?

#

I was trying to cast BlockState to InventoryHolder but it ain't too happy about that

#

do I actually have to handle chests as chests, furnaces as furnaces and so on?

sullen marlin
#

Uh I'm pretty sure they can be cast

torn shuttle
#

hm that's what I thought as well, especially since they're passing on the instanceof check

#

let me try again

sullen marlin
#

If they're passing the instance of then they'll definitely work

torn shuttle
#

    private void fullBlockRestore(Block block) {
        BlockState blockState = detonatedBlocks.get(block);
        blockState.setBlockData(blockState.getBlockData());
        if (blockState instanceof InventoryHolder)
            ((InventoryHolder) block.getState()).getInventory().setContents(((InventoryHolder) blockState).getInventory().getContents());
        detonatedBlocks.remove(block);
    } 

am I missing something obvious?

[21:58:14 WARN]: [EliteMobs] Task #16969 for EliteMobs v7.3.0 generated an exception
java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState cannot be cast to class org.bukkit.inventory.InventoryHolder (org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState and org.bukkit.inventory.InventoryHolder are in unnamed module of loader 'app')
        at com.magmaguy.elitemobs.explosionregen.Explosion.fullBlockRestore(Explosion.java:73) ~[?:?]
        at com.magmaguy.elitemobs.explosionregen.Explosion.access$000(Explosion.java:20) ~[?:?]
        at com.magmaguy.elitemobs.explosionregen.Explosion$1.run(Explosion.java:62) ~[?:?]

sullen marlin
#

You're not instanceofing the same thing you're casting

torn shuttle
#

erm sort of

#

by the time it gets to it it should have the same data

drowsy helm
#

detonatedBlocks.get(block) and block.getState() mght be different

torn shuttle
#

is just having the data not enough?

sullen marlin
#

^ cause you don't call .update first

torn shuttle
#

aha

#

ok thanks

sullen marlin
#

Also the set is redundant

torn shuttle
#

which one?

sullen marlin
#

You're setting the data to the data

torn shuttle
#

oh the instanceof?

sullen marlin
#

Just call .update(force)

torn shuttle
#

you know I did wonder why it was that copying the data wasn't doing a more in-depth copy

#

thanks for the help

sullen marlin
#

In fact all your code is redundant

#

Delete it all except for . update (force=true)

#

That'll restore the inventory without any extra code

torn shuttle
#

weird, using update() won't let me change the state

#

hm

#

oh oops

#

that was dumb

sullen marlin
#

Need the true

torn shuttle
#

also need to modify block and not the blockstate lol

#

hm well that partially worked but the inventory contents aren't getting restored

eternal oxide
#

if you are updaing from a BlockState using update you will wipe the inventory. If you are applying BlockData you should not need an update

torn shuttle
#

hm

solar trail
#

Hey - is there a better way to get an item name? Right now I'm using this line: player.getInventory().getItemInMainHand().getType().toString(), although that returns it in a less than ideal format

eternal oxide
#

thats the Material

solar trail
#

I know, I'm just not sure how I would go about making it show in a more user friendly way & that's what I'm asking about

solar trail
#

Ah, will read that. Thanks a bunch

torn shuttle
#

well I figured out the issue, it's never an insteadof inventoryholder for some reason

#

the plot thickens

eternal oxide
#

?paste show code

queen dragonBOT
torn shuttle
#

line 110 never triggers

#

fyi

#

though I am exploding and regenerating chests just fine, inventories aside

eternal oxide
#

check for instanceof Container

torn shuttle
#

that does trigger

eternal oxide
#

cast to Container and getContents()

torn shuttle
#

yeah switching over now

#

but wait, isn't this for Block objects

#

what happens if I try to do it to BlockData?

#

which is what I was storing

eternal oxide
#

why are you calling them all blockState if its BlockData?

torn shuttle
#

sorry

#

I am storing blockstate

#

but I was copying block data

#

since afaik you can't copy blockstate

eternal oxide
#

BlockState is already a copy

#

its a snapshot of that block at a point in time.

torn shuttle
#

hm let me check

#

is that snapshot meant to be able to store the inventory though

eternal oxide
#

I set type, set BlockData, then I add the inventory

#

if you have a BlockState you can get the inventory from it

#

notice I add the inventory after the block has been set with .update(true);

torn shuttle
#

fyi I'm pretty sure your set type there is extraneous

eternal oxide
#

its not

torn shuttle
#

doesn't set data modify it?

#

it seems to do it on my end

eternal oxide
#

if you don;t set the type it will thrown an MC error/warning in console about the wrong block type

#

it doesn;t error out as such, but it warns of wrong block types adn it says it will try to fix it

#

like [19:06:20 ERROR]: Block at 227, 38, -931 is Block{minecraft:stone} but has net.minecraft.server.v1_14_R1.TileEntityStructure@527ce791. Bukkit will attempt to fix this, but there may be additional damage that we cannot recover.

torn shuttle
#

hm

eternal oxide
#

you may not have to fill your inventory after as you are using BlockState. So long as you set type and data, then update it shoudl work.

#

I store my inventory separate so I do it after.

#

anyway good luck I'm off

somber hull
#
if (event.getClickedInventory() instanceof PlayerInventory) {
                for (String i : plugin.getConfig().getConfigurationSection("blocks.").getKeys(false)) {
                    plugin.getLogger().log(Level.SEVERE, i);
                }
#

It only prints one

#

Not sure why

dusty herald
#

remove the period after blocks

somber hull
#

Same thing

dusty herald
#

maybe try debugging with info instead of severe? idk

somber hull
#

It shouldnt matter

#

Since its being looped

#

wait

#

nvm the config file fucked

#

it never saved after i hit save'

#

wierd

#

fucking notepad

dusty herald
#

🤷‍♂️

sage swift
#

is there a good way to get the spawn reason of an existing entity? not using CreatureSpawnEvent

somber hull
#

If its logged in the nbt

#

Yea

#

Idk if it is tho

sage swift
#

you know what time it is

somber hull
#

@dusty herald i had saveDefaultConfig();

#

on onEnable()

dusty herald
#

you're supposed to do that

somber hull
#

hmm

#

it seems to be resetting it

#

@dusty herald it seems to be resetting the config on server restart

#

It has saveConfig() on onDisable()

dusty herald
#

try removing it

somber hull
#

ok

#

@dusty herald is this not suposed to be in ondisable?

#
    public void onDisable() {
        this.data.saveConfig();
        this.saveConfig();
    }
sage swift
#

no dont use that

#

that will overwrite changes you make if you don't reloadConfig()

somber hull
#

Ok

#

@sage swift

#

help mw

#

if(event.getClickedInventory() instanceof PlayerInventory) return;

#

where do i put the !

#

to do the opposite check

sage swift
#

outside of the parentheses

somber hull
#

nope

sage swift
#

see if you can figure that riddle out

somber hull
#

I put it oiutside of every parentheses on the line

#

syntax errror

quaint mantle
#

This might work
if (!(event.getClickedInventory() instanceof PlayerInventory)) return;

somber hull
#

yep

#

im big dumb

#

thanks

quaint mantle
#

Np <33

sage swift
#

lüp

somber hull
#

The keys are things like NETHERITE_INGOT

somber hull
somber hull
#

@quaint mantle

quaint mantle
#

Yes

somber hull
#

Can help, im kinda confused

#

Just tell me the basic idea

#

and i can figure it out

quaint mantle
#

I'm bad at events

somber hull
#

its just

#

getting a itemstack array

#

and checking if any of the blocks line up with a different list

sage swift
#

lüp

autumn cave
#

How can I pass in chat api components to an item's lore? Right now in spigot we have ItemMeta.setlore(List<String> lines) thats it. How could I use perhaps Bukkit, CraftBukkit or nms to achieve this? This is achieveable with minecraft commands, for example: /minecraft:give @p stick{display:{Lore:[{"color":"red","text":"stick"}]}}

somber hull
# sage swift lüp

i obviously dont know what this is, so if you would like to contribute to the conversation please do. If your just going to post things that wont help anyone please see yourself out

sage swift
#

loop through every item

somber hull
#

Yea but like

#

Would i do a loop inside a loop?

sage swift
#

well it's a set

#

so you can use Set#contains

somber hull
#

Leme check that rq

#

d; Set#contains

#

d;Set#contains

autumn cave
somber hull
#

d; spigot Set#contains

#

fuck

#

d;spigot Set#contains

#

wait, wrong discord

sage swift
#

set is not exclusive to spigot

somber hull
#

Like what does the Set#Contains mean

#

Im kinda new

#

Ive gotta ask this question at some point

sage swift
#

the pound sign means you call the method on an instance of the object

somber hull
#

got it

sage swift
#

so you can't just do it statically

somber hull
#

Where do i find the documentation for it

#

I cant find it on the spigot site

sage swift
#

if you want the big brain one line solution here java Stream.of(evt.getPlayer().getInventory().getContents()) .anyMatch(item -> config.getKeys(false).contains(item.getType().toString()));

somber hull
#

thank you 😄

#

Im dumb

#

Forgot that things other than spigot exist

#

lol

dusty herald
#

Bukkit?

quaint mantle
#

Use IntelliJ for better experience and for TabComplition

somber hull
quaint mantle
#

Okay :((

dusty herald
#

NetBeans all the way /s

sage swift
#

but yeah for your classic loop you'd do something like java boolean found = false; for (ItemStack item : player.getInventory().getContents()) { if (config.getKeys(false).contains(item.getType().toString)) { found = true; break; } }

dusty herald
#

mobile?

digital plinth
quaint mantle
#

What does getKeys means

digital plinth
#

why did this trigger a unhandled exception

dusty herald
#

also uh that world doesn't exist apparently

digital plinth
#

but how?

#

i set it

heavy island
#

why'd ya cut out the line numbers

sage swift
# quaint mantle What does getKeys means

if i have yml section: key: bla bla bla key2: bla bla bla key3: something else and i call config.getConfigurationSection("section").getKeys(false) i'll get a Set with "key", "key2", and "key3"

dusty herald
#

🤷‍♂️

digital plinth
digital plinth
#

proof*

heavy island
#

give us line numbers, you maniac

digital plinth
#

where

dusty herald
#

well apparently the world is null Supa

digital plinth
dusty herald
#

I'm saying null check those matchMaterials

digital plinth
digital plinth
#

.matchmaterial is the comand i found in the docs

heavy island
#

pos1.getWorld() is probably null.

dusty herald
#

I'm saying that matchMaterial is nullable??

digital plinth
#

uhh yea but does that matter

digital plinth
heavy island
#

I don't think it's matchMaterial

digital plinth
#

leme check

dusty herald
#

oh I mean no if you don't care about people inserting false arguments

heavy island
digital plinth
#

pos1 should be null

sage swift
#

bep bop bap i am correct 100% of the time so i dont need any null checks

heavy island
#

yeah

dusty herald
#

you madman gecko

heavy island
#

if you call .equals() on a null object, it throws an exception

sage swift
#

everything on my server runs perfectly

digital plinth
dusty herald
#

yes that is what I am saying to do

digital plinth
#

from two blocks

heavy island
#

the error is on line 44 and it says getWorld() is null >.>

digital plinth
#

kinda liek what happens when u left and right click in worldedit with the wand

dusty herald
#

maybe set the location and retrieve the world from that?

#

idk

heavy island
#

actually, maybe pos2.getWorld is null

#

it's one of the two positions

digital plinth
#

but it should have worked right?

dusty herald
#

debug it uwu

heavy island
#

yeah

digital plinth
#

okie dokie

#

so i check and see if the woorlds are null

heavy island
#

yes

digital plinth
#

pos1.getworld == null ?

dusty herald
#

try not setting the world btw

#

since you can just get it from the location 🤷‍♂️

digital plinth
#

okie i'll do the command before i set the position vars

#

thats how i created the vars btw

#

did i do something wrong

dusty herald
#

then why are you resetting it?

#

ah nvm I see

digital plinth
#

i just figures i'd add a value to it

dusty herald
#

does the world Lobby exist?

heavy island
#

^

digital plinth
dusty herald
#

huh..

heavy island
#

pog

digital plinth
#

but the location should be overwritten

dusty herald
#

that might be your issue bud

heavy island
#

we found the error

#

set it to the overworld for testing

#

kek

digital plinth
dusty herald
#

or just world

digital plinth
heavy island
#

yeah, it's world

digital plinth
#

i broadcasted the new value of the Location var

#

so its updated

#

:/

#

😮

#

its fixed

#

surprising ly

#

wait hold up

#

does this mean the location variable did not get updated?

heavy island
#

the issue was that, if a world doesn't exist, Bukkit.getWorld() will return null.

digital plinth
heavy island
#

yes

#

that was what fixed it

digital plinth
#

i have the code to overwrite it from the beginning :/

heavy island
#

well

#

if you must hardcode it, I guess you don't need to check

#

but neither of those things are great practices

#

what if someone wants to use it in another world
what if the default world name isn't "world"

digital plinth
#

of what?

#

uhh

wispy monolith
#

How can I get the name of the advancement in an event

digital plinth
#

lol

heavy island
#

but wouldn't the wand's effect only apply in the overworld?

wispy monolith
digital plinth
#

i did not design it to be like that

#

when u left of right click with an item

#

the pos1 and pos2

#

get new values

wispy monolith
#

it shows this when I use event.getAdvancement().toString();

heavy island
#

yes

#

but

digital plinth
#

from the blcosk u interact with

wispy monolith
#

org.bukkit.craftbukkit.v1_16_R3.advancement.CraftAdvancement@5cfd8b82

wispy monolith
#

this is an example

heavy island
#

pos1 and pos2 will ALWAYS be in "world"
you can't set the positions to the nether or the end, ever

digital plinth
#

what why?

heavy island
#

block positions != dimension position

#

when you use getWorld, you're selecting a dimension

digital plinth
#

wait blocks don't contain values of their dimension?

heavy island
#

nah

heavy island
#

those are just coordinates of where in the dimension the blocks are

wispy monolith
dusty herald
#

u can see what that does idk what it returns

digital plinth
#

whatttttt?

#

i can't change the world variable in the Location variable?

#

why?

heavy island
#

you can

wispy monolith
heavy island
#

just use getWorld on the position they're right clicking

digital plinth
#

pos1.setWorld(bukkit.getworld("blah"))

heavy island
#

it should already be available

dusty herald
#

try get Key getKey

heavy island
#

don't use Bukkit.getWorld()

digital plinth
heavy island
#

nonono, the position contains a world

#

like

digital plinth
#

for extra reassurance

#

XD

digital plinth
#

whas wrong with these

#

XD

heavy island
#

well

#

I guess that works

#

wait

#

why are you using Bukkit.getWorld()?

digital plinth
#

well yea i didn't change the code at that part

wispy monolith
#

and how can I make my plugin sends a message to the admins(OP) when there is a new version?

digital plinth
#

disposable

dusty herald
#

onJoin > check perms > send message

heavy island
#

it should be removed

digital plinth
#

okie

heavy island
#

I'm talking about this

wispy monolith
dusty herald
#

onJoin > Player#isOp() > send message

digital plinth
#

i should have overwritten the world right?

#

with this

dusty herald
#

PlayerJoinEvent yo

digital plinth
heavy island
#

hold on

#

so that's your event handler for right clicking

#

and this:

digital plinth
heavy island
#

is your command handler for setting positions?

digital plinth
heavy island
#

ah, so that's old

digital plinth
#

i figured i'd give them a value

heavy island
#

yeah, your solution should work now

digital plinth
#

should i not?

heavy island
#

in general, hardcoding a world is a bad idea

digital plinth
heavy island
#

indeed

dusty herald
#

hardcoding in general is a sin to me

digital plinth
heavy island
#

one question
if you're immediately reassigning the value of pos1, why are you storing it in your command executor?

digital plinth
#

i cant leave it blank

heavy island
#

actually, I should probably ask what your intentions are.
What's this code supposed to do?

digital plinth
#

the two positions are created in the Commands class, then the vairbales are reassigned values in another class

wispy monolith
heavy island
#

well

#

I guess your code isn't exactly incorrect at this point

digital plinth
#

okei thx

#

damn it so i created the variables here like this

#

and i gave them value in a different class

#

but the two position vars are null

#

why did the edits made in a different class not get passed on

somber hull
#

plugin.getLogger().log(Level.WARNING, plugin.getConfig().getConfigurationSection("blocks").getKeys(false).toString());

#

for some reason

#

it just logs []

#

i have triesd with blocks and blocks.

#
  sand:
  dirt:
#

thats the config

dusty herald
#

show full code and config

somber hull
#
        public void onEntityDeath(InventoryClickEvent event) {
            if (event.getClickedInventory() instanceof PlayerInventory) {
                if(!(event.getClickedInventory() instanceof PlayerInventory)) return;
                for (ItemStack item : event.getClickedInventory().getContents()) {
                    if (item == null) continue;
                    plugin.getLogger().log(Level.WARNING, item.getType().toString());
                    plugin.getLogger().log(Level.WARNING, plugin.getConfig().getConfigurationSection("blocks").getKeys(false).toString());
                    if (plugin.getConfig().getConfigurationSection("blocks.").getKeys(false).toString().contains(item.getType().toString())) {
                        plugin.getLogger().log(Level.WARNING, "aaaaaaa");
                    
                  }
                }
            }
            }
#

i need to rename the event lol

dusty herald
#

why are you converting it to a string?

somber hull
#

oh

#

idk

#

i thought i had to

dusty herald
#

it's not a string

somber hull
#

ok, well this should work right?

#

if (plugin.getConfig().getConfigurationSection("blocks.").getKeys(false).toString().contains(item.getType().toString())) {

#

oh wait

dusty herald
#

no

somber hull
#

how do i do that correctly?

digital plinth
#

why is it being checked twice

somber hull
#

Idk if i had noticed it sooner i would have removed it lol

somber hull
#

from the configuration section

#

leme try it

#

still no worky

#

leme try it without the .

#

nope

wispy monolith
#

How can I check that the advancment is not a recipe?

somber hull
#
if (plugin.getConfig().getConfigurationSection("blocks").getKeys(false).contains(item.getType().toString())) {
                        plugin.getLogger().log(Level.WARNING, "aaaaaaa");
#

idk whats going wrong here

quaint mantle
#

hey, i'm trying to make a simple plugin who prints "niceee" when a player joins, and it has never print "nice" when i joined, and i'm not getting any errors. Can someone help me?

Here is my code:

package com.sfx.mlgrush;

import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;

public class Main extends JavaPlugin implements Listener {

    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);
    }
    
    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event) {
        System.out.println("Niceeee");
    }
}
wispy monolith
somber hull
wispy monolith
#

ig for the console

quaint mantle
quaint mantle
#

bro i'm new

#

what's the error I made

somber hull
#

getLogger().log(Level.WARNING, "nice");

wispy monolith
somber hull
wispy monolith
#

gimme a sec

#

show me your config

somber hull
#
blocks:
  sand:
  dirt:
#

in my inventory

#

is a sand block

#

singular sand block

wispy monolith
#

so u want to make a list right?

somber hull
#

yea, but i also want them to have the freedom to add numbers

wispy monolith
#

in ur config

somber hull
#

so an amount of that item

#

so sand: 64

#

i havent added that yet

#

Im just future-proofing

wispy monolith
#

change it to

block:
  - 'sand'
  - 'dirt'
somber hull
#

But then how would i add the amount

wispy monolith
#

this is how u make lists in ur config.yml

somber hull
#

Yes

#

But how would i add the amount

wispy monolith
somber hull
wispy monolith
#

oh ok

#

I see

#

you can do like that ig

quaint mantle
#

it's not printing ice in my console

#

im on a bungeecord server

#

btw

somber hull
#

welp.

#

idk how to do bungee'

quaint mantle
#

but it's in my server folder

somber hull
#

¯_(ツ)_/¯

quaint mantle
#

not in the bungeecord folder

wispy monolith
#
blocks:
  sand:
    "sand"
    amount:
#

idk if this is right I'm not sure

quaint mantle
#
package com.sfx.mlgrush;

import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;

public class Main extends JavaPlugin implements Listener {

    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);
    }
    
    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event) {
        getServer().getConsoleSender().sendMessage("nice");
    }
}

#

is my code correct

somber hull
#

wouldnt sand: 64 be better

heavy island
wispy monolith
heavy island
#

it makes your code more complicated for no reason

somber hull
#

yea no thats retardd

heavy island
#

it's literally--

wispy monolith
somber hull
#

I know im going to add it

#

So

#

Im going to make sure that i dont cause trouble later

heavy island
#

if you know you're going to add it immediately

#

that's fine

wispy monolith
#

yeah we are just giving u and advice

somber hull
#

Yea i will

heavy island
#

but if you're not adding it now, it's best not to add that

somber hull
#

Well im going to add it as soon as im done with getting the base name of the material done

#

then ill work on getting the amount of items as well

wispy monolith
heavy island
#

that's fair

wispy monolith
heavy island
#

as long as you don't release something with a bunch of unused code, it's not really a problem

somber hull
#

i wouldnt do that lol

#

@quaint mantle getLogger().log(Level.WARNING, "nice");

#

anyway

#

i gotta head off

#

thanks for the help

#

👍

quaint mantle
#

anyone can help me

#

[08:31:00 ERROR]: Could not load 'plugins\mlgrush.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml

dusty herald
#

show the entire error

#

your plugin.yml is most likely missing api-version

quaint mantle
#

Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
... 14 more
[08:31:00 INFO]: Server permissions file permissions.yml is empty, ignoring it

dusty herald
#

your jar does not contain plugin.yml

quaint mantle
#

but how can I include it

wispy monolith
#

Show ur dircetory

dusty herald
#

what ide

quaint mantle
#

ckuose

#

eclipse

wispy monolith
quaint mantle
wispy monolith
#

no the left side of your screen thta have ur classes and packages

quaint mantle
#

it's the only plugins i have

wispy monolith
#

package explorer ig

wispy monolith
quaint mantle
#

i'll try

wispy monolith
#

just drag it to it

quaint mantle
#

oof tf

#

org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: com/sfx/mlgrush/Main has been compiled by a more recent version of the Java Runtime (class file version 59.0), this version of the Java Runtime only recognizes class file versions up to 52.0

wispy monolith
#

compile using JDK 8

#

(SDK 1.8)

quaint mantle
#

i'm trying to change the compiler version but idk how lol

wispy monolith
#

and add an api-version to your plugin.yml

quaint mantle
#

i did

#

it's 1.8

wispy monolith
quaint mantle
#

because my server is 1.8.9

#

i can't actually

wispy monolith
#

go to properties

#

@quaint mantle

#

and then java compiler

quaint mantle
#

i'm trying

wispy monolith
#

send a screenshot

#

so I can point to it

quaint mantle
#

tf is that now it says that it enabled my plugin, but when i try to join my server it says "failed to login: servers are in maintenance"

#

i tried restarting my server

wispy monolith
#

did u cahnge the compiler version?

quaint mantle
#

yes

wispy monolith
#

cool

#

then add an api-version and a description in ur plugin.yml

quaint mantle
#

yes

#

i said i added it

#

i putted 1.8

clear fable
#

Anyone here ever used Discord JDA? I'm trying to use it in a plugin and I'm getting a lot of exceptions

wispy monolith
#

ok

quaint mantle
#

ok done its working bruh

wispy monolith
quaint mantle
#

thanks dude

wispy monolith
clear fable
#

My code works, but whenever I run it it produces like 5+ exceptions like this: java.lang.IllegalStateException: zip file closed

wispy monolith
#

or at least the main class

#

hello?

#

?paste

queen dragonBOT
wispy monolith
#

here u can paste your errors code whatever

clear fable
#

sorry I was editing the pastebin

#

happens when sendPlayerMessage() is called

wispy monolith
#

ok so first u need to Make th JDA

clear fable
#

I am lol

#

wdym

wispy monolith
clear fable
#

I have that

wispy monolith
#

ok

#

gimme a sec

#

can u send the full error please

clear fable
#

if I omit playersWebhook.execute(); then I get no errors

wispy monolith
#

with all the exceptions that u can get

clear fable
#

When I have it the code works but spams errors

#

I forgot to mention I'm using a custom class to send webhooks

#

I'll send it

wispy monolith
#

What is your plugin trying to do

clear fable
#

send a discord webhook with data about players online

wispy monolith
#

like a log?

clear fable
#

kinda ye

quaint mantle
#

how to make a for loop with each player connected in the server

wispy monolith
#

just make the bot send the stuff to a channel with some events and that's it

clear fable
quaint mantle
#

thanks

clear fable
#

but I liked the custom bot names from the webhook

wispy monolith
clear fable
#

like with a webhook I can make the sent from user any name I want and any icon I want

flint elk
wispy monolith
queen dragonBOT
wispy monolith
flint elk
#

World world = Bukkit.getWorld(worldName);

wispy monolith
wispy monolith
flint elk
#

F

wispy monolith
#

line 20

flint elk
#

if(event.getCurrentItem().getItemMeta().getDisplayName().equals("§8» §eSettings") || event.getCurrentItem().getItemMeta().getDisplayName().equals("§8» §aWorlds")){

#

I've put it in a try catch

#

c:

lofty mulch
#

event.getCurrentItem() is null i suppose

clear fable
wispy monolith
clear fable
#

I mean webhooks shouldn't be this hard lol

chrome beacon
lofty mulch
flint elk
#

I FIXED IT

clear fable
flint elk
#

With a try catch :3

chrome beacon
lofty mulch
#

no

#

It should return ""

chrome beacon
#

Aight

lofty mulch
#

or if you didn't set display name, it should be Material name

chrome beacon
flint elk
#

It's a little server only for me

lofty mulch
#

add try catch then remove try catch

#

it's ok

wispy monolith
lofty mulch
#

webhook is easier

clear fable
#

yeah

lofty mulch
#

and save performance

clear fable
#

My webhooks aren't even related to the JDA but somehow sending a webhook message causes JDA errors? 🤔

lofty mulch
#

?

clear fable
#

I'm so confused lol

lofty mulch
#

webhook is http request

clear fable
#

ye

lofty mulch
#

remove JDA deps

clear fable
#

I'm using HttpsURLConnection to send the webhook but doing so causes an error from JDA

wispy monolith
clear fable
#

Only using it in 1 class

wispy monolith
#

ok so that is it

lofty mulch
#

you should show your dependency list

clear fable
#

I'm so confused tho bc HttpsURLConnection isn't even related to JDA and JDA throws errors about zip file errors?

lofty mulch
clear fable
lofty mulch
#

only <dependencies>

clear fable
#
<dependencies>
        <dependency>
            <groupId>net.dv8tion</groupId>
            <artifactId>JDA</artifactId>
            <version>4.2.1_253</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/libs/JDA-4.2.1_253-withDependencies-min.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.16.5-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>```
lofty mulch
#

remove JDA

clear fable
#

alr

#

then what?

lofty mulch
#

if you want to use JDA

#

use Hesham's answer

wispy monolith
clear fable
#

guys I am using webhooks and a bot so I need JDA and my webhook class 🤦‍♂️

lofty mulch
#

so

clear fable
#

cant remove either

lofty mulch
#

use Hesham's answer

clear fable
#

that doesnt use a webhook

lofty mulch
#

but for bot

#

and btw

clear fable
#

ye ik the problem is with the webhook

lofty mulch
#

the problem is JDA

clear fable
#

Hesham literally just suggested what I am already doing

#

that doesnt help

lofty mulch
#

?paste

queen dragonBOT
wispy monolith
#
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
  jda.getTextChannelById(ChannelID).sendMessage(event.getPlayer().getName() + " joined the server")
}
clear fable
#

ffs I dont want to send the message with JDA I said this already

#

I want to send a webhook

lofty mulch
#

webhook may be get rate limit

clear fable
#

I've said this like 5 times

wispy monolith
#

ok do what ever u want

clear fable
#

rate limit doesnt matter

lofty mulch
#

rate limit is the matter

clear fable
#

its not causing the problem

#

idc about the rate limit

lofty mulch
#

u dont get my word

#

so provide log, and mainclass

wispy monolith
#

also you are over complicating stuff even using JDA

clear fable
#

I already did but I'll send it again

mild kernel
#

Hey, I created a command in my plugin but I have a problem because I get this error:

[07:55:51 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'dratoggleforplayer' in plugin DontResetAttributes v1.0.0
[..]
Caused by: java.lang.NullPointerException
        at me.krystejj.dra.command.ToggleCommand.onCommand(ToggleCommand.java:18) ~[?:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[patched_1.16.5.jar:git-Paper-642]
        ... 19 more

this is my command:

public class ToggleCommand implements CommandExecutor {

    public ToggleCommand(DontResetAttributes plugin) {
        plugin.getCommand("dratoggleforplayer").setExecutor(this);
    }

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

        System.out.println(args); //<-------- this causes an error

        if (DontResetAttributes.affectedPlayersNames.contains(args[0])) {
            DontResetAttributes.affectedPlayersNames.remove(args[0]);
            commandSender.sendMessage(
                    ChatColor.GRAY + "Disabled DontResetAttributes for player " + ChatColor.AQUA + args[0]);
        } else {
            DontResetAttributes.affectedPlayersNames.add(args[0]);
            commandSender
                    .sendMessage(ChatColor.GRAY + "Enabled DontResetAttributes for player " + ChatColor.AQUA + args[0]);
        }

        return true;
    }

}

sorry for my bad english

lofty mulch
clear fable
#

90% chance its bad plugin.yml formatting

#

@mild kernel

#

OK I will type out my problem again but more descriptively