#help-development

1 messages · Page 844 of 1

remote swallow
#

looking at this its a module, does the parent have the module name

grim hound
#

try rejoining

scenic onyx
grim hound
sterile flicker
#

snoww

grim hound
#

yeee

#

if you wanna update it to the player immediately you'd need to do some packet spoofing

sterile flicker
#

which packets should I use

grim hound
#

yeah, but you should totally use a packet library

#

PacketEvents

#

would be best

#

most optimized

sterile flicker
grim hound
#

if it were me, I'd do it with reflection

chrome beacon
#

Just let ProtocolLib or PacketEvents handle it

grim hound
#

or are you fine with having your plugin support only 1 mc version?

grim hound
#

It's too slow.

#

and too unflexible

chrome beacon
#

It's good enough

grim hound
sterile flicker
#

I can't find a tutorial on how to add his to project.(packetevents)

chrome beacon
#

Same reason why people use 1.8

grim hound
#

Also, PacketEvents is more intuitive?

chrome beacon
#

they like it ig

grim hound
#

or

#

there's an even faster way

#

you could teleport the player to like, the nether and teleport him back

#

this way it'd refresh his chunks

#

the momental teleport needs to be to another world tho

#

@sterile flicker

sterile flicker
scenic onyx
#

???? @grim hound

#

i have try to recreate module

sterile flicker
#

or is there a built-in method for updating chunks

scenic onyx
grim hound
#

you can try it tho

grim hound
scenic onyx
grim hound
#

you could also just

#

go to like File > Project Structure > Libraries > +

#

and add select the nms jar file

#

you should already have it downloaded on your pc

bronze monolith
#

Required type:
String
Provided:
TextComponent

grim hound
river oracle
#

I smell paper and a lack of java knowledge

#

This isn't the place for paper if you have paper related questions go to their discord

sterile flicker
grim hound
#

np

sterile flicker
#

which yaw and pitch should I set for the nms entity so that it looks straight ahead?

rough harness
#

@tender shard ok i fixed the texture its working do i add the custom_model_data number here

tender shard
#

?

inner mulch
young knoll
#

no

sterile flicker
# grim hound np

but I also observe one problem the snow is not falling clearly in chunks around the player but somewhere nearby

sterile flicker
#

is it possible to speed up this process

#

?

grim hound
#

uhhh

sterile flicker
#

as you can see, there is snow only around and it has fallen in the center

grim hound
sterile flicker
#

after the relogging, it stopped snowing altogether

grim hound
#

mmm

#

are you sure you're getting the right chunks?

#

try to print them out

sterile flicker
grim hound
#

debug your values

