#help-development

1 messages ยท Page 379 of 1

wary topaz
#

i got muted

#

well timed out

tall dragon
#

a bukkit discord exists?

wary topaz
#

ye

tall dragon
#

people still use bukkit to develop plugins?

sterile token
#

Lol , just heard that discord exists

wary topaz
#

.

sterile token
#

oh weird

mortal hare
#

yay once again

#

my trie matching works

wary topaz
#

wt

mortal hare
#

easy autocomplete

tall dragon
#

dont think u can link discords mate haha

wary topaz
#

haha

sterile token
wary topaz
#

discord

#

invite

mortal hare
#

DFS with compressed Tries works so good on autocompletion

wary topaz
#

ohh they blocked the term get bukkit

sterile token
#

Atleast i used to sent many times the papi discord

sterile token
wary topaz
#

haha

sterile token
#

nop, they blocked uris

wary topaz
#

dang i wanna get-bukkit

#

haha

sterile token
#

also they removed the help commands from bot

wary topaz
#

?edge

#

!edge

sterile token
#

?bing

undone axleBOT
wary topaz
#

?google

undone axleBOT
wary topaz
#

?firefox

tall dragon
#

bing copege

wary topaz
#

lmfaoo

#

?yahoop

sterile token
wary topaz
#

?yahoo

undone axleBOT
wary topaz
#

LOL

tall dragon
#

firefox is not a search engine lmfao

#

its a browser

wary topaz
#

so is opera

#

lul

sterile token
#

?opera

marsh burrow
#

๐Ÿ˜ญ anyone know where I can atleast go to fix my issue, havent been able to compile in weeks now

mortal hare
#

do you guys name packages in plural or singular form?

undone axleBOT
#

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. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

mortal hare
#

like utils or util

wary topaz
#

utils

sterile token
wary topaz
#

for me

tall dragon
#

whatever is appropiate tbh

#

in that specific case id do utils

mortal hare
#

java uses util afaik

marsh burrow
tall dragon
#

they do

wary topaz
#

technically whatever you want but than you get yelled at by 4 big guys

sterile token
sterile token
wary topaz
#

tee-hee

#

haha

frank kettle
#

is there a way to make an hashmap return the values by their "added" order?

wary topaz
#

public hashmap ()

#

returns

#

oh

#

you mean added

sterile token
wary topaz
#

you gotta make a array whenever you add it

frank kettle
tall dragon
frank kettle
#

just asking in case there was some function that does make it happen

#

if not, all good

wary topaz
#

public arraylist(hashmap e)

#

return the one you changed

frank kettle
#

i will just make an arraylist of the order of keys i want and then display them

sterile token
#

oh right, not being rude i suggest reading about different java collecitons if you want to learn more about them

tall dragon
mortal hare
#

Why tf String is not iterable

#

my life is a lie

sterile token
#

There are many types, for example HashMap, HashSet, ArrayList, Queue, etc

mortal hare
#

even in CPP we have std::string iterators

wary topaz
#

LMFAOOOO my first message

mortal hare
#

why java does not have those wtf

frank kettle
ivory sleet
sterile token
marsh burrow
#

I've been compiling with that profile for years, havent had any issues till now

frank kettle
sterile token
#

I didnt mean whole java

frank kettle
#

never before needed to have a linked hashmap compared to an hashmap

tall dragon
#

knowing many collection types is a pretty big part of java tho

#

choosing the right collection is a big part for performance for example

wary topaz
#

is there a player right click event?

mortal hare
#

ObjectHeapPriorityQueue

#

what is this in fastutils

frank kettle
mortal hare
#

what does heap mean

#

is it linked list impl?

crimson terrace
wary topaz
#

ty

#

(event.getHand())?

#

is that the equiptment slot?>

crimson terrace
#

The event fires once for both hands afaik so just make sure its the hand you want ๐Ÿ˜›

undone axleBOT
#

The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.

For example, only executing code if the main hand was used:

@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
        return; // do not progress past this point  |
    }
    // provide functionality
}
wary topaz
#

whoa

#

okay

#

thank you

#

if (event.getHand() == EquipmentSlot.HAND) { // * if the hand used is the main hand:

#

oh wait that code did what I wanted ill just copy that lol

frank kettle
#

it tells there what it returns

charred blaze
#

does minecraft server uses only one thread?

#

does minecraft server uses only one core?

wary topaz
#

'return' is unnecessary as the last statement in a 'void' method

#

is that a glich?

#

or just should I put else{

rustic birch
#

uh oh , i think i made the hashmap but i get lots of errors

tall dragon
frank kettle
#

return at the end with nothing below is useless

tall dragon
#

ye

wary topaz
#

so ill remove the return

tall dragon
#

it also said //provide functionality

#

which would remove that warning

wary topaz
#

i can just make it a empty if statement

#

or just not call if!

tall dragon
#

no u cant

#

cuz it will still continue the method lol

wary topaz
#
        }
    }
#

is*

#

i didnt remove the comment

tall dragon
#

idk whats hard to understand its very simple

wary topaz
#

i nest after ๐Ÿ˜Š

#

lul

#

time to make the gui ๐Ÿ˜ข

#

dw ill do it on my own

tall dragon
#

well see ya in 5 minutes then

wary topaz
#

more like 60

#

its a gui of every player in a arraylist

#

with page switching

rustic birch
#

guys wish me luck

wary topaz
#

i wish u luck

rustic birch
#

thanks

#

cuz i also have hw but i really wanna finish this so

tall dragon
#

what were u working on again

#

cooldowns right?

rustic birch
#

i tihnk this will work

#

it did not

tall dragon
#

well can i see what ur doing? ๐Ÿ˜„

rustic birch
#

ye

#

if ide can open

tall dragon
#

o right ur the guy that has to close his ide while testing right?

#

yikesss haha

rustic birch
#

yeah

crimson terrace
#

coding on your phone might be easier ๐Ÿ˜‚

rustic birch
#

lol nope

tall dragon
#

run the server from ur phone

crimson terrace
#

or that

tall dragon
#

?paste

undone axleBOT
rustic birch
#

