#help-development

1 messages Ā· Page 2056 of 1

tender shard
#

guess I'll have to pass two parameters then

#
new MapDataType(LinkedHashMap.class, LinkedHashMap<K,V>::new, keyType, valueType);

ugly but better than nothing

tardy delta
#

smth like that ye

quaint mantle
tender shard
#

that's java 8 lol

quaint mantle
#

oh yeah nevermind

#

LinkedHashMap<K,V>::new is lambda

#

right?

tardy delta
#

ye

tender shard
#

yep it's a Supplier

quaint mantle
#

method reference

#

forgot those existed

tardy delta
#

same as () -> new LinkedHasMap

quaint mantle
#

i know lambda, thank you

tardy delta
#

:)

tender shard
#

buth with <K,V> šŸ˜›

#

hm weird

#

isn't this cast totally unnecessary?

#

intelliJ doesn't say its unneccessary but it also doesn't cry when I remove it

river oracle
quaint mantle
tender shard
#

stupiJ

viral crag
tender shard
viral crag
#

basically uses cookbooks or rules to evaluate your code

tender shard
#

I just use the builtin code inspection

lavish hemlock
#

Quick design question

#

I have a service interface that is designed for sending things

#

What do I name it? Sender?

fossil lily
#

How can I transfer an X axis number, to a location object?

lavish hemlock
#

Y'know what nevermind, Sender works fine

supple elk
#

anyone know why maven can't resolve this dependency?

#

it was working before and I just copied it again from the website to try and fix it but nothing

tardy delta
#

did you add repo

supple elk
#

šŸ¤¦ā€ā™‚ļø

#

thanks

#

it's always the little things šŸ˜”

viral crag
#

why are you asking about maven and showing the gradle example?

spring minnow
#

can someone help me do a thing?

#
    @EventHandler
    public void onClick(PlayerInteractEvent playerInteractEvent) {
        ItemStack itemStack = playerInteractEvent.getItem();
        if (!this.cache.containsKey(playerInteractEvent.getPlayer()))
            this.cache.put(playerInteractEvent.getPlayer(), new HashMap<>());
        Talisman talisman = getTalisman(itemStack);
        if (talisman != null) {
            Map<Attribute, Double> map = this.cache.get(playerInteractEvent.getPlayer());
            for (Map.Entry<Attribute, Double> entry : talisman.getAttributes().entrySet()) {
                if (!map.containsKey(talisman)) {

                    playerInteractEvent.getPlayer().sendTitle("§aTalisman §7" + talisman.getKey() + " §aenabled!", "§7§kIF U CAN READ U COOL");
                    playerInteractEvent.getPlayer().playSound(playerInteractEvent.getPlayer().getLocation(), Sound.BLOCK_BEACON_ACTIVATE, 1, 1);
                } else {
                    removeTalisman(playerInteractEvent.getPlayer(), map, talisman);
                }
            }
        }
    }
#

Idk how to do the ' thing xD

#

here

spring minnow
#

i'm making a talisman plugin, that when you use a talisman(configured) it changes some attributes, basically adds a % more to an attribute, so basically, a talisman can be configured to give 3% more health

#

but i can't figure out how to sum every percentage by the key attribute, to make 1 sum

#

so like, since there can be more than 1 talisman, i would like to make plugin sum every percentage from all talismans

#

but i can't figure out how to do it, can someone help?

#

no

#

the number has to be the sum of all attributes of the same type, so like if i have more than one talisman, and every talisman gives me a health boost, the applied health boost should be the sum of every health boost of every talisman

#

my english is bad cuz i'm italian so, idk if i explained well

spring minnow
young knoll
#

Just loop over then and add it all up?

spring minnow
#

zacken02 btw var CPP = "ugly" is approved

spring minnow
#

i mean

young knoll
#

Well are they all items?

#

Loop over ever item the player has then

viral crag
#

loop through your inventory and/or get your stack size

#

hard part is not counting but deciding when to update when you add or remove items

tender shard
sage merlin
#

hey im trying to remove the item in the inventory with the Persistent data container and when i do inventory.remove(item) it deletes 2 items but does not identify the difference in Persistent Data Containers

#

i want to identify the item based on its nbt tag and not its type

#

@tender shard based on your github you seem to be the perfect guy to know how i can identify two items that are the same except for persistent data containers

tender shard
#

I guess the easiest way is to simply loop over the inventory contents, then check every item's PDC manually

#

what exactly are you trying to do?

#

Remove EXACTLY the same item, but spigot removes also items that are the same except for having different PDC data?

sage merlin
#

i do not want it to remove two items i thought by setting a pdc for the item spigot would realize that they have different data and would remove only the clicked item and not the other item

tender shard
#

just loop over the inventory and remove all items that have your custom tag?

inv.setContents(Arrays.stream(inv.getContents()).map(item -> {
            if(!item.hasItemMeta()) return item;
            PersistentDataContainer pdc = item.getItemMeta().getPersistentDataContainer();
            if(pdc.has(someKey,DataType.STRING)) return null;
            return item;
        }).toArray(new ItemStack[0]));
viral crag
tender shard
#

this works fine for all my concrete List datatypes like DataType.asArrayList

#

only the one where someone can provide a collection class is where I don't get it to work

viral crag
#

hmm 4. Vector(Collection c): Creates a vector that contains the elements of collection c.

Vector<E> v = new Vector<E>(Collection c);

#

you create it without the collection - wondering if you are over the 10? Vector(): Creates a default vector of the initial capacity is 10.

#

even that doesnt make sense

tender shard
#

when changing asGenericCollection from <C extends Collection<D>,D> to just <C extends Collection,D> then I can use it as Collection<D> without problems but I want to be be C<D> instead of a generic collection

tender shard
#

copy/paste that part of code pls

#

let me paste it into my IDE

viral crag
#

which java version are you compiling with? maybe its in the change notes

tender shard
#

java 17 but with 8 as target

woeful crescent
#

I'm trying to use protocollib to add item details to the items lore dynamically, so that the information is not in the lore and is added on to the end of the item packet every time it is sent. However, even though I am cloning the item, my detail lines still get added to the actual item's lore (over and over again, no less).

viral crag
# tender shard java 17 but with 8 as target

the only real note in 8 is: Unlike the new collection implementations, Vector is synchronized. If a thread-safe implementation is not needed, it is recommended to use ArrayList in place of Vector.