sterile flicker
# grim hound debug your values
                    for (Chunk c : ChunkLoader.getChunks(player.getLocation(), 8)) {
                        int chunkXStart = c.getX() << 4;
                        int chunkZStart = c.getZ() << 4;
                        for (int x = 0; x < 16; x++)
                            for (int z = 0; z < 16; z++)
                                c.getWorld().setBiome(chunkXStart + x, chunkZStart + z, Biome.SNOWY_TAIGA);
                    }
                });``` can I change the ChunkLoader.getChunks() radius to 16 and for (int x = 0; x < 16; x++)
for (int z = 0; z < 16; z++) to for (int x = 0; x < 32; x++)
for (int z = 0; z < 32; z++)
#

to have snow in all 32 chunks

grim hound
#

not how that works

#

this only iterates through the 16 blocks of the chunk

ivory sleet
#

u’re hurting overall performance by harassing the common pool like that

lost matrix
#

Tell him clubi

#

Let alone calling spigot methods from it, which will simply throw an exception most of the time or result in undefined behavior

sterile flicker
ivory sleet
#

Why does it need to be async lol

sterile flicker
ivory sleet
#

Well, what exactly are you actually trying to do

sterile flicker
sterile flicker
ivory sleet
#

why are you watting me?

grim hound
#

I'm asking why it's bad

ivory sleet
#

because you rarely ever wanna dump a huge io or cpu bound task as a single runnable to a fork join pool

#

Rather

ivory sleet
#

You wanna split it up and properly take advantage of how fork join pool works under the hood by having smaller tasks

#

Because the entire point of fjp is “work stealing”

#

And that cannot be done if you have one fat task

grim hound
#

I mean it's still better than using the bukkit async scheduler

ivory sleet
#

each thread has its own queue of tasks, if a thread or aka worker has no tasks it can steal a task from another worker

#

Nah not really, depends, I mean the bukkit async scheduler uses a cached thread pool in the end

sterile flicker
ivory sleet
#

So assuming you don’t run epidemically long tasks

grim hound
ivory sleet
#

Its fine to use the bukkit async scheduler

ivory sleet
grim hound
#

ye

#

like I never actually knew how you should use fjp

#

now I know

#

Thanks Conclube

ivory sleet
#

Yeah its sadly used wrongly in alot of scenarios even in popular libs

ivory sleet
#

I mean isn’t there a packet that can do the magic (assuming there isn’t an api method for it)

sterile flicker
#

I don't want to use packetevents just for this

ivory sleet
#

Packetevents? U mean the library?

sterile flicker
#

in addition, everything is unstable for me, the weather resets after rejoin, my nms entity disappears, and I have to wait a very long time for snow

sterile flicker
ivory sleet
#

Let me check, one moment

#

Hmm, I looked at some stuff, but its heavily packet dependent

#

@lost matrix do u know if its possible to do this with spigot api? (W/O packets)

inner mulch
#

how do i stop maven from giving me the normal and the shaded jar (i only want the shaded one)

astral scroll
#

hey

#

can i get help rewriting some nms methods?

#

(they're obfuscated)

lost matrix
astral scroll
#

i already installed the mappings

#

but

#

the old version of the plugin

#

its obfuscated

#

like

#

1.16.3 obf -> 1.20.2 mapped

lost matrix
#

Probably changed a lot then

#

What does the method do?

tender shard
tender shard
#

that shows you the old and new method names etc

spring stag
#

Is there a way to add methods to locked classes? I want to add an isTool() method to the Materials class for a plugin?

ivory sleet
#

I mean yes but those solutions would require bytecode manipulation, instrumentation etc

#

You can prob just create a static utility method that takes a Material as its argument

young knoll
#

Extension methods when

spring stag
#

Ah gotcha

young knoll
#

Oh wait Kotlin

quaint mantle
#

Its really sad that it doesnt work, if we would be able to hook into these we would have been able to create events that we need and not wait until its added

#

Example: BlockChangeTypeEvent

proud badge
#

hmm what should I do if I want to remove an object from an arraylist in a loop? i cant do it normally cause ill get a stacktrace

remote swallow
#

iterator

young knoll
#

I mean you can freely create custom events

#

But you can't inject code to fire them into NMS

remote swallow
#

i think that exists on a list

lost matrix
quaint mantle
#

And i want the event because commands can delete blocks

lost matrix
proud badge
#

im confused what you meant by this

#

should I do it in a loop?

ivory sleet
tender shard
ivory sleet
#

Actually coll, lombok has it iirc

#

💀

lost matrix
proud badge
#

wut

tender shard
quaint mantle
#

Also add ;

proud badge
quaint mantle
#

You are defining gatename twice

#

?learnjava

undone axleBOT
proud badge
#

yes

young knoll
spring stag
#

Say I want a method that occurs when a player acquires an item. How would I set that up? I keep playing with the EventHandler but I don't quite fully understand it. I want something like this to occur when acquiring an item.

    // Creates Abundance Diamond
    public static void createADiamond() {
        ItemStack item = new ItemStack(Material.DIAMOND, 1);
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName("Abundance Diamond");
        meta.addEnchant(Enchantment.LOOT_BONUS_BLOCKS, 3, true);
        meta.addEnchant(Enchantment.LOOT_BONUS_MOBS, 3, true);
        meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
        item.setItemMeta(meta);
        abundanceDiamond = item;
    }


    public static void abundanceAbility(PlayerEvent event) {
        Player player = event.getPlayer();
        Inventory inv = player.getInventory();

        if (inv.contains(abundanceDiamond)) {
            for (ItemStack itemStack : inv) {
                if (itemStack.equals(Material.IRON_AXE) || itemStack.equals(Material.IRON_PICKAXE)) {
                    itemStack.addEnchantment(Enchantment.LOOT_BONUS_MOBS, 3);
                    itemStack.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);

                }
            }
        }
    }
quaint mantle
ivory sleet
spring stag
#

Nope, my only experience with modding and plugins is with Forge atm

quaint mantle
#

?events

#

?event

#

Aaah

echo basalt
#

unpopular opinion: spigot should have a native item builder

undone axleBOT
ivory sleet
quaint mantle
echo basalt
spring stag
ivory sleet
#

Yeah but by principle if something is mutable you don’t really need a builder for it, i mean u can still add it, but its not as meaningful,

quaint mantle
#

Forge coders is just looking at other source code and learning from it. The best way

ivory sleet
#

I do agree tho it would be useful in terms of convenience partly

shadow night
ivory sleet
#

Yes for immutable objects its useful

shadow night
#

I mean for mutable objects

young knoll
#

unpopular opinion: spigot should have native mixins

ivory sleet
#

well, usually it isn’t

shadow night
#

There could be some edge case scenario in which it can be good

ivory sleet
#

Because you can just the setters

#

Like

shadow night
ivory sleet
shadow night
#

Also, when will we get nms-less packet handling in spigot?

ivory sleet
#

wym with that lol

shadow night
#

I mean

#

I'm tired of using protocol lib

#

It's goofy

#

I want it in spigot

ivory sleet
#

jusr dont use protocollib lol

#

U can do protocollibless packet handling

shadow night
#

Then I have to either use another lib or some goofy injections

ivory sleet
#

I mean there is gonna be an injection somewhere

#

Whether its runtime or compile time

#

Anyway I heard packet events is good, tho I dont have any real experience w it

shadow night
#

But can't spigot do it and give me some more conviniencing stuff?

dry hazel
#

the protocol is not stable lol, how would you make a decent api out of it

shadow night
#

Last time I used protocollib I still needed nms because it wouldn't let me use the normal methods and forced me to use nms classes like Pairs and stuff

ivory sleet
#

I guess spigot as a service could, but like, packet stuff changes from version to version, so its hella lot to maintain

shadow night
ivory sleet
#

Yup

shadow night
#

Spigot/bukkit is known for deprecating all old stuff in favor for new stuff, but can't we get an exception with packets?

ivory sleet
#

The issue as ZlataOvce also said is that its hella fkn unstable

#

and its the lowest level stuff that exists in mc

shadow night
#

Will we atleast get tracking events from forge

ivory sleet
#

And since spigot is trying to do everything and abstract everything to a high level, it becomes a bit goofy

quaint mantle
#

I hate using packets 😭

ivory sleet
#

Tracking events as in?

ivory sleet
#

But its powerful when you need it at least

shadow night
spring stag
quaint mantle
#

Also when custom block support

shadow night
#

Very useful, especially when making server-sides for forge mods

ivory sleet
#

when the new regitry api stuff is merged draco

ivory sleet
quaint mantle
spring stag
#

Oh gotcha! Thank you!

#

Would the deprecated event still work?

quaint mantle
ivory sleet
#

Soon is vastly relative

#

But one day 🙏

spring stag
#

I'm trying to get the player but not if the player is a killer?

    @EventHandler
    public static void abundanceAbility(PlayerPickupItemEvent event) {
        Player player = event.getPlayer();
        Inventory inv = player.getInventory();
quaint mantle
#

What

#

My eyes hurt

#

?learnjava!

undone axleBOT
quaint mantle
ivory sleet
#

hmm

#

Hard to say

#

The pr is just a draft

#

But its fully plausible :)

#

I mean since a lot of minecraft server side has leaned more towards resource pack magic, I’d say there are good chances

ivory sleet
slate tinsel
#

How do I calculate the trajectory of a bow?

ivory sleet
#

It’s no directly bijective to players killing one another

ivory sleet
slate tinsel
spring stag
ivory sleet
#

Nope it doesn’t

#

It triggers when a player picks an item up precisely

spring stag
#

Regardless of killing another entity? huh. Thanks!

quaint mantle
#

Remove the getKiller

#

Player player = (Player) event.getEntity();

#

Also check if its a player

ivory sleet
spring stag
#

I'm just trying to check whether or not the player picks up a certain item

quaint mantle
ivory sleet
#

In the event class name it says Player as a prefix so…

#

Oh wait

#

Its the entity one

#

Fuck me

quaint mantle
#

Conclube pls read code before responding 😭

ivory sleet
#

Yeah then you need sth like
if (event.getEntity() instanceof Player player) {

}

ivory sleet
quaint mantle
#

@ivory sleet i want to report conclube

#

He is trolling

ivory sleet
#

?ban @ivory sleet

undone axleBOT
#

I cannot let you do that. Self-harm is bad 😔

quaint mantle
#

?kill @quaint mantle

#

It didnt tell me that self harm is bad :)

slate tinsel
quaint mantle
#

Use math

ivory sleet
#

hmm, yeah I think the trajectory of an arrow shot from a bow is actually calculated on the go

#

Since something could end up blocking it, etc

#

Like half way in yk

young knoll
#

Well yeah

echo basalt
#

it is

young knoll
#

It's called physics :p

echo basalt
#

You just shoot an arrow and it does physic

ivory sleet
#

ya

young knoll
#

But you can simulate said physics without the arrow

quaint mantle
#

@slate tinsel look at source code to see how mc calculates it

#

Ez fix

ivory sleet
#

lol yeah, prob easiest way

young knoll
#

Pretty sure it's just basic gravity + bounding box checks

quaint mantle
#

Or you could study physics

#

And get grade A in school

ivory sleet
#

yea, or just read about it on the internet lil fast

quaint mantle
#

But using itemdisplays / skulls is really too much work

ivory sleet
#

I mean the api might offer resource pack functionality that is yet not in the api

#

but not more than that I’d suspect

young knoll
#

What would one need

ivory sleet
#

@quaint mantle answer this ^

quaint mantle
#

Uhh

#

I can say a list of stuff that needs to be added

ivory sleet
#

Do it

#

Coll is a certified spigoter

quaint mantle
#

Ok i will write it in a document and paste it here

young knoll
#

I spigotted before

vagrant stratus
#

full of malware by KEK

young knoll
#

Man replied to a message from july

quaint mantle
#

Stuff that spigot needs (My opinion)

  • More Events (BlockTypeChangeEvent, BlockDataChangeEvent, etc.)
  • PDC for every Block
  • Custom Blocks
  • Custom Items
  • Custom UI Texture (already possible trough fonts, but we need it as a feature)
  • The custom stuff should be able to have a custom tag
  • Builders (ItemstackBuilders, etc.)
#

Only my opinion

ivory sleet
#

And what cannot currently be done with spigot api?

quaint mantle
#

Uh read it

chrome beacon
#

Component names

quaint mantle
#

The events

ivory sleet
#

but didnt choco have a pr for that alr olvio

quaint mantle
#

I cant do it with spigot api

ivory sleet
#

adding all the needed component stuff

chrome beacon
ivory sleet
#

Yeah I’ll link u, sec

quaint mantle
#

Doesnt pr mean personal record 😭

young knoll
#

Yes he has

remote swallow
remote swallow
chrome beacon
quaint mantle
#

Ohh

#

Ok

quaint mantle
chrome beacon
#

Yeah I need an account to view that

remote swallow
#

i dont think you can see them at all without an account

ivory sleet
#

Ah, well its component stuff basically, for the stuff that used to miss it

chrome beacon
#

Let's hope it gets merged soon 🙏

quaint mantle
#

Yes pls

ivory sleet
#

🙏🙏

remote swallow
#

probably a 1.21 merge most likely

ivory sleet
#

when everything else gets merged, yea

vagrant stratus
# remote swallow kekw

Sent them an email about some of the ones I found pre-downloading all their stuff. No idea if they'll even do anything kekw

remote swallow
#

"we dont care" i bet

ivory sleet
#

Ye fair

quaint mantle
#

So i want them

#

Otherwise i will switch from spigot to spigot

remote swallow
#

from spigot to spigot

#

yes

young knoll
#

Imagine how often those events would fire

#

:p

quaint mantle
#

Well uh ignore world generation

wintry lynx
#

so ive never been great with YAML so if someone could help me out that'd be wonderful.
oak_bark: "stripped_oak_log": to: "oak_log" costs: 1 drops: 'None' "stripped_oak_wood": to: "oak_wood" costs: 1 drops: 'None'
If I had this within a YML file how would i access it via java?
I need the names of the stripped_oak_log and stripped_oak_wood.

I currently have config.get("block_rclick_events.switch_block." + oHandItem) which returns the oak_bark class which Im pretty sure is either a List or Dict.

quaint mantle
#

Maybe a 100k times if you load new chunks

remote swallow
#

for the keys directly use getKeys

wintry lynx
remote swallow
#

one sec

#

oak_bark: # This is a config section, can be gotten with getConfigurationSection("oak_bark")
   "stripped_oak_log": # Also a config section but can be retrived from ConfigurationSection#getKeys(false)
      to: "oak_log"
      costs: 1
      drops: 'None'
   "stripped_oak_wood": # Same as above
      to: "oak_wood"
      costs: 1
      drops: 'None'
wintry lynx
remote swallow
#

the comments explain stuff

wintry lynx
#
  switch_block: #Swap block on clicked with item (ex. Waxing, Stripping, and Rebarking)
    oak_bark:
       "stripped_oak_log":
          to: "oak_log"
          costs: 1
          drops: 'None'
       "stripped_oak_wood":
          to: "oak_wood"
          costs: 1
          drops: 'None'```