breh let me put it in a file

#

oh

tall dragon
#

well uhh

#

hmmm

rustic birch
#

bruh

mortal hare
#

i would love to buy raspberry pi

rustic birch
#

i hate sitting on a desk for 6 hours

#

to just misstype a word

mortal hare
#

but I am too much fearful to look at my bank account lmao

tall dragon
tall dragon
#

idk tbh

rustic birch
rustic birch
quaint mantle
rustic birch
#

what does ultimate does on intellij

mortal hare
#

im a student

#

i pay bills

rustic birch
mortal hare
#

still

#

its inefficient

#

and would consume more energy than raspberry pi

wary topaz
#

quick question thats not for the gui, plugin.getConfig().getStringList("Bans").add(event.getEntity().getUniqueId() + "");
doesnt add it to the config

tall dragon
#

tbh ur better off just buying a 2 dollar server from pebblehost or something

wary topaz
#

oh wait I prob have to savei t

rustic birch
tall dragon
#

cant u just use an ftpclient?

#

drag and drop

rustic birch
#

reruning the server takes more time than on pc

tall dragon
#

true

#

but i would personally prefer it over closing my ide each time lol

rustic birch
#

lol

#

if it was vscode i would have no time loss

#

but intelli j uses so much ram

quaint mantle
#

why dont you vscode. its working fine if you are not working with gradle

rustic birch
#

i coudlnt set it up

quaint mantle
#

why

wary topaz
rustic birch
#

lol my client + 1gb ram server uses my 95% ram

rustic birch
tall dragon
rustic birch
#

but now i need to learn from my code, i mostly copied the hasmap stuff

tall dragon
#

now that u understand it i could show u a little util i made ages ago

#

maybe it will be usefull to u

rustic birch
#

yeah it can be i will read it

tall dragon
rustic birch
#

after i finish my hoem work

#

oh

#

you use uuid for it

quaint mantle
wary topaz
#

basically when I add the players uuid to a strnig list in the config it doesnt work. anyone know why?

tall dragon
#

bro where

#

its one big mess of stuff

wary topaz
#

55 155 170

rustic birch
#

i know python enough to make something like that

wary topaz
#

it worked with a arraylist idk why it aint workign with a stringlist

quaint mantle
#

chatgpt is cool

#

for simple things

tall dragon
#

ur getting the string list @wary topaz

wary topaz
#

?

tall dragon
#

when modifying that list it does not modify the file

#

u gotta get the list

#

modify the list

wary topaz
#

ohhh

tall dragon
#

set the list

wary topaz
#

very smart

#

how do I load the config?

tall dragon
#

arent u using default config?

wary topaz
#

