#help-archived

1 messages · Page 73 of 1

fair abyss
#

dont know bounding box api maybe you can do first one
but cant second one

red zenith
#

whichever block you're targeting, make it the center of a 3x3x3 bounding box?

#

or whatever arbitrary size box you want

keen compass
#

@fair abyss create first bounding box, then extend that bounding box out one, and check if there is anymore blocks connecting to that vein. If there is, extend the box in that relative direction

#

no loop involved with that 😉

red zenith
#

that's true, it does have the expand methods

fair abyss
#

can you write a simple code?

#

cus i dont understand with just saying "check if there is anymore blocks connecting to that vein"

keen compass
#

@fair abyss this is one of those perfect times to use recursion

fair abyss
#

recursion?

keen compass
#

recursion is where you call your method from inside your method

fair abyss
#

it makes it looping

#

-_-

keen compass
#

yes, but not quite the same though

fair abyss
#

actually same.

keen compass
#

its not

#

recursion is faster then a standard loop

frigid heath
#

wait hold on

#

so you're saying that recursively looping 3x3x3 boxes is not as fast as making a giant box, searching outside it, then recursively looping through it anyway?

fair abyss
#

recursion is faster then a standard loop
depends on the method's part which will be "re" done (dont sure how to tell) when recursion

keen compass
#

but recursion is a form of loop, but it isn't the same as a loop. A loop keeps repeating until it is done. recursion keeps calling your method until something stops it. However both of these things happen in two different areas of the JVM. Recursion to the JVM is like calling your method multiple times without having to code a loop for it to do that.

red zenith
#

Are veins contained entirely inside of a chunk?

upper hearth
fair abyss
#

"recursion keeps calling your method until something stops it."
you can stop your loop whenever you want.

upper hearth
#

Red being the one I mined, blue being the bounding box.

keen compass
#

if you use recursion to extend your box outwards if it detects more blocks that were connected it will know about them

frigid heath
#

frost

#

thats literally my implementation

fair abyss
#

i just wanted a method that wont loop

upper hearth
#

You'd have to extend every direction then lol

fair abyss
#

and you tell a method that loops

keen compass
#

just be careful with recursion though

#

as it happens on the stack

red zenith
#

well, you can add a constraint?

keen compass
#

well yes, you need a way to stop it

#

otherwise it will just be a race condition if you don't have a way to stop it lol

red zenith
#

well, that is why they call it re-cursing

keen compass
#

but unlike say a while loop, it will eat up all your resources and you will get stack exceptions XD

fair abyss
#

it will be same creating box and checking vein's relatives and expanding
or without box checking vein's relatives

red zenith
#

you blow your stack, and out come the expletives

keen compass
#

lmao

#

I am keeping that quote

#

XD

fair abyss
#

too many english word, much than my "capacity"

#

and google translate wont help me further 😛

keen compass
#

anyways, I have told you the most optimal method if you are making something to run on a large server or keeping in mind performance

#

recursion is faster then standard loops and if done right more efficient, and contains checks are always faster then loops

upper hearth
#

Floodfill is recursion though

fair abyss
#

dont say "always"

frigid heath
#

arent all our suggestions recursive

keen compass
#

No

#

a recursive method happens on the stack, a loop doesn't.

upper hearth
#

Still wondering why floodfill isn't better, considering it doesn't loop and is strictly recursive 🤔

keen compass
#

Only if you implement floodfill to be recursive

fair abyss
#

floodfill?

upper hearth
#

Is there another way to implement floodfill?

keen compass
#

Recursion is a special thing in Java that isn't done automatically

#

here is a simple example of recursion

#
int fact(int n)
{
    if (n < = 1) // base case
        return 1;
    else    
        return n*fact(n-1);    
}
fair abyss
#

you can think like it repeats itself until a conduition is true

keen compass
#

So that example is finding factorials of a number, however it will overflow if the base case isn't reached or not defined

upper hearth
#

Recursion just means the method calls itself, yes?

fair abyss
#

yep

upper hearth
#

Then obv if you don't escape it you'll be in trouble

fair abyss
#

but it can be "infinity" and it will cause error
if you code it wrong*

upper hearth
#

Well, as for Qther's problem, I would do a recursive flood-fill instead of messing with expanding BoundingBoxes ¯_(ツ)_/¯

fair abyss
#

theres a class called "BlockIterator" whats about checking it?

keen compass
#

BlockIterator, iterates over blocks in a defined area or line

fair abyss
#

can be async?

keen compass
#

not that I am aware of

fair abyss
#

just searched class but couldn't see

#

@upper hearth can you try running this class async?

keen compass
#

personally if it was me, I would just map out veins in region files though

frigid heath
#

isnt that the same as listOfBlocks.forEach(block -> something())

upper hearth
#

What class, BlockIterator?

fair abyss
#

yep

keen compass
#

world.getBlockAt is not thread safe last I recalled

fair abyss
#

location.getBlock is calling this method

#

-_-

frigid heath
#

im just gonna start implementing my method and if its broken ill use someone else's

keen compass
#

anyways, me, I would just implement an outside application to map veins though

fair abyss
#

just wondered, is dynmap running async?

keen compass
#

But that is if I was going to have something on my servers though and not something that was a public plugin

#

because I mean, why not just read the region files yourself since you already have access to your own files 😛

fair abyss
#

if its, checking its code can help

#

and who was the question owner :? 😆

frigid heath
#

me lol

keen compass
#

^

frigid heath
#

didnt expect it to evolve into this

fair abyss
#

sorry dessie, I tagged you 😛

keen compass
#

Nice thing about coming here, is sometimes you come out with more information then you were expecting

frigid heath
#

dont think i need to check anything yet i got a will and a plan

keen compass
#

and other times, certain things get pointed out that you didn't bother thinking about as well

#

or didn't realize was a thing as well

fair abyss
#

that's true

upper hearth
#

Idc that you tagged me lol

fair abyss
#

🙂

keen compass
#

so while although we may not agree on the best method here, you have plenty of information to go off of

fair abyss
#

no guarantee 😛 we can explode your server

keen compass
#

lmao

frigid heath
#

im gonna need to ask about tree feller soon lol

#

im already scared

upper hearth
#

@fair abyss Hm, yeah you can run it async looks like

fair abyss
#

so whats about getting blocks over it?

#

and deleting them sync (if possible async)

upper hearth
#

You want me to try to delete the blocks?

fair abyss
#

no

#

you helped well tx

upper hearth
#

I'm curious now tho lol

#

Yeah okay can't actually do anything to the blocks async, but you can iterate them async

keen compass
#

you can't delete boxes async. If you try you will get concurrentmodification exception

fair abyss
#

due to async, other player can be interact with already in queue vein
it can be some problem

keen compass
#

or CME for short

fair abyss
#

boxes? blocks?

keen compass
#

blocks

#

lol

fair abyss
#

too many word here 😄

upper hearth
#

I got IllegalStateException

keen compass
#

I guess that is the other exception to occur

fair abyss
#

so said "if possible"

#

then delete them sync

#

or

#

the best

#

taskchain

#

aikar has api for this

upper hearth
#

BlockIterator kinda cool tbh

keen compass
#

combine blockIterator with chunksnapshot

fair abyss
#

yep

#

and some taskchains

#

and some thread safe things

#

you have just crafted power puff girls!