#

also how does one use multi-line code in discord?

remote swallow
#

three backticks

#

you can use getConfigurationSection("block_rclick_events.switch_block.oak_bark").getKeys(false)

#

that would return the 2 strings "stripped_oak_log" and "stripped_oak_wood"

#

with no quotes

wintry lynx
#

It would return it in a list?

#

That I could iterate through?

young knoll
#

yes

remote swallow
#

returns a set

#

so yeah same thing pretty much

wintry lynx
#

Even better

#

Thanks a ton, currently making it so peeps can put bark back on the trees since it sucks when you accidentally strip a log lol

#
                        Set<String> blocks = config.getConfigurationSection("block_rclick_events.switch_block." + oHandItem).getKeys(false);
                        for (String temp : blocks) { //Loop Through all items
                            Bukkit.broadcastMessage(temp);
                        }
                    }
#

Should work

remote swallow
#

yeah

wintry lynx
#

Thanks for the help, I dont usually store data in the keys names themselves so I wasnt sure what to do.

ivory sleet
#

Well that’s if you want it deduplicated

spring stag
#

How does this look?

    @EventHandler (priority = EventPriority.MONITOR)
    public static void abundanceAbility(EntityPickupItemEvent event) {
        if (event.getEntity() instanceof Player) {
            Player player = (Player) event.getEntity();
            Inventory inv = player.getInventory();
            ItemStack aDiamond = event.getItem().getItemStack();

            if (aDiamond != null && aDiamond.isSimilar(abundanceDiamond)) {
                for (ItemStack itemStack : inv) {
                    itemStack.addEnchantment(Enchantment.LOOT_BONUS_MOBS, 3);
                    itemStack.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
                    Bukkit.getLogger().info(itemStack + " was enchanted."); // check for enchantment
                }
            }
        }
    }
glad prawn
#

for (ItemStack itemStack : inv) what

young knoll
#

Dang you enchanting their whole inventory

glad prawn
#

is that chatgpt code

young knoll
#

You can merge the instanceof and the line below it into a single line on modern java

#

Assuming you do want to enchant every item in their inventory, that looks fine

spring stag
vagrant stratus
spring stag
#

so next best option is just enchant everything or add a huge filter in the if logic

young knoll
#

Use tags or enchantment targets

#

Or make a set of only the materials you want to enchant

spring stag
#

create an enum that contains the items i want and just filter through them?

ivory sleet
#

an enumset maybe

#

Or just identityhashset perhaps :>

spring stag
#

word

ivory sleet
#

EnumSet is like a HashSet but for enums yk :)

young knoll
#

But what about when we kill the enum!!!1

ivory sleet
#