is it .load("config.yml)"

#

yes

#

default

rustic birch
#

Thanks alot for help everyone im going off for today

tall dragon
#

ur alrdy doing getConfig lol

wary topaz
#

so why aint it working

tall dragon
#

pretty sure u have to do something like saveDefaultConfig in onenable or somethn

wary topaz
#
    public void onEnable() {
        // Plugin startup logic
        saveDefaultConfig();
        new everything(this);
    }```
tall dragon
#

never rlly worked with this config system from bukkit

wary topaz
#

already done

tall dragon
#

well then it should be loaded fine

wary topaz
#

is it because im doing saveconfig and not savedegfaultconfig in the everything class?

tall dragon
#

no

#

saveConfig is right

quaint mantle
#

i mean i dont think adding to getStringList () response will work

tall dragon
wary topaz
#

i added a "" so it thinks its a string

quaint mantle
#

isn't it just a new object, why would it update config

tall dragon
#

show ur new code

wary topaz
tall dragon
#

bruh its the same

wary topaz
#

what did you want me to do?

tall dragon
#

List someList = getList
//modifyList
config.setStringlist(bla, list);
saveconfig

quaint mantle
#

setStringlist is not a thing

wary topaz
#

its set

#

no wait

#

its getstringlist.set

tall dragon
quaint mantle
#

nah

wary topaz
#

its not

#

just checked

onyx fjord
#

is weak hashmap good for caching things?

wary topaz
#

yes

quaint mantle
# wary topaz its set
FileConfiguration cfg = plugin.getConfig();
ArrayList<String> abc = cfg.getStringList("thing");
abc.add("test");
cfg.set("thing", abc);
saveConfig();

try this

onyx fjord
#

aight epic

#

what if the define limit is met, does the last entry get removed or what

storm barn
#

Hello everyone,

wary topaz
#
        List<String> abc = cfg.getStringList("Bans");
        abc.remove(p2.getUniqueId() + "");
        plugin.saveConfig();
        plugin.getConfig().getStringList("Bans").remove(p2.getUniqueId() + "");
        plugin.saveConfig();
        queueforfix.add(p2.getUniqueId());```
#

hi

#

i changed it to a list

#

cause a stringlist aint a array

quaint mantle
#

list is immutable afaik

wary topaz
#

unless you transfer

#

?
\

tall dragon
#

why u saving twice now

quaint mantle
#

immutable means you cant change it

wary topaz
#

oh i was gonna delete that one

#

Incompatible types. Found: 'java.util.List<java.lang.String>', required: 'java.util.ArrayList<java.lang.String>'

storm barn
#

I had a question about some plugins I have. Any plugin that has a gui does not work all of a sudden. For example, when using my /shop plugin I am able to keep the items that pop up instead of going to the pages. This is happening with all my guis. Is there an easy fix for this?

wary topaz
#

what version spigot u use

storm barn
#

1.19.2

wary topaz
#

check your clickevent for yoru inventory

storm barn
#

okay i will

cunning canopy
#

What is the point of squaring the distance before comparing it. Is it to ensure no negative numbers if you get what I mean?

wary topaz
#

Yes

#

idk lol

tall dragon
#

then don't answer lmfao

vivid skiff
tall dragon
#

u should use #removeIf instead of foreach

#

unless thats a hashmap isnt it

cunning canopy
#

found this snippet from the CraftBukkit implementation. ```java
Entity nearestHitEntity = null;
RayTraceResult nearestHitResult = null;
double nearestDistanceSq = Double.MAX_VALUE;

    for (Entity entity : entities) {
        BoundingBox boundingBox = entity.getBoundingBox().expand(raySize);
        RayTraceResult hitResult = boundingBox.rayTrace(startPos, direction, maxDistance);

        if (hitResult != null) {
            double distanceSq = startPos.distanceSquared(hitResult.getHitPosition());

            if (distanceSq < nearestDistanceSq) {
                nearestHitEntity = entity;
                nearestHitResult = hitResult;
                nearestDistanceSq = distanceSq;
            }
        }
    }
vivid skiff
mortal hare
#

its easier to calculate squared value

#

than taking a square roots

#

square roots are a bit expensive

vivid skiff
tall dragon
cunning canopy
# mortal hare no

but why would you need to compare the distance squared instead of just comparing it as is?

mortal hare
#

its a nifty hack that you can use whenever you dont need the actual distance

vivid skiff
mortal hare
#

its faster to check squared value than square root one

cunning canopy
#

because of negatives?

tall dragon
cunning canopy
mortal hare
#

distance is
sqrt((x2-x1)^2+(y2-y1)^2) right

#

the thing is you dont need to take a square root

#

to detect how distant he is

#

he can take the square root on his calculator

#

and make a value defined to the square

vivid skiff
mortal hare
#

distanceSquared = 9
if (distanceSquared == 9)

is faster than
if (sqrt(distanceSquared) == 3)

#

its a hack

cunning canopy
mortal hare
#

yes

cunning canopy
#

aah

#

thank you

mortal hare
#

but you see

#

if you need real distance this wouldnt work

#

because your returned value is squared

#

its just a way to bypass square root calculations

cunning canopy
#

yes but for comparing its perfect?

mortal hare
#

yes

tall dragon
# vivid skiff How should i fix it?
        Map<Block, Long> map = getmap;

        Iterator<Block> iterator = map.keySet().iterator();
        while (iterator.hasNext()) {
            // ur conditions
            iterator.remove(); // remove the entry
        }

using a iterator should fix it

fluid river
terse pumice
#

anyone know how I can change the angle on a spawn entity with protocollib? I can't seem to work it out, it mentions a float but I am unsure whether that is what I actually want?

sterile token
#

Please i need your help im fucking stucked, trying to make a cusotm menu editable i cant code the proper logic for it

fluid river
#

register your listener?

fluid river
tall dragon
fluid river
#

yez

#

@EventHandler

tall dragon
#

eh well it happens

fluid river
#

Server#getPluginManager().registerEvents(JavaPlugin, Listener);

#

take jree fava lessons from me

#

(checkmybio)

cunning canopy
#

what is the raySize argument in World#rayTraceEntities?

#

is it the "thickness of the ray"?

tall dragon
fluid river
undone axleBOT
tall dragon
#

wish that worked like that

fluid river
#

wasn't there a fucntion which did this thing

tall dragon
#

not that i know of

fluid river
#

oh i see

tall dragon
#

woulnt have been the right class tho

#

๐Ÿ˜„

fluid river
#

there was a ?jd

#

?jd

fluid river
#

and ?jd-s

cunning canopy
tall dragon
fluid river
#

my bad

#

?jd-b

#

?jd-bc

fluid river
#

ez

cunning canopy
#

Found this in the docs: raySize - entity bounding boxes will be uniformly expanded (or shrinked) by this value before doing collision checks

#

but I dont really get what its supposed to mean

fluid river
#

idk test this

tall dragon
#

its simple

#

when the ray would normally miss slighly it could hit if u set that to 1

cunning canopy
#

ooh

#

so

fluid river
#

smth like ray thickness

cunning canopy
#

its a multiplication factor of the box size?

fluid river
#

so it can hit bounding boxes

tall dragon
#

xD

fluid river
#

even if the point is missing

cunning canopy
tall dragon
#

it just expands the near box in every direction

#

or shrinks

cunning canopy
#

alright but would it not be more efficient to just make the ray bigger?

fluid river
#

there is no real ray

quaint mantle
#

Check the observer pattern.

cunning canopy
#

I know

fluid river
#

so no

cunning canopy
#

oh wait nvm whoops

fluid river
#

you can try making more rays

#

in a circle

cunning canopy
#

so in theory the "ray" is infinitely thin right?'

fluid river
#

and calculate for each ray

tall dragon
#

i feel like thats not all that expensive

fluid river
#

ofc it is

#

imagine

cunning canopy
#

is raytracing and raycasting the same thing?

fluid river
#

if you have a thin ray

fluid river
#

you need to calculate new point for each ray vector

cunning canopy
#

whats the difference

fluid river
#

using sin and cos

quaint mantle
fluid river
#

and then check if this exact ray hit anything

cunning canopy
quaint mantle
#

Nobody gonna give deep info

fluid river
#

cuz thin ray is a cone

tall dragon
fluid river
#

the greater the distance, the greater the spread

#

or at least a cylinder

cunning canopy
tall dragon
#

i have no idea

tall dragon
#

its a bit confusing

cunning canopy
#

welp, thats one way to confuse the developers

tall dragon
#

probably just due to alot of people thinking its the exact same thing

quaint mantle
cunning canopy
#

no, how?

fluid river
#

or maybe cuz rayTrace() is using recursion, but not related to the picture

#

just to move the point 0.00001 xyz and check if it finally hit something

#

and if distance reached the limit, return null

quaint mantle
tall dragon
fluid river
#

idk, but i seen some cases where people did that

#

idk sources of raytrace

tall dragon
#

seems like a good way to crash ur server to me

fluid river
#

well, raytrace should have distance

#

so method doesn't endlessly repeat

#

and some kind of length

cunning canopy
fluid river
#

on which the point moves each recursion step

tall dragon
#

well still

fluid river
#

like if you are on 0,0,0 and looking forward, and raytrace

tall dragon
#

if i had 20 blocks distance

#

thats 1999999.9999999998 calls

fluid river
#

point just moves to 0,01 then 0,02

#

and so on

cunning canopy
sullen marlin
#

its called that cause its called that

fluid river
#

hello md5

quaint mantle
#

hi md_5

tall dragon
#

i mean good point eh

fluid river
#

i usually used like 9999% weirder formula

#

to get the target

#

lemme find

cunning canopy
# fluid river can you send a link/screenshot

from the CraftBukkit implementation:

@Override
    public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, double raySize, Predicate<Entity> filter) {
        Validate.notNull(start, "Start location is null!");
        Validate.isTrue(this.equals(start.getWorld()), "Start location is from different world!");
        start.checkFinite();

        Validate.notNull(direction, "Direction is null!");
        direction.checkFinite();

        Validate.isTrue(direction.lengthSquared() > 0, "Direction's magnitude is 0!");

        if (maxDistance < 0.0D) {
            return null;
        }

        Vector startPos = start.toVector();
        Vector dir = direction.clone().normalize().multiply(maxDistance);
        BoundingBox aabb = BoundingBox.of(startPos, startPos).expandDirectional(dir).expand(raySize);
        Collection<Entity> entities = this.getNearbyEntities(aabb, filter);

        Entity nearestHitEntity = null;
        RayTraceResult nearestHitResult = null;
        double nearestDistanceSq = Double.MAX_VALUE;

        for (Entity entity : entities) {
            BoundingBox boundingBox = entity.getBoundingBox().expand(raySize);
            RayTraceResult hitResult = boundingBox.rayTrace(startPos, direction, maxDistance);

            if (hitResult != null) {
                double distanceSq = startPos.distanceSquared(hitResult.getHitPosition());

                if (distanceSq < nearestDistanceSq) {
                    nearestHitEntity = entity;
                    nearestHitResult = hitResult;
                    nearestDistanceSq = distanceSq;
                }
            }
        }

        return (nearestHitEntity == null) ? null : new RayTraceResult(nearestHitResult.getHitPosition(), nearestHitEntity, nearestHitResult.getHitBlockFace());
    }

fluid river
#

this one with dot

#

but changed to entity

#

and target location to

#

entity location + entityHeight/2

#

so perfectly the middle

cunning canopy
fluid river
#

idk, never tested

cunning canopy
#

efficient sorry

fluid river
#

only used dot

tall dragon
#

depends on ur needs

fluid river
#

tho this dot > 0.99D

#

Is making a cone

#

so if you are trying to get entity in like 200 blocks away

cunning canopy
#

a cone like the 3d form?

#

shape idk the word

fluid river
#

you can hit several entities

#

yes

#

where the point is your eye

#

and dot is the circle

cunning canopy
#

how is that making a cone

#

isnt that just comparing some vector math stuff?

fluid river
#

it is

cunning canopy
#

and how is that makign a cone?

fluid river
#

you use .dot()

#

which is simply checking how close the point is to the target point

#

and as long as the target can stand higher/lower, to the left and to the right

#

the search area is circular

#

cuz distance is measured with sqrt(x^2 + y^2)

cunning canopy
#

aha thanks

fluid river
#

well iirc the dot does this

#

just gives you a double representing distance

#

if you set it to 0.01, it will be very precise

sterile token
#

Please i need an explanation why my optional is not getting present, if the menu inventory is exactly the same

#

Im using the next codes


    @EventHandler
    public void onMenuClick(MenuClickEvent event) {
        Player player = event.getPlayer();
        Optional<Menu> optional = previews.getPreview(event.getMenu());
        if (optional.isPresent()) {
            Menu menu = optional.get();
            player.sendMessage("[Editor] Editing menu " + menu.getTitle());
            if (!player.hasPermission("escaparate.preview.edit")) return;
            menu.set(event.getSlot(), new Button(event.getItem())).update();
            player.sendMessage("[MenuClick] Menu " + menu.getTitle() + " has been updated!");
            return;
        }
        event.setCancelled(true);
    }

    public Optional<Menu> getPreview(Menu menu) {
        return getPreviews().stream()
            .map(preview -> new Menu(config.getString("Menus.Editor").replace("%display%", preview.getDisplay()), config.getInt("Menus.Rows")).set(preview.getContent()).update())
            .filter(preview -> preview.getInventory().equals(menu.getInventory()))
            .findAny();
    }
fluid river
#

lez go

fluid river
wary topaz
#

List<BanEntry> list = (List<BanEntry>) event.getPlayer().getServer().getBanList(BanList.Type.NAME).getBanEntries();
How can I convert tihis to a array list?

cunning canopy
#

mafs?

fluid river
#

ArrayList<BanEntry> list = event.getPlayer().getServer().getBanList(BanList.Type.NAME).getBanEntries();

fluid river
#

there was a meme book

#

called easy mafs

wary topaz
#

Incompatible types. Found: 'java.util.Set<org.bukkit.BanEntry>', required: 'java.util.ArrayList<org.bukkit.BanEntry>'

cunning canopy
#

aah

fluid river
#

oh that's a set

wary topaz
#

yaeh

wary topaz
#

is that a thing for a set?

#

stream.tolist

#

ill try that

fluid river
#

var arrlist = new ArrayList<BanEntry>(event.getPlayer().getServer().getBanList(BanList.Type.NAME).getBanEntries());

wary topaz
#

ArrayList<BanEntry> list = (ArrayList<BanEntry>) event.getPlayer().getServer().getBanList(BanList.Type.NAME).getBanEntries().stream().toList();

quaint mantle
#

tf is var

echo basalt
#

new ArrayList<>(whatever)

fluid river
sterile token
quaint mantle
fluid river
#

basically you just use var instead of type name

#

ArrayList<BanEntry> -> var

quaint mantle
#

Dynamic variable?

fluid river
#

no it's not

quaint mantle
#

So how?

fluid river
#

var cannot be used without initialization

#

if you do var i; java throws error

quaint mantle
#

ok

fluid river
#

var i = 1; turns i to int

#

and so on

#

so it's still static

wary topaz
#
            for (int i = 0; i < list.size(); i++) {
                ItemStack playerHead = new ItemStack(Material.PLAYER_HEAD,1);
                ItemMeta playerHeadMeta = playerHead.getItemMeta();
                playerHeadMeta.setDisplayName(list.get(i).getDisplayName);
            }```

Cannot resolve symbol 'getDisplayName'
fluid river
#

and var cant be null

#

cuz ban entry doesn't have displayname?

wary topaz
#

it doesnt?

fluid river
#

can you get player from ban entry?

quaint mantle
fluid river
#

why not just

wary topaz
#

How can it get the name than

fluid river
#

event.getPlayer().getServer().getBanList(BanList.Type.NAME).getBanEntries().forEach(e -> {
// your code
});

echo basalt
#

you can use an enhanced for loop

#

I hate List#forEach

#

It's pretty much worse in every single way

wary topaz
#

How can I do that?

echo basalt
#

for(Object whatever : myCollection)

wary topaz
#

alr

fluid river
#

or yeah, use ^^^

wary topaz
#

ty

tardy delta
quaint mantle
#

I use List#forEach() idk why hate.

fluid river
#

cuz imlusion

wary topaz
#

wait what is the object "whatever"?

tall dragon
#

its a name...

fluid river
#

variable name

wary topaz
#

oh

#

alr

fluid river
#

and change type to BanEntry

#

not to Object

#

or to var at least

echo basalt
echo basalt
#

you gotta make sure your collection is not null and you can't modify external variables

wary topaz
#
            Inventory bannedplayers = Bukkit.createInventory(event.getPlayer(),45,ChatColor.BLUE + "List of banned players!");
            var list = new ArrayList<>(event.getPlayer().getServer().getBanList(BanList.Type.NAME).getBanEntries());
            for (Object whatever : list) {

                ItemStack playerHead = new ItemStack(Material.PLAYER_HEAD,1);
                ItemMeta playerHeadMeta = playerHead.getItemMeta();
//                playerHeadMeta.setDisplayName(list.get(i).getTarget());
            }
        }```
#

and yes this is for debug ill add the item later

fluid river
#

you are not creating an anonymous class with that

echo basalt
#

you are

wary topaz
#

???

echo basalt
#

lambdas are anonymous classes

wary topaz
#
    public void onClickReviveToken(PlayerInteractEvent event) {
        if (event.getHand() == EquipmentSlot.HAND) {
            Inventory bannedplayers = Bukkit.createInventory(event.getPlayer(),45,ChatColor.BLUE + "List of banned players!");
            var list = new ArrayList<>(event.getPlayer().getServer().getBanList(BanList.Type.NAME).getBanEntries());
            for (Object whatever : list) {

                ItemStack playerHead = new ItemStack(Material.PLAYER_HEAD,1);
                ItemMeta playerHeadMeta = playerHead.getItemMeta();


            }
        }
    }```
