#help-development

1 messages · Page 954 of 1

slender elbow
#

and naturally the handlers list itself will also be in the companion object

modest tartan
#

Ok so how would I do the companion object, I don't intend to be fed but I haven't given them a look

ancient plank
#

kotlin is pretty easy to understand tbh, I can read it okay-ish but I can't write it because I don't know it

slender elbow
#
class BlahEvent {
  companion object {
    // ... static handler list stuff
  }
}
modest tartan
#

Yeah I'm still a bit lost.

#

I've got this ```kotlin
private val HANDLERS = HandlerList()

override fun getHandlers(): HandlerList {
    return HANDLERS
}

companion object {
    val handlers = HandlerList()
    fun getHandlerList() : HandlerList {
        return handlers
    }
}
#

Should I make the companion object extend event?

#

Cuz this doesn't work and I tried a couple guesses already that all didn't work still. The issue is that when I use the companion it can't find any of the pieces its looking for so idk how this helps. I know I'm not understanding something

tender shard
#

you are creating two separate HandlerList objects

modest tartan
#

I just got it figured out I think I have this now ```kotlin
companion object Event {
val HANDLERS = HandlerList()

    @JvmStatic fun getHandlerList() : HandlerList {
        return HANDLERS
    }
}
tender shard
#
class MyEvent : Event() {
    
    companion object {
        private val HANDLERS = HandlerList()
        
        @JvmStatic
        fun getHandlerList(): HandlerList {
            return HANDLERS
        }
    }
    
    override fun getHandlers(): HandlerList {
        return HANDLERS;
    }
    
    // Other stuff
}

sth like this should do

modest tartan
#

Yup

#

Appreciated

#

Thank you both

tender shard
#

(the whole design is flawed anyway though lol)

modest tartan
#

What design is flawed?

tender shard
# inner mulch How?

I meant bukkit's event system, not the code sent. It feels pretty weird to require BOTH, a static get handler method, AND an instance method returning the same handler list. should be a registry taking in a Class<? extends Event> instead or sth

young knoll
#

We didn’t have generics back then!

sullen marlin
#

pretty sure it's done that way as an 'optimisation'

#

no map.get(..) call, baked into the event itself

young knoll
#

Event system overhaul when

remote swallow
#

when we do mor ebreaking changes

#

we can make y2k write all the commodore

tender shard
sullen marlin
#

static method is for registration

#

instance method is for calling

tender shard
#

Ah ok

remote swallow
#

does the server lag if i registered my player move event listen 25 times

young knoll
#

These days you could avoid the map.get with like

#

A collection of consumers

tender shard
sullen marlin
#

no, because how do you get the consumers for an event

remote swallow
young knoll
#

Right

#

Oh I know, ASM!

tender shard
#

Gson somehow is able to get around type erasure or sth

sullen marlin
#

think you're both missing the point

tender shard
#

Probably

sullen marlin
#

the point is it eliminates a Map<Class, EventConsumerCallerThingyMajig>

tender shard
#

I‘m a coding noob, dont ask me questions or assume that I know things

young knoll
#

Lol

sullen marlin
#

because rather than map.get(event.getClass()) you just have event.getEventConsumerCallerThingyMajig()

tender shard
#

All i know is that kotlin is great (pls dont ban)

ivory sleet
#

banned

remote swallow
#

conclube

#

have you ever heard of cat ears

tender shard
#

Again? Conclube?

ivory sleet
#

yea :,)

ivory sleet
young knoll
#

Conclube gave me my ears

#

Remember

remote swallow
#

i wonder if conclube happens to have 6 bucks spare

#

hes poor so probablynot

young knoll
#

So are you

ivory sleet
#

Hmm I can see what I can do once I get home

#

Im in italy rn

remote swallow
#

why are you there

#

of all places

young knoll
#

He went to grab a pizza

remote swallow
#

might run into the one who we wont name

ivory sleet
ivory sleet
#

Did I miss someone?

remote swallow
#

who is supposedly from italy

#

that we wont name

ivory sleet
#

Idk

#

Pope?

remote swallow
#

conclube

#

use brain cells

ivory sleet
#

the one who I banned?

remote swallow
#

maybe

ivory sleet
#

ah ok

remote swallow
#

idk if you banned them

young knoll
#

Yeah he banned the pope

native gale
#

In which order plugins are loaded?

remote swallow
#

i think its just alphabet

native gale
#

Hm, okay

tender shard
#

nope

#
  1. output of listFiles()
  2. sorted by their "load order" in plugin.yml
remote swallow
#

well yeah

#

im pretty sure list files is alphabet

tender shard
#

that means:
on linux: random
on windows: by alphabet

and then ofc by their depend/softdepend

tender shard
remote swallow
#

ah

tender shard
#

definitely windows goes by alphabet but linux doesnt, so I assume linux goes by inode

#

macOS: no clue, probably inode too

inner mulch
#

can i set entitytype.snowball invisible?

#

setInvisible didnt work

tender shard
#

send your code please. it should work. iirc it's possivle to make eggs invisible, so it'd be weird if snowballs wouldnt work

inner mulch
#

does it maybe have to do with the fact that im doing it with packets?

tender shard
#

?nocode :p

undone axleBOT
#

It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.

sleek estuary
#

Is it recommended to check to avoid overflow even though it is not likely to happen?

inner mulch
# tender shard ?nocode :p

i will try it with api first, if that doesnt work i will send the code, i think my packet usage is the problem

worthy star
echo basalt
#

It's only used by minecademy ppl

worthy star
#

it looks good tbh

native gale
#

Idk, I avoid plugins that use this

#

Because it once mangled my server.properties

worthy star
#

how?

native gale
#

And it was a huge headache to figure out what exactly caused that

native gale
#

At the same time it saves it in wrong encoding

echo basalt
#

mm auto registering

#

fancy

#

I hate anything that scans shit with reflections and auto registers magic

native gale
#

Since my motd contains Japanese characters, every time I started a server it was turning into mahsed potato of symbols

worthy star
#

so its not really good

native gale
#

Idk how good it is, I avoid it

worthy star
#

i mean, the bro spent so much time on it

echo basalt
#

The code's clean but it's just not great

worthy star
#

each package has packages with classes

echo basalt
#

and the reputation it brings is whatever

inner mulch
#

?paste

undone axleBOT
echo basalt
worthy star
#

real

echo basalt
#

And if you want to disassociate one day you're fucked and have to learn everything again

tender shard
worthy star
#

best thing is
learn how the original thing works
make your own private api

sleek estuary
tender shard
#

I even have to do things like this:

does Bukkit.getPlayer(playerName) actually return something in PlayerDeathEvent?

Because some plugins create a fake player and stuff like that... so yeah, better check twice!

#

in fact I got 3 NPC checks lol

sleek estuary
#

if player was null, it would throw a nullpointerexception when executing player.getname

tender shard
#

(for example Citizens iirc? Or another NPC plugin, I don't remember)

sleek estuary
tender shard
#

because that plugin calls that event

#

spigot itself doesnt call the event, but the respective NPC plugin calls it

native gale
tender shard
#

where 277 is this

sleek estuary
#

1112 omg -'

remote swallow
#

where Bukkit

tender shard
maiden thicket
#

TRUE Bukkit.getServer the goat

tender shard
#

preferring static hacks over the DI'd server instance? epic, fr?

remote swallow
#

Bukkit.getPlayer > Bukkit.getServer().getPlayer > PLUGIN#getServer().getPlayer

tender shard
#

No.

maiden thicket
#

TRUE

native gale
#

I prefer the last one btw

sleek estuary
maiden thicket
#

Bukkit#getPlayer easier to write fr

tender shard
#

passed server instance > Bukkit.get....

native gale
#

Because I do that in Kotlin and it lets you just write

#

server.getPlayer()

tender shard
#

I'm a lawyer and not somebody who studied O(n^2) shit lol

maiden thicket
#

also

#

plugin.getServer = Bukkit.getServer

sleek estuary
# tender shard where 277 is this

here is not the player instance, you used bukkit.getplayer. If this is within that spawnangelchest method, why didn't it just pass the player instance?

maiden thicket
#

same reference

#

it comes from Bukkit.getServer

tender shard
maiden thicket
#

no im looking at paper right now

#

no idea what mockbukkit is

tender shard
#

for unit tests it's pretty normal to pass in a custom class implementing Server

maiden thicket
#

this isn't a unit test

#

they initalize the Server field in the javaplugin class with bukkit.getserver

tender shard
#

no ofc not, but that class is tested through unit tests?

maiden thicket
#

idk

tender shard
#

why would I rely on the static Bukkit.getServer() if I already got a Server object?

maiden thicket
#

easier to type and they reference the same thing so tbh it's not a huge issue

tender shard
#

easier to type? does your IDE not feature auto completion?

maiden thicket
#

Bukkit.getServer() versus creating a variable to reference my plugin just to access getServer

river oracle
#

tbh Bukkit#getServer only makes sense if you don't already have a plugin instance

#

that's what alex is insuating

maiden thicket
#

well yeah but there's no negative differences

tender shard
maiden thicket
#

or impacts

#

it's honestly just depending on the developer

river oracle
maiden thicket
#

okay man

#

🤓 ☝🏾

sleek estuary
#

If it takes into account performance, using bukkit.getserver is better. if it takes organization it is debatable

tender shard
#

please explain how it's better, and please also explain how (if it's true) it's not considered premature optimization

#

and I know that many of this stuff is very bad

#

remember, I did not study computer science, and this code was written by me in 2018, when I just started coding

maiden thicket
#

public fields go brrr

sleek estuary
young knoll
#

If you already have a server instance Bukkit.getServer is an extra method call

#

But yes it does save like

#

8 bytes

tender shard
young knoll
#

Sorry, 4 bytes in most cases

maiden thicket
#

pretty sure the memory difference is very minimal yeah

#

allocating a reference to ur plugin vs just accessing it through bukkit

young knoll
#

What will I do without those 4 bytes!

sullen marlin
#

Think of the garbage collection overhead

maiden thicket
#

pretty sure the allocation to the plugin instance is constant runtime

sullen marlin
#

/s

maiden thicket
#

man md_5 just

#

make getServer() private

young knoll
#

Even worse, if my heap is over 32gb it’s 8 bytes!!!!!11

maiden thicket
#

make everyone access thru reflections

#

do a little trolling

#

late april fools update

tender shard
#

tl;dr: yeah I know that my code isn't great. but there's no point in rewriting sth that's working fine

maiden thicket
#

we dont judge for old code

#

trust

river oracle
tender shard
maiden thicket
#

TRUE

grave notch
#

Ok, I'm sure I could've somehow found this out myself but I can't for the life of me figure this out. When I take the decompiled classes for a 1.12.2 or a 1.8.8 version of minecraft from the decompile-latest folder after running BuildTools, there are a few files that have decompile errors with seemingly no patches associated with those files. The one file I'm really stuck on right now is the PlayerSelector.java file, is there something else that spigot does other than patch files that I'm not aware of?

sullen marlin
#

Spigot doesn't use all the files

#

So if you're adding a new file you need to fix the error yourself

maiden thicket
#

i was highkey waiting for someone ty say 🤓 we don't support 1.8.8 and 1.12.2 here

inner mulch
river oracle
sullen marlin
#

Decompilers aren't perfect

inner mulch
sullen marlin
#

Hide entity / set visible by default

tender shard
young knoll
#

Can’t you theoretically set their item to air

#

Or does that explode

inner mulch
#

i cannot hide it because then i cant make it setpassenger

sullen marlin
#

Though if the method is on Entity it should probably work, although that's like the invisibility potion type of inviaibit

inner mulch
#

1.20.4

sullen marlin
#

So if you can't splash potion it Mojang probably doesn't support it

sleek estuary
grave notch
#

right, so if I just don't include that file it will still compile? I'm sorry I do not know about the custom POM setup Spigot likely uses to accomplish that and I'm just trying to set up a server that I can directly mod for quick experiments, and am not sure how Spigot can get away with not fixing those decompile errors despite BuildTools logging that it decompiled the class

sullen marlin
#

Because it uses the compiled class

#

Spigot patches like < 20% of the server or something

tender shard
sleek estuary
#

md_5 are you the dev of velocity?

inner mulch
#

so eggs cant be invisible?

tender shard
inner mulch
#

is there any entity with not hitbox which can be invisible

sullen marlin
young knoll
#

Did you try setItemStack

sleek estuary
inner mulch
#

im not using dropped itemstack

young knoll
#

Or setItem or whatever it is

inner mulch
#

i have a real egg

young knoll
#

Yeah but projectiles have a method for that too

grave notch
#

ok so what makes Spigot use compiled classes in place of source files during jar creation? There's like 10 POM files and I am not good with Maven lol

inner mulch
#

hmm

#

ok

#

i will try

tender shard
young knoll
#

ThrowableProjectile#setItem

sleek estuary
inner mulch
tender shard
sleek estuary
#

When they ask you this, include my name with my projects

sullen marlin
sleek estuary
#

Thank you for your attention

inner mulch
young knoll
#

Try with something other than air

inner mulch
young knoll
#

Alright then it doesn’t like air

inner mulch
#

maybe it would work but the itemstack creation doesnt work?

#

can i create a itemstack of air?

young knoll
#

Yeah

inner mulch
#

yo what is Material.CAVE_AIR

young knoll
#

Cave air

rough ibex
#

its air that generates in caves

#

theres also VOID_AIR

#

just use AIR

inner mulch
#

it doesnt work tho

#

air itemstacks dont work

#

it just defaults to snowbal

#

l

young knoll
#

Well if you had a resource pack you could solve that

inner mulch
#

any ideas to create an entity with no hitbox, which can be invisible, but not hidden? invisible but still exists client side?

young knoll
#

Marker armor stand

#

Display entities

#

Interaction entity

inner mulch
#

problem is it has to be a perfect size like the snowball, so that i can make my hologram have lines

#

i need entities in between

#

i cannot use display entities as im supporting bedrock

young knoll
#

F

#

Bedrock sucks

inner mulch
#

i hate bedrock too, but crossplay servers are better as every1 can play on them

young knoll
#

Well with enough effort you can just use bedrock stuff for bedrock players

inner mulch
#

yes but there is no bedrock stuff

#

for this

#

or is it

#

*there

young knoll
#

Bedrock can have custom entities

maiden thicket
#

i saw that being done from the server side and i was like huhhh

swift void
#

oes anyone know of an plugin that can do something like the dungeons in the game Trove, where they are randomly generated around the world and have mobs placed inside them?

drowsy helm
worldly ingot
#

import de.jeff_media.daddy.Daddy_Stepsister

#

Nobody's gonna mention this?

rough ibex
#

nope

valid burrow
worthy yarrow
#
public class PetRegistry {

    private static Map<UUID, ChickenPet> chickenPets = new HashMap<>();


    public static void registerChickenPet(ChickenPet pet){
        chickenPets.put(pet.getPetId(), pet);
    }

    public static Map<UUID, ChickenPet> getChickenPets(){
        return chickenPets;
    }

    public static void unregisterChickenPet(UUID petId){
        chickenPets.remove(petId);
    }

}```
Any suggestions for more methods? I was thinking of refining the registry to take / store any instance of a pet class but didn't have the time to actually mess with it
spiral bramble
#