true :(

#

Maybe Sets.newSetFromMap(new IdentityHashMap<>());

#

Idk if the method is in guavas Sets, or if one exists in Collections

#

but yeaa

remote swallow
#

just badly damage it

ivory sleet
#

@Deprecated Corpse_1

remote swallow
#

@Deprecated(forRemoval = true) is a better death

spring stag
ivory sleet
#

yeah important to explicitly set the annot data lol

young knoll
ivory sleet
young knoll
#

Ah yeah

#

They are all in there

ivory sleet
#

^^

spring stag
#

Thx!

opaque scarab
#

Does anyone know how i can set the biome of a chunk (org.bukkit.chunk) with a net.minecraft.world.level.biome object?

#

The biome is custom

ivory sleet
#

I suspect nms at this point or packets sadly

#

Might B wrong tho

echo basalt
#

yeah it's nms exclusively

spring stag
#

How does this look?

        @EventHandler (priority = EventPriority.HIGHEST)
    public static void abundanceAbility(EntityPickupItemEvent event) {
        if (event.getEntity() instanceof Player) {
            Player player = (Player) event.getEntity();
            Inventory inv = player.getInventory();
            ItemStack aDiamond = event.getItem().getItemStack();
//            Set<Material> tools = Tag.ITEMS_TOOLS.getValues();

            if (aDiamond != null && aDiamond.isSimilar(abundanceDiamond)) {
                for (ItemStack itemStack : inv) {
                    if (Tag.ITEMS_TOOLS.isTagged(itemStack.getType())) {
                        itemStack.addEnchantment(Enchantment.LOOT_BONUS_MOBS, 3);
                        itemStack.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
                        Bukkit.getLogger().info(itemStack + " was enchanted."); // check for enchantment
                    }
                }
            }
        }
    }
remote swallow
#

doing that on monitor hurts

spring stag
#

Sorry, my java is still elementary

inner mulch
#

why does in the BlockFormEvent

Block block = event.getBlock();```

return the same block? does somebody know how i can get the real new block, after the formevent?
remote swallow
spring stag
inner mulch
#

so we can tell you if it would work

spring stag
#

So when I pick up an "Abundance Diamond" it'll enchant all the tools in my inventory

inner mulch
#

i dont see where the variable itemStack is declared

#

oh

#

im blind

spring stag
#

lol all good

inner mulch
#

use Tag.ITEMS_TOOLS.isTagged(material) rather than creating a set

#

its cleaner, but other than that i think it should work

spring stag
#

I updated it. How does it look?

inner mulch
#

wait are you looking for cleaner code, or are you worried about it working?

spring stag
#

Working

inner mulch
#

okay

#

did you test it?

spring stag
#

testing it atm but I haven't even been able to enchant anything

inner mulch
#

so the enchanting part doesnt work?

spring stag
#

Nope

inner mulch
#

did you test if the aDiamond.isSimilar(abundanceDiamond) fires correctly?

#

maybe you are picking up the wrong itemstack

#

you can add debug messages after each of your if's and see which fire and which stop your code

spring stag
#

word

inner mulch
#

?

spring stag
#

i'm checkign with new logger msgs atm

minor junco
#

Is there a way to check for the lazily loaded textures on an ItemStack (such as player heads)?

#

Using "vanilla" spigot

ivory sleet
#

PlayerProfile api

#

it has an update() method

#

which is executed async

opaque scarab
#

What replaced level.chunk#getBiomeIndex and #markDirty() ? Looking at a tutorial for 1.17 but trying to update it to 1.20

remote swallow
#

what did getBiomeIndex return

opaque scarab
remote swallow
#

looks like it was just removed

#

im guessing for data driven biomes

#

markDirty was removed too it seems

opaque scarab
# remote swallow looks like it was just removed

That sucks. This was the code I’ve been trying to update: ```
private void setBiome(int x, int y, int z, World w, BiomeBase bb) {
BlockPosition pos = new BlockPosition(x, 0, z);

      if (w.isLoaded(pos)) {
    
         net.minecraft.world.level.chunk.Chunk chunk = w.getChunkAtWorldCoords(pos);
         if (chunk != null) {
        
            chunk.getBiomeIndex().setBiome(x >> 2, y >> 2, z >> 2, bb);
            chunk.markDirty();
         }
      }
  }
I’m also using mojang’s remapping instead.
remote swallow
#

i couldnt see anything on mappings, check with ur ide and see if thers any methods that take a Biome that might reference setting it

rough harness
opaque scarab
opaque scarab
#

Origin Realms?

opaque scarab
#

Oh alr nice

ivory sleet
#

@orchid gazelle got more code?

orchid gazelle
#
why does this not remove the player from the hashmap?
it does but somehow it doesn't```
#

uhm I got 500 lines associated with it lmao

wet breach
#

is player a key or a value?

orchid gazelle
#

player is the key

ivory sleet
#

bad probably

orchid gazelle
#

I also tried removing the value

ivory sleet
#

Can you make it UUID instead to begin with/?

wet breach
#

your hashmap isn't like final or static is it?

orchid gazelle
#

well I can but it should only apply to online players in the first place

#

my HashMap is static

ivory sleet
#

Hmm, well if you got more code it would be easier to figure out

orchid gazelle
#

alright imma search for what may be important

ivory sleet
#

you’re not reloading the server or anything?

orchid gazelle
#

no

wet breach
#

it could be related to your map being static but I don't have enough info to go off of to really determine that

orchid gazelle
#
        sessions.remove(player);
    }``` is a method I am statically calling from another method independent from it
#

this cancel object is in the HashMap as the Value and may basically delete itself from the hashmap

ivory sleet
#

Yeah sounds about right

orchid gazelle
#

now, whenever I throw off another call that checks for the value, it is still there

ivory sleet
#

U doing anything async?

orchid gazelle
#

well I am calling the check if it is still there in an AsyncPlayerChatEvent

wet breach
ivory sleet
#

and its a regular HashMap?

wet breach
#

maps are allowed to contain a single null key

orchid gazelle
#

I let it print out the key entries on message

ivory sleet
#

DaFeist

orchid gazelle
#

public static HashMap<Player, ChatPrompt> sessions = new HashMap<>();

ivory sleet
#

Try switch it to a concurrent hash map first and foremost

wet breach
ivory sleet
#

because a regular hashmap may not at all be appropriate depending on what u’re doing in the async chat event

orchid gazelle
wet breach
#

Concurrent Modification Exception

#

it applies even if you do a read well suppose to

wet breach
#

but in some situations it may not get thrown

ivory sleet
#

Alr dafeist

#

try again

#

Else can u send the event handler code at least

orchid gazelle
# ivory sleet try again

now im getting Caused by: java.lang.NullPointerException: Cannot invoke "Object.hashCode()" because "key" is null at java.util.concurrent.ConcurrentHashMap.replaceNode(ConcurrentHashMap.java:1111) ~[?:?] at java.util.concurrent.ConcurrentHashMap.remove(ConcurrentHashMap.java:1102) ~[?:?]

ivory sleet
#

haha

#

Frostalf sniped it

#

player is null

orchid gazelle
#

so it basically only removes the player?

#

that's stupid of java ngl

ivory sleet
#

well

wet breach
#

well no it makes sense

ivory sleet
#

you were using the same key, null all along

orchid gazelle
#

that's also confusing

#

since I literally let it print out the Player

ivory sleet
#

Where did u do that

#

Show us some code :D

orchid gazelle
#

in the ChatEvent

#

1sec

#
    @EventHandler
    public void onChat(AsyncPlayerChatEvent event) {
        Player player = event.getPlayer();

        if(!ChatPrompt.inSession(player)) return;

        ChatPrompt session = ChatPrompt.getSession(player);

        boolean valid = session.procCurrentInput(player, event.getMessage());

        if(!ChatPrompt.inSession(player)) return;

        event.setCancelled(!valid);

    }```
ivory sleet
#

where did u print it

orchid gazelle
#

right before the first if clause

ivory sleet
#

Ugh yeah thats weird

orchid gazelle
#

well, do I just remove key AND value now?

#

sessions.remove(player, this); like this

wet breach
#

you could, but its probably due to how you are removing the stuff in that the value is doing the removing and the only thing that was keeping the value alive was the map, but the value can't go away because its being used

orchid gazelle
#

uhmm lol

wet breach
#

the only acceptable thing that could happen here is the key turns null and the later the value should disappear if the object goes away

orchid gazelle
#

so do I make cancel() static and then invoke sessions#remove with sessions#get from the argument?

ivory sleet
#

I’m already quite surprised you use a static hash map in a concurrent environment

echo basalt
#

why you got a static map

#

why is the key "player"

orchid gazelle
#

it manages all sessions

echo basalt
#

you're asking for memory leaks

orchid gazelle
#

can only be in the map there if player is on server

#

and only one session per player

wet breach
#

basically the issue you are running into is the whole self derefencing thing. Its not easy to setup an object to make itself null without issues and generally you need something else to make it null or go away

wet breach
#

not sure if making it static would work, because all that does is makes the method stay in memory. I think your issue is more or less the map being static. But try having your value object use another object to do the removing