keen compass
#

but I would only design a public plugin that way though

fair abyss
#

it allows to chain async tasks with sync and then ahain async etc.

keen compass
#

if I were to implement this on my server, I would go the route of doing all this ahead of time. That is read the region files, store the veins into a binary file. Then when I need it, use memory mapped file to load all that information 😉

fair abyss
#

using Bukkit.TaskChainFactory (or similar thing not sure)

#

"a map"

#

can be big

upper hearth
#

But what if the world changes :(

keen compass
#

memory mapped files don't have to be loaded into memory all at once either

fair abyss
#

oh another problem

#

other worlds 😄

keen compass
#

how is the world going to change ahead of time?

upper hearth
#

magic

fair abyss
#

just explode 10 tnt

#

then you will se 50*10 block change

upper hearth
#

Idk that seems like more work than it needs to be

keen compass
#

my method works with pre-generating a map

#

so I mean, you would get all your ore veins then

fair abyss
#

what when

#

some bitch

#

places ore

#

akdlşkcxvşlas

upper hearth
#

I mean that might be the way to go if you know you're always gonna have 1 world lol

keen compass
#

region files is just raw NBT, nothing overly complex about it

fair abyss
#

i wanted to say

#

your data wont have in game changes right?

keen compass
#

the point is to have the veins mapped out ahead of time, so that when players interact with said veins

#

you already know its a vein

#

and then you can save the data or remove it afterwards as it isn't needed

fair abyss
#

but what i place my own vein with my hand

#

as a player

upper hearth
#

It wouldn't work

fair abyss
#

talking about this

keen compass
#

then it doesn't count as one obviously so it takes care of player made ones if you didn't want it to work on player made ones

fair abyss
#

it can be best for "trees"

#

cus you cant just place it

#

and a exploit: a tree can grow

upper hearth
#

Well for trees you wouldn't want to do that

fair abyss
#

not for all trees 😄

keen compass
#

could just make custom trees that are predictable instead of unpredictable trees

fair abyss
#

if you have well custom trees

#

you can do this

#

thinking same thing xD

keen compass
#

but I think there is some api for trees though

fair abyss
#

not sure

#

and it cant be better than

#

your solution

upper hearth
#

Meh, but with our methods before you could easily transfer that code to trees

fair abyss
#

thats the painful part

upper hearth
#

Floodfill and the bounding box are decently dynamic

fair abyss
#

its 6.04 am

#

i should sleep hours ago

#

if you could find a "good solution" tag me, i will read it when i wake

keen compass
#

there is api for trees

#

but it isn't really all that great for say when trees have logs everywhere

#

like them super large trees for example

upper hearth
#

Yeah

keen compass
#

the api would work for simple trees though

fair abyss
#

im talking about "well custom trees"

keen compass
#

well I know, was kind of hoping there was some api though that would help in getting all the logs of a tree

#

since the server should know what a tree is and there is, but its really limited on it

#

there is that, and if you use the second method for generating the tree you can get all the blocks that are part of said tree

#

so that is handy for custom trees or even regular trees if you wanted to generate them

frigid ember
#

Hey guys, how do I get a mapview from an itemstack?

    ItemStack i = p.getItemInHand();
    
    MapView map = ((MapView) i);
    
    map.setScale(Scale.CLOSEST);

This is what I have tried but it's not working

gloomy violet
#

Am I allowed to make an auto update-downloader? I understand how to do this. At some point Bukkit had some specifications when it came to automatically downloading content. I'm just wondering if this could breach any Spigot TOS in any way.

chrome heron
#

how to disable spawner spawning

keen compass
#

that should help you understand maps a bit more

frigid ember
#

@keen compass I've got this, but when I click it doesn't change the zoom

    @EventHandler
    public void onInteract(PlayerInteractEvent e) {
    Player p = e.getPlayer();
    
    ItemStack i = p.getItemInHand();
    
    MapView map = Bukkit.getMap(i.getDurability());
    
    if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
        map.setScale(Scale.CLOSEST);
    }
    else {
        map.setScale(Scale.FARTHEST);
    }
    }

https://www.youtube.com/watch?v=WcKQgZVDbfI&feature=youtu.be

keen compass
#
ItemStack item = new ItemStack(Material.FILLED_MAP);
MapMeta meta = (MapMeta) item.getItemMeta();
meta.setMapId(mapId);
item.setItemMeta(meta);

@frigid ember

#

once you have a proper map, you should be able to set the scale

frigid ember
#

@keen compass theres no .setMapId, I'm on 1.8

keen compass
#

ah I can't help you then

#

I don't know the api for 1.8

muted valve
#

Hello, this probably isn't fully related, but is there a way to completely update a line(Frame) on FeatherBoard.

wanton vine
#

hey I was wondering if anybody knew how to fix this issue

#

I have a shop set up in ShopGUIplus

#

but all of the spawners in the shop turned to stone after I updated my server

#

so did the spawners in crazy crates

#

PLEASE HELP

frigid heath
#

@wanton vine like updated minecraft versions?

#

in that case its probably a id mismatch

#

or something wrong with nbt

wanton vine
#

nbt?

frigid heath
#

yes

wanton vine
#

whats that

frigid heath
#

named binary tags

wanton vine
#

so I mean what can i do

frigid heath
#

nothing i guess

#

just make new spawners

idle zodiac
#

How can I use FAWE in my plugin?

#

nvm

#

worked it out lol

#

nvm

#

I can't use this for some reason
EditSession editSession = ClipboardFormats.findByFile(file).load(file).paste(worldName, new Vector(0, 64, 0), allowUndo=false, true, (Transform) null);
It says that it can't find load in ClipboardFormats

frigid heath
idle zodiac
#

nvm did it

wraith thicket
#

The static abuse...

#

But if I were to guess, you're most likely creating an infinite loop of destroying blocks.

muted valve
#

I'm new at plugin dev but aren't you missing a break; statement for this case? case WOODEN_PICKAXE:

tiny dagger
#

switches are interesting tho

#

it goes to next case

#

it's considered as one case

#

for example

#

switch (mat) {
case oak_sign:
case birch_sign:
case everyothersign:
return true;
default:
return false;
}

#

for every signs return true

#

otherwise false

keen compass
#

@tiny dagger in Java 14 switch case is a lot better 😄

tiny dagger
#

i noticed

#

but the functionality is still similar

keen compass
#

yes, just pointing out that the updated java versions are better 😛

#

maybe slowly we can instill everyone to progress forward XD

tiny dagger
#

that wouldn't be a problem tho

keen compass
#

GC is a lot better in Java 14 as well, in case that matters to anyone

tiny dagger
#

right now i have both java 8 and jdk 14 installed

#

😂

#

i'm afraid to uninstall java 8

#

maybe it messes something

keen compass
#

I have java 8 installed, but I don't use it. I usually only keep older versions for purposes of debugging in the event it might be a java dependent thing or something

#

not very common but it happens sometimes

#

the only version I don't have and just completely skipped was java 9

#

gave me way too many problems and it appears many other projects did the same thing as well lol

idle zodiac
#

Ok, so my island creation is throwing a NPE i think

#

aaaaa

keen compass
#

you think?

idle zodiac
#

idk yet

#

i forget XD

#

i'm just reloading

keen compass
#

Well, it is pretty obvious if it is

idle zodiac
#