Hey there, I haven't touched plugin development in 5 years so I'm looking for some help with saving Player Data.

I've made PlayerData and WandData classes, and the yaml is saving as:

[[REDACTED]]: !!com.starfluxgames.basicwands.configurators.PlayerData
  wands:
  - amplifier: 1.0
    appliedPotion: BAD_OMEN
    cooldown: 10.0
    duration: 10.0
    self: true
    wandType: DIAMOND_SWORD

Although upon either reloading the config, it complains that Global tags aren't allowed !!com.starfluxgames.basicwands.configurators.PlayerData

I'm not sure if I'm missing something here. Any pointers are appreciated. Thanks

worthy yarrow
#

?pdc

spiral bramble
#

Thanks, wasn't aware of that I'll have a look into it.

worthy yarrow
#

It's the modern way to persist data nowadays so have some fun

spiral bramble
#

I'm guessing config files are still using FileConfiguration? Or has that changed too

worthy yarrow
#

iirc, yes should be fine

#

I still use fileconfiguration with no issues

spiral bramble
#

Brilliant thanks

worthy yarrow
#

No worries!

worthy yarrow
sullen marlin
#

maybe an AbstractPet for uuid, name, level

worthy yarrow
sullen marlin
#

yes but only the pet specific stuff

worthy yarrow
#