#

so the value isn't the one removing itself

orchid gazelle
#

well if it's static it isn't it removing itself

#

so I guess imma try that out rq

#

boom NullPointerException lol

#

yay it is fixed

#

thanks a lot! I would have had a hard time finding out what this is, as I already had for like 2 hours of debugging lmao

#

just calling java public static void cancel(Player player) { sessions.remove(player); } now

wet breach
orchid gazelle
wet breach
#

the proper fix though

#

is to make your map not static

#

and make methods to remove or add static instead

echo basalt
#

AKA encapsulation

orchid gazelle
#

then I have like a Singleton lol

wet breach
#

no

#

you can make methods static for the removing so you can access anywhere without making the object istelf static

#

since that is what you want

#

that would have solved your entire problem instead of making a bunch of other methods static because your map is static

orchid gazelle
#

what Object is it associated then?

wet breach
#

HashMap is an object

echo basalt
#
public class MyDataManager {

  private final Map<UUID, Whatever> myMap = new ConcurrentHashMap<>();

  public Whatever getWhatever(UUID playerId) {
    return myMap.getWhatever(playerId);
  }

  public void putWhatever(UUID playerId, Whatever whatever) {
    myMap.put(playerId, whatever);
  }

  public void invalidate(UUID playerId) {
    myMap.remove(playerId);
  }
}
#

ezpz

orchid gazelle
#

I am confused

echo basalt
#

map wrapper

orchid gazelle
#

yeah ok fair

wet breach
#

it doesn't need to be static, but you are making it static because you want to access it easily everywhere. Instead you should make 2 methods that are static that interact with the map

orchid gazelle
#

well to be fair I am only making one method static for it

wet breach
#

at the moment

echo basalt
#

static aboose

#

just have a getter for your map wrapper

wet breach
#

^

echo basalt
#

DI it around

orchid gazelle
#

I am already wrapping it with getSession

#

just using sessions.remove twice outside ofi t

wet breach
#

then getSession should have been static. All I am saying is your problem you had was because you made your map static and was using it incorrectly. There is a lot that goes on with map's and hashmaps beyond just the code you make

orchid gazelle
#

getSession is static

echo basalt
#

still not a fan of it being static

#

no static

#

bad

wet breach
#

yeah I am not a fan of it either, but its not my project so all I can do is just explain the issue XD

orchid gazelle
#

imma change that rn

#

but that's still a singleton then

#

since I have to have that one manager lol

echo basalt
#

can't you just init it on your uh

#

plugin class

orchid gazelle
#

yeah gotta store it tho

#

and access staticly

wet breach
#

so you can easily initialize a map there and it won't go away along with making methods to access it

#

plugin main class can be accessed statically

#

which is one of the few classes at the beginning where its acceptable to do that

sterile flicker
#

does anyone know how to use packetsevents to update the weather?

rotund ravine
#

Playerweather is exposed in the API

sterile flicker
quaint mantle
#

Uh i cant buy vulcan

torn oyster
#

is there a way to increase npc size

#

i see that on the hive bedrock

#

but was wondering if it was possible in java

echo basalt
#

bedrock is something special

#

closest thing you have is modelengine

torn oyster
#

is there a way to hide hunger and hearts without creative mode

#

but show xp bar

weak adder
sterile flicker
#

How do I set the damage for a snowball?

#
                                Snowball.class,
                                player.getLocation().toVector()
                                        .subtract(snowman.getLocation().toVector()));```
sterile flicker
umbral ridge
wet breach
#

you sure do ask for a lot of help

#

might be wise to learn some java

umbral ridge
#

you need to learn how to read crash reports

wet breach
#

that crash report is actually vague to be fair however I have a pretty good idea what might be the cause of it

umbral ridge
#

yeah me too uwu

hushed spindle
#

which repository would you guys recommend if i want to make an api easy to import for others

#

maven central?

quaint mantle
#

        ItemStack item = new ItemStack(Material.NETHERITE_SWORD);
        ItemMeta itemMeta = item.getItemMeta();
        assert itemMeta != null;
        itemMeta.setDisplayName(ChatColor.DARK_AQUA + "Excalibur");

        ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(this, "Excalibur"), item);


        recipe.shape(" N "," N "," R ");

        recipe.setIngredient('N', Material.NETHERITE_INGOT);
        recipe.setIngredient('R', Material.BLAZE_ROD);

        Bukkit.getServer().addRecipe(recipe);

    }  ```

my code is like this. My problem is that the name Excalibur in the "displayname" does not appear on my sword. can anybody help me?
hushed spindle
#

getItemMeta() does not get the item meta currently on the item, it gets a copy of it

#

so changes made to this item meta dont immediately reflect to the item

quaint mantle
#

thx

#

i now understand 🥲

tender shard
#

Central requires setting up pgp keys

tender shard
hushed spindle
#

what about jitpack or is that unreliable

tender shard
#

Jitpack is really wonky

#

But better than nothing

sterile flicker
#

I want to register my nms entity so that it doesn't disappear so easily, but the problem is that entityplayer doesn't extend the EntityInsentient class. please help public void registerEntity(String name, int id, Class<? extends EntityInsentient> nmsClass, Class<? extends EntityInsentient> customClass) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { List<Map<?, ?>> dataMap = new ArrayList<Map<?, ?>>(); for (Field f: EntityType.class.getDeclaredFields()) { if (f.getType().getSimpleName().equals(Map.class.getSimpleName())) { f.setAccessible(true); dataMap.add((Map<?, ?>) f.get(null)); } } if (dataMap.get(2).containsKey(id)) { dataMap.get(0).remove(name); dataMap.get(2).remove(id); } Method method = EntityType.class.getDeclaredMethod("a", Class.class, String.class, int.class); method.setAccessible(true); method.invoke(null, customClass, name, id); }

tender shard
#

Just register for maven central if you dont wanna self host

hushed spindle
#

cool cool

sterile flicker
grim hound
sterile flicker
grim hound
#

Sure

sterile flicker
#

    private final net.minecraft.server.v1_16_R3.Chunk chunk;

    public PacketMapChunk(final World world, final int x, final int z) {
        this(world.getChunkAt(x, z));
    }


    public PacketMapChunk(final org.bukkit.Chunk chunk) {
        this.chunk = ((CraftChunk)chunk).getHandle();
    }

    public final void send(final Player player) {
        ((CraftPlayer)player).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(chunk, 20));
    }

    public static final void refreshChunk(final Chunk chunk) {
        refreshChunk(chunk.getWorld(), chunk.getX(), chunk.getZ());
    }


    public static final void refreshChunk(final World world, final int x, final int z) {
        final Collection<? extends Player> players = Bukkit.getOnlinePlayers();
        refreshChunk(world, x, z, players.toArray(new Player[players.size()]));
    }

    public static final void refreshChunk(final World world, final int x, final int z, final Player... players) {
        final PacketMapChunk packet = new PacketMapChunk(world.getChunkAt(x, z));
        for(final Player player : players) {
            packet.send(player);
        }
        world.refreshChunk(x, z);
    }
}```
#
                    int chunkXStart = c.getX() << 4;
                    int chunkZStart = c.getZ() << 4;
                    for (int x = 0; x < 16; x++)
                        for (int z = 0; z < 16; z++)
                            c.getWorld().setBiome(chunkXStart + x, chunkZStart + z, Biome.SNOWY_TAIGA);
                    PacketMapChunk.refreshChunk(c);
                }```