sorry i'm dumb

tiny dagger
#

but i don't understand why from java 7 to 8 we moved fast

#

but from 8 we just stoped to it

#

🤔

keen compass
#

because Java 7 was being dropped from support

#

Java 8 is an LTS release and its support ends at the end of this year

idle zodiac
#

yes

keen compass
#

the next LTS is Java 11

idle zodiac
#

It's throwing an NPE

keen compass
#

Java 16 is the next LTS after that if I recall correctly

idle zodiac
#

would you ;lioke to see my very crappy code?

keen compass
#

everyone has crappy code at one point or another

idle zodiac
#

i've just started

keen compass
#

so don't feel bad, but if you want help with the NPE, some code does help 😉

idle zodiac
#

i have a good knowledge of java

keen compass
#

?paste

worldly heathBOT
idle zodiac
#

but not very good knowledge of stuff

#

9ok

#

thanks

#

That's my code for is gn

#

gen

#

i'm using a command

#

and its just throwing null pointers everywhere XD

keen compass
#

can you also create a new paste for the stack trace you received ?

idle zodiac
#

ok

green hornet
#

anyone know what might cause smoeone to instantly eject after being added as a passenger

idle zodiac
#

um

#

that is not sql

#

XD

keen compass
#

if they press left shift, you get removed from a vehicle @green hornet

green hornet
#

im doing spawnEntity and addPassenger but hten onDismountEvent is firing

keen compass
#

are you also spawning the vehicle at the same time?

green hornet
#

yeah

#

vehicle will stay there

keen compass
#

wait a tick between spawning your entities and adding the entity to the vehicle to allow the server to register the entity

green hornet
#

okey

#

its weird it was working fine

keen compass
#

it is the only thing I can think of =/

lavish heron
#

is there a free plugin where i can right click an item in my inventory and it can give me money from my economy plugin?

idle zodiac
#

use skript

#

ez

#

fun

#

reliableish

#

you dont need to create a plugin for that

lavish heron
#

ok

idle zodiac
#

Did anyone find out why my command is throwing an NPE lol

keen compass
#

@idle zodiac so the first NPE is your world is null

idle zodiac
#

Ah

#

explains it XD

#

how do i fix lol

#

i'm so stupid

#

and cold

keen compass
#

reason being is the world doesn't get created because you don't have a method to create it

idle zodiac
#

oooo

#

ok

#

sooo

#

now what

#

brb

keen compass
#

getServer().createWorld(WorldCreator wc);

idle zodiac
#

so

#

how would i implement that into my mess

#

thanks btw

keen compass
#

would recommend a new class file that sets all the appropriate stuff for WorldCreator

idle zodiac
#

OK

#

I've never done any of this beffore ol

#

cries over skript

#

brb

keen compass
#

I don't know what skript is

green hornet
#

that indeed fixed it!

#

thanks 🙂

keen compass
#

you are welcome 😉

idle zodiac
#

my brain

#

what the fuck do you mean

#

how doesnt it work

tiny dagger
#

i think he says the plugin got removed

#

like from inactivity

idle zodiac
#

from where?

#

is he using like aternos

#

XDDD

tiny dagger
#

premium plugins have an expiration date you know?

idle zodiac
#

WTF

#

WHAT

#

HOW

#

that is a scam

tiny dagger
#

if you don't update in 6 months

#

as the dev of the plugin

idle zodiac
#

TF

tiny dagger
#

it gets removed

idle zodiac
#

but if you have it on pc it shou;ld still work

tiny dagger
#

yes

#

it works

#

you just won't get updates

idle zodiac
#

my braincells are deceased by the amazing engrish

#

if you dont get updates, so what

#

tf

#

that 's a bit dodgy

tiny dagger
#

@idle zodiac your english is so good that you still struggle understanding bad grammar but okay 😉

idle zodiac
#

no

#

ym eniglsueh nrie ag rea good

#

fuck

#

ye

#

ik

#

i mean

#

my enslguih is top tier

#

XDDDDD

#

i can't wait for someone to be wooshed now but

#

ye

vernal spruce
idle zodiac
#

XD

#

So

#

I'm trying to create a world

#

I was using multiverse before but am experimenting with WorldGenerator

#

How do I use it effectively?

idle zodiac
#

So

#

I've done that

#

and It's working

split oxide
#

hej, question, so i made an update for my plugin but how do i change my project version?

#

(in intelji idea)

carmine minnow
#

I use a queue plugin, and I was wondering if there is a way to have a string of multiple words count as one argument?

ripe ledge
#

guys I need help

#

I am making a listener event on some class, but I know I need to put this.getServer().getPluginManager().registerEvents(this, this); on Main class on onEnable, but how I connect this to the other class that the listener is there?

#

please help me

#

pleaseeee

carmine minnow
#

you use this.getServer().getPluginManager().registerEvents(new ListenerClass(), this); in the Main class

ripe ledge
#

Ok, thanks!

sturdy oar
#

'this' is not required tbh

ripe ledge
#

But someone can explain me what this line of that command doing?

sturdy oar
#

it's registering a class that must implement a listener

#

if you don't register it , the event handlers won't work

neat oxide
#

Why are we doing it like that? or am i free to put it back to a normal state

chrome heron
#

how to disable villager trading 1.15

#

spigot

#

anyone know?

fleet crane
sturdy oar
#

I mean having villagers without trades is kinda useless

#

unless you have zombie farms

bronze marten
#

maybe its not for survival purposes

arctic cloud
#

Might be some rpg thing where they just walk about as civilians

cursive mulch
#

Is it possible to cancel the 'respawn point set' message when clicking a bed, only using the spigot API?

pastel basin
#

I'm pretty sure there's a way with nms

cursive mulch
#

I know nms

#

I don't*

ripe ledge
#

How I can spawn mob with .getWorld().spawnEntity() but with passenger?

#

help please

pastel basin
#

Entity#addPassenger(anotherEntity)

ripe ledge
#

what?

#

how?

pastel basin
#

spawn the entity then add the passenger to it

ripe ledge
#

how

pastel basin
#

Entity#addPassenger(anotherEntity)

sweet hemlock
#

spawn entities a and b
Then a.addPassenger(b)

ripe ledge
#

oh ok I will try

#

but the entity is not a

#

is just in a command

#

look:

#
@EventHandler
    public void onLand(ProjectileHitEvent event) {
        if (event.getEntityType() == EntityType.TRIDENT) {
            if (event.getEntity().getShooter() instanceof Player) {
                Player player = (Player) event.getEntity().getShooter();
                if (STlist.contains(player.getName())) {
                    //spawn zombies
                    Location loc = event.getEntity().getLocation();
                    loc.setY(loc.getY() + 1);
                    for (int i = 0; i < 3; i++) {
                        loc.getWorld().spawnEntity(loc, EntityType.DROWNED);
                        
                    }
                }
            }
        }
    }
sweet hemlock
#

use backticks for code like
```java
code
```

ripe ledge
#

oh k wait

#

here

pastel basin
#
Entity drowned = world.spawnEntity(loc, Entity Type.DROWNED);
ripe ledge
#

what

#

can you replace put that in this?