Right right yeah you're right

#

Considering the abstract bit, would I still implement the interface?

sullen marlin
#

yes

worthy yarrow
#

Right

#

Alright let me work on the abstractpet

#

and then probably just chicken abilities for now

#

I want to go for something similar to the saicopvp chicken pet where you take no fall damage and I'm pretty sure it changed your gravity iirc

glad prawn
#

naming it Pet is fine not need to AbstractPet

worthy yarrow
#

only reason it's abstractpet rn is because the interface is currently called pet lol

#

my psychology book says it's most likely because you eat when you think about that

#

or have in the past

worthy yarrow
#

If you're thinking about it that much then that's your likely answer lol

worthy yarrow
spiral bramble
#

Apologies if I'm misunderstanding PDC here,

I've got myself setup with

public class PlayerData implements PersistentDataType<byte[], UUID>

This is just storing a UUID correct?

Are there any examples on storing an entire serialized class? ie.

public class WandData {
    public String wandType;
    public String appliedPotion;
    public float duration;
    public float amplifier;
    public float cooldown;
    public boolean self;
}
#

^ Reading the examples for toPrimative and fromPrimative it looks like it's serializing the byte[] directly

worthy yarrow
spiral bramble
#

Yeah, so this is essentially breaking the string down into it's bytes directly

#

Oh boy this is gonna be fun

sullen marlin
#

put each value as a different pdc key and assemble it that way?

#

theyre all primitive typs

spiral bramble
#

I'm looking to store a List<WandData>

#

Ah I get what you're talking about now

#

Obviously I'd need some helper methods, but that's my idea

sullen marlin
#

yeah something like that

worthy yarrow
#

Looks fine to me

spiral bramble
#

I miss my JSON serialization 😂

#

Thanks, I'll see what I can get going

worthy yarrow
#

I was made aware of a cool thing with the namespacedkey: private static final NamespacedKey chickenPetKey = NamespacedKey.fromString("coolpets:chicken_pet_key"); requires no real instance of the main

#

this convo

worthy yarrow
tender shard
tender shard
tender shard
#

ah ok. besides that, looks good

worthy yarrow
#

i was refactoring everything to implement pet, interface was originally called pet

tender shard
#

why is your TaskManager a singleton? Why not just static methods?

#

And you're still not caching the namespaced key in line 20 of that paste

#

oh and what's runChickenTasks? 🥲

worthy yarrow
worthy yarrow
worthy yarrow
#
private final NamespacedKey chickenPetKey = ChickenPet.getChickenPetKey();

private static boolean isPetInsideInventory(Player player, UUID petId){
        for (ItemStack items : player.getInventory().getContents()){
            if (!(items != null && items.hasItemMeta())){
                return false;
            }

            ItemMeta itemMeta = items.getItemMeta();
            PersistentDataContainer container = itemMeta.getPersistentDataContainer();

            if (container.has(chickenPetKey, PersistentDataType.STRING)){

                String petIdString = container.get(chickenPetKey, PersistentDataType.STRING);

                if (petId.toString().equals(petIdString)){
                    return true;
                }
            }
        }
        return false;
    }

So is this fine?

#

I'll put it into a flat file later when I get to that bit

trim lake
#

Im working on custom autopickup plugin and how can I handle mending enchant? I kinda dont want repair item with own method and want to keep PlayerItemMendEvent to be called and let MC repair that item, is there any way? I want exp to be autopicked up (give to player) as well

tender shard
#

that's not how events work

trim lake
#

hmm, so it will not be possible in that case probably?

tender shard
#

you'll have to actually recreate the original mending behaviour. I'm currently greping my IntelliJ folder to find how I'm doing it, because I also had to do this once

trim lake
#

Im making that for server with using own custom durability of items and kinda want to be ezy to hook to it ideally true MendEvent. This custom durability is one of reasons Im making that autopickup plugin so 😄

trim lake
tender shard
#

ok weird - in my Drop2InventoryPlus plugin, I have commented out MendingUtils and it still seems to work somehow lol

trim lake
#

u are giving xp from breaking block directyl to player with Player#addXp (or how its called) method?

tender shard
#

tbf I have no idea what I am or was doing regarding XP

#

auto pickup plugins are a mess

#

tbh I really have no idea how I'm doing it in Drop2Inv. I only know that I'm only calling giveExp and somehow it works. I have searched the whole project for the "mending" string and I found nothing, but somehow it still works

#

I also looked into CraftPlayer#giveExp and there's no mention of mending either

worthy yarrow
#

ghost functionality 😄

trim lake
#

loooks like u are saving the ExperienceOrb from events (witch will be problem bcs Im cancelling exp drop) and probably mending will edit that orb and what left will add to player? Im kinda confused. But I was thinking about same method kinda... but will be pain to do it anyway lol

flint coyote
#

Well the mending is probably tied to xp increase instead of xp pickup. Therefore you don't have to explicitly do anything

tender shard
trim lake
flint coyote
#

oh alr

tender shard
#

was Enchantment.MENDING renamed at some point or sth maybe?

trim lake
#

nop

tender shard
#

then sorry, i have no clue how I was doing it

trim lake
#

no worries, so u are not seting xp drop in BlockBreakEvent for example? bcs Im setting it to 0 and before that I will do event.getPlayer().giveExp(event.getXp()) to prevent double pickup of them

#

I will try to find a way to let player pickup exp naturally somehow

tender shard
# trim lake no worries, so u are not seting xp drop in BlockBreakEvent for example? bcs Im ...
#

it references EventManager.giveAdjustedXP which I already showed above

trim lake
#

perfect I probably got it how I will do it, just spawn orb at player and should be good lol, kinda looks like u are doing that way

#

it shouldnt be picked up by another player hopefully

tender shard
tender shard
trim lake
#

I appreciate it that u shared the code! u are always soo helpful! thanks man

tender shard
#

np!

mint marsh
dawn flower
#