sterile flicker
grim hound
#

Seems probable

#

You should know that the chunk itself is probably updated

#

But the packet telling the player that isn't sent

#

I think you could my approach with just teleporting the player to another world and teleporting him back a tick later

wet breach
#

why is packets being messed with?

quaint mantle
#

Grim sux

#

I just wanna buy vulcan but i have no permission

wet breach
#

why do you want to buy vulcan?

quaint mantle
#

Bc it is a decent anticheat

grim hound
quaint mantle
#

Yeah ...

#

But i like it

grim hound
#

And grim only false flags his non-major checks

wet breach
grim hound
#

Like placing and breaking stuff

quaint mantle
#

Yeah ok

sterile flicker
wet breach
#

you don't need everything from the anti-cheats out there, most times you only need some very specific things

grim hound
#

You know how terrible an anticheat made on request for 20$ will be?

wet breach
#

most of the stuff is do able from api only

grim hound
#

Probably all major cheats

#

Which is not easy at all

#

So don't listen to him

wet breach
#

again it depends. Lets say you have a mini-game, there is only very specific things you would only need to stop in such a scenario

grim hound
#

Finding an existing ac is much better than hiring someone to do it

wet breach
#

it does

grim hound
#

I've been an ac dev for 2 years

#

So it really doesn't matter

#

If you only need a specific thingy blocked, you wouldn't be seeking an ac to buy

wet breach
#

and I have been a dev with java since nearly its beginning, how long you been a dev isn't relevant in whether you need to stop all cheats that are not relevant to the game

#

if you don't have pvp enabled for example, why do you need an AC for pvp?

#

but I digress you know more I suppose so I will just go back to what I was doing before 🙂

sterile flicker
grim hound
grim hound
#

But I guess pride isn't something I can argue with

grim hound
sterile flicker
wet breach
#

I am probably more versed in the realms of cyber security then 90% of anyone here, don't have to tell me but self proclaiming yourself as being better doesn't make you better

grim hound
#

Most ac have a config capable of disabling checks

grim hound
#

So it could be the thing crashing your server

grim hound
#

You're talking about how self-proclaiming doesn't matter yet you

#

Do it yourself?

#

Do you even pay attention to what you write

wet breach
#

I was trained in the military which I can prove and have done so

#

so its not a self proclomation

grim hound
#

And you didn't even take into account what I've written before

grim hound
#

Now you're just throwing words

sterile flicker
grim hound
#

Are coding a completly new entity, with a new hitbox and texture?

tender shard
sterile flicker
# grim hound Why would you need that?

the entity disappears when I log out of the server even though I have @EventHandler public void onEntitySpawn(CreatureSpawnEvent event) { event.getEntity().setRemoveWhenFarAway(false); }

grim hound
#

Who's that

wet breach
grim hound
#

And I assume you'd be fine with using an already existing mob

#

World#spawnEntity

#

And just put like Zombie.class

#

Or whatever mob you wanna use