golden turret
#
tender shard
#

my problem is this:

    static <C extends Collection<D>, D> PersistentDataType<?,Collection<D>> asGenericCollection(final @NotNull Class<C> collectionClazz,
                                                                                    final @NotNull Supplier<C> collectionSupplier,
                                                                                    final @NotNull PersistentDataType<?, D> type) {
        return new CollectionDataType(collectionClazz, collectionSupplier, type);
    }

This returns a PDC type that uses Collection<D>

    static <C extends Collection<D>, D> PersistentDataType<?,C> asGenericCollection(final @NotNull Class<C> collectionClazz,
                                                                                    final @NotNull Supplier<C> collectionSupplier,
                                                                                    final @NotNull PersistentDataType<?, D> type) {
        return new CollectionDataType(collectionClazz, collectionSupplier, type);
    }

This returns a PDC type that uses a raw C

What I need is a PDC type that returns a parametrized C

sage merlin
nova fossil
#

I HATE nms

fossil lily
#

The namespace is stored with the key right? Its like a hashmap?

#

In PersistantDataContainers

tender shard
#
        inv.setContents(Arrays.stream(inv.getContents()).map(item -> {
            if(!item.hasItemMeta()) return item;
            PersistentDataContainer pdc = item.getItemMeta().getPersistentDataContainer();
            if(pdc.has(someKey,DataType.STRING)) return null;
            return item;
        }).toArray(ItemStack[]::new));

This should work. haven't tested it but I'm sure it'll do

tender shard
#

by removing the whole CollectionClazz from the constructor

#

seems like that confused javac since ofc I wasn't able to pass a parametrized class there

crisp steeple
#

yeah thats what i was going to say

tender shard
#

now I just get the proper class by calling the supplier.get().getClass() and casting that to C lmao

sage merlin
tender shard
nova fossil
#

Does anyone know if there’s a way to get a block’s step sound, and then play it (without particles) without nms?

tender shard
#

one second

#

ItemStack[]::new is the same as creating an anonymous IntFunction<ItemStack[]>, like this:

        inv.setContents(Arrays.stream(inv.getContents()).map(item -> {
            if(!item.hasItemMeta()) return item;
            PersistentDataContainer pdc = item.getItemMeta().getPersistentDataContainer();
            if(pdc.has(someKey,DataType.STRING)) return null;
            return item;
        }).toArray(new IntFunction<ItemStack[]>() {
            @Override
            public ItemStack[] apply(int value) {
                return new ItemStack[value];
            }
        }));

@sage merlin

sage merlin
#

item is null

sage merlin
tender shard
sage merlin
#

the item is null

tender shard
#

which item

#

of course, many items will be null

desert musk
#

for the spigot plugin is it normal that the highest minecraft version is 1.18.1?

tender shard
#

simply check if the item is null and if yes, continue

#

yeah then just do

#

if(item == null) return null; at the beginning

#
        inv.setContents(Arrays.stream(inv.getContents()).map(item -> {
            if(item == null) return null; // <--------
            if(!item.hasItemMeta()) return item;
            PersistentDataContainer pdc = item.getItemMeta().getPersistentDataContainer();
            if(pdc.has(someKey,DataType.STRING)) return null;
            return item;
        }).toArray(ItemStack[]::new));
#

see the second line I added

sage merlin
#

i have a question how is this gonna delete the item with a unique PCD

tender shard
#

we turn the inventory contents to a stream. the map method takes an itemstack as input and returns another itemstack. in this case, we simply return null when the PDC key is found, otherwise return the original item. so we simply replace all itemstacks in the array with "null" that have the tag you'r elooking for. then we turn the stream back into an array and apply it to the inventory

sage merlin
#

nothing is really happening

#

added a debug message its the if statement

tender shard
#

try to remove the hasItemMeta() method

#

sometimes it does weird things

sage merlin
#

nope

tender shard
# tender shard ```java inv.setContents(Arrays.stream(inv.getContents()).map(item -> { ...

this is the fancy version of this:

        ItemStack[] contents = inv.getContents();
        for(int i = 0; i < contents.length; i++) {
            ItemStack current = contents[i];
            if(current == null) continue;
            if(!current.hasItemMeta()) continue;
            PersistentDataContainer pdc = current.getItemMeta().getPersistentDataContainer();
            if(pdc.has(someKey,DataType.STRING)) contents[i] = null;
        }
        inv.setContents(contents);
fossil lily
#
Entity mob = new Entity();

How can I create a new entity like this? I dont want to spawn it yet.

tender shard
#

you can't just create an Entity

tender shard
#

why would you want to create one without spawning it anyway?

tender shard
# crisp steeple nms

it won't be a Bukkit Entity then but an NMS one. seems like they want to create a bukkit entity without spawning it

fossil lily
#

hmmm

tender shard
#

maybe explain what you need it for

fossil lily
#

im rethinking stuff

crisp steeple
sturdy heron
#