yo what's a good method to try to fix ghost blocks? if it's even possible serverside (i'm not asking for code i just want a method)

#

my idea is send block updates more frequently but i'm not sure if that's a good way

#

like maybe if you can ask the client for the blocks visible to it using nms

sullen marlin
#

ram requirements for everything just keep increasing

mint marsh
#

Thanks for the quick fix 🙂

onyx fjord
#

shouldve used reposilite

#

i think it needs like 48MB of ram

ivory sleet
#

Yea reposilite isnt such a bad software

pliant topaz
#

How would I get the the item a player has placed into a custom gui? Cause I cannot figure out how I'd get the item as when the event (InventoryClickEvent) is triggered it is still null

lost matrix
pliant topaz
#

yes, i need it to be detected when the item is placed in the inventory

#

the problem is i cannot get the slot where the item was placed and even if it'd be null apparently

lost matrix
#

Because the item is still on the cursor of the player at that point in time.

pliant topaz
#

ik

#

is there any way I could check in which slot the player wants to move th item into?

gleaming frost
#

Hello does anyone know how i can stop furnaces from dropping xp when broken? setting the blockbrokenevent exptodrop to 0 doesnt work.

ocean hollow
#

how can I remove 100 itemStacks from inventory?

public static void removeAmount(Inventory inventory, ItemStack itemStack, int amount){
    ItemStack cloned = itemStack.clone();
    itemStack.setAmount(amount);
    inventory.removeItem(cloned);
}

``` I wrote this, but it doesn't work
#

it only takes one item

ocean hollow
#

it does nothing, if I do it using Inventory#remove

ocean hollow
#

but I have 64 items, but I need to remove only 5, for example

mint marsh
#

for loop? 😅

ocean hollow
#

oh. ok 😦

mint marsh
#

I've never worked with inventories

lost matrix
ocean hollow
#

I did it using for, and everything works just fine

#

what is the difference between yaw, pitch and direction. One is in the angles, and the other is like a vector, don’t they describe where the player is looking, for example?

lost matrix
#

So you simply wrote the same logic which already existed again...

echo basalt
#

So if you look right your yaw increases type deal

#

The default value is 0 which is facing +Z iirc

#

Pitch is your up-down head rotation

#

So if you look up, the pitch increases

#

The default value is 0 which is facing straight ahead

ocean hollow
#

if I change the vector, will yaw and pitch change?

echo basalt
#

Your direction is what happens when you grab your yaw/pitch angles and you convert them to a Vector

#

So if you look up it's 0,1,0

#

The only way to change yaw/pitch is to teleport the player to the new position

#

That has the new angles

#

(Or force the player to spectate an entity that's being teleported)

ocean hollow
#

method by ChatGPT

    private static Location addLocation(Location location, double x, double y, double z){
        Location result = location.clone();
        double cosPitch = Math.cos(Math.toRadians(location.getPitch()));
        double sinPitch = Math.sin(Math.toRadians(location.getPitch()));
        double cosYaw = Math.cos(Math.toRadians(location.getYaw()));
        double sinYaw = Math.sin(Math.toRadians(location.getYaw()));

        double newX = x * cosYaw * cosPitch - z * sinYaw * cosPitch - y * sinPitch;
        double newY = x * sinYaw * cosPitch + z * cosYaw * cosPitch + y * cosPitch;
        double newZ = x * sinPitch + z * cosPitch;

        return result.add(newX, newY, newZ);
    }

    public static Location countLocation(Location location, double dX, double dY, double dZ){
        Location bulletLoc = addLocation(location, dX, dY, dZ);
        Bukkit.broadcast(Component.text(location.toString()));

        Vector oldDir = location.getDirection().clone();
        Vector newDir = new Vector(oldDir.getX() - dX, oldDir.getY() - dY, oldDir.getZ() - dZ);

        bulletLoc.setDirection(newDir);
        Bukkit.broadcast(Component.text(bulletLoc.toString()));
        return bulletLoc;
    }

I wrote this, but nothing happens. locations continue to be identical

lost matrix
#

What are you trying to do?

umbral ridge
#

don't use chatgpt

ocean hollow
lost matrix
#

To achieve a random spray pattern?

ocean hollow
#

so that the "display entity" flies out from the muzzle, and not from the player's eyes

lost matrix
#

This will depend on the client setting as well. Keep in mind that some people are left handed.

ocean hollow
#

I can ignore that other people are left-handed)

gleaming frost
#

Is it possible to access a furnaces inventory on the block break event ?

lost matrix
# ocean hollow I can ignore that other people are left-handed)

Here is what you should do:

  1. Trace the impact Location
  2. Change the origin Location to your gun
  3. Calculate the vector from impact to origin (convert to vectors and subtract [impact - origin])

This will give you a new Vector which points from your origin (the gun) to your impact.

lost matrix
rapid vigil
#

like pre command preprocess or pre async join etc

lost matrix
#

Probably just for clarification

rapid vigil
#

then they should add Pre to all event names :p

echo basalt
#

change the original eye location's yaw and pitch by a tiny amount before tracing

#

that's random spray

#

as for the gun thing yeah you need uh magic

quaint mantle
echo basalt
#

Looks AI generated

#

?gui

gleaming frost
echo basalt
#

You shouldn't compare inventory titles in the first place

quaint mantle
echo basalt
gleaming frost
#

casting to furnace?

lost matrix
ocean hollow
lost matrix
#

No you dont. The direction is literally defined by the pitch and yaw.

#

It only difference is that it also has a length

echo basalt
#

Which is usually 1

ocean hollow
lost matrix
#

What is dx dy and dz?
This looks a bit weird

gleaming frost
#

anyone know where the internal xp is stored of the furnace block?

ocean hollow
lost matrix
ocean hollow
#

thank you, now it works

ocean hollow
#

lol, but how can I find start gunLoc?

#
        Location result = location.clone();
        double cosPitch = Math.cos(Math.toRadians(location.getPitch()));
        double sinPitch = Math.sin(Math.toRadians(location.getPitch()));
        double cosYaw = Math.cos(Math.toRadians(location.getYaw()));
        double sinYaw = Math.sin(Math.toRadians(location.getYaw()));

        double newX = x * cosYaw * cosPitch - z * sinYaw * cosPitch - y * sinPitch;
        double newY = x * sinYaw * cosPitch + z * cosYaw * cosPitch + y * cosPitch;
        double newZ = x * sinPitch + z * cosPitch;

        return result.add(newX, newY, newZ);
    }``` I have this, but it is incorrect
#

if there is -1 for x or -1 for y, then it will shift down

#

moving forward is not a problem, but right/left, down/up

lilac dagger
#

did you try Vector direction = location.getDirection();?

#

assuming it's the direction you want

lost matrix
# ocean hollow ``` private static Location addLocation(Location location, double x, double y...
  public Location getGunLocation(Location eyeLocation) {
    // The hard part is finding those magic numbers.
    double forwardOffset = 0.5;
    double rightOffset = 0.3;
    double downOffset = 0.3;
    Vector direction = eyeLocation.getDirection();
    
    Vector adaptedForward = direction.clone().multiply(forwardOffset);
    Vector adaptedRight = direction.clone().crossProduct(new Vector(0, 1, 0)).normalize().multiply(rightOffset);
    Vector adaptedDown = new Vector(0, -1, 0).multiply(downOffset);

    return eyeLocation.clone().add(adaptedForward).add(adaptedRight).add(adaptedDown);
  }
spare prism
#

why does this command give me a default looking leather chestplate?

minecraft:give SunwooHan minecraft:leather_chestplate{
  Count:2b,
  tag:{
    Count:1b,
    Damage:0,
    id:"minecraft:leather_chestplate",
    tag:{
      Damage:13,
      Enchantments:[
        {id:"minecraft:thrive",lvl:2s},
        {id:"minecraft:unbreaking",lvl:4s}
      ],
      Trim:{
        material:"minecraft:diamond",
        pattern:"minecraft:silence"
      },
      display:{
        Lore:['{"italic":false,"extra":[{"color":"#D2ED87","text":"Идеальный волшебный нагрудник, для волшебников"}],"text":""}'],
        Name:'{"text":"","extra":[{"text":"Волшебный нагрудник","obfuscated":false,"italic":false,"underlined":false,"strikethrough":false,"color":"#D2ED87","bold":false}]}',
        color:10043692
      }
    }
  }
}
lost matrix
#

Not a development related question i would argue

spare prism
young knoll
#

Use McStacker

acoustic pendant
#

How can i have a string like this: 1,2,14,15,19 and split it to get every number? I'm thinking on using #split and a loop but not sure

worldly ingot
#

You’re thinking right

lost matrix
acoustic pendant
#

i''l try then

spare prism
#

got ya

#

but

#

i have to get all the nbt from an item

#

and apply it to the command

young knoll
#

Why do you need the command tho

#

The api is perfectly capable of giving an item to a player

spare prism
#

I'm making a plugin that would generate a /give command from an item in hand

#

it should support all the nbt data

#

PDC is not enough, cause it doesn't cover all the nbt

spare prism
young knoll
#

Well all the data will be part of the api

#

But it might be a bit of a pain

spare prism
acoustic pendant
# worldly ingot You’re thinking right
 String boughtPets = plugin.data.getConfig().getString("Available." + player.getName());
                    String[] ids = boughtPets.split(",");
                    int number = ids.length;
                    if (plugin.data.getConfig().getString("Available." + player.getName()) != null) {
                        for (int k = 0; k < number; k++) {
                            if (Objects.equals(ids[k], String.valueOf(petManager.getId()))) {
                                //code
                            }
                        }``` something like this?
spare prism
#

i just dont get why is the item a default one

lost matrix
acoustic pendant
#

thx!

young knoll
#

Seems you have an item tag within your item tag

#

Also wtf is the thrive enchantment

modern plank
#

how do i make an entity look at a certain location?

ruby ermine
#

How can I make enchantments on essentials kits such as from efficiency 5 to efficiency 9? If I enter 10 I only get efficiency 5

young knoll
#

You may have to enable the unsafe enchantment config setting

ruby ermine
#

thx it worked

proper cosmos
#

Is there anyway to cancel villager inflation from hit?

dawn flower
#
            ClientboundBlockUpdatePacket packet = new ClientboundBlockUpdatePacket(
                    new BlockPos(x, y, z),
                    Blocks.DIRT.defaultBlockState()
            );
            sendPacket(player, packet);```
what's the alternative to this in 1.20.4
chrome beacon
#

Just use the API?

lost matrix
#

Player#sendBlockChange()

dawn flower
#

yeah my little brain didn't realize that

#

just found it on accident

undone axleBOT
#

Please paste your pom.xml file, or build.gradle (or build.gradle.kts) if you're using gradle on the following website: https://paste.md-5.net/

dawn flower
#

so uh i sent a fake block update to the player and i want to listen for when he breaks the fake block, i used my tiny brain and thought of a packet listener but the thing is it sends 2 packets, one for when you start digging and one for when it's broken and i'm really confused, i tried to use my last 5 brain cells to debug the fields maybe there's a field that tells you if the block was broken was attempted to be broken but there are 0 fields

#

what should i do?

kindred sentinel
#

Is there any pom.xml tutorials?

dawn flower
lost matrix
# kindred sentinel Is there any pom.xml tutorials?

If you install the minecraft development plugin in Intellij and let it generate a default spigot maven project, then the pom is quite good.
pom.xml is basically a configuration file for your maven project.

dawn flower
#

yeah and if you need dependencies 99% of the time they provide a copy paste

kindred sentinel
#

like shading

#

I wanna try to make it by myself

dawn flower
#

you don't have to worry about shading tbh

#

pom.xml is usually covered on basic java tutorials so look for that

kindred sentinel
#

oh ok thanks

ocean hollow
#

the same with Random

ocean hollow
#

but it takes argument

chrome beacon
#

one in the IDE and another when compiling

chrome beacon
#

^^

golden tulip
#

Can I change the Bungeecord messages in the message.properties with a plugin?

valid burrow
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!

valid burrow
#

just try to make it

#

and if you are stuck at one point ask here

#

thats way more efficent than looking for a tutorial you will forget 2 days later anyways

grim hound
#

bruh

#

PlayerSpawnLocationEvent does not change the rotation

alpine urchin
#

good morning

grim hound
#

like it's a Location, you change everything BUT rotation?

grim hound
#

retroopaj

#

h

#

make em array instead of maps for your packet listeners

alpine urchin
#

you tell me to do a lot of stuff hm

grim hound
#

just this

#

cuz it hurts me knowing the performance could be this enchanced

alpine urchin
#

@grim hound i could optimize it kind of using EnumMaps technically

grim hound
#

okay lemme just rewrite that whole class for you

alpine urchin
#

no

#

do not

grim hound
#

array

#

is

#

speed

#

map is also speed

#

but array is more speed

alpine urchin
#

why u keep telling me what to do

alpine urchin
#

go make ur own project

grim hound
#

I am

grim hound
#

cuz now I have to TELEPORT the player

#

which is slower

#

than a location set

#

PERFORMANCE NOOOO

alpine urchin
#

having readable/understandable code is also important

#

and your idea makes it more difficult for people removing and adding listeners

#

later on

#

so i say no to your idea

grim hound
#

but it

#

s like 7 times faster

river oracle
#

I'm so confused what the fuck

        registerSubcommand(object : Command(CommandLabel("deserialize", "test.test")) {
            override fun execute(sender: CommandSender, args: Array<out String>?): Boolean {
                val player = sender as Player
                val deserialized: ItemStack = GenericAdapters.INSTANCE.deserialize(serialized, ItemStack::class.java)
                player.inventory.addItem(deserialized)
                player.sendMessage("Deserialized Stack")
                return true;
            }
        })```
`TestCommand.kt:25:13 'execute' overrides nothing`
#

it literally overrides something, I feel like I need to nuke gradle

eternal oxide
#

setting a location and teleport are the same under the hood

alpine urchin
#

again

#

but its already a no from me to accepting it

#

you can use reflection to replace my event manager with your idea on your own platform

river oracle
alpine urchin
#

and override my methods

grim hound
#

am just finishing

#

i'll send you the class

alpine urchin
#

no

#

i dont want it

grim hound
#

think it through

alpine urchin
#

bruv

grim hound
alpine urchin
#

on your own plugin that shades packetevents you can overide methods in my event manager

#

simple

#

does it the way you want

river oracle
#

but he wants you to instead to adopt his listener platform!

alpine urchin
#

that's a red flag

river oracle
#

no its not you just don't understand how its better. Providing an option to make your own is not good enough

alpine urchin
#

your sentence was written confusingly

#

but like if someone says no, continually trying to shove it up their throat for weeks or whatever isn't smart

#

sure you can make an issue on githbu and ill look at it

alpine urchin
#

show your code idea on github issues

#

your idea

#

or whatever

#

and ill just look at it

#

and we'll see

tidal glacier
#

Hey!

#

I urgently need help in my Minecraftbut plugins

#

I have the top quality plugins but are in Turkish language

#

Can anyone help me in translation

#

I am also ready to pay.

#

@alpine urchin hey!

tidal glacier
grim hound
tidal glacier
#

Actually I needed your help in translation

alpine urchin
#

@grim hound did not listen to me

grim hound
#

👍

grim hound
#

ain't it nice?

tidal glacier
#

I need your help, I can pay too!

alpine urchin
#

no

grim hound
alpine urchin
#

you implemented one method

grim hound
grim hound
#

I did all

tidal glacier
#

But these plugins are best quality... I am a Youtuber

alpine urchin
#

@tidal glacier hi

#

what u need?

tidal glacier
#

Hey!

#

I need help in translation of my plugins

alpine urchin
#

fom what language to what

tidal glacier
#

I have purchased these plugins for 150$ each

tidal glacier
alpine urchin
#

i only know english

grim hound
#

like I said

tidal glacier
#

You can use Google translator

alpine urchin
#

i can try using google translate to evaluate

alpine urchin
#

what it should be

#

okay sure @tidal glacier

#

lets talk in dms

tidal glacier
#

The problem is not translator

grim hound
#

ADD ME TOO

alpine urchin
#

dont add him

tidal glacier
#

The problem is how to translate the plugin.

grim hound
#

brah

alpine urchin
#

inside one method

tidal glacier
#

@alpine urchin
Accept my request

alpine urchin
#

u didnt incorperate priorities in my event system at all

alpine urchin
#

no unregister method uses your listeners array

#

some still use the map

alpine urchin
grim hound
alpine urchin
#

thought your idea was rely on arrays only

#

and ignore the map

#

so whats ur idea

grim hound
#

sorts the values by pritority

quaint mantle
#

can someone help me

hybrid spoke
quaint mantle
#

i’m trying to make an enchantment called QuickDraw and than another one called SwiftShot, these 2 can’t be on at the same time, can only be on a bow or crossbow, the first level of quickdraw pulls back the bull at 15% more, level 2 is 30% more, and level 3 45% more. SwiftShot makes the bow more accurate so the “bulletdrop” is smaller for when you are farther away.

quaint mantle
hybrid spoke
#

order executed

hybrid spoke
quaint mantle
#

i have tried to code it but i do all the steps i make the rarity, what it can be enchanted on, and all of that but then for the first one rn i have NO idea how to make the bow pull back faster

hybrid spoke
#

dont think you can fuck around with the bow since thats client sided iirc

#

but you can manipulate the velocity of the arrow if its shot sooner

tidal glacier
#

Hey!

quaint mantle
tidal glacier
#

@hybrid spoke
Hey!

hybrid spoke
warm bramble
#

Hi there, I'm trying to get my head around block display entities and having some troubles.

I am applying two transformation matrixes, which are only sort of working:

 float[] display1Matrix = {0.5000f,0.0000f,0.0000f,0.0000f,0.0000f,1.0000f,0.0000f,2.0000f,0.0000f,0.0000f,1.0000f,0.0000f,0.0000f,0.0000f,0.0000f,1.0000f};
float[] display2Matrix = {1.0000f,0.0000f,0.0000f,0.0000f,0.0000f,1.0000f,0.0000f,0.0000f,0.0000f,0.0000f,1.0000f,0.0000f,0.0000f,0.0000f,0.0000f,1.0000f};

display1.setTransformationMatrix(new Matrix4f(FloatBuffer.wrap(display1Matrix)));
display2.setTransformationMatrix(new Matrix4f(FloatBuffer.wrap(display2Matrix)));

display.addPassenger(display1);
display.addPassenger(display2);

The resizing of display1 works fine, it goes half the width like I would expect. However, I would expect it to be two blocks above display2, but they render inside each other within the game.

What is causing this? It's like the passengers can not exceed the width/height of the display itself, but I tried setting a height and width on the display and this did not help in any way.

Any ideas? Thanks

tidal glacier
#

Help*

hybrid spoke
hybrid spoke
warm bramble
#

No difference unfortuantely

#

The matries I provided works just fine via /summon

hybrid spoke
#

do they work without being set as passengers

warm bramble
#

As in as their own individual block displays?

hybrid spoke
#

yeah

warm bramble
#

Hmm, let me see

#

Looks like they still render the same

hybrid spoke
#

maybe its how you spawn them, their init location could be important as well

#

im not that experienced in transformation matrix's

warm bramble
#

I'm jusg using the location of the player

hybrid spoke
#

and if you add the y to the one which should be above?

warm bramble
#

I mean, sure I can do that, but that's a bit of a nightmare, I was hoping I could pass in a bunch of matrix to be rendered

hybrid spoke
#

maybe @lost matrix can help with that

#

i think he has done more than me with matrixes

warm bramble
#

Okay, I look forward to hearing what they say then

#

For reference, these display entities can expand the boundaries of a normal block just fine - i.e. a 2x1 block

alpine urchin
hybrid spoke
alpine urchin
#

XD

hybrid spoke
#

sounds like the german matratze

#

which would be mattress

icy beacon
#

And to say that something belongs to a matrix you'd say matrix' instead of matrix's

#

English totally sucks

#

Wait nvm I forgot if this rule applies to x or z

hybrid spoke
#

just know that if its an s at the end

#

that youd do the '

icy beacon
#

Yeah I'm certain about that

#

Not sure about x now

peak depot
#

I have a mod to wall climb and I want to make a plugin that when a player is at an Ice wall (I get it via Player#getTargetBlock) he like slides down there but smoothly how would I do it I tried applying veloctiy but that "bugs" him down I want a smooth slide

hybrid spoke
#

otherwise simulate cobweb

#

or fake a ladder or smth

quaint mantle
hybrid spoke
peak depot
hybrid spoke
#

isnt levitation the one where you fall smoother?

peak depot
#

slowfalling

hybrid spoke
#

that might be it

peak depot
#

levitation is that what shulker give

quaint mantle
hybrid spoke
hybrid spoke
young knoll
#

?gui

quaint mantle
#

i've seen this

hybrid spoke
peak depot
#

colorcodes?

hybrid spoke
#

as well

mellow pebble
#

May someone help me to understand better how practice servers work for example those arenas they will be objects which will be added to HashMap which will store available ones but like i then need tons of arenas in singular world like idk if i have 50 players i would need minimum of 25 arenas for example ?

hybrid spoke
mellow pebble
# hybrid spoke usually you load them dynamically instead of having a set set of arenas

what do you mean dynamically i mean I would personally make arena manager which would load all possible arenas into HashMap which will take Name and Arena as key and value and basically if it is available it will be in that HashMap if not it will not be added but once game in that arena is finished it would be cleared (since blocks placed would be tracked and removed on game finish) and then added back to available arenas

hybrid spoke
#

and once he's done it will get removed

#

with that you can also keep a few preloaded so that they will be available sooner without having to wait until it finished generating

mellow pebble
mellow pebble
hybrid spoke
#

within a few ticks i assume

#

using fawe, flawless

#

but depends on your hardware

mellow pebble
hybrid spoke
#

you can come back and ask for help with fawe if you cant manage to do it

mellow pebble
hybrid spoke
#

you would have a setup of the map which will be loaded for every generation

#

for example you build the map at 0,0,0. you can just generate the new one in his own world at the given coords

#

with that all the location points you might have set stay the same

#

just the world changes

mellow pebble
#

ill have to see with that really

dawn flower
#
    @EventHandler
    public void onJoin(PlayerJoinEvent e) {
        Bukkit.getScheduler().runTaskLater(PacketInterceptor.plugin, () -> {
            PacketInterceptor.injectPlayer(e.getPlayer());
        }, 1L);
    }```

```java
    public static void injectPlayer(Player player) {
        Channel channel = getChannel(player);
        Interceptor interceptor = (Interceptor) channel.pipeline().get(handlerName);
        if (interceptor == null) {
            try {
                channel.pipeline().addBefore("packet_handler", handlerName, new Interceptor());
            } catch (NoSuchElementException e) {
                e.printStackTrace();
            }
            uninjectedChannels.remove(channel);
        }
    }```

this throws
```[17:56:56 WARN]: java.util.NoSuchElementException: packet_handler```
which makes no sense because it only does it if i try to join but if i was already in the server and i reload the server (it does this onEnable)
            for (Player player : plugin.getServer().getOnlinePlayers())
                injectPlayer(player);

it works normally
hybrid spoke
#

you really dont want to set up 25 arenas and have your players wait until someone is done

mellow pebble
hybrid spoke
cinder abyss
#

Hello, what is the equivalent for AbstractCriterionTriggerInstance in 1.20.4 in nms?

formal egret
#

Im starting a new plugin strictly for versions 1.13-current and I am wondering which Java version is best for programming in? I previously used Java 8. Should I stick with Java 8 or move to Java 17?

hybrid spoke
#

java 8, because using a higher java version will make your plugin unavailable for <1.16

cinder abyss
#

but you can dev with java 17

hybrid spoke
#

at least if you use features of higher java versions

#

you can also use java 17 and only use java 8 features, luckily java is backwards compatible

cinder abyss
formal egret
#

thanks for the help 🙂

noble olive
#

Hey I have the following hashmap

Hashtable<Integer, Material> materialHashMap = new Hashtable();
            Iterator<Material> materials = Arrays.stream(values()).iterator();
            int i = 0;

            while(materialHashMap.size() < 256 && materials.hasNext()) {
                Material material = materials.next();
                if (material.isSolid() && !material.hasGravity() && !material.isInteractable() && !material.equals(FARMLAND) && !this.isTagged(tagBlacklist, material)) {
                    materialHashMap.put(i, material);
                    ++i;
                }
            }

Im trying to get the block id aka the integer in the hashmap
getKey() doesnt seem to work any suggestions would be appreciated

blockID = (materialHashMap.getKey(((Player)sender).getWorld().getBlockAt(x, 256 - y, 16 * row + z))).ordinal();
lost matrix
noble olive
lost matrix
#

Use two maps and map in both directions, or use guavas BiMap which internally maps into both directions.

tidal glacier
#

whats the ratio for texture pack icon?

slender elbow
#

1:1?

river oracle
cinder abyss
river oracle
alpine urchin
green prism
#

Hello, can you please help me finding the solution for this problem?

#

(What I did is a double click over an equal item that was in my inventory)

lost matrix
#

Cancel the InventoryClickEvent

eternal oxide
#

Cancel inventory drag event

worthy yarrow
#

Cancel all the inventory related events 😄

#

When it comes to separation of concerns, say you’ve got an event listener that has multiple functions based on properties of said event, would it be better to just split functions into helper methods or perhaps multiple instances of the event listener?

lost matrix
#

Cancelling the InventoryClickEvent will always prevent the InventoryDragEvent from being fired

eternal oxide
#

it doesn't

worthy yarrow
#

As in a sort of manager I suppose you could say that dictates the functionality of the event when it occurs, based on some properties

ruby ermine
hybrid turret
#

i'm probably too dumb for google rn, but google won't help.
how do i get a list of strings from an sqlite db?

in this table i basically store options for an action and the action is stored with each options so that my PreparedStatement looks like this:

SELECT options FROM GUIOptions WHERE action = ?;

I then just set the String to the action supplied and want to get all the results in a List of Strings or an Array, doesn't matter tbh.

hazy parrot
#

if i understood right

List<String> foo = new ArrayList<>();
while(resultSet.next()) {
  foo.add(resultSet.get(...));
}
#

something like that

ruby ermine
#

can someone help me with geyser and playit gg so my friends can join me?

hybrid turret
#

thanks

ruby ermine
#

thx

azure vault
#
@EventHandler
def notifyPlayerSpawnLocation(event: PlayerSpawnLocationEvent): Unit = {
    event.setSpawnLocation(SpawnLocation)
}
```even though i have this, the first time a player joins they spawn at a random location
#

and yes, the listener is registered

acoustic pendant
#

is there any way so the IDE doesn't give an error when doing this?

azure vault
#

its only the first time where this doesnt work

acoustic pendant
#

yea thanks

worthy yarrow
#

Could someone help me with tasks/runnables? I'm unsure of what to use for a task that should be ran every second during runtime, it should only stop when onDisable is called / plugin shutdown

hot dune
#

Hello! How can I get an item which was added to the inventory by /give command? I can't find correct event

#

InventoryClickEvent, InventoryMoveItemEvent, InventoryPickupItemEvent don't work

hazy parrot
worthy yarrow
#

I don't think there's any method for this. You'll have to essentially recreate whatever item you're looking for and implement detections for when that item is added to a player inventory @hot dune

rough ibex
rough ibex
#

= {} is a giveaway

#
  • def
worthy yarrow
hot dune
#

item that given by vanilla give command, so I think it's vanilla one xd

worthy yarrow
hot dune
#

I try to check if the item is an equipment (e.g. sword or tool), so they are always are one in the stack

#

I just write /give @p minecraft:diamond_axe and I need to get this item and then change it's lore and other stuff

worthy yarrow
#

Mmmm

#

I'd rather just do a custom command that gives an item, then within that class you can define the items lore/meta/etc through pdc meaning you create an itemstack object that has persistent data. This itemstack now holds data that will persist over server restarts and what not

hot dune
#

okay, will try

#

anyway one day I gonna rewrite some vanilla commands xd

worthy yarrow
#

I'm 99% sure there's no method to access the vanilla commands... meaning you can't really do anything without recreating the command yourself

acoustic pendant
#

Okay so i've done this to get the following string:
effect[FIRE_RESISTANCE,1]

#

And i was wondering if this is the correct way or maybe other more optimized would work

worthy yarrow
lost matrix
acoustic pendant
river oracle
#

you have a couple "tokens" here first the [ token which is some sort of arguments then , which denotes the start of a new argument and ] which denotes the end of an argument

lost matrix
acoustic pendant
river oracle
#

if you use a for loop you can use this to your advantage if you want to go crazy and have much more advanced tokens in the future you can use an abstract syntax tree

river oracle
# lost matrix

ngl bukkits serializations are almost never as ideal as they could be but changing them is also problematic in of itself

worthy yarrow
lost matrix
# acoustic pendant yea
PotionEffect effect = ...;
FileConfiguration config = ...;

// Saving effect:
config.set("some.effect", effect);

// Loading effect
PotionEffect loaded = config.getObject("some.effect", PotionEffect.class);
river oracle
#

saying use the serializable isn't really as cool as it sounds

young knoll
#

Well you can save the key

river oracle
#

granted their serialization method isn't Ideal either

young knoll
#

But you still need other data

lost matrix
young knoll
#

I guess you could do key,duration,level

#

or
type: type
duration: duration
level: level

lost matrix
#

Outside my screen, scrolling up take effort

river oracle
worthy yarrow
#
public class ChickenPet extends Pet {
    private static final NamespacedKey chickenPetKey = NamespacedKey.fromString("coolpets:chicken_pet_key");
    private static final NamespacedKey chickenLevelKey = NamespacedKey.fromString("coolpets:chicken_pet_level_key");
    private static final NamespacedKey chickenMetaKey = NamespacedKey.fromString("coolpets:chicken_meta_key");
    public static NamespacedKey getChickenPetKey(){
        return chickenPetKey;
    }

    public ChickenPet(UUID petId, String petName, int petLevel){
        super(petId, petName,petLevel);
        registerPet();
    }

    @Override
    public ItemStack petItem(){

        ItemStack chickenPet = new ItemStack(Material.CHICKEN_SPAWN_EGG);
        ItemMeta chickenPetMeta = chickenPet.getItemMeta();
        chickenPetMeta.getPersistentDataContainer().set(chickenPetKey, PersistentDataType.STRING, getPetId().toString());
        chickenPetMeta.getPersistentDataContainer().set(chickenLevelKey, PersistentDataType.INTEGER, getPetLevel());
        chickenPetMeta.getPersistentDataContainer().set(chickenMetaKey, PersistentDataType.STRING, petName);

        chickenPetMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', chickenPetMeta.getPersistentDataContainer().getOrDefault(chickenMetaKey, PersistentDataType.STRING, "&4Chicken_Pet")));
        List<String> chickenPetLore = new ArrayList<>();
        chickenPetLore.add(0, ChatColor.translateAlternateColorCodes('&', "&6" + getPetLevel()));
        chickenPetLore.add(1, ChatColor.translateAlternateColorCodes('&', "&7Chicken pet allows you to fall gracefully through the skies!"));
        chickenPetMeta.setLore(chickenPetLore);

        chickenPet.setItemMeta(chickenPetMeta);

        return chickenPet;
    }

    public void registerPet(){
        PetRegistry.registerChickenPet(this);
    }

}```
Given that I'm using final namespeacedkeys, would saving them to a flat file be ideal?
modern plank
#

how do i make an entity look towards another entity

lost matrix
modern plank
kindred sentinel
#

How to connect sqlite driver to plugin? I got an error "No suitable driver found for jdbc.sqlite", after trying just use sqlite

lost matrix
lost matrix
kindred sentinel
#

I only added this to plugin, how should I shade driver?

lost matrix
lost matrix
lost matrix
#

And didnt you say something about the default pom containing "useless stuff" like shading

#

Anyways. You need to add the maven shade plugin to your pom.

#

Then the dependency gets shaded

kindred sentinel
#

I think I have it

lost matrix
#

How do you compile?

kindred sentinel
#

Maven > Lifecycle > package

#

and profiles

lost matrix
#

Alright that should do the trick

kindred sentinel
#

,_,

lost matrix
#

Show your code and exception pls

#

And someone else has to jump in bc im gonna go eat

kindred sentinel
#

?pom

undone axleBOT
#

Please paste your pom.xml file, or build.gradle (or build.gradle.kts) if you're using gradle on the following website: https://paste.md-5.net/

kindred sentinel
young knoll
#

I thought spigot shaded the SQLite driver

eternal oxide
#

it does, but you have to init it on older versions

worthy yarrow
#

When it comes to pdc, is it a good thing to store namespacedkeys in a flat file?

hazy parrot
#

Why

#

Keys should somehow be "hardcoded" into your plugin

worthy yarrow
#

That's what I thought, I was just confused with some description of "caching" the keys

hazy parrot
#

That just means that u don't have to create new namespacekey every time u need it

#

Just save it in variable and reuse it

worthy yarrow
#

Like I said, was a bit confused on the description was all

junior cradle
#

How to create entities with metadata? it's just that I can create the entity itself, but I can't ask it some things ProtocolLib 1.20.4

worthy yarrow
#
    private static final NamespacedKey chickenLevelKey = NamespacedKey.fromString("coolpets:chicken_pet_level_key");
    private static final NamespacedKey chickenMetaKey = NamespacedKey.fromString("coolpets:chicken_meta_key");```
So as an example:

now just implement getters for my keys and use them this way correct?
flint coyote
#

Either that or you use dependency injection (DI) to hand them over. In that case you can use a keyholder class you create a single instance of

worthy yarrow
flint coyote
#

Avoiding what?

worthy yarrow
#

di

flint coyote
#

Well in that case I'd just make a seperate static class (private constructor) and declare those keys public

worthy yarrow
#

This convo

flint coyote
#

That also helps others to work with them if they need/want to

#

he also declared it as public which is perfectly fine as they can't be modified

worthy yarrow
junior cradle
#

Who understands something in ProtocolLib

pliant topaz
#

Is there any way I could reliably (or at leats most of the time) refresh an inventory? (without closing and reopening as items will be lost upon doing that)

lost matrix
lost matrix
alpine urchin
lost matrix
#

Or edit single slots

pliant topaz
#

that's what I'm doing, but it isn't updating

junior cradle
#

How do I set the type for Villager packages ProtocolLib set metadata?

pliant topaz
kindred sentinel
glad prawn
#

isnt it should be jdbc:sqlite:path?

lost matrix
kindred sentinel
lost matrix
slender elbow
#

uhhh

#

"jdbc:sqlite:" ...

#

not "jdbc**.**sqlite"

slender elbow
kindred sentinel
sand spire
#

My method to see if an inventory has space for a list of items is somehow modifying the item I'm checking. Can anyone see what is causing this and why? https://pastes.dev/QpONvo5UhR

edit: I still have no idea why this is happening but chatgpt said the itemstack is getting split in partial stacks to try and fit them in the inventory and for some reason that modifies the original instance

kindred sentinel
glad prawn
#

fine for me

smoky anchor
sand spire
#

actually it sounds like this line on the wiki is explaining my exact problem now I'm just confused if it's a bug or a feature

#

I guess I will just do this to solve it

List<ItemStack> itemsToAdd = new ArrayList<>();
        for (ItemStack itemStack : itemStackList) {
            itemsToAdd.add(new ItemStack(itemStack));
        }```
#

or stream idk what is better

worthy star
#

if i want to make a chat filter using regex, should i put all of them in a enum? like

public enum FilterRegex {
  WORD("regex")

  final String string;
  
  FilterRegex(String string) {
    this.string = string;
  }
}```, and then loop through enum values and check the message word matches the regex?
lost matrix
worthy star
#

i've got this java for(WordType type : WordType.values()) { System.out.println(ass.matches(type.string)); System.out.println(ass.replaceAll(type.string, "no bad words")); } but i don't think its good

rotund ravine
worthy star
#

ik

#

this is why i use it

glad prawn
worthy star
#

no

#

i replaced "Ass" with "badass" and it didn't break it

glad prawn
#

is your string just contains Ass

glad prawn
worthy star
#

should i split the string?

pliant topaz
#

Why is it, that when I do setItem in an gui it only updates when the amount is greater than one?

pliant topaz
#

1.21 latest build

#

read about it in forums too, is this some kind of known bug?

lost matrix
#

Setting the amount to 0 should remove the ItemStack iirc. In older versions it resulted in ghost items.

lusty flax
#

hey, im getting this error whenever whenever i try to log into my server (it seems to be to do with tab prefixes) and im not too sure what im meant to do to fix it in my code, cus the prefix its trying to load is under 16 chrs

pliant topaz
lost matrix
lusty flax
pliant topaz
lost matrix
pliant topaz
#

ik

sand spire
#

It would be easier to understand the issue if you show some code

pliant topaz
#

okay, wait

#
player.setItemOnCursor(new ItemStack(Material.AIR, 1));```
activeInventory being the current opened inventory for said player and the item on the cursor being a netherite pickaxe with some metadata
#

when this happens it results in lots of weird behaviour and inventory bugs/ghost items

lost matrix
#

Ah, the behavior in this also depends on the cancelled state of the event. Its quite tricky.

pliant topaz
#

when cancelled it just doesnt do anything, when not cancelled the weird behaviour occurs

#

I guess it rlly all just comes down to testing a whole lot of stuff and seeing if it works, am I right?

inner mulch
#

Are ressource packs cross compatible can anyone use a ressource pack no matter befrock or java?

chrome beacon
#

no

inner mulch
#

What do i need to change?

kindred sentinel
echo basalt
#

Poor smile getting blasted with 19 questions at once

echo basalt
echo basalt
lost matrix
#

Or you wait for 1.20.5 🙂

kindred sentinel
#

OHhh

echo basalt
#

Exactly

kindred sentinel
#

It works! Thanks!

cinder abyss
#

Hello, how can I change the name of displayed on a villager trade popup but without modifying villager's name?

agile quiver
#

Hello do you know how to lock the head movement of the player like for a cinematic?

cinder abyss
#

modifying that

lost matrix