@EventHandler
    public void onLand(ProjectileHitEvent event) {
        if (event.getEntityType() == EntityType.TRIDENT) {
            if (event.getEntity().getShooter() instanceof Player) {
                Player player = (Player) event.getEntity().getShooter();
                if (STlist.contains(player.getName())) {
                    //spawn zombies
                    Location loc = event.getEntity().getLocation();
                    loc.setY(loc.getY() + 1);
                    for (int i = 0; i < 3; i++) {
                        loc.getWorld().spawnEntity(loc, EntityType.DROWNED);
                        
                    }
                }
            }
        }
    }
sweet hemlock
#

Spawn 3 zombies separately, each on separate variable with Entity type

ripe ledge
#

Sorry for the confusion, I am new on this

#

can you write this?

sweet hemlock
#
World w = loc.getWorld();
Entity zombie1 = w.spawnEntity(...);
...
Entity zombie3 = ...
zombie1.addPassenger(zombie2);
...
stiff monolith
#

Can my friends recommend an enhanced plug-in for spigot1.11.2 version?

ripe ledge
#
World w = loc.getWorld();
Entity zombie1 = w.spawnEntity(...);
...
Entity zombie3 = ...
zombie1.addPassenger(zombie2);
...

@sweet hemlock Ok, thanks!

hollow thorn
#

how would i make a flying minecraft

stiff monolith
#

gamemode 1

sweet hemlock
#

Turn gravity off for minecart and increment it's y position?

hollow thorn
#

no as in a flying veihcle

#

minecart

#

similar to the ones shown

stiff monolith
#

/fly

hollow thorn
#

in all of the car plugins

#

using bukkit

sweet hemlock
#

Minecart can't float with effects

#

Turn gravity off and vector it up

#

I haven't tried it, but I'd test that out

stiff monolith
#

You mean the effect that will be attacked by the latent image shellfish?

sweet hemlock
#

That's status effects, yeah, and minecarts don't have it iirc

subtle blade
#

They cannot. Only living entities

ripe ledge
#
World w = loc.getWorld();
Entity zombie1 = w.spawnEntity(...);
...
Entity zombie3 = ...
zombie1.addPassenger(zombie2);
...

@sweet hemlock And how I can make the zombies not fire on day and give them a item?

sweet hemlock
#

Search it up, maybe do something in their inventory

pastel basin
ripe ledge
#

Ok, thanks!

frigid ember
#

Hello, my friend bought plugin and now is removed and not work. Please help

ripe ledge
#

I want to give a drowen a trident

#

Someone knows how??

sweet hemlock
#

Use LivingEntity instead of Entity type

#

Or use Drowned type

#
Drowned zombie1 = (Drowned) w.spawnEntity(...);
lament wolf
#

Do you know what is npc.getBukkitEntity().getPlayer() for ? Why we can"t just cast EntityPlayer into Player ?

subtle blade
#

Because EntityPlayer does not implement Player

#

Player is an interface in Bukkit, CraftPlayer is its implementation. Patched into NMS is a field in the Entity class to hold an instance of CraftEntity

formal nimbus
#

Hey, does anyone know how I could display an item in chat?

#

You know how you sometimes see on servers you can type a command and the item name will be sent in a chat message in square brackets

#

and if you hover over it you can see the details of the item

stiff monolith
#

miaochat

#

By default, the generated configuration files are all in Chinese. You only need to modify the configuration files.

formal nimbus
#

right... I'll have a look I guess. thx 🙂

stiff monolith
#

😋

frigid ember
#

Hello, my friend bought plugin and now is removed and not work. Please help

stiff monolith
#

Why was it removed? be more specific.

ripe ledge
#

Use LivingEntity instead of Entity type
@sweet hemlock Where

formal nimbus
#

How do I get the item name of a default item?

#

I tried ItemStack.getItemMeta().getDisplayName()

#

but I don't think it has a name since it's default?

pastel basin
#

You mean the localized name?

formal nimbus
#

I gues yeah

#

*guess

#

didn't know what it was called

pastel basin
#

ItemMeta#getLocalizedName()

formal nimbus
#

ah, thx

ripe ledge
#

Someone please help meee
I am trying to summon drowen that cant burn in day and I can't find answer anywhere how to do that
Someone knows?

#

And how to give the drowen a trident

pastel basin
#

add helmets to them

#

search it up on google you already asked this question 10 times, don't expect anyone to be giving you code just like that

formal nimbus
#

Epicnitcity is still doesn't seem to work?

swift compass
#

Hi, I Have a question. How to add permission on tab completion, I mean block default spigot command tab completion for player.

pastel basin
#

@formal nimbus I think you can't get the localized name from a created item, from what i read you can only get from items in the player inventory

formal nimbus
#

oof

#

well that sucks

idle zodiac
#

I am trying to load a schematic, but when I recreate the schematic it isn't changing when i recreate the world

formal nimbus
#

how tf am I meant to get the name then

idle zodiac
#

It's just saying "Index out of bounds"

pastel basin
#

you can check if the item has a localized name #hasLocalizedName or #hasDisplayName and if not just format and return the material name

idle zodiac
#

and loading an oold version oof the schem

formal nimbus
#

I guess yeah

#

also

#

for some reason my bukkit scheduler is ending at random points

#

the scheduler should stop once the timer reaches 3

#

I originally set it to 0

#

but the timer keeps going down to -4

#

and now it keeps going to 1/2

pastel basin
#

you cant mix async with bukkit api

formal nimbus
#

wut

pastel basin
#

use

new BukkitRunnable() {
//runnable
}.runTaskTimer(plugin, 20l, 1l);
formal nimbus
#

;-;

#

fine

pastel basin
#

if you want to stick with BukkitScheduler you can always use #runTaskTimerSynchronously or whatever is called, I don't use BukkitScheduler

formal nimbus
#

kk

#

how do I cancel it?

#

the bukkitrunnable

pastel basin
#

BukkitRunnable#cancel();

formal nimbus
#

thx

#

apparently I can't make a static referance?

pastel basin
#

show me

formal nimbus
#

the method it's in is not static

#

nor is the class

pastel basin
#

since you are inside BukkitRunnable class you can just use cancel()

formal nimbus
#

o swick

#

is there a way I can slow down the delay from inside the runnable?

#

so if the delay is a timer

#

*delay is a variable

#

and I change the variable inside the runnable

#

will that update it?

pastel basin
#

you can always cancel it and run it again

#

cancel();
runTaskTimer(...);

formal nimbus
#

🤔

wise dock
#

or you can run your code say every other time. add a counter inside your runnable, and an if

formal nimbus
#

what are the 2 itemIndexs for?

#

are they an id?

pastel basin
#

or you can run your code say every other time. add a counter inside your runnable, and an if
why check stuff and do math when you can do what I just said

#

what are the 2 itemIndexs for?
@formal nimbus runTaskTimer(plugin, delay, period);

formal nimbus
#

ooh

#

ok

#

thanks 😄

#

wait

pastel basin
#

np

formal nimbus
#

however

pastel basin
#

what

formal nimbus
#

if I start it again

#

my timer varaible will be reset right?

wind dock
formal nimbus
#

if so I can go back to using an atomic

#

so it doesn't get rest every time

wind dock
#

the plugin is called chatmaster

wise dock
#

why check stuff and do math when you can do what I just said
because depending on your use case canceling and starting runnables can be more expensive than incrementing an integer

wind dock
#

is it safe to use?

#

I dont wnat a plugin haveing all the deatils of my pc