How would you setup the flags for relative teleportation in ProtocolLib?
Current Code:

        ProtocolManager protocolManager;
        protocolManager = ProtocolLibrary.getProtocolManager();

        PacketContainer relativeTeleport = protocolManager.createPacket(PacketType.Play.Server.POSITION);


        //Code for PacketType.Play.Server.POSITION
        relativeTeleport.getDoubles().
                write(0, (double) 0).
                write(1, (double) 0).
                write(2, (double) 0);
        relativeTeleport.getFloat().
                write(0, (float) 0).
                write(1, (float) 10);
        //Tried this but gave me an error for the getSets, it said Byte on the wiki.vg but I have no idea how to set that up
        relativeTeleport.getSets().
                write(0, new HashSet<>(Arrays.asList(PlayerTeleportFlag.X, PlayerTeleportFlag.Y, PlayerTeleportFlag.Z)));```
https://wiki.vg/Protocol#Player_Position_And_Look_.28clientbound.29
tender shard
tender shard
#

using NMS is 10 times easier to send packets

crisp steeple
#

^^^^^

crisp steeple
#

protocol just makes it harder imo

tender shard
#

yep!

sturdy heron
#

Well protocol does have the advantage of reflection

tender shard
#

well for listening, protocollib is good

tender shard
sturdy heron
#

cross version compatible

fossil lily
#

nevermind

#

thanks anyways

#

i was being smol brain

tender shard
woeful crescent
crisp steeple
#

let me look at a project i worked on

woeful crescent
#

sorry for bumping so much

crisp steeple
#

it had something similar to what you're doing

woeful crescent
#

ok

crisp steeple
#

on this

sturdy heron
crisp steeple
#

it was nms instead of protocol (i didnt make it)

tender shard
tender shard
#

but the NMS packet constructors are quite easy to undertsand

quaint mantle
#

p.getInventory().addItem(e.getBlock().getDrops());
Im trying to add a collection of items to the player inventory, how do i do that?

crisp steeple
#

it makes a nms copy of the item and then sets the item field using reflection

sturdy heron
#

Someone seriously needs to make some proper NMS tutorial series it would get a million views

tender shard
tender shard
crisp steeple
#

i havent used protocol so i dont know how it works on there, but the nms method above works @woeful crescent

woeful crescent
woeful crescent
#

wait there's no link @crisp steeple

sturdy heron
#

Well, off to scavenge the internet for scrap pieces of code to find out how it works

echo basalt
crisp steeple
echo basalt
#

I know some NMS and I can provide nice examples but eh

#

protocollib does 90% of the work

#

discovering NMS is mostly just middle-clicking stuff until you find what you want

echo basalt
#

There are like 2 item packets

woeful crescent
#

?

#

What do you mean by remove the lore from the real item?

echo basalt
#

the client-side lore becomes real

#

so you must remove it unless you want duplicating lore

#

Here's an example

woeful crescent
#

interesting

echo basalt
#

You gotta remove all the fake lore and re-add it on the item

#

I believe there's the WINDOW_ITEMS packet that actually has an extra field for the item on the cursor

#

the code example doesn't include it (because I didn't push the latest version) but you must handle it otherwise dragging an item will make it seem like it has no lore

woeful crescent
#

uhhhhhhhhh

#

I'm confused

#

all im doing is sending the client a different item, I thought

echo basalt
#

Well

woeful crescent
#

Like if I tell the client something different why should that affect what the server thinkks the cliebnt's inv is?

echo basalt
#

The creative inventory is a clusterfuck to say the least

woeful crescent
#

well i mean, I'm not really talking about creative here

echo basalt
#

Also items are mutable and such

woeful crescent
#

So like

#

I'm confused

#

A player isn't in creative, and gets sent a differnet item than is actually in their inventory. Why does that actually affect their inventory?

#

Maybe i need to clone the lore since lists are mutable?

#

Nah

#

yeah it already does that in getLore()

echo basalt
woeful crescent
#

I used a command that prints the item's nbt

#

and it outputted all those lines

#

for some reason

crisp steeple
#

@woeful crescent hopefully didnt miss anything

Field[] fields = _packet.getClass().getDeclaredFields();
Arrays.stream(fields).forEach(f -> {
    try {
        f.setAccessible(true);
        net.minecraft.server.v1_8_R3.ItemStack item = (net.minecraft.server.v1_8_R3.ItemStack) f.get(_packet);
        if (item != null) {
            ItemStack itemStack = CraftItemStack.asBukkitCopy(item);
            // do stuff to itemstack
            f.set(_packet, CraftItemStack.asNMSCopy(itemStack));
        }
    } catch (IllegalAccessException e){
        e.printStackTrace();
    }
});
echo basalt
#

yeah that's the NMS version

#

Let's like

#

rewrite this code a little

#

There are 2 packets to worry about

woeful crescent
#

That's the serverside nbt

crisp steeple
echo basalt
#

SET_SLOT, which just has an item and a slot index
WINDOW_ITEMS, which has the entire inventory and the cursor, one is an itemlist and the other is just an item

woeful crescent
#

yes, that's what i did

echo basalt
#

ight

#

The items in the modifier array are also mutable

#

I believe that's where your error is

woeful crescent
#

Yes

#

Does the server use that array for anything other than being sent to the plauyer?

echo basalt
echo basalt
#

On later versions it's a list

#

try creating a new array and writing it on the packet

#

instead of modifying the existing one

woeful crescent
#

Got it

#

that makes sense

quaint mantle
#

Would anyone know how I would teleport a list of players to a location e.g.
ListOfPlayers.teleport(location)

echo basalt
woeful crescent
#

Loop through all of them

#

^

echo basalt
#

how lazy are you to the point of avoiding a for loop

quaint mantle
#

yea sorry its 1am my brain aint functioning

woeful crescent
#

lol

quaint mantle
woeful crescent
echo basalt
woeful crescent
#

It can automatically iterate through any collection and arrays too

echo basalt
#

iterators are kinda weird with for loops

quaint mantle
#

dont be mean im new to this

echo basalt
#
for(Iterator<T> iterator = ...; iterator.hasNext();) {
  T object = iterator.next();
}
#

But iterators aren't really used nowadays

woeful crescent
#

at least it was for me

echo basalt
#

I never really struggled with for loops

#

But I see how people might

ivory sleet
#

Iterators are pretty much not touched nowadays yeah

echo basalt
#

only place I see it nowadays is BlockIterator

ivory sleet
#

removeIf, stream and forEach have little overhead but offers better abstraction

#

Mye

echo basalt
#

I understand removeIf (helps avoid CME)

#

But I stay away from the rest due to personal preference

ivory sleet
#

Mye

#

Well I just believe it gets a bit more readable by eliminating some boilerplate but none is superior fr

echo basalt
#

I just don't see the need for a method that runs a for loop

#

But eh you do you

ivory sleet
#

Mainly due to abstraction

#

But that’s kinda a non sense argument depending on pov

echo basalt
#

Yeah

#

Anyways

#

fun thing I discovered lately

ivory sleet
#

:0

echo basalt
#

The offhand key sends packets even when there's no item

#

Which is extremely useful for specific projects (like those "minecraft but.." videos)

ivory sleet
#

Not that I flirt with packets that often but certainly interesting ngl

echo basalt
#

Because you can trigger actions and have it act as a hotkey

ivory sleet
#

Oo

echo basalt
#

I just made a basic protocollib action that calls a custom event

young knoll
#

Yep

echo basalt
#

and made mob basketball

young knoll
#

You don’t event need packets

#

There’s an event

echo basalt
#

Yeah

ivory sleet
#

Epic

echo basalt
#

but I already had the packet code before I noticed that the event existed :(

ivory sleet
#

🄲

echo basalt
crisp steeple
#

theres a lot of interesting packets actually

#

especially the animation ones

echo basalt
#

there's a packet to force a player's fov

echo basalt
#

time to make a camera plugin with smooth transitions and zoom shots

vestal barn
#

my plugin is saying [00:27:18 ERROR]: Could not load 'plugins/PowermageCore.jar' in folder 'plugins' org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml at java.lang.Thread.run(Thread.java:833) [?:?] Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml when the plugin.yml is there

quaint mantle
#

can you show us ur plugin.yml?

echo basalt
#

he doesn't have one

vocal cloud
#

Is it there though

echo basalt
#

or didn't put it in the right folder

#

most likely

tender shard
quaint mantle
echo basalt
quaint mantle
#

ahhh

vocal cloud
#

org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml

tall dragon
quaint mantle
upper niche
quaint mantle
#

what IDE are you using?

quaint mantle
tender shard
#

open your .jar with winrar / 7zip / etc and you will se that there is no plugin.yml

quaint mantle
echo basalt
#

That one is nice

upper niche
#

thanks

echo basalt
#

I also have a packet tutorial on spigot if you want to send packets through ProtocolLib

quaint mantle
echo basalt
echo basalt
#

The tutorial is a bit outdated

quaint mantle
tall dragon
#

yea thats the problem with nms

echo basalt
#

my experiences with NMS were just me messing around trying to make entities walk to places and make fake block break packets

tall dragon
#

its always outdated

echo basalt
#

It's quite hard to make something long-lasting because understanding NMS is like

#

active work

#

not something you can learn and remember in 3 years

#

you gotta decompile half the code and guess a lot

quaint mantle
#

I personally like writing plain nms but I cant understand a word I am writing lol

#

maybe I will give protocollib a go

tall dragon
#

nms is a full time job šŸ˜‚

echo basalt
#

ProtocolLib is just for sending packets

#

has some util methods

#

metadata packets on protocollib are kinda painful to write

#

or client-side entities as a whole

tawny otter
#

Any Efficient way to detect if a player/entity is exposed to rain?

tender shard
echo basalt
vocal cloud
tender shard
#

did you already upload it somewhere?

tawny otter
vocal cloud
tender shard
upper niche
#

thank you

crisp steeple
#

np

tender shard
upper niche
#

looks like someone can't look down the line of suggestions

tender shard
#

to check for rain, simply get the uppermost block at the player's position and then check if the player's height is below or above it

#

World#getHighestBlockAt

tall dragon
#

why not just use getPlayerWeather??

tender shard
golden turret
#

which event is called when a wither/ender dragon breaks a block?

tall dragon
#

EntityChangeBlockEvent iirc

quaint mantle
golden turret
#

aaa

#

change block

#

🤔

quaint mantle
#

yea then just check if the entity is an enderdragon

crisp steeple
#

bungeecord wildin

ember estuary
#

what packet is sent to players if someone opens a chest?

#

(so that it plays the chest open animation+sound on their client)

tall dragon
#

probably multiple packets tbh

#

one for the animation one for sounds and one for the window items ig

echo basalt
#

BLOCK_ACTION

#

and it uses some weird internal IDs that change every version

#

on 1.16.5 it was 18970 for trapped chest and 22969 for regular chest

ember estuary
#

i see, tyvm

tall dragon
#

mc operates in mysterious ways :d

echo basalt
#

where each id has a blockstate

#

chest-open, chest-closed

outer pond
#

^

echo basalt
#

etc etc

tall dragon
#

ah, alright

tender shard
#

Are there any other commonly used map or collection interfaces/classes that I forget in this list?

Collections

  • List
  • ArrayList
  • Set
  • HashSet
  • LinkedList

Maps

  • Map
  • HashMap
  • LinkedHashMap
  • EnumMap
echo basalt
#

ConcurrentHashMap

#

EnumSet

tender shard
#

thx

echo basalt
#

Sometimes people use IdentityHashMap

tender shard
#

oh yeah that one is also nice

tall dragon
#

Dequeue?

echo basalt
#

Queue, Dequeue

#

ConcurrentLinkedQueue

tender shard
#

alright that's already 6 new things I can add lmao

echo basalt
#

iterator 🤔

tender shard
#

but that's neither a map nor collection šŸ˜›

tall dragon
#

TreeMap

echo basalt
#

uh

#

[]

tender shard
#

oh yeah treemap is good

#

I already got arrays

tall dragon
#

PriorityQueue

echo basalt
#

ResultSet (sql)

tender shard
#

I won't need resultset

tall dragon
#

Hashtable!

tender shard
#

noone is going to store a REsultSet in a PDC lmao

echo basalt
#

oh yeah hashtable

tall dragon
#

EnumSet

echo basalt
#

already mentioned

tall dragon
#

where

#

ah

#

sowwy

#

yea thats all i can think of

lavish hemlock
#

Hey

#

Do I use java.util.logging.Logger or Log4j2 in my plugin?

tall dragon
#

that.. depends on ur needs ig

lavish hemlock
#

I just wanna log shit lol

tall dragon
#

if its just some simple logging i woulnt go for Log4j but i guess its also preference

tender shard
#

oh wait

#

EnumSet is abstract

#

what's an impl of EnumSet?

#

Queue is also abstract

#

Deque is also abstract

vocal cloud
#

You can find usages to find out

echo basalt
tender shard
#

I didnt find any for EnumSet

echo basalt
#

call it with the enum class

#

and then add your elements

#

EnumSet.of...

tender shard
#

oki

#

thx

echo basalt
#

there are 2 impls

tender shard
#

lol wtf is a JumboEnumSet

echo basalt
#

depending on size

tender shard
#

how much is Jumbo? šŸ˜„

echo basalt
#

Jumbo is for really big sets

#

64

tender shard
#

hm I wouldnt call that really big

echo basalt
#

well

#

how often do you make enums with 64 elements or more

tender shard
#

Material comes to my mind

echo basalt
#

that's the only one

tender shard
#

but yeha it's not common, you're right

#

what about Sound?

#

isn't that an enum too?

echo basalt
#

I guess

#

but would you really need an EnumSet for sound

#

I often use it for like 3-10 materials at most

tender shard
#

probably not lol

#
    static <D extends Enum<D>> CollectionDataType<EnumSet<D>,D> asEnumSet(final @NotNull Class<D> enumClazz) {
        return asGenericCollection(() -> EnumSet.noneOf(enumClazz),asEnum(enumClazz));
    }

so this creates an EnumSet that's empty, right?

echo basalt
#

yes

tender shard
#

perfect

#

I think that's enough builtin maps and collections now lol. If there's still anything missing, people shall just use asGenericCollection or asGenericMap

lavish hemlock
#

iirc the implementation of RegularEnumSet uses a bit field

#

While JumboEnumSet useeeess...

#

A long array

tender shard
#

yep

lavish hemlock
tender shard
#

quite interesting idea to do it like that lol

lavish hemlock
#

btw does AsyncPlayerChatEvent refer to the sending or receiving of chat messages

tender shard
#

it's when the player sends a message to the server

lavish hemlock
#

So basically sendMessage would fire a chat event?

tender shard
#

no, sendMessage is server -> client
AsyncPlayerChatEvent is client -> server

lavish hemlock
#

Or sorry yeah

tender shard
#

but

#

Player.chat()

#

would probablly call the event

worldly ingot
#

Last I recall, it does, yes

lavish hemlock
#

And specifying the sender in sendMessage makes it appear as if that person sent the message?

worldly ingot
#

No, because sendMessage() just sends the player a string of text

lavish hemlock
#

So then what does the sender parameter do?

worldly ingot
#

The sender UUID will determine whether or not the message should be ignored by the client

lavish hemlock
#

Oh

worldly ingot
#

(e.g. if ignored in the social menu)

#

So I mean, yes, you can associate it with a player if you really want

#

But sendMessage() is just a system message by default

tender shard
#

I just double checked. AsyncPlayerChatEvent gets called everytime the client sends a message to the server. Messages from the server to the client don't trigger anything

lavish hemlock
#

You don't do it in that packet

#

There's another packet for specifying window items

#

Yeah

tender shard
#

Since Player implements ConfigurationSerializable, I wonder if this could be abused for some funny stuff

lavish hemlock
#

What the fu-

tender shard
#

I thought it'd contain the attributes, potioneffects, inventory, PDC etc but no, just the name lmao

glass mauve
#

what is the equivalent to array[1::] (Python) in Java?

tender shard
#

what does that do in python?

glass mauve
#

if you have an array like [1, 3, 37, 18, ...], then it will create a new array without the first element, so [3, 37, 18, ...]

tender shard
#

ah okay, then it's this:

Object[] arrayWithoutFirstElement = Arrays.copyOfRange(originalArray, 1, originalArray.length);
glass mauve
#

thanks šŸ˜„

tender shard
#

?learnjava

undone axleBOT
tender shard
#

inventoryContents.length

#

btw that will always return the same size as the Inventory itself

torn shuttle
#

quick q does anyone know off the top of their heads an item that looks invisible when worn as a helmet?

tender shard
#

unless you're in creative

#

I guess

torn shuttle
#

doesn't count as a helmet for mobs unfortunately

tender shard
#

wdym with "count as helmet"?

torn shuttle
#

actually never mind I found a better way to do it, I think I was editing the wrong file earlier

tender shard
#

btw barrier won't work anyway lol

#

?learnjava

undone axleBOT
torn shuttle
#

yeah the helmet thing is a bit too good for its own good lol

tender shard
#

[x] is correct

glass mauve
#

[x] should work

tender shard
#
ItemStack tenthItem = inventoryContents[9];
#

but for real, go learn basic java

desert musk
#

CraftWorld isn't detected by my API still šŸ¤”

tender shard
#

did you add spigot as dependency?

desert musk
#

yep

tender shard
#

?paste your pom.xml

undone axleBOT
desert musk
#

ok hold on

#

it's different than what the others are though

tender shard
#

you did not add spigot as dependency

desert musk
#

didn't i?

#

uhh

tender shard
#

only spigot-api

desert musk
#

imma make a new project

desert musk
#

oh what's the difference

tender shard
#

spigot includes NMS, CraftBukkit etc classes

#

spigot-api only contains the API

desert musk
#

oh so i must've used api for this on e

tender shard
desert musk
#

ok yes i remember this

#

will do

#

i'll come back later if i have the problem again with spigot

tender shard
#

oki

nova fossil
#

I’ve just spent all day trying to update my plugin that uses NMS for 1.18
I give up

#

I’m gunna recode the entire thing, I can’t take it anymore, what I’m doing probably isn’t even possible anymore

tender shard
#

what's the problem?

echo basalt
#

when in doubt, abuse reflections

tender shard
echo basalt
#

unless you abuse them properly

torn shuttle
#

when in doubt jank it up till it works then ignore the jank for as long as possible

torn shuttle
#

nah

tender shard
outer pond
desert musk
#

also it is normal that the minecraft version for the spigot module plugin only goes to 1.18.1 right?

nova fossil
#

1.18 changed so much about the nms, I just have to recode it, I can’t use reflection anymore

echo basalt
#

then do whatever

glass mauve
#

bruh since yesterday I have to log in to the Minecraft Launcher every time again :/

tender shard
echo basalt
#

how do you think protocollib does it?

tender shard
echo basalt
#

if the version is 1.17.1, call method 1

#

otherwise, call method 2

tender shard
#

yeah why would someone use reflection for that

#

if it changes with every version anyway, just use maven modules

#

then you can use mojang mappings and don't have to rewrite your code for every update

#

reflection made sense when spigot had their own names for some stuff

#

since 1.17 it's just stupid

leaden gust
tender shard
#

I don't have to check whether "playerConnection"is now called "a" or "c" or "f"

#

it'll always just be "playerConnection"

#

e.g. this is for 1.18:

    private static Connection getPlayerConnection(final Player player) {
        return ((CraftPlayer)player).getHandle().connection.connection;
    }
#

and in 1.19 it will be the same

#

with reflection you have to make a list "a.c" in 1.18, "b.f" in 1.19, "y.d" in 1.20, etc

outer pond
#

Quick pseudo code

Player player = ...;
final Class<?> playerConClass = Class.forName("net.minecraft.server.network.PlayerConnection");
Field playerConField = Arrays.stream(player.getClass().getDeclaredFields())
    .filter(field -> field.getType() == playerConClass)
    .findAny()
    .orElseThrow(IllegalStateException::new);
// TODO
echo basalt
#

that also works ye

#

just loop through the fields

outer pond
#

Why's that?

tender shard
#

the Connection field has the type ServerGamePacketListenerImpl

#

and only that has a field of type Connection

#

in 1.17, your code would work

torn shuttle
#

god I wish I could just go to the gym rn instead of sitting here trying to make mobs sit still

tender shard
#

that's why it was "player.connection" in 1.17 but "player.connection.connection" in 1.18+

torn shuttle
#

wouldn't work, it's an intricate set of things they need to do / not do

outer pond
#

This is 1.18 code, b is the connection

torn shuttle
#

I got it down already just messing with leather color parsing at this point

echo basalt
#

it's like 2am

tender shard
echo basalt
#

I could go to bed

torn shuttle
#

it's 2 am, I could go to the gym if 24 gyms were legal

echo basalt
#

or I could be messing with throwable mobs and projectile-like thrown items

torn shuttle
#

24h*

outer pond
tender shard
#

oh huh

outer pond
tender shard
#

wait

outer pond
#

This is without mappings btw

tender shard
#

then what you sent is 1.17 code?

torn shuttle
#

would you look at this sexy looking gentleman up on these roofs

#

he's looking dapper

outer pond
#

My pseudocode wont work because I accidentally used CraftPlayer instead of the EntityPlayer handle

#

But the concept is the same, you can loop the fields

echo basalt
#

can't think of a way to optimize it further without making a block removal queue that would look weird

tender shard
#

1.18+

    private static Connection getPlayerConnection(final Player player) {
        return ((CraftPlayer)player).getHandle().connection.connection;
    }

1.16

    private static PlayerConnection getPlayerConnection(final Player player) {
        return ((CraftPlayer)player).getHandle().playerConnection;
    }

so yeah newer versions have something "inbetween" the player and the actual connection

torn shuttle
outer pond
echo basalt
tender shard
#

yes, 1.18 thing is with mappings

echo basalt
#

if I hold F

#

it spams the pickaxes

torn shuttle
outer pond
#

Well without mappings it's easier to figure out what's actually going on under the hood

echo basalt
#

imagine using mappings

outer pond
#

Oh they can be useful

echo basalt
#

I just look at a() and b() all night

tender shard
outer pond
#

But I couldn't be bothered yet to set up mappings for my small use cases kekw

torn shuttle
#

aaz(1 * 320 / math.pi * 2); //todo: document this

crisp steeple
#

nms field names are so fun

echo basalt
torn shuttle
#

pretty sure somewhere in the now nearly 1k classes of my plugin I put down a comment saying something like "I know this isn't a good solution but you try to figure a better one out"

echo basalt
#

so that's why copilot suggests me that crap all the time

outer pond
#

My best comment so far, took me pretty long to write and literally no one will ever read it because I decided to throw the project away lul

torn shuttle
#

ah yes

#

971 classes

#

I knew it was close to 1k

glass mauve
tender shard
#

and the angle is the angle, who would have guessed šŸ˜›

outer pond
torn shuttle
#

for some reason math comments tend to be the longest

#

I used to have my own rotation matrix and boy was the comment for that long

glass mauve
#

bc math is complicated

tender shard
torn shuttle
#

lol who comments classes

glass mauve
#

xD

torn shuttle
#

the name of the class is the comment

tender shard
glass mauve
#

holy f*ck

torn shuttle
#

ya see your problem there is that the class name should be that entire comment

echo basalt
#

ew what the fuck

echo basalt
#

top-tier comments right here

outer pond
tender shard
glass mauve
#

true

torn shuttle
#

who needs comments, not I

echo basalt
#

I'm the kind of guy that makes nice looking comments for obvious things

outer pond
#

I mean it explains the method, maybe you could put a few more articles in there but that's about it

echo basalt
#

And also apology letters at the top of the class

torn shuttle
#

I always dedicate every single class to someone who inspired me in my life

glass mauve
echo basalt
torn shuttle
outer pond
torn shuttle
#

I have 1k classes

#

they all say the same thing

glass mauve
#

I have 6 šŸ˜„

echo basalt
#

I think I have 200?

torn shuttle
#

I never said it was going to be different people

echo basalt
#

not sure

echo basalt
#

my ssd is so empty that intellij broke indexing

#

hm ok I can see why

tender shard
torn shuttle
#

meanwhile I'm just vibing with my 8tb NAS

outer pond
#

That's quite a small ssd lul

echo basalt
#

I can fit the entire shrek movie in about 2 pixels worth of quality

tender shard
glass mauve
#

68mb should be enough

outer pond
#

When I built my pc I decided to cheap out and buy a 120 GB ssd, I regretted my decision pretty much immediately

echo basalt
#

I have like 20gb worth of projects idk what to delete

torn shuttle
tender shard
#

lol

torn shuttle
#

maybe you should start compressing them

echo basalt
#

the entire 120gb drive is just windows + coding stuff

torn shuttle
#

or at least get pictures of feet that aren't size 14+

tender shard
#

it's backups of my proxmox VMs. it only says 18TB in total because it's 4x10TB in a raid1. and it only says 3.73TB used because ZFS is extremely nice in compressing data

torn shuttle
#

also just saying 40tb nas costs very little

echo basalt
#

I'm still waiting for the day where I can make a gui on MS-paint and pass it through a scanner that renders it in-game

outer pond
echo basalt
#

damn

torn shuttle
#

you can buy hdds in size 8tb or 10tb for peanuts compared to years ago

tender shard
#

true, but backups would take forever with my home internet

echo basalt
outer pond
#

I've never deleted a single project, still have all of my beginner stuff

tender shard
#

oh Magma, you're the ELiteMobs dude

#

didn'T know that

torn shuttle
tender shard
#

I think there's an EliteHooks.class in like 30% of my plugins lol

torn shuttle
#

what's your min wage

tender shard
#

erm

#

I mean

echo basalt
#

what the fuck

tender shard
#

EliteMobsHook.class

echo basalt
#

that's the price for like a 4tb cheapo drive here

torn shuttle
#

what you hooking up to?

#

like I said

#

storage is dirt cheap

echo basalt
#

ehh even then

kind hatch
echo basalt
#

I wouldn't use an 8tb hdd as my boot drive

desert musk
desert musk
#

CraftWorld is not found

outer pond
#

I wouldn't use hdd's at all anymore, my backup hdd's are terribly slow

tender shard
desert musk
#

definitely

tender shard
#

?paste your pom.xml again

undone axleBOT
desert musk
echo basalt
#

lemme delete my page file

#

shit's occupying 5gb

kind hatch
torn shuttle
tender shard
torn shuttle
#

some poor souls even still dump to magnetic tape

torn shuttle
#

yep that makes sense

outer pond
desert musk
#

I added the dependency by clicking on the modules for my project and adding the spigot-1.18.2.jar

#

is there more I have to do?

echo basalt
#

imagine not using 2 laptop hdd's on 45k hours each as a raid0 array

#

that is something I totally do not do

tender shard
torn shuttle
full forge
#

My hdd has a write speed at 2 mb/s at max

desert musk
torn shuttle
#

it's like a dishwasher or a washing machine, it's not blazing fast but you don't have to be there for it either

tender shard
#

this one? and still nothing happened?

#

Then do File -> Invalidate Caches -> tick all boxes and click "Invalidate & Restart"

desert musk
torn shuttle
#

bet you can get 100 tb of storage for under 1k if you buy during some specific sales or in bulk deals

outer pond
echo basalt
#

should I spend more than 2 days worth of lunch on a good ssd šŸ¤”

kind hatch
echo basalt
#

but then I lose the fun of having to wipe my drive every week

torn shuttle
outer pond
desert musk
#

thanks for your help as always

tender shard
#

:3

torn shuttle
#

I remember that one

#

honestly I am going to be fine with my 8tb for a good long while here so I'm not sweating the details

#

by the time I upgrade I'll probably be buying a 20 tb drive or something

#

and it will probably cost well under 300usd

tender shard
#

Proxmox Backup Server has support for tape backups lol

#

who do they think I am?! Pixar?! IBM?!

torn shuttle
#

google

echo basalt
#

why backups

#

just use googlecloud's 15gb of free storage

#

and abuse github

kind hatch
#

I thought tape was used for archival purposes.

torn shuttle
#

it is

tender shard
#

lol

echo basalt
#

yes

#

it's plenty

torn shuttle
#

but also as like the 3rd or 4th point of backups

echo basalt
#

stores like 2 projects and a picture or two

tender shard
echo basalt
#

and has blazing fast speeds of like 242 bytes / second

kind hatch
#

Who needs tape when you could use punch cards.

torn shuttle
#

it would be a little embarassing if mr putin threw a couple of nukes out and then suddenly the banks are telling us that they just don't remember who has how much money

#

so they keep that kind of data in tapes in bunkers

tender shard
torn shuttle
#

how sick must it be to have bunker in your business expenses

outer pond
torn shuttle
#

everything gets dumped to my NAS

#

I could set my computer on fire right now and I'd still have the files from 5 minutes ago on the NAS

outer pond
#

Maybe I should also start looking into backup solution, I would be really fucked if my drives would suddenly go up in flames haa

tender shard
echo basalt
#

I don't think I need a backup solution

kind hatch
#

I know I need to, but fuck it’s an expensive up front cost that I’m saving up for.

echo basalt
#

if any of my drives fail

#

I got all my code backed up

tender shard
torn shuttle
#

hm idk I never looked too much at timemachine

echo basalt
#

on google drive, important projects on github and on my work laptop šŸ¤”

torn shuttle
#

it just detects new files and file changes and dumps them to the backup

tender shard
torn shuttle
kind hatch
torn shuttle
#

yeah good example of why I spent 200 euros on a 8tb hdd instead

#

actually might've been less, I can't remember

outer pond
#

190€ for a Seagate 8 TB hdd

torn shuttle
#

I still got one of the better rated ones

#

for NAS applications

kind hatch
#

Also, hard drives will last FAR longer than an ssd. If you want a good setup. Use HDDS for storage and have an nvme ssd for a cache.

torn shuttle
#

eeeeeeeeeeeeh

#

ymmv there

kind hatch
#

ymmv?

torn shuttle
#

your mileage may vary

tender shard
#

are there any special kinds of collections or maps that do NOT allow null as value?

#

(i don't care about map keys, just the values)

crisp steeple
#

my C drive gets to 0 available bytes practically every other day

outer pond
tender shard
#

me too but better be safe then sorry

desert musk
#

why can't I resolve the symbol of my own main class :/

tender shard
#

then I can forget to allow null as value in my lib

torn shuttle
#

damned hippies

#

who needs to map trees anyway

tender shard
#

exactly, there isn't even a Tree API in spigot

outer pond
tender shard
outer pond
#

Yeah well good luck with that then lul

kind hatch
torn shuttle
#

gaddamn tree huggers get the hell off my lawn

desert musk
#

that's weird

#

java's picky sometimes and really loose other times

desert musk
#

uhh

#

ok so when i name my main class SoftcoreSMP then it cannot be referenced in other classes

#

"unknown symbol"

quaint mantle
#

import it..?

desert musk
#

can't

#

unknown symbol

#

lol

quaint mantle
#

screenshot

desert musk
#

ok

#

WTF?

#

it resolved itself i'm not joking

#

i swear to god

quaint mantle
#

yeah its called an IDE 😳

desert musk
#

make me look like an idiot

#

yeah but only after i deleted and then renamed the class :icant:

#

šŸ˜„

#

thanks intellij

sharp flare
#

what does this spicy thing mean in intellij first time to encounter it

torn shuttle
#

hey don't talk shit about my waifu intellij

desert musk
#

i aint talkin shit 😳

#

intellij by far best ide i've ever seen

#

but still an ide 😁

torn shuttle
#

jetbrains gave me a free year-long sub to all of their services and I'll be damned if I allow anyone to speak ill of my new waifu

desert musk
#

lol

desert musk
sharp flare
#

I use student account on jetbrains ez 1 year and renewal

tender shard
#

lombok ā¤ļø

outer pond
#

I'm still using a Jetbrains student license even though my last year of school was three years ago haa

torn shuttle
#

I already spent my student license

outer pond
#

But it will run out this year :/

sharp flare
#

oh ok, then my guess is correct with lombok

torn shuttle
#

and I am pretty sure it doesn't cover the whole array of intellij services either

tender shard
sharp flare
#

As I'm using Getters

desert musk
#

i wish c++ had it as good

tender shard
#

idk why they even give out ultimate to law students

quaint mantle
#

rust >>>>>>>>>>>

outer pond
desert musk
#

java makes me wanna learn rust

torn shuttle
tender shard
desert musk
#

cuz i already like cpp

outer pond
outer pond
tender shard
#

yeah RIP

torn shuttle
#

might be the case, might even be the case that wasn't the case years ago when I took my student license

tender shard
#

does anyone know whether arrays in java use integers as index?

torn shuttle
#

actually I'm not even sure rider existed when I started the license

outer pond
#

I'll have to pay my license in a few months, god Jetbrains is kinda expensive

tender shard
#

like can I do new ItemStack[Long.MAX_VALUE] ?

torn shuttle
#

it's easy

outer pond
#

lol

sharp flare
#

magma how is elitemobs doing currently, I missed grinding it myself back in the days

desert musk
#

omw to learn rust

outer pond
#

Ouch :(

torn shuttle
worldly ingot
sharp flare
#

what kind of endeavors

vocal cloud
tender shard
#

oh another question

worldly ingot
#

but yes, integers, not longs

torn shuttle
#

the arena is officially coming out after this long wait and primis chapter 2 is about to come out as well (both coming out before the end of the month)

tender shard
#

I have a List<Integer>, is it not possible to turn thisinto an int[]?

outer pond
#

Wasn't there a graduation discount thing?

torn shuttle
#

also the arena is a wild ride

worldly ingot
#

.toArray(int[]::new)

sharp flare
worldly ingot
#

Oh, that might actually give you a type error

#

Nevermind lol

tender shard
torn shuttle
# outer pond Ouch :(

yeah been there, paid one year then they showed up on stream, thanked me for using their services and gifted me a free year sub

tender shard
torn shuttle
#

ye

#

I even have the clip to prove it

tender shard
#

I'll just do mapToInt

worldly ingot
#

Yeah, stream and mapToInt

#

That's the only way you're going to inline that

torn shuttle
#

mr choco bring me money

worldly ingot
torn shuttle
#

do you miss the glory days of my music career choco

#

those were the days

worldly ingot
#

Truly something else

torn shuttle
#

I made $5 from it, still remember it

#

I believe that makes my music career more successful than 99% of artists out there because I lost no money and even made $5

glass mauve
#

I am just learning SPigot Plugin Development, give me some ideas that I can implement, but not too difficult šŸ˜„

torn shuttle
#

take a topological scan of the earth and recreate it in minecraft in a 1:1 scale

glass mauve
#

._.

#

give me one hour

torn shuttle
#

I mean the hardest part is trying to figure out how you're going to deal with the projection distortion

glass mauve
#

projection distortion?

torn shuttle
#

project a sphere to a plane and tell me how that works out

tender shard
#

lol people claim java has autoboxing/unboxing but sometimes it's not that trivial

glass mauve
tender shard
#

int[] from PDC to List<Integer>:

final List<Integer> nullValuesList = Arrays.stream(pdc.getOrDefault(KEY_NULL, DataType.INTEGER_ARRAY, new int[0])).boxed().collect(Collectors.toList());
nimble torrent
#

no

tender shard
#

also the annotation syntax for primitive arrays is weird

static List<Integer> intArrayToList(final int @NotNull [] array)

the @ NotNull has to be between int and []

torn shuttle
#

annotations are basically entirely jank

#

it does feel like it got tacked on at some point throughout java's development

tender shard
#

I find them very useful

torn shuttle
#

the best jank is also some of the most useful code out there

#

that's why no one gets rid of it

#

if I had to do getters and setters without lombok I'd be serving time for a string of assassinations of java developers at oracle after I lost my mind defining getter #100,203,120

vocal cloud
glass mauve
#

can you create your own Event Listeners like BreakBlock etc?

vocal cloud
#

Yup

tender shard
#

it'll tell you primitives can't be Nonnull

glass mauve
#

is there any good tutorial on that?

vocal cloud
tender shard
#

I am still using 8

vocal cloud
#

NotNull warns me but not Nonnull and it runs fine of course

tender shard
#

hm yeah maybe that'sthe problem then

crisp steeple
vocal cloud
glass mauve
#

ok ty

solid forge
#

Ello i am noob i need help
why does the code not work

@Override
Public void onEnablee(){

}

it says Syntax error
and also the method must override or implement a supertype method
please help

crisp steeple
#

I wonder why

glass mauve
#

typo

#

onEnable

solid forge
#

I wonder how

#

oo thankyou

#

it works :D

#

but still syntax error

glass mauve
#

and isnt public lower case

solid forge
#

ohh is it

#

yes it is
it is all shiny now

#

thx

vocal cloud
#

Dear God please learn Java first

#

😭

glass mauve
#

and get an ide xD

quaint mantle
#

?learnjava

undone axleBOT
solid forge
#

oh no

public void onEnable(){
 Bukkit.getLogger.info("hello how are you i am under the water uwuwuwuwuwu");
}

it says the field getLogger not found

solid forge
#

it says error
the dependency not resolved

crisp steeple
solid forge
#

but a field is also a method?
cuz if you consider the polymorphism field and methods should be one facet of two sides?

tender shard
#

stop trolling

solid forge
#

what

#

so how i solve that

#

add ()?

quaint mantle
#

?kick @solid forge trolling

undone axleBOT
#

Done. That felt good.

tender shard
#

lol

quaint mantle
#

check his old messages

glass mauve
#

xD

quaint mantle
#

he must have amnesia or is extremely retarded

solid forge
#

sorry mate sorry mate

#

sorry dude

#

just dont

#

dont do that again

#

emotional damage

hexed hatch
#

Do it again

glass mauve
#

Do it

solid forge
#

no pls

#

nooooo

quaint mantle
#

democracy šŸ™‚

solid forge
#

ok real question
how does bungeecord complete intent work

glass mauve
#

šŸ˜„

solid forge
#

like im trying to delay a bungeecord login event now
and maybe like delay it for 20 seconds or sth

#

like is the registerintent and completeintent async or sync?

tender shard
#

my next question about maps: is there ANY map that can store null as key more than once? I highly doubt there is but I wanna be sure šŸ˜„

#

maybe there is a weird map implementation that can store null <> something more than once and then returns a random one when using map.get(null) lol

solid forge
#

multimap?

tender shard
#

what does a multimap even do

#

never used it

#

let me look the javadocs

solid forge
#

multiple keys

solid forge
#

tbh null can be a key but its just weird