fluid river
#

isn't that an anonymous fucntion?

#

cuz anon classes have new everytime

#

oh i see

#

sorry

echo basalt
#

() -> {
...
}

is the same as

new Runnable() {
  @Override
  public void run() {
    ...
  }
};
tardy delta
#

Player::remove is the same as new Consumer<Player>() { void accept(Player player) { player.remove(); } }

fluid river
#

method(new Runnable() {

})

quaint mantle
#

Ah yes, syntax sugar.

fluid river
#

but yeah i just read oracle documentation

tardy delta
#

a lambda compiles down to the same thing as an anomymous class

echo basalt
fluid river
tardy delta
#

just invokedynamic stuff

echo basalt
#

they're more compact to write but compiles to the same

cunning canopy
#
Vector startPos = player.getEyeLocation().toVector();
                Vector dir = player.getEyeLocation().getDirection().normalize().multiply(8);
                BoundingBox ray = BoundingBox.of(startPos, startPos).expandDirectional(dir);
                Collection<Entity> entities = player.getWorld().getNearbyEntities(ray);
``` will this collection be sorted from first to last entity?
sterile token
#

Does bungeecord plugins, works on velocity?

quaint mantle
sterile token
quaint mantle
#

50% work 50% wont

chrome beacon
echo basalt
#

working on a new sql abstraction

#

๐Ÿค”

quaint mantle
echo basalt
#

this uses jdbc underneath ??

quaint mantle
#

Yea english still broken ๐Ÿ˜ฆ

echo basalt
#

but makes tables n all for me

cunning canopy
#

anyone know if World#getNearbyEntities is sorted in some way?

undone axleBOT
gleaming grove
cunning canopy
cunning canopy
#

but collections are ordered right?

#

?stash

undone axleBOT
sterile token
#

Please i need help, for some annoying reason my menus are not matching, but i dont find the reason!!!!

@EventHandler
public void onMenuClick(MenuClickEvent event) {
  Player player = event.getPlayer();
  previews.getPreviews().forEach(preview -> {
    Menu menu = new Menu(config.getString("Menus.Editor").replace( "%display%", preview.getDisplay()), config.getInt("Menus.Rows"));
    menu.set(preview.getContent()).update();
    if (!menu.getInventory().equals(event.getMenu().getInventory())) {
      player.sendMessage("[Editor] Menus doesn't match");
      return;
    }
    menu.set(event.getSlot(), new Button(event.getItem())).update();
    player.sendMessage("[Editor] Menu " + event.getMenu().getTitle() + " has been updated");
});
event.setCancelled(true);
}
#

For some reason, my code is cancelling menu edition in all the menus, when must no cancel it on editor menu

tardy delta
#

uhh

sterile token
#

I cant find the reasons tho, i know its something to menu comparing. But the menus have the same title, same rows and same items, so it must be not returning

gleaming grove
#

Because this return is not related to onMenuClick but to forEach lamnda function

sterile token
#

oh that makes more sense know

gleaming grove
#

instead of foreach(preview ->{}) try for(var preview : previews.getPreviews())

sterile token
#

right

chrome beacon
#

I usually use IF

#

?scheduling

undone axleBOT
analog thicket
#

How would i check if a string is an item?

sterile token
analog thicket
#

ive found the isItem(), but cant get it to work...

analog thicket
sterile token
#

Hmn

placid birch
chrome beacon
#

The code wouldn't run

#

So you'd need to save it somewhere and reschedule on load

sterile token
placid birch
#

So if I make it so that when I mine a stone block, and I set the stone to bedrock for 10 seconds when broken, would the block still be bedrock when the server opens.

round finch
#

Save on shutdown

chrome beacon
#

Yes

#

So you need to save and reschedule

wary topaz
#

            Collection<BanEntry> bannedPlayers = allBaned();
            Iterator var11 = (new ArrayList(bannedPlayers).iterator());```