pastel basin
#

my timer varaible will be reset right?
no because you already instantiated the class with that integer, when you do runTaskTimer it doenst instantiate it again

#

it just runs the method run()

formal nimbus
#

ah

#

ok

#

that's really helpful

#

thanks 😄

pastel basin
#

because depending on your use case canceling and starting runnables can be more expensive than incrementing an integer
@formal nimbus you should probably use this then

#

instead of cancelling and running again just check the integer with a fixed time

formal nimbus
#

wdym

bitter vine
#

I sent you an email 2 days ago, can someone reply?
for delete my account
at deletion@spigotmc.org
but noone replied!!
@fleet crane
I know that you think about account deletions.. please help me

pastel basin
#

@formal nimbus will the runnable run less than 20 ticks?

formal nimbus
#

no, the runnable delay is going to increase

pastel basin
#

how much?

formal nimbus
#

delay between each repeat I mean

pastel basin
#

by 1?

formal nimbus
#

I'm making a crate scrolling system

#

so imagine it's scrolling fast

#

then when the timer gets low

#

it slows down by 15 / timer

#

or something like that

#

so every repeat

#

it gets slower

pastel basin
#

how did you do it with the old code

#

just cancel and run again?

wind dock
#

I dont want a plugin having all teh details of my pc

#

but its for a mutechat plugin :/

formal nimbus
#

how did you do it with the old code
@pastel basin I didn't lol

#

it seemed too dificult

#

but this seems easier

pastel basin
#

this is easier however it may be a little performance expensive

formal nimbus
#

;-;

#

I mean, it's not essential that it slows down

wise dock
#

@wind dock it's the standard metrics system. you can also opt out of it, read the last line in the screenshot

wind dock
#

do any other plugins need it

formal nimbus
#

so as long as the timer is accurate (which it is now) then it's gucci

wind dock
#

besides mutechat?

wise dock
#

many plugins use the same metrics site

wind dock
#

oh

wise dock
#

the plugin doesn't need it to do it's thing

wind dock
#

but is it safe to just not opt out?

pastel basin
#

I think you would need two integers, one for the time passed and one for the delay you want to set it

wise dock
#

it should be perfectly safe to opt out

wind dock
#

is it safe to also not opt out?

wise dock
#

that's up to you. it's a bit of a privacy thing, but the stats are aggregated for the most part

pastel basin
#

this is complicated idk how to this now

formal nimbus
#

lol

#

as I said, it doesn't really matter

#

it's just a small cosmetic thing which would have been nice

#

but I appreciate the help 🙂

wise dock
#

let me scribble down quickly something that might help Jet

formal nimbus
#

😮

wise dock
#
int counter = 0;
int delay = 0;
new BukkitRunnable() {
   counter++;
   if (counter > delay) {
     // your code
     delay++;
     counter = 0;
   }
}.runTaskTimer(plugin, 20l, 1l);```
#

uff

#

how do you format this thing for java?

pastel basin
#
` ` `java
` ` `
idle zodiac
#

I am trying to load a schematic, but when I recreate the schematic it isn't changing when i recreate the world
https://hastebin.com/uqaviqexid.java
It's just saying "Index out of bounds" and loading an oold version oof the schem

remote socket
#

How can I loop through this list backwards?

        List<String> lines = plugin.getConfig().getStringList("lines");
        int counter = 1;
        for (String line : lines) {
            objective.getScore(line).setScore(counter);
            counter++;
        }
lament wolf
#

```Java

// CODE

wise dock
#

@formal nimbus so that's sort of a linear increase. first time it runs at 1 tick, next iteration after 2 ticks, 3rd after 3 more ticks and so forth

#

you can play with the increments and formula for different increases

