#help-development

1 messages · Page 1730 of 1

quartz valve
#

Still no errors

indigo cave
#

ItemStack itemstack = event.getRecipe().getResult();
itemstack.addEnchantment(...);
event.setCurrentItem(itemstack);

quartz valve
#

i will try

indigo cave
#

np

clever meteor
#

hey can any1 help me im trying to make a kit and when i do it says that kit is improperly defined contact administrator

drowsy helm
chrome ferry
#

Hey, i have a menu setup so when the menu opens it sets all the skull owners async. (So it doesn't block server thread), now i believe spigot caches the skull owner once. I was wondering if anyone knows if i can access it at all?

#

oh god

#

please

#

please at least use a switch and case 😭

drowsy helm
#

just use a list or immutable set?

#

you're setting the same enchant

chrome ferry
#

or that yea

#
    @EventHandler
    public void onCraftItem(CraftItemEvent event){
        switch(event.getRecipe().getResult().getType()) {
          case IRON_PICKAXE:
          case DIAMOND_PICKAXE:
          case GOLD_PICKAXE:
          case STONE_PICKAXE:
          case WOOD_PICKAXE:
            ItemStack itemStack = event.getRecipe().getResult();
            ItemMeta itemMeta = itemStack.getItemMeta();
            itemMeta.addEnchantment(Enchantment.DIG_SPEED, 3, true);
            itemstack.setItemMeta(itemMeta);
            event.setCurrentItem(itemstack);
        }
    }
#

i mean

#

thats much better than before

#

😭

drowsy helm
#

i dont think you can access the cache what do you plan on doing with it?

chrome ferry
#

Instead of setting the skull async, it'll just set while the menu has opened so it doesn't have a quick ugly switch delay

drowsy helm
#

huh

#

it already gets it from the cache if its loaded?

#

you don't need to do it manually

chrome ferry
#

I set all the skull owners async after the menu is loaded

#

so i wanna check if it is cached, if it is it wont set it async

drowsy helm
#

correct me if im wrong but even if you do set the owner async it will still fetch data on the main thread

chrome ferry
#

It doesn't

#

As before i did it async it froze

drowsy helm
#

interesting

chrome ferry
#

As you can see, i load up the menu first and it takes a bit. thats fine thats the requests

#

Then when i refresh it has that quick blink of the skull changing owners, not sure if you can see that?

drowsy helm
#

yeah i can

#

and when on the main thread it just freezes?

#

wouldn't think that little amount would

chrome ferry
#

Well

#

I'm talking about like each skull there being a different skin (other servers reported it)

drowsy helm
#

yeah

chrome ferry
#

and thats when spigot already has it cached

#

so i wonder if i could check if it is cached from spigot and then it wont load async and not have that loading effect when the menu is open

drowsy helm
#

i mean if not you could always make your own cache

chrome ferry
#

Yeah i could, that is correct just dont wanna use much ram i mean if it is possible to access spigot cache then that would be the most suitable even if it has to use reflection i'll cache that obviously

#

Or maybe, just keep the loading effect after its cached. i'm not sure if i like that though haha

drowsy helm
#

I mean reflection sounds more costly than less than a mb of usage

#

at maximum

chrome ferry
#

Hmm, how would spigot cache skull owners?

#

Do they cache like the player texture?

sullen marlin
#

Just store one itemstack?

chrome ferry
#

Itemstacks will change

drowsy helm
#

i mean the texture value and signature is only a few hundred chars

#

its not a huge amount

chrome ferry
#

Yea, i've decided i'll cache it myself just wondering thats how they do it right. Something like a map of uuid and skull texture?

drowsy helm
#

yeah pretty sure i did something similar a while back

#

give it a go

chrome ferry
#

nice just crashed my intellij lmao of opening the implmentation of SkullMeta

drowsy helm
#

just decompile lmao

chrome ferry
#

(thats what i did)

drowsy helm
#

not in intellij lol

chrome ferry
#

ohhh haha

#

i think intellij likes that ram and cpu

drowsy helm
#

nom nom

eternal night
#

I can also recommend just having a local copy of the spigot workspace

chrome ferry
#

Yea i do

#

just ease of use right in intellij though haha

summer scroll
#

god damn 5.4gb

chrome ferry
#

yeah lmao

#

okay so i can just cache the game profile and uuid in a map

#

or not even that

drowsy helm
#

can just have uuid, texxture value and signature

#

thats all you need

chrome ferry
#

so so i'll use mojangs PropertyMap object then

tender shard
#

btw: this didn't work because you didn't set the itemmeta back to the item

chrome ferry
#

plus naming conventions too 😩

drowsy helm
#

you applied it to the itemstack

#

not the meta lol

verbal nymph
#

Which of these two would be faster / the preferred way to check for a player?

e.getEntity() instanceof Player
e.getEntity().getType() == EntityType.PLAYER
chrome ferry
#

instanceof

drowsy helm
#

instanceof

#

not sure of speed but its preferred

chrome ferry
#

speed, well

#

if the enum is big

#

it has to go through the enum

#

so its bad

verbal nymph
#

Makes sense, thank you!

pastel stag
#

easiest way to run a method every hour in java?

drowsy helm
#

runnable

chrome ferry
#

Use Bukkit scheduler for spigot though

crimson terrace
pastel stag
#

ty

summer scroll
#

runTaskLater

regal dew
eternal oxide
#

If you want it to run at a specific time (real world) don;t use the scheduler

chrome ferry
#

it has to iterate the enum constants

#

iirc

sullen marlin
#

It doesn't

#

But also just use whatever

#

I'd use instanceof if I'm casting it, but otherwise doesn't matter

chrome ferry
#

Wait is that .name()

regal dew
#

no

chrome ferry
#

that iterates

#

theres something in the enum that iterates i cant remember tho

sullen marlin
#

none off the top of my head

#

Even valueOf doesn't

chrome ferry
#

swear i heard that somewhere, eh oh well

regal dew
#

but really dont microoptimise code like this

#

Code stuff that’s readable and maintainable

chrome ferry
#

but instanceof is 100% cleaner

regal dew
#

Optimise when its noticeable

verbal nymph
#

This will probably never become noticeable. But still a good feeling to do it in a performant way 😄

tender shard
#

Okay so I think I found a bug either in the API or in the javadocs

#

CraftItemEvent

Description in Javadocs:

Called when the recipe of an Item is completed inside a crafting matrix.

Actual behaviour: gets called when the player takes the item out of the result slot. But the description says it should be called when the last ingredient gets put into the matrix

ivory sleet
#

As it has to copy the internal array iirc

young knoll
tender shard
tender shard
young knoll
#

Really?

tender shard
#

yep

young knoll
#

I haven’t checked but that seems weird

tender shard
#

I just debugged this for 20 minutes so I'm really sure^^

bronze notch
#

Hi there, is anyone here experienced with Kotlin and annotation processing (with Maven)? I am building my own annotation processor, but it only works with gradle. But unfortunately my plugins were built with Maven.

indigo cave
#

actually it still should work, since both work with .m2

bronze notch
#

A maven plugin requires their dependencies to have a pom I thought.

ivory sleet
#

APs should work regardless of maven/gradle

agile sluice
#

how to make cobblestone generator slower in the end world? anyone knows?

abstract surge
#

hey i cant found in 1.16 Material.DAYLIGHT_DETECTOR_INVERTED

sullen dome
ancient plank
#

since inverted is a state, not a block itself

quasi flint
#

How can i put all the blocks of one type in a hashmap when i have an chunksnapshot?

indigo cave
#

stream

quasi flint
#

?

indigo cave
#

get all blocks and chunk and then stream

tardy delta
#

this doesnt seem to do anything to prevent mob collision

@EventHandler
    public void onEntitySpawn(EntitySpawnEvent event) {
        if (event.getEntity() instanceof LivingEntity)
            ((LivingEntity) event.getEntity()).setCollidable(false); // todo remove?
    }
echo basalt
#

both entities need to not be collidable

tardy delta
#

i set players too

#

player.setCollidable(false);

marble granite
#

is there an easy way to get distance between chunks?

echo basalt
#

Math.hypot(chunkOne.getX() - chunkTwo.getX(), chunkOne.getZ() - chunkTwo.getZ());

marble granite
#

oh

#

well, thank you

echo basalt
#

Yeah nw

tardy delta
#

i'm confused i don't see a pf

indigo cave
#

i think players are always collidable

late dove
#

advise VDS or VPS in order to start the server there.

compact cape
#

Is there a way to put a code even before onEnable?

indigo cave
rigid hazel
#
@Override
    public void onDisable()
    {
        for(Guild guild : this.getGuilds())
        {
            for(GuildChunk guildChunk : guild.getOwnedChunks())
            {
                guildChunk.getChunk().load(true);
                this.getLogger().info("Chunk loaded successfully!");
                for(Entity entity : guildChunk.getChunk().getEntities())
                {
                    this.getLogger().info("Located entity");
                    if(entity.getCustomName() != null)
                    {
                        this.getLogger().info("Has custom name");
                        if(entity.getCustomName().startsWith("Verteidiger von "))
                        {
                            entity.remove();
                            this.getLogger().info("Is a guardian: Removed!");
                        }
                    }
                }
            }
        }
    }
#
[16:41:50] [Server thread/INFO]: [CCRP] Chunk loaded successfully!
[16:41:50] [Server thread/INFO]: [CCRP] Chunk loaded successfully!
[16:41:50] [Server thread/INFO]: [CCRP] Chunk loaded successfully!```
#

Please help. There are 3 Zombified Zoglins, which should get despawned by server shutdown, but they don't. Why?

ancient plank
#

Zoglins

golden turret
#

and if for some reason you need it before onLoad, try initializing variables in the scope 🤡

true perch
#

I really don't understand why sometimes I'll get an index out of bounds error with this line: queue.remove(0); when there's a check directly prior.

if (queue.size() == 0) {
    break;
} else {
    queue.remove(0);```
quaint mantle
#

then also check if queue.get(0) is null

#
if (queue.size() == 0 || queue.get(0) == null)
    break;
else
    queue.remove(0);
true perch
quaint mantle
#

Try return

#

Main.what?

#

Main.uwu 🙂

true perch
#

I'll just add the null check.

quaint mantle
#

Try sortedmap = treemap

true perch
#

oh no no it's an arraylist

quaint mantle
#

make a new itemstack with one item of the type e.getItem().getType() and remove that

quaint mantle
#

Ex:
SortedMap<K, V> map = new TreeMap<>();

#

meh its easy and safer to just add the null check

true perch
#

The only think I do with the ArrayList is .add, .get, and .remove which is why this puzzles me

#

yeah it's just like breaking my head

quaint mantle
true perch
#

I have no idea how it can get past that size check XD

quaint mantle
#

Why don’t u give it a try

true perch
#

The ArrayList does it's job great, just logically, I can't wrap my head around why it's giving the out of bounds exception.

#

Yeah a null check is a simple solution, I'm just wondering why

quaint mantle
#

I don't think so

true perch
#

It's very unsafe, stick to the main thread onDisable

quaint mantle
#

i also think theres a way to remove only a certain number from inventory but yeah

true perch
#

So you want to run all of the SQL commands onDisable?

quaint mantle
#

maybe you could run a synchronous task in which you can run async tasks, wait for parent synchronous task to finish and then allow server to disable

#

idk tho

true perch
#

It definitely sounds like you will need to restructure

#

Consider not sending all SQL commands onDisable, rather send them to an async thread as new info is needed to the SQL

valid solstice
#

java.lang.IllegalArgumentException: Plugin already initialized! how would you fix this?

#

im assuming this happened because im making another instance of the main?

hasty prawn
#

Yeah it is

#

Don't do that

valid solstice
#

i did something like MainFile main = new MainFile;

#

so that i could do main.getconfig()

hasty prawn
#

Yeah don't. Use DI or Singleton if you need your plugin instance

valid solstice
#

ok ill check those out

#

thanks

valid solstice
#

then i can call it in another class

#

is that a good way

hasty prawn
#

That's what Singleton is

quaint mantle
#

why do you want people to test your plugins for you lol? nobodys gonna do that

#

test them yourself?

#

I mean thats when an alt is useful lol

valid solstice
#

ok thanks

quaint mantle
#

read the error message

eternal oxide
#

new ItemStack(e.getItem().getType(), 1); Before you test for null

ivory sleet
#

?di idk if this might explain a bit why just passing your dependency down to ya fella component is somewhat better

undone axleBOT
valid solstice
eternal oxide
#

You test every method return that can be null before using it.

valid solstice
eternal oxide
#

getItem() can be null

ivory sleet
#

No worries, ping if you got any questions

#

(;

quaint mantle
#

:)

ivory sleet
#

ItemStack!

#

ItemStack?

#

or idr if it was ! or two !!

eternal oxide
#

I already told you

quaint mantle
#

e?.item

tardy delta
#

my eyes

quaint mantle
#

dont even need to call the getter

eternal oxide
#

you are using getItem().getType() without checking the return of getItem()

quaint mantle
#

it just does

ivory sleet
#

no but types can be T? to mark it Nullable and T! Or if it was T!! Which declares it as unknown nullability

#

Reinvented regex mybud

#

(:

#

From inventory?

#

easy way

#

Loop through the inventory contents

quaint mantle
#

O(n) >:(

#

sequential search gross

ivory sleet
#

I don’t know if it’s possible with O(1)

#

Not with the current impl

hasty prawn
#

An inventory is O(1) is it not? Inventory size can't be higher than 54

quaint mantle
#

binary search ?

quaint mantle
ivory sleet
quaint mantle
#

so not bad and not worth trying to optimize tbh

ivory sleet
#

Depends

#

Ik Bukkit loves to clone ItemStacks

#

So might be worth optimizing if possible

#

iirc some method clones the item stack 2-3 times

maiden thicket
#

huh xd

#

oh in lotlin

#

kotlin

quaint mantle
#

kotlin

#

lol

ivory sleet
#

Well smtng like
Inventory inv = ..;
for (int i = 0; i < inv.size(); i++) {
var item = inv.getItem(i);
if (item.getType() != Material.WOEE) {
continue;
}
int amount = item.getAmount();
if (amount == 1) {
inv.setItem(i, null); //might have to use an air stack idr
break;
}
item.setAmount(amount-1);
inv.setItem(i,item);
break;
}
@quaint mantle iirc something like this should work

#

On phone so something might be a bit yeah

quaint mantle
maiden thicket
#

is it any different

#

than java

quaint mantle
maiden thicket
#

i mean like how different

lavish hemlock
maiden thicket
#

did u get used to it instantly

quaint mantle
#

its like java if java was written in 2021 and not 199whatthefuckever

lavish hemlock
#

Kotlin is pretty different

maiden thicket
#

damn

ivory sleet
lavish hemlock
#

it's much more concise of a language

maiden thicket
#

how did u learn it exactly

quaint mantle
maiden thicket
#

ahh ic

#

is it worth it

lavish hemlock
ivory sleet
#

Kotlin is quite similar to Java so just learning the Java equivalent is easy

quaint mantle
quaint mantle
ivory sleet
#

But it has a lot of additional features which you’ll have to learn

#

Yeah kotlin is way more functional than Java

lavish hemlock
#

it's a very safe language too

#

there's a lot of nullability features

ivory sleet
#

Also coroutines 😌

maiden thicket
#

is reflections easier 😔

ivory sleet
#

Yeah

maiden thicket
#

COROUTINES

lavish hemlock
ivory sleet
#

About the same

quaint mantle
#

everythings easier

maiden thicket
#

c# type of vibe

lavish hemlock
#

it doesn't force you to use try/catch

#

ever

maiden thicket
#

😩

ivory sleet
#

Well we don’t have checked exceptions

#

In kt

maiden thicket
#

i just do @hoary knollthrows 😅

#

bruh

#

are u kidding

#

who tf is @ sneaky

lavish hemlock
#

if you do need to declare exceptions for a method, just apply the @Throws annotation to a method

ivory sleet
lavish hemlock
#

but that's mainly for interop

maiden thicket
#

i meant @ SneakyThrows in lombok

ivory sleet
#

But other than that

maiden thicket
#

oh shi

ivory sleet
maiden thicket
#

does kotlin basically have lombok shit for u

lavish hemlock
lavish hemlock
maiden thicket
lavish hemlock
#

data class

ivory sleet
#

Kotlin avoids checked exceptions

maiden thicket
#

oo

ivory sleet
#

So no need for sneak throw

lavish hemlock
#

Getters/setters are obsolete

ivory sleet
#

Properties 😌

maiden thicket
#

properties ?

lavish hemlock
#

Since all public values, AKA properties, compile a getter/setter

maiden thicket
#

o

ivory sleet
#

^

lavish hemlock
#

And data class also compiles equals and hashCode by default

ivory sleet
#

And it’s interoperable with java getters and setters

lavish hemlock
#

Oh ye also primary constructors

ivory sleet
#

So you can simultaneously use both Java and Kotlin although that’s like wanting to shoot yourself in the foot

lavish hemlock
#
data class Person(
    val name: String,
    val age: Int
)
#

which you call like Person(">:)", 499065)

#

yeah, there's no new, constructors are treated like methods... bc they are

ivory sleet
#

also everything immutable by default 😌

maiden thicket
#

oooooo

lavish hemlock
#

ye which is good for concurrency

#

which Kotlin does really well bc of coroutines

quaint mantle
#

.

lavish hemlock
quaint mantle
#

kotlin is just sm better in every way

lavish hemlock
#

there's var and val

#

var = variable (mutable)
val = value (immutable)

#

then for collections, you have List and MutableList (plus the mutable/immutable versions for everything else)

ivory sleet
#

If everything is immutable then it’s free thread safety 😏

quaint mantle
#

i was thinking of arrayOf and the mutable version nvm

lavish hemlock
ivory sleet
#

Rust is amazing

lavish hemlock
#

basically an object can only store one mutable reference to itself at a time

#

which stops data races

ivory sleet
#

Yep

lavish hemlock
#

as only one source can modify the reference at a time

ivory sleet
#

Oo yeah then we don’t have generic wildcards in kotlin which is quite nice

#

Site declaration variance (:

lavish hemlock
#

although, I'm curious to know how they differ

ivory sleet
#

Oh yeah *

lavish hemlock
#
Probably what it means is that Kotlin doesn't have wildcards in the same form as they are present in Java. Instead, Kotlin uses a different concept of mixed-site variance, which adds an option to specify the variance at declaration-site, that is something you cannot do with Java wildcards.
ivory sleet
#

Well you can’t use * out T or * in T

lavish hemlock
#

I fucking hate wildcards btw

ivory sleet
#

just out T and in T

lavish hemlock
#

y'know

#

Java's generics system is very hard to work with sometimes

ivory sleet
#

indeed

#

Capture of capture of capture (:

lavish hemlock
#

for like really big, complex projects, IDEA loves to give you the weirdest errors

#
- Error -
Expected: Class<T>
Result: Class<T>

something like that ^

#

which, T is different in both contexts

ivory sleet
#

Yuh

lavish hemlock
#

the expected T comes from Class while the resulted T comes from a method in Class that shadows the name of T

#

(although I don't think Class does this bc OpenJDK aren't fucking idiots except for when they broke everything again)

ivory sleet
#

I’ve got the classic sometimes
Required <I,O>
Provided <I,O>
but yeah

lavish hemlock
#

rip

ivory sleet
#

Though kotlin to the rescue!

hasty prawn
#

Just provide it better smh

ivory sleet
#

Yeah jfc I’m a dodo

hasty prawn
ivory sleet
#

^ responsible for the mess Java caused me

dull whale
#

how can I get the string content of a textcomponent?

ivory sleet
#

Probably need to use a legacy serializer

dull whale
#

sorry I had a component not a textcomponent

quasi stratus
#

I'm a bit new to plugin-making and I have a plugin Halara-Core that'd I'd like Halara-Lobby to have access to. I've already added the dependency in Halara-Lobby's plugin.yml and was wondering where I go from here.

#

I've tried just adding it as a library in the project but I don't believe that's the way to go about this- I could be wrong.

long ocean
#

Has anyone experienced issues with not all portals working after last spigot update?

#

Some portals will teleport, and some work. No errors in console, i can't figure out what is the difference. Even portals side by side, only one will work.

gritty urchin
#

How to display text below nametag

#

1.8.8

quaint mantle
cinder plume
#

guys , difference between CreatureSpawnEvent and EntitySpawnEvent?

quaint mantle
#

one is triggered when an Entity spawns, one is triggered when a Creature spawns

#

if I had to take a shot in the dark at what you're using it for, use EntitySpawnEvent

cinder plume
#

what would be the difference between a 'creature' and an 'entity'

#

stupid question but hmm whatever

tardy delta
#

is there any good tutorial about mysql?

long ocean
#

A creature is the type of entity

#

And vriend, map was generated this last mc update 1.17, spigot is currently CraftBukkit version 3257-Spigot-dc75aca-960f310 (MC: 1.17.1). Im puting in some debug messages to track down where it stops working.

cinder plume
#

What would be the best approach to check if a zombie i have stored the entity UUID of has spawned or not ?
using entityspawnevent?

quaint mantle
#

I don't think 1.17 worlds are compatible with 1.17.1 servers

#

that might be your problem

cinder plume
#

wait ill send a pastebin of the code

quaint mantle
#

syntax might be wrong because I use kotlin but you get the idea

cinder plume
#

yes legit what i did

quaint mantle
#

are you getting the CraftEntity uuid or just using java's uuid lib to generate a new uuid tho?

cinder plume
#

check the pastebin

but for some reason the >--< doesnt spawn

wispy bridge
#

Is there any way to change which direction an entity is looking without having to teleport them to a location with the direction changed?

quaint mantle
#

have you registered the event listener in your main class?

cinder plume
quaint mantle
#

actually you can eliminate the checks for entity type because the uuid is unique

cinder plume
#

yeah that too.

#

let me try that.

long ocean
#

vriend, when going through portals that wont work, the PlayerPortalEvent triggers but then PlayerTeleportEvent never triggers.

quaint mantle
cinder plume
#

didnt print the >--< when the zombie with the uuid spawned

wispy bridge
quaint mantle
#

I would use getLogger.info(">--<"); for now to debug, one less thing to troubleshoot

long ocean
cinder plume
wispy bridge
#

Just check with Bukkit.getEntity(UUID)

#

If its null, then the entity doesnt exist

quaint mantle
#

unless PlayerTeleportEvent isnt usually called when entering a portal

#

which seems like it might be the case

cinder plume
#

no like i want a way to constantly check if the custom mob i spawned is dead or alive on the server , thought this would be the best way to do so.

wispy bridge
#

That still applies

#

If you really want to check every tick just make a runnable

quaint mantle
#

then when an entity spawns do the check strubbe said an when an entity dies do the same check

quaint mantle
tardy delta
#

well uhh for a database for my plugin should you guys recommend postgreSQL or sqlite3?

wispy bridge
#

Yes I understand that, im saying if they really wanted to check every tick

gritty urchin
#

Trying to mount silverfish to player

#

however it is hiding the players nametag

gritty urchin
#

How do I prevent this?

wispy bridge
#

Just store every custom mob's UUID in a list, then use EntityDeathEvent and remove it if the entity that died's UUID is on that list

long ocean
#

Guess i will have to wait for md5 to find and fix the glitch.

quaint mantle
#

sqlite is my choice

tardy delta
cinder plume
wispy bridge
wispy bridge
#

If they have the circumstances to spawn the entity they should know whether or not its been spawned

#

Im not entirely sure how they're getting the UUID of a mob that has not existed as an object or not been created yet

cinder plume
#

im trying to ensure the custom mob i spawned , spawns only one of its kind

wispy bridge
#

If its null, then no entity, when you spawn one, fill it with the entities UUID

#

When it dies (Checked using EntityDeathEvent), set the UUID back to null

cinder plume
#

ok wait ill send a pastebin of the functions wait a second

wispy bridge
#

Did you happen to switch from LUA to Java?

cinder plume
#

no i did not

wispy bridge
#

Oh haha, it just looks like it

cinder plume
#

ahhh , nah man xD

wispy bridge
cinder plume
wispy bridge
#

Whenever you're doing your odd integer thing

#
@EventHandler
    public void bossSpawnStateSetter(EntityDeathEvent event) {
        if (event.getEntity().getType() == EntityType.ZOMBIE || event.getEntity().getType() == EntityType.SKELETON) {
            if (event.getEntity().getUniqueId() == boss_uuid) {
                bss = 0;
                Bukkit.getServer().broadcastMessage("<--->");
            }
        }
    }
cinder plume
#

as in?

#

ohh

#

right , as in when it dies

wispy bridge
#

boss_uuid = null in place of bss = 1

#

Oh yes, wrong event whoops

cinder plume
#

ok so when it dies i set it to null ?

#

right

wispy bridge
#

Yes

#

Also you should follow some naming conventions for the future

#

Like, your variable name for the Boss' UUID should be called bossUuid or whatever, _ are not really cool

wispy bridge
cinder plume
#

okay , wait.

#

no no , if i do that then , i wont be able to use the boss_uuid for other things

#

because it will set it to null

#

i use the boss uuid for other things too

#

and it works for them

#

just doesnt detect spawns

wispy bridge
cinder plume
#

ohh wait

#

oh wait

#

ok

#

i just saw u edited

#

wait

wispy bridge
#

Remember, you're setting it when it dies

#

I said I used the wrong event earlier

cinder plume
#

wait

wispy bridge
cinder plume
#

line 56 of the pastebin

wispy bridge
#

You already know the conditions of the zombie spawning

#

Its when you call the method

#

Like, you dont need to check if the mob has been spawned if you set the UUID of the mob after it has been spawned by your method

cinder plume
#

no , i need to ensure there's only 1 of them in the server/world so i use the bss thing which stands for boss spawn state , and if its 1 that means a special zombie exists , if its 0 that means it doesnt and then another special zombie can spawn

wispy bridge
#

Just remember to set it back to null when you're done with your mob, so you know the space is available

wispy bridge
#

The UUID would be filled in when it spawns, then set to null when it dies

cinder plume
#

yes

wispy bridge
#

Therefore, checking whether the UUID is or is not null will tell you whether the mob is or is not alive

cinder plume
#

but my doubt was , why is it not detecting the mob by uuid when its spawned

#

my issue arises in the entityspawnevent thing

#

its not working

wispy bridge
#

You dont need to do that

#

Theres no need for entity spawn, you have already spawned the mob, through your method

cinder plume
#

hmm true.

wispy bridge
#

No need to check whether it has spawned through the event because the only circumstances where it might spawn are circumstances which you control

cinder plume
#

true true

#

so should i make the bss thing 1 in the function ?

#

it would be better that way , right?

wispy bridge
#

You dont need your integer thing

cinder plume
#

instead of doing it in some exterior body

wispy bridge
#

Just set the UUID to null

#

boss_uuid = null whenever it dies

#

Im assuming your integer is for telling whether its alive so its not needed anymore

cinder plume
#

no its to ensure another custom mob of the same kind is not spawned when the bss integer is 1

#

okay , ill consider that.

wispy bridge
clever meteor
#

hey can some1 help me with kit improperly defined contact administrator

cinder plume
#

owh , i think i grasp it now.

#

i use that instead of the bss thing.

wispy bridge
#

Yes

cinder plume
#

more effective hmm.

#

yes true.

#

thanks a lot

#

ill try this

wispy bridge
#

You should ask this in the Paper discord, not this one

azure meteor
#

Ohk

wispy bridge
#

Doesnt matter but just to let you know

#

The spawn one is called bossDeathSetter or whatever, this ones called SpawnState

cinder plume
#

sorry mb if it caused u probs

wispy bridge
#

It didnt haha its just for neatness

cinder plume
#

yep , ty

#

gotta try the null thing rn

wispy bridge
#

👍

round elbow
#

how can I update a chest gui?
like
I have this variable named "cat" for example
i need it to be named "dog" on click
i know how to setup hashmaps and stuff btw
just asking about the way of updating the gui
without having to re-open the gui through command or whatever
how can I update it so it shows the new value of name/lore of clicked item

wispy bridge
round elbow
#

no no
I use serialized data that is linked to the gui
so when you click it writes data and saves it
now i want to know how to update it to show new VALUE not update name of the item manually

#

;-;

#

its not really dog and cat
those are examples

#

its something bigger but eh

wispy bridge
#

If you close the inventory then open it a tick later it shouldnt be noticable

round elbow
#

how to wait lmao

wispy bridge
#

BukkitRunnable

round elbow
#

this is the only thing that stopped me from using cooldowns

#

waits and timers

#

lol

#

hmmm ima google that

quaint mantle
#

hi, how would I make a chest GUI like an echest plugin open with a command I guess
like just a virtual chest that is openable with a command and keeps items in it without deleting

#

oh wait I just found a wiki post

round elbow
wispy bridge
#

PersistentDataContainer

wispy bridge
wispy bridge
cinder plume
#

Terminated by watchdog o-0

wispy bridge
#

Can I see it?

cinder plume
#

sure

#

line 240 is just this

#

allPlayerss.addAll(Bukkit.getOnlinePlayers());

#

this rarely comes

#

and then i restart server and then all works well

#

this crash

#

i restarted and tried all , it worked well

wispy bridge
#

Mhm, your crash relates to your allPlayers list, I cant really get the full picture of why it might be crashing but im pretty sure you are constantly adding players to that list like multiple times

#

Or, an infinite amount of times

hasty prawn
#

Send the entire Endless class

#

?paste

undone axleBOT
cinder plume
#

wait how did u pinpoint it to line 240

wispy bridge
cinder plume
#

ye but which part of the hastebin log had the line 240 thing

wispy bridge
#
me.trg.theraidgame.events.Endless.ZombieTeleportAbility(Endless.java:240)
cinder plume
#

doesnt it say the same for 255 256 etc too

wispy bridge
#

Yes but those are the tiers which lead to that line

wispy bridge
#

Or the specific reason of the crash

cinder plume
#

oaky

round elbow
wispy bridge
cinder plume
#

lemme think

round elbow
#

like serializer?

#

wait a second what

wispy bridge
#

Its stored in the NBT

round elbow
#

hmmm nice

#

idk how to use it

#

worth learning or serializer?

wispy bridge
#

Entity#getPersistentDataContainer

#

ItemMeta#getPersistentDataContainer

wispy bridge
round elbow
wispy bridge
#

Well, whatever you want? Haha

cinder plume
#

ok i have taken a general all players list instead of taking al players again and again from the server

#

that should fix the inf looping prb

round elbow
#

well technically i can use whatever
but what do u think works more efficiently/easier to access?

hasty prawn
#

@cinder plume Did it crash when the Zombie tried to teleport

wispy bridge
#

PersistentData

round elbow
#

i bet its datacontainer lol

#

yep guessed it

round elbow
#

serializer hard to use but extremely useful

cinder plume
#

let me recheck the log to be sure

#

nope . right after the boss spawned

hasty prawn
#

Because it looks like if there's not a valid spot for it to teleport, it's an infinite loop

cinder plume
#

i think he was trying to use the teleport

#

yeah

hasty prawn
#

Since safetpc is never 1

cinder plume
#

so the problem didnt stem from the allPlayers thing?

wispy bridge
cinder plume
wispy bridge
#

Does it ever find a good one?

cinder plume
#

oh wait

hasty prawn
cinder plume
#

wait

#

yes

wispy bridge
#

lol

#

You should get a random location then do more with that location rather than using that random location and getting another one

#

Like if its in the ground try to find a high available place rather than picking a new random place

#

Or an adjacent free space

cinder plume
#

this shud fix it

wispy bridge
#

.csharp????

cinder plume
#

no ts not idk why its in that lmao xD

wispy bridge
#

xd

cinder plume
#

ok so this shud fix the inf loop

#

and not crash it

#

alr

wispy bridge
#

I dont see anything different

cinder plume
#

no

wispy bridge
#

What changed?

cinder plume
#

the thing is , the while loop had the whole thing inside

#

like

#

the whole function

#

now its not inf loop

wispy bridge
#

It looks exactly the same

cinder plume
#

uhh wait

#

how do i show u

#

wait

wispy bridge
#

Wait

#

No you're right

#

I missed a bracket

cinder plume
#

yep

#

this shouldnt inf loop now

wispy bridge
#

Try it

#

¯_(ツ)_/¯

#

Theres no stop condition though

cinder plume
#

well the zombo doesnt use the tp ability always

#

the stop condition is safetpc = 1 right

wispy bridge
#

Like, if somebody is in a hole it will forever try to choose a new location

cinder plume
#

so when it becomes 1 , the while loop stops

wispy bridge
cinder plume
#

hmm , wont it just tp to the player?

#

like right at the player

wispy bridge
#

If you set it to do so, yes

cinder plume
#

no it wont hm.

wispy bridge
#

But as of right now, it will check forever

cinder plume
#

thats true too

#

yes

wispy bridge
#

Just have an integer tick up everytime in your while loop

cinder plume
#

if it checks 10 times then tp to the player and punish the loser for caving in

#

thats the idea right

wispy bridge
#

Yes

cinder plume
#

true that should fix this

wispy bridge
#

10 times might be too low

cinder plume
#

ye

wispy bridge
#

30-50 should be alright

cinder plume
#

whts the tick speed of a general compiling procedure in java?

#

like

#

isint it instant ?

wispy bridge
#

What do you mean?

#

How long does it take per while loop? Nanoseconds

cinder plume
#

like if im in a hole , wont it like hit 50 in like an instant

wispy bridge
#

Yes

#

Its a computer

cinder plume
#

yes , actually seems fiar

#

fair

#

ye , okay.
got it

ivory sleet
wispy bridge
#

The invention of computers is the pinnacle of mankind

ivory sleet
#

one way to look at it

ashen flicker
#

It didn’t happen over night, and it’s hugely based on mathematics. I think it was gonna happen eventually regardless. We tend to continuously find more and more efficient methods of communicating and solving problems.

eternal oxide
#

Computers are just lots of light switches crammed together.

cinder plume
#

just thinking about how one day man thought 'ima make a computer' is just crzy

wispy bridge
#

You need to add the stop condition in your while loop

cinder plume
#

its there right?

#

tpchecks ==50

wispy bridge
#

Because the program wont exit the while loop until your safetpc == 0 condition is met

wispy bridge
cinder plume
#

that is in the while looop

#

wait

#

see line 22

wispy bridge
#
while (safetpc == 0 && tpchecks != 50)
cinder plume
#

wont that stop it ?

wispy bridge
ivory sleet
#

what are you trying to do?

wispy bridge
cinder plume
#

no no no , on the contrary , shouldnt safetpc become 1 when it checks 50 times for a safe spot and doesnt find it ?

#

line 22 is in the while loop tho?

ivory sleet
wispy bridge
#

Oh shoot

cinder plume
#

ye xD

wispy bridge
wispy bridge
cinder plume
#

ok thats fine too ig

wispy bridge
#

Yes your way is fine

cinder plume
#

epic so this shud work cools

wispy bridge
#

Wait

#
        if(tpchecks == 50){
            spploc = allPlayerss.get(bossSpC(allPlayerss.size())).getLocation();
        }
        if(safetpc==1 || tpchecks == 50){ //checks 50 times and then straight up teleports to the player
            zombieboss.teleport(spploc);
            Bukkit.getServer().broadcastMessage(ChatColor.DARK_BLUE + "[Sug]: " + ChatColor.GRAY + "I'm coming to kill you! Skadoosh~!");
            }
#

Dont need the or

ivory sleet
#

What a peaceful zombie boss

cinder plume
cinder plume
wispy bridge
#

Too ez

cinder plume
#

nah frl he deals like 4 hearts to netherite armor

#

as fast as the plyer

ivory sleet
#

is this a public plugin of yours or just something else?

cinder plume
#

public plugin ?

#

nah im just developing it to pass time

#

ill upload it once im done

ivory sleet
#

alr

cinder plume
#

im learning java in school so doing this too side by side

#

uni*

ivory sleet
#

ah thats pog

cinder plume
#

yep yep

ivory sleet
#

in school we just learn silly python

cinder plume
#

i learnt python in school , doing oop in collg

#

python is extremely efficient

ivory sleet
#

yeaa, I mean oop kinda sucks but its a nice paradigm to know

cinder plume
#

easy to understand and used for a lot of things these days

cinder plume
cinder plume
#

so fascinating

#

yep

ivory sleet
#

arguably the worst thing that was created imo lol

wispy bridge
#

I think I might just have bias because I learned OOP first

ivory sleet
#

but at the same time Ig its somewhat good of a style in certain scenarios

cinder plume
#

i dont have a bias and i still love oop

#

learnt oop this year

ivory sleet
#

I just like functional more

wispy bridge
#

¯_(ツ)_/¯

cinder plume
#

same i love functional too

#

but , oop is cool

ivory sleet
#

sure state is nice but damn it messes things up also imo

cinder plume
#

its a fun and new concept

lavish hemlock
#

I like mixing the two

cinder plume
#

i dont understand why people say stop using a lot of statics

#

doesnt static actually work with the state of memory ?

lavish hemlock
#

OOP is great for making an easy-to-understand structure
Functional is great for making easy-to-understand implementations

wispy bridge
cinder plume
wispy bridge
#

Dont quote me on that

lavish hemlock
#

I don't use static a lot of time bc of extensibility

ivory sleet
#

invokestatic is somewhat faster than invokevirtual

gray prairie
#

som1 can help

#

How can i turn off /ban bukkit? (litebans)

ivory sleet
#

and true constants get inlined also which is nice

#

just deny the permission

gray prairie
#

me

#

?

ivory sleet
#

yaaa you xD

wispy bridge
#

xd

gray prairie
#

xd

#

ok

cinder plume
#

i like statics , but i never understood the reason people say stop using statics

#

a person ik said statics undermines the reason of OOP

wispy bridge
#

That is probably the most based take I have heard on the matter

#

I can kind of see that, yes

cinder plume
#

yep

#

because u can just make everything static

#

and , just call by A.number

#

no need to create an object

#

just makes life easier in a way

wispy bridge
#

I wouldnt abuse it though

cinder plume
#

yep i just wanna understnd the reason why not to abuse it

#

like is it technical or just a silent rule

#

to never use it a lot

wispy bridge
#

Its one of those things that people say but nobody knows where it started I think, its just not very good practice for the future

ivory sleet
#

problem with static is that you cant achieve any sort of inheritance, abstraction or polymorphism

wispy bridge
#

Based

cinder plume
#

but what about the technical side, does it mess with memory?

ivory sleet
#

and its a problem especially in test driven development

#

well everything messes with the memory more or less?

cinder plume
#

no as in , like how bad is using a static

#

bcuz sometimes i feel , its needed

#

bcuz some variables are most of the times needed to be static

wispy bridge
ivory sleet
#

in terms of speed its not bad

#

its faster than general oop (in java)

#

but you will suffer with tightly coupled code etc

cinder plume
#

tightly coupled ?

ivory sleet
#

your code becomes rigorously dependent on specific instances

#

which makes it hard to test

#

and since you dont have classes for things (assuming you only use static) you wont be able to mock your stuff either

cinder plume
#

i would also assume beginners like me would have found statics easier to use to transfer values between classes initially , and then found out and understood oop very well and stopped using statics , right?

ivory sleet
#

yeah

#

usually thats the case

cinder plume
#

makes sense

ivory sleet
#

first over use static then drop it

#

then overuse lombok then drop it

#

then overuse generics then drop it

#

etc

#

lol

cinder plume
#

lombok ?

ivory sleet
#

uh yeah google it

cinder plume
#

its some automatic shi

ivory sleet
#

it tries removing boilerplate code

cinder plume
#

wow

#

lmao

#

anyways ill head out for now , will test all in a while and let yall know tomorrrow its late for me here

#

thanks for all the help guys 😉

ivory sleet
#

good luck

wispy bridge
#

Lombok epic

ivory sleet
#

useless

#

imo

#

and if you really hate boilerplate code and verbosity kotlin suits you much better

wispy bridge
#

If I need to rush a commission it literally saves my life

ivory sleet
#

wet

wispy bridge
#

dry

ivory sleet
#

I mean IntelliJ has code gens for most stuff

#

and keybinds for those

wispy bridge
#

Oh really?

#

Sick

ivory sleet
#

ya

glossy venture
#

people say that singltons are not recommended

#

but what if you wanted to make some kind of service

#

and have that accessible to the outside

ivory sleet
#

if its an api yes

glossy venture
#

you will need inheritance from some base class which is not possible with static

ivory sleet
#

altho you could use ServiceLoaders technically

#

or ServicesManager from spigot

glossy venture
#

but you have to inherit from a base class

ivory sleet
#

wat

#

you can have a static singleton which provides your api

glossy venture
#

yeah

ivory sleet
#

probably an api context object

proud fiber
#
    @EventHandler()
    public void onInventoryClick(InventoryClickEvent event) {
        if(!event.getInventory().equals(inv))
            return;
        if (event.getCurrentItem() == null) return;
        if (event.getCurrentItem().getItemMeta() == null) return;
        if (event.getCurrentItem().getItemMeta().getDisplayName() == null) return;
        
        event.setCancelled(true);
        
        Player player = (Player) event.getWhoClicked();
        
        if (event.getSlot() == 0) {
            
            player.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "You are now Super Steve!");
        }
        if (event.getSlot() == 8) {
            player.closeInventory();
        }
        return;
        
    }``` does anyone know why it doesn't do anything?
ivory sleet
#

that doesnt matter ?

glossy venture
#

shouldnt matter

ivory sleet
proud fiber
#

yeah i've tried, nothing works in that whole thing

#

it doesn't give errors too

#

it was working in main.java before i added it to the gui.java

glossy venture
#

have you registered it as a listener?

proud fiber
#

this is the whole file

glossy venture
#

wdym

proud fiber
glossy venture
#

theres no class declaration?

#

does it implement org.bukkit.Listener

proud fiber
#

mhm

glossy venture
#

this is the only method?

proud fiber
#

yep

glossy venture
#

does the event run?

#

or is there something wrong with the code in the method?

proud fiber
#

as far as i know, it doesnt

glossy venture
#

put a print statement at the start of the method

#

to test

#

if it even runs

proud fiber
#

okay

#

let me see

ivory sleet
glossy venture
#

yeah

#

static is good for constants and simple utility methods in my opinion

#

but i never put data fields in there

ivory sleet
#

yeah

glossy venture
#

as i might want to inherit it later

ivory sleet
#

well I do use static for some other stuff like factory methods

glossy venture
#

yeah

#

like methods that dont depend on data outside of parameters

#

and maybe some other static constants or stuff

#

i do keep static fields for storing instances of course

ivory sleet
#

uh well it all depends on the context really lol

#

but ya

glossy venture
#

thats basically my reasoning but there are of course exceptions

#

they are easier to debug though

#

because you dont need to keep track of instances

ivory sleet
#

harder to test

proud fiber
glossy venture
#

well then it doesnt run

ivory sleet
#

its hard to automate a unit test with static

glossy venture
#

i dont know what unit tests are 😅

#

configuration section doesnt exist

ivory sleet
#

automated tests which test individual instances

glossy venture
#

ooh

#

isnt there like a java library for it

ivory sleet
#

junit yeah

white thicket
#

How can I get a spawner block entity type?

ivory sleet
#

intellij supports it excellently also

proud fiber
ivory sleet
glossy venture
#

or a part of main

#

make sure onEnable runs completely

proud fiber
# glossy venture send main
package me.aly.heroes;

import org.bukkit.Bukkit;
import org.bukkit.command.CommandExecutor;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;

import Gui.gui;
import superjump.superjump;

public class Main extends JavaPlugin implements CommandExecutor, Listener {


    
    @Override
    public void onEnable() {
        this.getCommand("superjump").setExecutor(new superjump());
        Bukkit.getServer().getPluginManager().registerEvents(this, this);
        this.getCommand("hgui").setExecutor(new gui());
    }

    @Override
    public void onDisable() {
        
    }
    

    

    
}
    


glossy venture
#

until the point where you register it

proud fiber
#

that is main

glossy venture
#

bro

proud fiber
#

oh shit

#

sorry

glossy venture
#

u forgot to change the listener this in registerEvents with the gui class

#

doesnt matter

#

ofc

#

i have that all the time

#

stupid mistakes that take me like an hour to figure out

proud fiber
#

legit took 3 hours no joke

glossy venture
#

._.

#

ive had like 2 days once

#

was horrible

#

it was my first plugin so i got tired of it and i moved on

#

i can never seem to finish projects

proud fiber
#

rip

glossy venture
#

the configuration section is null

ivory sleet
glossy venture
#

or you are querying it from the wrong config file

glossy venture
#

i always try to do everything at the start

#

because i am so excited

ivory sleet
#

for instance luckperms was once in a time where it was inferior to pex lol

#

yeah thats the issue

#

because things take much longer than what u plan on,

glossy venture
#

nice

glossy venture
#

have cthat with school too

#

lmfao

ivory sleet
#

for instance tie shoes take like 5 seconds right?

#

but how long does it take to write the instructions for the dumbest being on earth?

glossy venture
#

the name of the world is null

#

im like a master at procrastination

ivory sleet
#

means you're effectively calling Bukkit.getWorld(null)

glossy venture
#

where are you getting the world name from

#

the config?

#

i gtg

#

cya

white thicket
ivory sleet
#

have you tried googling?

#

cuz I believe there exists a quite solid thread on that topic on the forums

glossy venture
#
public abstract class Service extends Thread {
  static ArrayList<Service> services = new ArrayList<>(10);

  String name;
  public Service(String name) {
    super(name);
    this.name = name;
    services.add(this);
  }

  public void destroy() {
    this.disable();
    services.remove(this);
  }

  AtomicBoolean enabled = new AtomicBoolean();

  public boolean isEnabled() { return enabled; }

  public void enable() {
    this.enabled.set(true);
    this.start();
  }

  public void disable() {
    this.enabled.set(false);
    try { this.stop(); } catch (Exception e) { e.printStackTrace(); }
  }
  
  @Override
  public abstract void run(AtomicBoolean enabled);
}

look at this epic service class

#

aight bye

ivory sleet
#

oo

white thicket
indigo cave
eternal oxide
#

did you save your config with saveDefaultConfig() ?

undone axleBOT
eternal oxide
#

Manager.arenas is null

#

read the error

#

you defined it as a LIst but never initialized it

indigo cave
#

Caused by: java.lang.NullPointerException: Cannot invoke "java.util.ArrayList.iterator()" because "com.hitman.minigame.Manager.arenas" is null

indigo cave
#

code?

#

._.

#

private static ArrayList<Arena> arenas = new ArrayList<>();

#

and fixed

#

and why static

#

why is everything static

#

create singletion

#

then only create 1 instance in the command class

proud fiber
#
    @EventHandler
    public void onInventoryClick(InventoryClickEvent event) {
        if(!event.getInventory().equals(inv))
            return;
        if (event.getCurrentItem() == null) return;
        if (event.getCurrentItem().getItemMeta() == null) return;
        if (event.getCurrentItem().getItemMeta().getDisplayName() == null) return;
        
        event.setCancelled(true);
        
        Player player = (Player) event.getWhoClicked();
        
        if (event.getSlot() == 0) {
            
            player.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "You are now Super Steve!");
        }
        if (event.getSlot() == 8) {
            player.closeInventory();
        }
        return;
        
    }``` this doesn't work, nothing is being done. and yes it's registered this time
#

i've tried to test by printing on start and it worked

quaint mantle
#
if(!event.getInventory().equals(inv))
            return;
if (event.getCurrentItem() == null) return;
if (event.getCurrentItem().getItemMeta() == null) return;
if (event.getCurrentItem().getItemMeta().getDisplayName() == null) return;
#

one of these is getting triggered

proud fiber
#

yeah

#

but

#

i didnt press a null item

#

i pressed the one in slot 0

eternal oxide
#

sysout after each test to see where its failing

quaint mantle
#

^

proud fiber
#

plus it let's me take stuff from the gui

quaint mantle
#

put the setcancelled before the return

#

also i dont think you need a return statement either

eternal oxide
#

what stack trace are you getting?

#

?paste

undone axleBOT
eternal oxide
#

its really annoying to view it in here like that

#

read the error

#

getArena(int) is returning null

#

Manager

#

it says it in the error, in the caused by line

#

read the because part

indigo cave
#

by: java.lang.NullPointerException: Cannot invoke "com.hitman.minigame.Arena.getState()" because the return value of "com.hitman.minigame.Manager.getArena(int)" is null

#

thats the most important part

glossy venture
#

@quaint mantle you need to learn how to read exception messages

#

If you understand the syntax its quite easy

#

Since java 16 it gives even more information

#

You can see exactly what caused a nullpointerexception adn what was null

#

Also a CommandException is thrown when an error occurs while running a command

#

Youre going to have to look at Caused by: to see the actual exception

eternal oxide
#

both because getArena(id) is returning null. Likely the List is empty. You have no arenas

glossy venture
#

For example:

An exception occured: org.bukki.command.CommandException:
  at org.bukkit.... // this is the stack trace
Caused by: java.lang.NullPointerException: // this is what we are after
  Could not do something because Test.hello is null // detailed error message, very useful
   at com.example.Test.main (Test.java:66) // tells you exactly where and at what line the error occured (file name:line number)
#

Late answer but im on phone

#

I had to manually type that

#

Np

eternal oxide
#

sysout your arenas as it checks them