quaint mantle
#
    public void onSpread_GlowBerry(BlockSpreadEvent e) {
        BlockState state = e.getNewState();
        BlockData bd = state.getBlockData();
        if (bd.getMaterial() == Material.CAVE_VINES) {
            state.setType(Material.CAVE_VINES_PLANT);
        }
    }```
the block doesn't change even if it matches the if statement. how can i fix it?
tender shard
#

cancel the event

#

and then set the block's blockstate

quaint mantle
#

the cancellation is normal, but it looks like CAVE_VINES is growing even though I set it to Material.CAVE_VINES_PLANT.

hollow oxide
#

I quite want something that works along with commands

/tp player 0 0 $scoreboard players get player Zcord$

i just want to do a plugin that can look at every commands, and change whats between $ by numbers and also give the command back to minecraft

i know that a /tp is ez to recreate so i could just overide it
but i quite want to use it in /execute and stuff

also i just want to know if it's possible

chrome beacon
#

You can use the Preprocess event to catch and modify commands

hollow oxide
#

thx

chrome beacon
cinder abyss
#

Hello, how can I check if a block isn't complete? (like a flower or grass)

halcyon hemlock
#

get the block state I think

#

and then cast it to some class that is related to growth or damageable or something

halcyon hemlock
#

like water

cinder abyss
tender shard
#

isSolid checks if you can place against sth, so a layer of snow is solid

cinder abyss
#

but not for flowers 🤔

tender shard
#

flowers should be solid too

cinder abyss
#

humm

#

I want to check if the block is a flower or a replaceable block

dawn flower
#

is it possible to stop certain logs with specific text to not show in the console? (smthing like Console Spam Fix)

tender shard
# dawn flower is it possible to stop certain logs with specific text to not show in the consol...

Spigot uses Log4j to log console output, hence making it easy to listen to incoming console messages, or to block certain console messages from appearing. Prequisities You need to have Log4J on your classpath. We simply add the dependency to our pom.xml using the provided scope, as Spigot already contains those classes on runtime: Create...

dawn flower
#

can u force any head to not even place not even for a split second like hypixel?

tender shard
#

maybe cancel the interact event

dawn flower
#

i want it to be like adventure mode

#

but wihtout adventure mode

chrome beacon
#

you'll need adventure mode

quaint mantle
quaint mantle
hollow oxide
# hollow oxide I quite want something that works along with commands /tp player 0 0 $scoreboar...

same topic
i'm using preprocess and it seems promising (thx Olivo)

But in:
/execute as @a at @s run tp @s 0 0 $scoreboard players get @s Zcord$

how do i know who is the @s in the $ $?

and sometime it gets even more complexe so I can't recode every @

||for exemple:
execute at @a[scores={OpNum=5..13},nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick"}}] as @s run tp @s ^ ^ ^$scoreboard players get @sZcord$||

hollow oxide
#

thx

tender shard
#

that evaluates the @s (and others) into a list of entities

storm scaffold
#

How do I make a fake player appear in tab to certain players, with a skin on? I'm trying to hide players (including armour) from specific other players, and the only thing that seems to do that also removes them from tab

shadow night
#

You'd need to change their skin I think

fickle mantle
#

Hey, I need help with a scoreboard plugin. Why do all player have the same scoreboard, even tho I use Bukkit.getScoreboardManager().getNewScoreboard()?

storm scaffold
shadow night
#

Ah

#

I think you would needed to add a player into the world for that since that's linked to tab, atleast that's how I remember it being

hollow oxide
molten cloak
#

Hello, how do I fix when I using a lobby created by /mv import (name of file). how do I make so new people spawn there instant when they join and not to the ''world'' (using multiversecore)

ivory sleet
#

You need to still have it cached somewhere else its gonna get gcd

#

And you then you also need to set it explicitly

ashen turtle
#

Is it new year bug or em I missing something? But plugin file size limit went down to 2MB for spigotmc uploads.

#

My guess php.ini got a reset and all files got hard 2MB limit

fickle mantle
worldly ingot
#

Ah, possibly a bug due to the upgrade. Will let md know

orchid gazelle
#

what is the normal hard limit?

#

8?

worldly ingot
#

4.5mb

remote swallow
#

8 for free 4 for prem

orchid gazelle
#

ouch

#

yeeaaah I won't be able to upload all my plugins on spigot then lol

worldly ingot
#

md did some upgrades to PHP so ye. Probably that

tender shard
remote swallow
#

idk you have premium resources

#

you should know

tender shard
#

i never reached the limit

quiet ice
#

It probably is the other way around - why would premium resources have less storage than free ones?

sterile flicker
chrome beacon
sterile flicker
chrome beacon
#

chunkload and unload is a start

#

save the data and load it again when needed

sterile flicker
chrome beacon
#

That's up to you

#

There are many ways to save data

sterile flicker
chrome beacon
#

Save the information you need to

#

for example npc location and name

sacred ice
#

Hi, does any have a Minecraft server stresser bots software ? I want to test my plugin with a lot of players on local ? my version is 1.18.2 I didn't found anything on the internet up to this server version, thanks

sterile flicker
sterile flicker
#

is there a better way to do this so that all players can see the nms entity and it is visible to everyone until it is killed?

chrome beacon
#

Look around in the internals and see how it's handled

#

You're working with NMS you need to be able to read the code yourself

sterile flicker
#

I looked at the codes of other npc plugins but did not find what I need

chrome beacon
#

You could just use an existing plugin like Citizens if you don't know how to read NMS code

molten cloak
#

Hello, how do I fix when I using a lobby created by /mv import (name of file). how do I make so new people spawn there instant when they join and not to the ''world'' (using multiversecore)

sterile flicker
# chrome beacon You could just use an existing plugin like Citizens if you don't know how to rea...

solution is @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { if (EntitySilkworm.summoned) { PlayerConnection connection = ((CraftPlayer) event.getPlayer()).getHandle().playerConnection; connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, EntitySilkworm.entityPlayer)); connection.sendPacket(new PacketPlayOutNamedEntitySpawn(EntitySilkworm.entityPlayer)); } }

chrome beacon
#

Yeah

#

Does look like your code contains some static abuse or not following naming conventions

shadow night
#

Yes

sterile flicker
#

is there a class for inheriting from an ifrit entity?

shadow night
#

ifrit?

tender shard
#

what is an ifrit entity

shadow night
#

You mean blaze?

tender shard
#

ifrit?

sterile flicker
#

blaze

#

yes

tender shard
#

just extend the blaze class?

shadow night
#

Ig man just didn't know what a blaze was called in english lol

sterile flicker
desert musk
#

is setCancelled a thing anymore?

#

why doesn't it exist for a PlayerDeathEvent

shadow night
#

You probably can't cancel a death then

#

Not all events are cancelable

desert musk
#

1.20.2 code of someone cancelling the same event

shadow night
#

Well

#

¯_(ツ)_/¯

desert musk
#

does anyone know?

slate tinsel
#

Hello! now this code gives a vector / block, I would have liked a more detailed list, so more vectors how do I do it? So the goal of this is to retrieve the projectile's Trajectory 🙂

shadow night
remote swallow
#

player death event is has the setCancelled on paper not spigot

shadow night
#

Well, so my suspicion was true

desert musk
#

i see

shadow night
#

And you need the entity damage event and see when the player basically dies

desert musk
#

so does this plugin just need to be a paper one?

remote swallow
#

if you want the easy way to cancel yeah, if not use the damage event and do the math

shadow night
#

Either you use the entity damage event solution or you can switch to paper

desert musk
#

interesting

shadow night
#

But you'll have to ask for support at paper if you use paper

chrome beacon
#

also don't release your plugin on spigotmc if it doesn't support spigot

desert musk
#

thanks

quiet ice
opal elbow
#

Is there a way to deactivate the slot highlight for certain items when hovering over them in the inventory?

slender elbow
dense laurel
#

I just started using Mojang Brigadier and one problem i have is that CommandSourceStack does not exist. I'm using 1.0.18 (latest), and i don't really know what to do. Any ideas on how could i fix that?

worldly ingot
#

A lot of types are defined under server internals

hard matrix
#

Hey, is it possible to disable skins when the players join? in a plugin?

inner mulch
#

i think it is, with packets, i dont know how tho

storm scaffold
#

What do I do to make a player completely invisible to others, but not in tab?

inner mulch
#

minecraft invisibility potion

#

just kidding

#

but

#

why would you want that?

tender shard
#

maybe Player#hideEntity(otherPlayer)

inner mulch
#

no

tender shard
#

not sure if it works on players

inner mulch
#

then there wouldnt be a player in tab

tender shard
#

i thought that only applies to hidePlayer

inner mulch
#

oh actually

#

you could be right

tender shard
#

i am not sure though lol

inner mulch
#

i guess @storm scaffold has to try

storm scaffold
#

hidePlayer and hideEntity both seem to make them disappear in tab

inner mulch
#

cometcake why dont you just use invisibility

#

you can hand out infinite invisibility without particles

#

then there would be a player in the tab lsit

storm scaffold
warm mica
#

You could possibly use hidePlayer and make them reappear on the tab with a plugin lika TAB, if that's possible and if you're just doing it for yourself

storm scaffold
warm mica
#

Alternatively you could block the spawn player packet from getting sent

storm scaffold
#

How do I do that?

shadow night
#

Have you not thought of just sending an add player packet and spawning the player in some ass of the world or is that not an option?

warm mica
storm scaffold
storm scaffold
echo basalt
#

there is

#

there always is

#

what's wrong with just sending an entity destroy packet

#

it'll still appear on tab

storm scaffold
echo basalt
#

with nms

warm mica
#

Players will flicker when they spawn

echo basalt
#

:)

astral scroll
#

Someone knows a Annotation based commands libs?

echo basalt
#

ACF, Cloud command

astral scroll
#

k thanks

storm scaffold
warm mica
#

Maybe there's an up-to-date tutorial available somewhere

astral scroll
#

remember NMS changes every version

shadow night
#

Yeah, so you'll have to do some funky stuff to keep it working

tender shard
warm mica
#

With protocollib you could do that more easily while supporting cross-version

tender shard
#

yeah listening to packets is one of the few situations where I'd also use protocollib

spring stag
#

So I am trying to create a method that goes through the players inventory and names everything, (this is for testing). However, it only names the items in the player's hotbar. Any suggestions on getting the players complete inventory?

    @EventHandler
    public void itemPickupEvent(EntityPickupItemEvent event) {
        Player player = ((Player) event.getEntity()).getPlayer();
        Inventory inventory = player.getInventory();
        for (ItemStack item : inventory) {
            player.sendMessage(item.getTranslationKey() + " is in your inventory.");
        }
    }
hollow oxide
#

is there a way to preprocess a command executed by a command block??
I know there is PlayerCommandPreprocessEvent.

Should i create a fake player (somehow) then make him execute every command send by a command block?

any other idea?

mellow edge
#

new WorldCreator(World).createWorld(); expects just the folder name in the server's directory or absolute path?

worldly ingot
#

What do you think cancelling the BlockPlaceEvent does? :p

#

You just can't. The client makes predictions and places the block. So unless you're in adventure mode, you cannot stop that single tick placement. The server is the one saying "no no no, your prediction is wrong" and sends back a packet saying otherwise

#

You have to stop it in the client to begin with, which you do with adventure mode (or the CanPlaceOn tag of an item)

deep herald
#

can anyone help me with plugin messaging?

#

im trying to check their bungee server thru bukkit

proud badge
#

What is better:
Having multiple Queues (3) with different types of objects
or
Having one Queue that accepts "Object" (any object) and using instanceof when looping through the queue

worldly ingot
#

If the objects are each your own defined types, maybe making an interface for them is better. Otherwise, maybe a wrapper type. If they're all distinct from one another, three separate queues is fine. It depends on the situation

proud badge
#

do yall think executing a discord webhook would be laggy

#

Im trying to figure out what is causing lag in my code

quaint mantle
#

Wrap webhook.execute() in bukkit async task.

worldly ingot
#

Unless it's async already in which case whatever, but yeah. Just be sure your web requests are done asynchronously

proud badge
quaint mantle
#

fix: Get better internet

proud badge
#

rip

#

ok ill try wrapping it in async

young knoll
#

Try time travel

proud badge
#

see if it slows down my stuff

slender elbow
#

unless you are spawning hundreds of threads, doing something async will not change the speed at which it runs

worldly ingot
#

what do you mean? I thought async = faster :(

#

like a bazillion times faster

quaint mantle
#

should I be unit testing exceptions

#

Async math

#

like illegal state, nullpointer, etc

#

Async rendering

worldly ingot
echo basalt
#

I create a new thread every time I send a message to my player so it arrives faster

slender elbow
#

yeah keep doing that

quaint mantle
#

also

#
public class FileJsonConfigDao implements ConfigDao<JsonObject> {

    @NotNull
    public static FileJsonConfigDao newInstance(@NotNull Path configFolder, @NotNull Gson gson) {
        return new FileJsonConfigDao(configFolder, gson);
    }

    @NotNull
    public static FileJsonConfigDao withTypeAdapters(@NotNull Path configFolder, @NotNull Map<Type, Object> typeAdapters) {
        GsonBuilder gsonBuilder = new GsonBuilder().serializeNulls().disableHtmlEscaping().setPrettyPrinting();
        typeAdapters.forEach(gsonBuilder::registerTypeAdapter);
        return new FileJsonConfigDao(configFolder, gsonBuilder.create());
    }

    @NotNull
    public static FileJsonConfigDao createDefault(@NotNull Path configFolder) {
        Gson gson = new GsonBuilder().serializeNulls().disableHtmlEscaping().setPrettyPrinting().create();
        return new FileJsonConfigDao(configFolder, gson);
    }

    private final Path configFolder;
    private final Gson gson;

    private FileJsonConfigDao(@NotNull Path configFolder, @NotNull Gson gson) {
        Preconditions.checkNotNull(configFolder, "Parameter configFolder is null.");
        Preconditions.checkNotNull(gson, "Parameter gson is null.");

        this.configFolder = configFolder;
        this.gson = gson;
    }

Would static constructors be appropriate here, this is kinda of more of a "internal" thing

echo basalt
#

yeah that follows effective java's principles

#

reading that book rn

quaint mantle
#

hm

#

i just, idk how its gonna end up

quaint mantle
#

I thought abt it

echo basalt
#

I'd call newInstance within your methods though

quaint mantle
#

wdym

echo basalt
#
  @NotNull
    public static FileJsonConfigDao createDefault(@NotNull Path configFolder) {
        Gson gson = new GsonBuilder().serializeNulls().disableHtmlEscaping().setPrettyPrinting().create();
        return FileJsonConfigDao.newInstance(configFolder, gson);
    }
#

type deal

quaint mantle
#

oh

echo basalt
#

and I'd prob call your withTypeAdapters(Collections.EMPTY_MAP) or sumn

#

basically if you were to change any of the methods the others should adapt to the new changes

proud badge
slender elbow
#

then use a single thread Executor so it keeps one alive instead of spawning one every time you need it

proud badge
#

look let me explain how my code works

slender elbow
#

lol

proud badge
#

actually

#

Whilst typing that out I realised a way to make this better

quaint mantle
#

Every n ticks head of queue poped and processed.

spring stag
#

How would I go about checking the ItemStack value of an item that I pick up? I've tried the following statement but nothing happens when I pick something up.

    @EventHandler
    public static void itemPickupEvent(EntityPickupItemEvent event) {
        if (event.getItem() == ItemManager.abundanceDiamond && event.getItem() != null) {
          Player player = ((Player) event.getEntity()).getPlayer();
          Inventory inventory = player.getInventory();
          for (ItemStack item : inventory) {
              if (item.containsEnchantment(Enchantment.LOOT_BONUS_BLOCKS) || item.containsEnchantment(Enchantment.LOOT_BONUS_MOBS)) {
                  player.sendMessage("Enchantments have already been added");
              } else if (item.getType().equals(Material.IRON_AXE) || item.getType().equals(Material.IRON_PICKAXE)) {
                  player.sendMessage(item.getTranslationKey() + " is in your inventory.");
                  item.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
                  item.addEnchantment(Enchantment.LOOT_BONUS_MOBS, 3);
                  player.sendMessage(item.getTranslationKey() + " is now enchanted.");
              }
          }
      }    
}
young knoll
#

ItemStack.isSimilar

young knoll
#

Although pdc is probably better

molten hearth
#

omg this mongodb async library is so shit im going insane

#

does anyone know if i can even tell if it connected successfully

quaint mantle
molten hearth
#
MongoClient client = MongoClients.create(null);

client.listDatabases()``` doesnt even throw an error
molten hearth
#