formal nimbus
#
int counter = 0;
int delay = 0;
new BukkitRunnable() {
   counter++;
   if (counter > delay) {
     // your code
     delay++;
     counter = 0;
   }
}.runTaskTimer(plugin, 20l, 1l);```

@wise dock interesting, but I would then have to restart the bukkit runable with the new delay right

marsh nova
#

@remote socket Use the traditional for loop starting at 0 and increasing until the length, but reverse it by starting at the length and decreasing until 0

wise dock
#

no, that's the beauty of it

#

your code only runs inside the if when the time has passed, nothing extra for you to do

formal nimbus
#

but how does that increase the delay between each loop of the runnable?

remote socket
#

@remote socket Use the traditional for loop starting at 0 and increasing until the length, but reverse it by starting at the length and decreasing until 0
@marsh nova Then how do I get the list item

idle zodiac
#

I think I've worked mine out lol

wise dock
#

it doesn't increase the delay of the loop, but your relevant code only runs every xxx loops

marsh nova
#

lines.get(index)

formal nimbus
#

ooh

#

no Isee

#

I get it now

#

ok yeah that looks good 😄

remote socket
#

wait nvm i have another solution

formal nimbus
#

I'll try that now

remote socket
#
List<String> lines = plugin.getConfig().getStringList("lines");
        int counter = lines.size();
        for (String line : lines) {
            objective.getScore(line).setScore(counter);
            counter--;
        }
wise dock
#

don't forget to add your cancel() at some point to finish the runnable 🙂

marsh nova
#
List<String> list = new ArrayList<>();
for (int n = list.size() - 1; n >= 0; n--) {
  String element = list.get(n);
}
remote socket
#

My solution also works

formal nimbus
#

don't forget to add your cancel() at some point to finish the runnable 🙂
@wise dock yep 😄

wise dock
#

@formal nimbus one other thing i wanted to mention, when you do Bukkit.getScheduler().cancelTasks(...) it cancels all runnables for your plugin. If 10 people are doing crates it'll cancel for all of them. Probably not what you want, so it's almost never a good idea to do CancelTasks unless say you do cleanup for your plugin

formal nimbus
#

lol yeah

#

ok thanks for the heads up

pastel basin
#

that why if you dont want to cancel the task inside the runnable you can just store it in a field and cancel somewhere else

#

it will cancel only the delay that was running

formal nimbus
#

I've got it working 😄

#

I used the example heatseeker gave me, but I set the delay to -50

#

that way it's 2.5s before the delay actually kicks in

#

at which point it slows down nicely

#

now I can add some randomness to the delay

formal nimbus
#

anyway I can turn this into a string?

#

I tried adding .toString afterwards

#

but it didn't wokr

#

getType() returns all caps

#

so I was trying to convert to string to do .toLower()

sturdy oar
#

you want the type name?

#

like "COBBLESTONE"

wanton delta
#

Is this an enum you made or

formal nimbus
#

enum?

wanton delta
#

....yea

idle zodiac
#

How can I run a command on an entity?

formal nimbus
#

I don't know what an enium is ;-;

#

*enum

sturdy oar
#

wutt

#

how can you not

wanton delta
#

Is this the Material enum?

formal nimbus
#

;-;

wise dock
#

@formal nimbus try java player.getInventory().getItem(13).getType().name()

formal nimbus
#

o

sturdy oar
#

yeah .name() is a method from Enum

#

every enum class gets it

formal nimbus
#

I see

wanton delta
#

You should look at what enums are

#

Very essential tool in java

formal nimbus
#

👌

sturdy oar
#

Has someone used SQLite here?

idle zodiac
#

OMG

#

How can I run a command on an entity?

sturdy oar
#

dispatchCommand

idle zodiac
#

thanks

sturdy oar
#

you know the javadocs exists tho

formal nimbus
#

@formal nimbus try java player.getInventory().getItem(13).getType().name()
@wise dock works thx

wise dock
#

you're welcome

idle zodiac
#

I've spawned in an entity, but then I can't run the command on it as when I set the entity as a variable it doesn't like it

vernal spruce
#

Run a command with entity? What?

idle zodiac
#

so

#

I'm Loading a schematic

#

and I want there to be a chest with items

#

but I cant have a chest with items in a schem

#

So I'm trying to either set a block with nbt

#

or spawn an entity then execute a setblock command

#

The Problem is though

#

that it's in a different world

#

sooooo.....

#

what tf do i do XD

#

unless...

#

I use skript for that bit

#

and use a custom skript cmd

#

probably is the easiest way out lol

old barn
#
@EventHandler
    public void MesadeEncantar(PlayerInteractEvent e) {
        Player p = (Player)e.getPlayer();
        Block b = e.getClickedBlock();
        if(b.getType() == Material.ENCHANTMENT_TABLE) { /*line 16, error*/
            return;
        }
        if(e.getAction() == Action.LEFT_CLICK_BLOCK) {
            return;
        }
            if(!(p.getItemInHand().getType().toString().toLowerCase().contains("pickaxe") 
                    || p.getItemInHand().getType().toString().toLowerCase().contains("sword")
                    || p.getItemInHand().getType().toString().toLowerCase().contains("axe")
                    || p.getItemInHand().getType().toString().toLowerCase().contains("boots")
                    || p.getItemInHand().getType().toString().toLowerCase().contains("helmet")
                    || p.getItemInHand().getType().toString().toLowerCase().contains("leggings")
                    || p.getItemInHand().getType().toString().toLowerCase().contains("chestplate")
                    || p.getItemInHand().getType().toString().toLowerCase().contains("spade")
                    || p.getItemInHand().getType().toString().toLowerCase().contains("bow")
                    || p.getItemInHand().getType().toString().toLowerCase().contains("hoe"))){
                e.setCancelled(true);
                p.sendMessage("§cError");
                return;
            }else {
                e.setCancelled(true);
                p.chat("/enchantmenu");
                return;
            }
        }

Why is it wrong? Say it's on line 16, where I scored, but I don't see an error.

frigid heath
#

just use enums

wise dock
#

@idle zodiac java Chest chest = (Chest) block.getState(); Inventory inventory = chest.getInventory(); inventory.clear();
And then you add items to it as you do with any other inventory

#

You just need to be sure that chunk is loaded, obviously

hoary parcel
#

Almost everything you do will cause a sync chunk load anyways

#

Which is awful but unavoidable on spigot

split oxide
#

Question, how do i change my project.version in intelji idea for spigot?

split oxide
#

its probably a stupid question but how?

wise dock
#

Personally I'm using Eclipse, but have you tried Google?

split oxide
#

i have tried, but it only shows results on updating the ide

wise dock
#

Google this "how do i change my project.version in intelji idea for spigot" without quotes and look at first 1 -2 results 🙂

split oxide
#

holy sh*t, thank you

#

i only needed to change a number in pom.xml

sturdy oar
#

@old barn that looks really bad

trim fjord
#

Is anyone proficient with Asynchronous Database Structure with the usage of the API? If so can somebody help me out to get a better understanding? I ended up developing my database way back not thread-safe and I am experiencing server lag with high player counts. This wasn't an issue with low amounts of players such as 20, but after the server increased with players I have noticed lag with the LoginEvent etc.

If so please @ me, thanks.

sturdy oar
idle zodiac
#

I'm getting a null-pointer exception when trying to change the block at a Location. It's saying that the chunk is loaded, and I tried my best to load the world. What's going on?
https://hastebin.com/kigixawahe.java

dire horizon
#

I have a question with the vehicles plus lite plugin. How do I become an admin in aTernos?

idle zodiac
#

he uses aternos

#

sentence him to death

dire horizon
#

jajs

#

you tell me

chrome edge
#

@idle zodiac what the hell is that code? -_-

#

World world = Bukkit.createWorld(worldCreator); will work for you

#

You just call all of the world interface

#

@trim fjord You should have used async for every database structure. Especially for login event. Spigot has async events(thanks to md_5) and you should use it.

#

As FendiTony777 mention it above, you may use CompleteableFuture task.

royal verge
#

@elfin wave

trim fjord
#

@chrome edge Not what I meant, but thanks.

#

It's hard to explain to be honest sorry my man 😂

chrome edge
royal verge
#

can i get help here about spigot software

chrome edge
#

Please explain with more details so we could help you easily.

trim fjord
#

I'll DM you

royal verge
#

k

marsh nova
#

don't ask to ask, just ask

#

also @trim fjord you can use a thread pool and connection pool, both fixed and of equal size, to maximise db performance

#

combined with completablefuture and if you need it use Guava or Caffeine caches

royal verge
#

ok what does this part of config.yml mean (bungee)
`listeners:

  • query_port: 25577
    motd: '&1Another Bungee server'
    tab_list: GLOBAL_PING
    query_enabled: false
    proxy_protocol: false
    forced_hosts:
    pvp.md-5.net: pvp
    ping_passthrough: false
    priorities:
    • lobby
      bind_local_address: true
      host: 0.0.0.0:2560
      max_players: 1
      tab_size: 60
      force_default_server: true`
trim fjord
#

@marsh nova I use HikariCP

royal verge
#

i guess this is the wrong server

chrome edge
#

@royal verge part? You mean everything xD

#

Look at the bungee wiki

royal verge
#

@chrome edge what evrything

marsh nova
#

@trim fjord you can also make the server's scheduler into an Executor for use with CompletableFuture

royal verge
#

k

marsh nova
#
Executor asyncExecutor = (cmd) -> Bukkit.getScheduler().runTaskAsynchronously(plugin, cmd);
#

although the default thread pool is not the best tbh

#

the scheduler thread pool, that is

chrome edge
#

._.

royal verge
#

what's the difference between host and listeners
bungee

oak stump
wise dock
#

simple: java if (!(sender instanceof Player)) { sender.sendMessage(Utils.chat("&cYou can't give yourself an item! You're the console")); return true; }

oak stump
#

oh lol

#

thx

wise dock
#

yw 🙂

marsh nova
#

hence ClassCastException

#

do an instanceof before you make any casts

oak stump
#

huh

#

anyways i have another issue 😦

#

i have a listener which gives the player an effect when they equip these bits of armour

#

doesnt wanna work

#

listener:

#

whoops

subtle blade
#

listeners never registered

#

You just created instances of them

oak stump
#

oof

#

didnt even realise

wise dock
#

also i strongly suggest you make some sort of method for verifying item meta and applying the effect instead of copying basically the same code 4 times. better readability and easier maintenance down the road

oak stump
wise dock
#

repost the listener, seems you changed something in it

oak stump
#

kk

wise dock
#

yea, check for null if they have no armor equipped in that slot

subtle blade
#

Equipment methods are all nullable

#

It's worth noting that methods in the API are all annotated with whether or not they're nullable

oak stump
#

u lot are 10x more helpful then the guys on {TheSourceCode} discord server

#

can u give me an example

#

cuz i gotta do this like 100x

wise dock
#
if ((helmet != null) && (helmet.getType() == Material.LEATHER_HELMET))```
marsh nova
#