What's wrong with my iterator?
#

public static Collection<BanEntry> allBaned() {
return Bukkit.getBanList(BanList.Type.NAME).getBanEntries();
}

chrome beacon
#

What are you trying to do?

wary topaz
#

Make a gui with all the banned players

chrome beacon
#

Just use a for loop???

remote swallow
#

I doubt you should be making an inv with the player as a holder

wary topaz
#

the getbanentries returns a list

chrome beacon
#

Yeah

remote swallow
#

You can use one anyway

wary topaz
#

How would I implement it?

analog thicket
chrome beacon
undone axleBOT
wary topaz
#

;-;

worldly ingot
remote swallow
round finch
#

What kind of code was that

#

Item in runnable function

analog thicket
#

If you know what i mean

remote swallow
#

What string

chrome beacon
#

A line on the sign

analog thicket
#

A line on a sign

chrome beacon
#

You can match the string to the material enum

worldly ingot
#

If you want to check whether or not it's a valid material, you can use Material#matchMaterial(String) and check if it's not null

remote swallow
#

Ohhh, use get or match material, witch ever throws an exception on none found or check for null

worldly ingot
#

Then do an additional Material#isItem() check to make sure

analog thicket
#

Aaarh okay i see thanks

sterile token
wary topaz
#
            List<BanEntry> banEntries = new ArrayList<>(Bukkit.getBanList(BanList.Type.NAME).getBanEntries());

            for (int i = 0; i < ; i++) {
                ItemStack playerHead = new ItemStack(Material.PLAYER_HEAD);
                ItemMeta playerHeadMeta = playerHead.getItemMeta();
                playerHeadMeta.setDisplayName(banEntries.get(i).getTarget());
            }```
Instead of gettarget, How can I make it return a display name?
rapid topaz
#

is it possible to make a plugin that stops operators from doing commands?

sterile token
rapid topaz
#

so i can stop admin abuse

wary topaz
#

yes

lost matrix
lost matrix
wary topaz
#

ebic ebic dont you dare

remote swallow
#

What does get target return

sterile token
wary topaz
#

?

#

no?

#

epicebic idk

remote swallow
#

Hover over it

wary topaz
#

the target name of IP adress

#

which one is it

#

or*

sterile token
# wary topaz no?

For some reason im looping over all the previews i currently have, and none of the inventory are matching, not matter if they have the same content, title and size, Im really messed right now

wary topaz
#

Could you show us the code?

sterile token
lost matrix
wary topaz
#

Hmm

#

how many slots are there in a 5x9 inventory? counting the 0

analog thicket
wary topaz
#

is it 46?

lost matrix
gleaming grove
lost matrix
chrome beacon
sterile token
lost matrix
sterile token
#

yeah you are right

remote swallow
analog thicket
sterile token
#

Because i dont know the previre obj neither

#

๐Ÿค”

lost matrix
sterile token
#

You are right

#

Hahaha

cunning canopy
#
Collection<Entity> collectionEntities = player.getWorld().getNearbyEntities(ray);
                ArrayList<Entity> entities = new ArrayList<>(collectionEntities);
                Collections.sort(entities);
``` intellij is yelling at me saying `reason: no instance(s) of type variable(s) T exist so that Entity conforms to Comparable<? super T>` is it actually a problem?
lost matrix
cunning canopy
lost matrix
# cunning canopy Do I just return a number value that they are to be sorted by?