huh

quiet ice
#

Does anyone remember some project that uses classical gradle shading out of the top of the head?

#

Okay figured it out - it's something along:

task uberJar(type: Jar, dependsOn: remapJar) {
    archiveClassifier = 'remapped-all'
    from remapJar
    configurations['uberDependencies'].forEach {
        from zipTree(it).getFiles()
    }
}

Obviously that doesn't work yet but the idea is there

tender shard
quiet ice
#

Opted for the safer option

tender shard
#

Create a task of type Jar that collects the ziptree of all dependencies that have your custom configuration

#

Well or just let it collect everything thats scope implementation or whatever

quiet ice
#

Yeah, I only need to set the duplicate stuff strategy and remove dependencies that shouldn't belong there

tender shard
#

Thats why i‘d create a custom configuration for the shaded stuff

quiet ice
#

Yeah, but transitive deps are here to mess your day up

tender shard
#

Yes probably:')

quiet ice
#

Actually my approach does not work as it puts everything in the root directory by default... Somehow

tender shard
#
configurations { shade }
dependencies {
  shade "groupid:artifactId:version" // optionally exclude transitive stuff or whatever
  compileOnly "groupid:artifactId:version"
}
tasks.register<Jar>("shadedJar") {
  from(configurations.shade.collect { it -> it.isDirectory() ? it : zipTree(it) })
}

shouldnt sth like that work?

quiet ice
#

Yeah that is the approach I'll go with

spring stag
#

Does the Inventory class only relate to the players hotbar?

echo basalt
#

no

#

It relates to any "gui"

#

As in horses, villagers, chests, brewing stands, furnaces

#

They all have inventories

spring stag
#

Ah

#

gotcha

#

just dug through the javadoc and found what I was looking for as well lol

proud badge
#

should varchar be uppercase

orchid trout
#

no

proud badge
#

ok

glad prawn
#

yes for me

wet breach
proud badge
#

ah so its something similar to “variable names must begin with lowercase”

#

Where it isnt required

wet breach
#

yeah, it helps distinguish what is keywords and what is not in the queries

#

and you already do it in your queries partially

#

with the CREATE TABLE statement might as well keep consistency 😛

#

also you can reduce your columns

#

just store location either as a string or a base64 string

#

then you can remove all those columns and have a single one for location

#

if you store as a normal string, you just expand on every ,