nullpointerexception is the easiest to fix

#

the hardest NPE I've had is when a sun.misc.Unsafe object was null because reflection failed on jdk11

subtle blade
#

Well that's just your own fault lol

sharp dew
#

?cla

worldly heathBOT
naive goblet
#

Imagine catching NPE

marsh nova
#

someone actually recommended that

#

on the discord for a plugin I contribute to

#

"why not just catch all errors when the shop is loaded, and then no more NPE!"

#

catch Throwable and swallow the exception. The best approach

wise dock
#

While what you quoted is terrible advice, catching NPEs actually depends on context, in some it makes perfect sense.

marsh nova
#

such as?

wise dock
#

Such as in production when you must 100% ensure something keeps working, and you have a way to recover the state after catching whatever exceptions it is you never thought should happen but did.

marsh nova
#

in that case, you might want to catch RuntimeException or Exception

#

but never specifically NullPointerException

wise dock
#

That is correct

#

I could perhaps point there could be edge cases where the recovery depends on the exception types, but we're nitpicking already 🙂

marsh nova
#

CraftBukkit does that for event listeners, commands, plugin enabling, etc.

#

catch Throwable, print the exception, let users know there's a plugin error

torn robin
#

?help

naive goblet
#

?ask

worldly heathBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply.

oak stump
#

lol still doesnt wanna give the effect on armour equip

#

what code should i send u

#

cuz there r no errors

#

it just doesnt give the effect

#

@wise dock or @subtle blade ???

wise dock
#

@oak stump does the player get the message just not the effect, or neither?

oak stump
#

niether

#

oof

#

speeling

wise dock
#

aha. then it's a different issue. you sure your meta text matches exactly?

oak stump
#

lol no

#

xD

wise dock
#

well then make sure 🙂

#

you could print it in the server logs and take a peek after you equip the items

oak stump
#

lol iz all good

#

thx alot

#

i should know this

#

4 years

wise dock
#

you got this

torn robin
oak stump
#

ive done java nd 3 bukkit and yet i am loosing my mind

#

fair to say im only 13 lol

wise dock
#

well, that is great!

boreal tiger
#

mhm thats not quite what I was looking for but thanks. I'll keep looking @torn robin

wise dock
#

what i do when such state happens is i take a break, and try to get my mind off it for a few mins to cool down

oak stump
#

lol

#

still not working

#

gimma a sec

boreal tiger
#

I agree, taking breaks helps when you're stressed over a certain problem

#

mhm right

#

what defines a village though?

#

is it certain blocks?

oak stump
torn robin
#

i'd look into structure blocks and world generation

#

what exactly are you trying to achieve?

wise dock
#

i think "village" as a concept is based on world seed, so by reverse engineering the formula used in world gen you can determine where one would be placed

oak stump
torn robin
#

@torn robin .

boreal tiger
#

yeah but I meant, in the new versions a player can technically create a new village by bringing some villagers

torn robin
#

again though what are you trying to achieve?

oak stump
#

@wise dock could u find the issue, there r no errors and it just doesnt work

wise dock
#

that's a different type of village, based off certain criteria such as valid housing and so forth

#

@oak stump i could, but honestly i don't have the time right now to look at a whole plugin. Plus it's valuable lessons to learn to debug issues youself. I can offer pointers in how to debug it though

oak stump
#

yesh plz

boreal tiger
#

right, thanks for the help. 👍 @wise dock

wise dock
#

okay so print messages in the server logs. the more the merrier. print whatever crosses your mind, before if and inside the if.

#

then equip the item and see which ones actually get logged, so you know what code ran

oak stump
#

okay

#

probably needs return statements ngl

wise dock
#

print the meta text too, so you know how it looks, etc.

oak stump
#

kk thx

wise dock
#

not in this case, because you said player doesn't see the message either

#

so i'd look into why the code inside the if block (sending the message and applying the effect) doesn't run

oak stump
#

yep

#

thikn i fixed it

#

retyped whole block

#

nope

#

lol

wise dock
#

print things in the log

oak stump
#

yesh

#

omg the console messages r not even appearing

#

wtf

wise dock
#

aha, now think where you'd print the next message, like right at the beginning of the event handler

#

if that doesn't appear either you know what to do 🙂

oak stump
#

yep

wise dock
#

nvm...

oak stump
#

wut

#

lol r u gona stpo helping?

#

cuz i think ive screwed this up alot

wise dock
#

well, no at first i looked at your main and saw nothing getting registered, then realized you did it in the listener. i usually prefer to do it in main, because this way you can see at a glance which ones are event handlers rather than having to go thru the entire source code

oak stump
#

ohhh

#

i shall do that

wise dock
#

yes, that is good form

#

however i do have a question: in your inventory click, you go thru all online players and then do your thing

#

why?

#

like, think about it for a moment because the error is a bit subtle i think here

oak stump
#

oh lol

#

didnt even notice

wise dock
#

so you're triggering whatever action when player is clicking in an inventory, right?

#

and you're looking to see if they have armor equipped. are you sure that happens in the same tick?

oak stump
#

lol not at all

wise dock
#

correct

oak stump
#

so what would i do about that

wise dock
#

so whatever action resulting from the inventory click will be visible next tick

oak stump
#

y r u so smart xD OR ITS IM REALLY DUMB

#

whoops caps

wise dock
#

not at all, it's a bit subtle this time, not something really obvious

oak stump
#

so what would i do about the tick thing

wise dock
#

like when you're trying to close an inventory from a click in an item in that inventory in the same tick. doesn't work.

oak stump
#

lol i have never encountered waiting any amount of ticks

#

how would i do it

#

?ticks

#

lol

#

how to wait?

#

cmon mr bot

wind dock
#

anyone know how to make it so that placeholderapiu doesnt detect me as online even though im vanished? I use supervanish

naive goblet
#

Supervansh has a placeholder for it?

wise dock
#

one way, not saying it's best but works in this case is something like this: ```java
@EventHandler
public void onInvClick(InventoryClickEvent e) {
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
// your code here
}
}, 0L);
}

naive goblet
#

bruh

#

lambdas

wind dock
#

@naive goblet really?

#

which 1

naive goblet
#

No idea

wind dock
#

oh

#

do tehy?

#

or is that a guess

naive goblet
#

Idk have you checked the placeholder list on github?

wind dock
#

yes

oak stump
#

one way, not saying it's best but works in this case is something like this: ```java
@EventHandler
public void onInvClick(InventoryClickEvent e) {
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
// your code here
}
}, 0L);
}

@wise dock thank youuuu

wind dock
#

Im dumb

#

Isee now

naive goblet
#
//EventHandler
Bukkit#getScheduler().runTaskLater(plugin, ()-> {
  //code w/o override run method
}, 0L);
#

@oak stump I'd say use lambdas since Runnable accepts that

oak stump
#

whut

wise dock
#

@naive goblet how is your code better from a learning point of view than explicitly listing all the code?

naive goblet
#

I think learning is a dynamic process. Learning how to spare lines and what some stuff is in code might be helpful later?

oak stump
#

what does 0L mean

naive goblet
#

Represent ticks

wise dock
#

0L in this particular case means next server tick

oak stump
#

oh so it would apply after they equip the armour