Here is an example which sorts the list by the height of each entity:

    List<Entity> entityList = new ArrayList<>();
    
    Comparator<Entity> heightComparator = new Comparator<Entity>() {
      @Override
      public int compare(Entity e1, Entity e2) {
        return Double.compare(e1.getHeight(), e2.getHeight());
      }
    };
    
    entityList.sort(heightComparator);

This is a simplification:

    Comparator<Entity> heightComparator = (e1, e2) -> Double.compare(e1.getHeight(), e2.getHeight());

And this is the most compact way (But harder to read):

    Comparator<Entity> heightComparator = Comparator.comparingDouble(Entity::getHeight);
lost matrix
cunning canopy
#

What sorting algorithm is that?

gleaming grove
#

is there better more optimalized way to repeat string x times? @Override public TextBuilder repeat(String text, int length) { for (; length> 0; length--) { builder.append(text); } return this; }

lost matrix
#

Just looked it up: Uses mergesort
Native arrays use dual pivot quicksort since java 8

#

Interesting they also change the sort algorithms based on the size of the underlying array.

#

Anyways that should be irrelevant here. Any sorting algorithm will do just fine.

lost matrix
#
    public TextBuilder repeat(String text, int length)
    {
        builder.append(text.repeat(length);
        return this;
    }
gleaming grove
#

thx

small hawk
#

How can i check if my custom config is empty? I need to create starting sections, when it's created first time

remote swallow
#

Get values and check for isEmpty

frank kettle
#

is there a a way to implement a URL returned valued inside an async?

Example:

private String returnedValue(String url) {
        new BukkitRunnable() {
            @Override
            public void run() {
                return new URL(url);
            }
        }.runTaskAsynchronously(PluginMainClass.getInstance());
}```
#

i dont want an URL connection to lag the server

#

if not, i have a way to do what i want without that

#

just curious

shadow gazelle
#

You can do it in a new thread

lost matrix
frank kettle
#

its to get the texture of a players skin

lost matrix
#

I would use a CompletableFuture for that

frank kettle
#

never heard of that

#

im searching about it

lost matrix
#

Let me think if there is an easier way.
But CF is basically the gold standard for such a thing

frank kettle
#

ty for the help

#

i will look into that, never heard before

shadow gazelle
#

@brave sparrow didn't you say you were working on a jar loader?

brave sparrow
#

Yep

lost matrix
# frank kettle i will look into that, never heard before

Example i just made up:

  public void tellPlayerHisKills(Player player) {
    UUID playerId = player.getUniqueId();
    CompletableFuture<Integer> future = requestKillsFromDatabase(playerId);
    future.thenAccept(kills -> player.sendMessage("You have %d kills.".formatted(kills)));
  }
  
  public CompletableFuture<Integer> requestKillsFromDatabase(UUID playerId) {
    return CompletableFuture.supplyAsync(() -> loadKills(playerId));
  }
  
  private int loadKills(UUID playerId) {
    // some DB action...
    return kills;
  }
sterile token
#

Smile, i have been 1h more checking and same fucking issue

#

I dont udnerstand the reaosn and im getting up to rage about fucking api

lost matrix
#

Show your whole mess pls

sterile token
#

yess thanks!!

sterile token
#

For some reason, literally none of the menu works now

#

All this shit happens becaue i havent code my own and custom api

lost matrix
#

Never write getters or setters for any collections or other data structures

#

Thats No. 1

shadow gazelle
sterile token
lost matrix
#

Anyways lets see what we got here

sterile token
#

right really thanks man i have been whole afternoon with this shity๐Ÿ’€

#

Also i forget these code, where i create the editing menu

#

Its prety simple hat i need to do, but cant figure the right logic

lost matrix
#

Btw the standard for this:

if (!optional.isPresent()) return;

Is this:

if (optional.isEmpty()) return;
sterile token
#

Because fucking menus doesnt have a way for tracking them

lost matrix
#

Still reading

sterile token
#

right

#

im just wait patientlly, np

#

Must be the java version

lost matrix
#

empty()

#

Just that mb

cunning canopy
#

what stashrepo is the implementation of the thing that calls PlayerInteractAtEntity event?

lost matrix
#

bukkit

sterile token
#

Im really confused about menus

#

I dont know why they didnt add a fucking traccking system, something like a unique id or name for traccking

cunning canopy
lost matrix
cunning canopy
#

where in the code is the event called?

sterile token
#

So, what can be happening smile?

#

I checked thousans fo time the code

lost matrix
#

Im still trying to put the pieces together. There is a lot of very weird code here...

#

Like this

#

wtf?

lost matrix
sterile token
lost matrix
#

I need more code. Is this on github?

#

If you have such a method:

#

Then you should never, ever create a Preview somewhere else.

#

Same goes for Menu

#

Those need to be removed

mortal hare
#

i want to test quickly my base classes for my command api

#

is there any way to use onCommand

#

to listen for all commands

#

?

#

its only for a temporary checking to see how my dispatching abstract classes work

#

or should i listen to event?

lost matrix
mortal hare
opal juniper
#

there is an event

lost matrix
#

Alright? And you want to do what with this?

mortal hare
#

commands require to get commandexecutor set

#

is there any dirty way to make this work for all the commands/inputs

#

without registering it

#

via getCommand()

lost matrix
#

Yeah, dont do that. Listen for the CommandPreprocessEvent

mortal hare
#

ik, im just testing my abstract classes too see how internal my custom dispatching work

#

before i would begin to properly integrate it into bukkit plugin

gleaming grove
ivory sleet
#

usually for tests u probably just wna unit tests ur own components, and then integration tests which mockbukkit could help with

gleaming grove
#

" internal my custom dispatching work" by this I understand own components with custom logic

mortal hare
#

i have divided my gradle into two subprojects

#

core and bukkit

#

to separate bukkit and generic logic apart

#

i have designed simple classes inside core subproject

#

and i want to do simple impl for bukkit for it

cunning canopy
#

anyone know how PlayerInteractEvent.getClickedPosition() is calculated?

gleaming grove
mortal hare
#

Pure

gleaming grove
#

I guess Junit will be good enoght

#

for unit tests

mortal hare
#

I didnt use any interfaces regarding the bukkit api

ivory sleet
#

even if u use stuff like Player

#

just mockito or mock urself

#

unless u need greater emulation of the impl of Player

#

in which its almost an integration test, thus mockbukkit :>

gleaming grove
#

sadly there is not framework now for integration tests with bukkit ;< I hope someone create it

ivory sleet
#

mockbukkit can be used

#

mini has one also

gleaming grove
#

what's mini? I can't find that one in google

ivory sleet
gleaming grove
#

thanks

ivory sleet
#

its javascript tho iirc

#

but I mean, still automated integration tests

#

so ye

gleaming grove
ivory sleet
#

ye

#

I mean there are cons and pros :)

sterile token
lost matrix
sterile token
lost matrix
#

I need more code then

mortal hare
#

i managed it to work on bukkit

#

but its so raw and codesmelly rn

#

it doesnt support tab completion and other neat stuff im going to implement in the future

quaint mantle
#

anyone know how to add support for vault permissions?

brave sparrow
mortal hare
#

I've made Jar loader myself too

#

all you need is some reflections to instanciate the main class

#

and URLClassloader to achieve that

sterile token
lost matrix
sterile token
#

hmnn right

#

I will have to fix this shit in my own so, because i need to finish it haha

#

But thanks

quaint mantle
#

anyone know the vault support discord

eternal oxide
#

you don't need any vault support

quaint mantle
#

cant figure out how to add vault permissions to my plugin

#

like make a new permission provider or whatever

eternal oxide
#

oh and don't use Vault#has to test permissions, as all that does is query Bukkit. Use Vault#playerHas

#

it tells you straight on Vault github how to use it

quaint mantle
#

vaultapi or vault

eternal oxide
#

api

short galleon
#

Does someone have an idea? md_5

brave sparrow
#

Iโ€™m just making sure it has a decent API

modest garnet
#

but no data is stored in my database when i join.

#

anyone know why?

hazy parrot
#

It's probably better to send relevant code

half arrow
#

?

sterile token
# half arrow ?

patient! This is a community all people helping are volunteers, so you cant expect instant help

#

Sorry if sound rude, but that the reality of asking for help in community discords

half arrow
#

Sorry my bad! not my intention to come across like that

eternal oxide
#

This line Enchantment enchantment = Enchantment.getByKey(NamespacedKey.minecraft(enchantmentKey.toLowerCase())); is not finding an entry for durability under the minecraft namespace

half arrow
#

thank you, i've switched up how i'm saving the enchantment name

#

using getKey().getKey() instead of getName()

#

sorted thanks

quaint mantle
#

getKey().getkey() ???

eternal oxide
#

yes

quaint mantle
#

Why

#

Why not just getKey()

eternal oxide
#

getKey and getName are each part of the Keyed

quaint mantle
#

Weird convention

eternal oxide
#

just all depends how he wants entries in his data to look

half arrow
#

tbh i'd rather just the vanilla enchant name without 'minecraft:'

#

which getKey().getKey() gives

sterile token
#

Its really weird this issue

#

And i have read their docs and all some seems correctly

#

Starting from that menus title are differnet, so there instantly the inventory objects are not the same to be overriten each other

slim pier
#

when i typing Material.item then cpu usage is 100% help me

vocal cloud
sterile token
#

Also, is Material.item a thing?

slim pier
#

Material.OAK_DOOR, Material.AIR , etc every item

sterile token
#

Also you never gived any test, rather nothing

#

To see us what or how did you even ge ttha conclusion

kind hatch
#

I think he's talking about his IDE, not the server.

sterile token
slim pier
#

yes ide

sterile token
#

right, but that is pretty common

#

IJ is really resource intensive

slim pier
#

how can i solve this problem?

subtle folio
#

CPU limiter?

vocal cloud
#

There's no reason it should be using that much

buoyant viper
buoyant viper
vocal cloud
#

Sure but not to max a cpu

echo basalt
#

all fun and games until you do a new Player()

sterile token
rare rover
#

how do i use modules with spigot?

#

got this

sterile token
#

In that example specific, they are maven modules

#

Buth you java modules and gradle or maven modules, they are for different things

#

Now choco can give you a better explanation

worldly ingot
#

When you have a module-info.java file you're dealing with Java 9+'s Jigsaw modules, which Bukkit doesn't support (nor does it really need to)

rare rover
#

๐Ÿคจ

#

How are plugins using them then

sterile token
#

so choco, the way to go are maven or gradle modules

rare rover
#

I see them every once and awhile on github

sterile token
rare rover
#

Ohhhhh

#

So i learn that then

#

Ty

sterile token
#

In your example, they are built over maven modules

#

But you can do the same for gradle too

sterile token
worldly ingot
#

Yeah, Maven & Gradle modules are a completely different concept. They're pretty much just subprojects

sterile token
#

Some fast questio nnone related, what event should i use for allowing items to get moved in custom inventory ?

#

Like would work an editor

lost matrix
sterile token
#

Hmn

#

I tried but didnt sucess

#

I now moved to menu api haha

#

So i skip all that issues

lost matrix
#

Triumph?

sterile token
#

Yes!

#

Amazing menu api haha

#

Idk why i didnt use it from the start

lost matrix
#

decent choice

sterile token
#

Now just need to fix the issue with the editor menu

#

Because items are not being aved

#

So i need to listen to click event right?

lost matrix
#

What are you trying to do in the first place?

sterile token
#

Allow the menu to being modfied

#

Like you will do with a kit editor, where they provide you the kit and you can move the things, etc

lost matrix
#

Ok but for this you need to know if this is viable for this GUI library.
Do you need a live update of the gui changes on other opened views or
do you only need the changes to apply when the gui is opened the next time?

sterile token
#

All works perfect, the issue is with saving back the edited items into the preview object

#

Final code, i just written to test

lost matrix
#

Update the preview on the close event. Not every time someone clicks around.

sterile token
#

oh ok

#

but how i would know the items on close event?

#

nothing im an idiot

#

I just need to get the gui items and save it back

#

Omg why the inventory is not a fucking hash map

#

๐Ÿ˜ก

lost matrix
#

What? What would the key be?

sterile token
lost matrix
#

So an array. Just worse.

sterile token
#

now i have to do an ugly for int, to get the itemstack ๐Ÿ˜‚

lost matrix
#

getContent() returns an ItemStack[]
Which works exactly like a Map<Slot, ItemStack> would work.

sterile token
lost matrix
#

Alright you got something in mind. Youll manage

sterile token
#

but right the logic is true?

#

I need to get the inventory content on close, that we can agree tru?

lost matrix
#

Yes

sterile token
#

fine, and really thanks

#

sorry for losting your whole day!

lost matrix
#

Oh i didnt lose anything. Worked 3.5h on both my projects. Thats my daily goal.

sterile token
#

oh pretty nice

#

Once i finish this i would fast start with the menu api, so then i dont depend on 3rd parties and dont have this isuses

lost matrix
#

Oh yes. This sounds like a Verano idea...

sterile token
#

hahaha

#

I really like how people laught at me but i dont care because once everything works well, then i will laught haha

quaint mantle
#

Why do people make fun of Verano?

#

I mean, what's wrong with doing your own library?

sterile token
#

Yeah it would be better using custom libraries

#

Take as an example Imliussion he has many custom libraries, and none laught at him

rare rover
#

bro what

#

why ain't this working

#

whoops

lost matrix
rare rover
#

why can't i select the Testing class from my 2nd "project"

lost matrix
rare rover
lost matrix
#

First of all: The parent project should not have any code in it

rare rover
#

huh?

lost matrix
#

Delete the src folder in your top project

rare rover
#

in the API module? or the bottom one

sterile token
#

yeah i was going to point that, the parent project should not contain any code

lost matrix
rare rover
#

im guessing the one that isn't embeded into a module

#

ah

lost matrix
#

You create 2 modules and those can depend on one another.

#

*But not each other ofc

rare rover
#

okay so, how would all of this work? Sorry for being that guy but like how would the plugin work without an src in the main path

sterile token
rare rover
#

ty

lost matrix
#

Every module has its own src