wise dock
#

it would run that code after the event that triggered it finishes to completion

naive goblet
#

^

wise dock
#

think about it this way; what happens if the event is cancelled?

#

like say another plugin cancels the inventory click event?

#

so the way it works internally is all plugins that listen to InventoryClickEvent have a chance to process the event, then next server tick the armor (in this case) is actually equipped and visible if none of the plugins canceled it

naive goblet
#

Is the Inventory a custom menu?

#

or the normal PlayerInv?

oak stump
#

why is there 1 bracket 0l);

wise dock
#

so the method runTaskLater expects a long number as the last parameter. in this case we wait 0 ticks, and have to put a L to convert it to long instead of int

oak stump
#
    public void onInvClick(InventoryClickEvent e) {
        Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
        
            Player p = (Player) e.getWhoClicked();
            final ItemStack helmet = p.getInventory().getHelmet();
            final ItemStack chestplate = p.getInventory().getChestplate();
            final ItemStack leggings = p.getInventory().getLeggings();
            final ItemStack boots = p.getInventory().getBoots();
            
            @Override
            public void run() {
                if ((helmet != null) && (helmet.getType() == Material.LEATHER_HELMET)) {
                    if (helmet.getItemMeta().getDisplayName() != null) {
                        if (p.getInventory().getHelmet().getItemMeta().getDisplayName().equalsIgnoreCase("§0Assassin Hood")) {
                            p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 1, true, false));
                        
                }, 0L);
                }```
#

this doesnt work?

wise dock
#

no it doesn't

oak stump
#

im so confused lol

wise dock
#

you have to look at the inventory next tick

naive goblet
#

Because it's kind of how it's built. You could as well do this:

Bukkit.getPluginManager().registerEvents(new Listener() {

}, Plugin.getPlugin(Plugin.class));
wise dock
#

put everything except the first line with Player p inside the runnable

oak stump
#

yep

naive goblet
#

@oak stump Another thing to think of is explicit else or implicit else.

#

It avoids nesting if statements which can be very hard to read.

wise dock
#

and the first line with Player p before Bukkit.getScheduler(). You will also have to write it like so java final Player p = (Player) e.getWhoClicked();

#

so the logic reads like so: you get the player that clicked, wait 1 tick, then start looking in the inventory for armor

naive goblet
#
//nested
void method() {
  if (condition) {
    if (condition2) {
      //code
    }
  }
}

//implicit else
void methodd() {
  if (!condition) {
    return;
  }
  if (!condition2) {
    return;
  }
  //code
}```
oak stump
#

lol im so confused

#
    public void onInvClick(InventoryClickEvent e) {
        
            final Player p = (Player) e.getWhoClicked();
            final ItemStack helmet = p.getInventory().getHelmet();
            final ItemStack chestplate = p.getInventory().getChestplate();
            final ItemStack leggings = p.getInventory().getLeggings();
            final ItemStack boots = p.getInventory().getBoots();

            if ((helmet != null) && (helmet.getType() == Material.LEATHER_HELMET)) {
                if (helmet.getItemMeta().getDisplayName() != null) {
                    if (p.getInventory().getHelmet().getItemMeta().getDisplayName().equalsIgnoreCase("§0Assassin Hood")) {
                        p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 1, true, false));```
Can u do this one for me so i understand
wise dock
#

okay but before i do it, did you understand the logic part?

naive goblet
#

That would be to spoonfeed you, no

wise dock
#

like how things work?

oak stump
#

okay but before i do it, did you understand the logic part?
the logic yes

#

how to do it

#

no

wise dock
#

okay, there's a bunch of new concepts for you so it's perfectly normal it's a learning curve here

oak stump
#

ye lol, usually im pretty good at this stuff, even helping others but ive hit a road curve xD

naive goblet
#

Okay so think like this

Bukkit.getPluginManager().runTaskLater(plugin, ()-> {
  //code that should be executed after the event
}, 0L);```
#

Idk in your case as heatseeker said it might be worth checking if the event was cancelled or not?

oak stump
#

lol where did heatseeker go xD

naive goblet
#

Idk

oak stump
#

Idk in your case as heatseeker said it might be worth checking if the event was cancelled or not?
yesh but why would it be cancelled if that is the only plugin

naive goblet
#

I mean what are you really trying to do?

#

If your plugin is the only then dont

wise dock
#

Okay @oak stump I'm going to give you a bit of code, but I want you to promise me something

#

I want you to read it carefully and either ask or Google anything you don't know

naive goblet
#

also it might be worth mentioning when working with java use the java keyword in the block
```java

wise dock
#

Don't just take it verbatim and move on, because it contains a lot of new concepts that you need to learn

#
    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onInvClick(InventoryClickEvent e) {
        Player p = (Player) e.getWhoClicked();
        checkInventoryNextTick(p);
    }
    
    private void checkInventoryNextTick(final Player p) {
        Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
            @Override
            public void run() {
                final ItemStack helmet = p.getInventory().getHelmet();            
                // more stuff here
            }
        }, 0L);
    }```
#

Start from the first line, go thru them carefully until you learned and fully understood all concepts

#

Once you do, I'd like you to tell me what the first line does exactly

remote socket
#

There is only line 3 on the board

#

Is there perhaps something should be in the loop

naive goblet
#
    //Event will always try to run and ignore if cancelled
    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onInvClick(InventoryClickEvent e) {
        //Create a p variable from the event we can reference later 
        Player p = (Player) e.getWhoClicked();
        //Use method from our own class
        //this defines it as it will be from this class
        this.checkInventoryNextTick(p);
    }
    //Custom function
    private void checkInventoryNextTick(final Player p) {
        //Creates a new BukkitTask
        Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
            @Override
            public void run() {
                //Code to be executed in the task
                //When called it will be called after the event is handled
                final ItemStack helmet = p.getInventory().getHelmet();            
                // more code with the if's
            }
          //0L to make it execute 0 ticks later
        }, 0L);
    }
#

@oak stump idk if this helps you but mhm

#

@remote socket whats wrong?

#

Or I mean explain more

torn robin
#

does 0L actually work? I've always done 1

remote socket
#

The last line in the config is the only line which shows on the board

naive goblet
#

@torn robin Well, how it's handled should still make it execute afterwards?

subtle blade
#

Because it's kind of how it's built. You could as well do this:

Bukkit.getPluginManager().registerEvents(new Listener() {

}, Plugin.getPlugin(Plugin.class));

@naive goblet
Please don't do this

#

lol

torn robin
#

ooh that's a GOOD IDEA

naive goblet
#

🤡 .

subtle blade
#

Anonymous inner Listener is monkaS

#

Talk about stacktrace hell

torn robin
#

and make it register another listener when an event fires

#

loop da loop

subtle blade
#

If you really want to, use .registerEvent() 😄

remote socket
#

Do I need to make a new Team for each line on the board?

naive goblet
#

RoyalScribblz how wait that's a scoreboard?

#

Yeah might be the case

sudden parrot
#

why cant i buy a plugin

#

it doesn't work

#

i click on the buy now

naive goblet
#

Check so you have money on your acc

old elk
#

Is there a way to sync permissionsex through all of my linked servers on bungee cord? So I would add a player to a rank on 1 server and it would apply to all servers?

sudden parrot
#

why i cant just buy with paypal

naive goblet
#

Lmao pex