#help-development

1 messages · Page 2102 of 1

eternal night
#

so that would reduce your line numbers by a bit

granite owl
#

try resource to call the "destructor"

#

?

eternal night
#

well to call .close

granite owl
#

yea

#

i use that for my native methods

#

from my dll

#
¬í ur ![Lorg.bukkit.inventory.ItemStack;–lr¤Ï  xp   )sr org.bukkit.util.io.WrapperòPGìño L mapt Ljava/util/Map;xpsr 5com.google.common.collect.ImmutableMap$SerializedForm         L keyst Ljava/lang/Object;L valuesq ~ xpur [Ljava.lang.Object;ÎXŸs)l  xp   t ==t vt typet metauq ~    t org.bukkit.inventory.ItemStacksr java.lang.Integerâ ¤÷‡8 I valuexr java.lang.Number†¬•
”à‹  xp  
Ÿt NETHERITE_SWORDsq ~ sq ~ uq ~    q ~ 
t     meta-typet enchantst Damageuq ~    t ItemMetat 
UNSPECIFICsr 7com.google.common.collect.ImmutableBiMap$SerializedForm          xq ~ uq ~    t 
DAMAGE_ALLuq ~    sq ~    q ~ "sq ~ sq ~ uq ~    q ~ 
q ~ 
q ~ t amountuq ~    q ~ sq ~   
Ÿt 
DIAMOND_BLOCKsq ~    @sq ~ sq ~ uq ~    q ~ 
q ~ 
q ~ uq ~    q ~ sq ~   
Ÿt WOODEN_SWORDsq ~ sq ~ uq ~    q ~ 
q ~ 
q ~ q ~ &uq ~    q ~ sq ~   
Ÿt  CHICKENsq ~    sq ~ sq ~ uq ~    q ~ 
q ~ 
q ~ q ~ &uq ~    q ~ sq ~   
Ÿt  FEATHERsq ~    sq ~ sq ~ uq ~    q ~ 
q ~ 
q ~ q ~ 
uq ~    q ~ sq ~   
Ÿq ~ 0sq ~ sq ~ uq ~    q ~ 
q ~ q ~ uq ~    q ~ q ~ q ~ "sq ~ sq ~ uq ~    q ~ 
q ~ 
q ~ uq ~    q ~ sq ~   
Ÿt 
GRASS_BLOCKppppppppppsq ~ sq ~ uq ~    q ~ 
q ~ 
q ~ uq ~    q ~ sq ~   
Ÿq ~ ppppppppppppppppppppppp
``` so it serialized just fine
modest acorn
#

guys when i try test my plugin the Console print an error on this code, can someone help me?

granite owl
#

lets see the deserialization process

granite owl
#

so lets see if it deserializes ```java
ItemStack[] is = (ItemStack[]) NonReflectables.deserializeBukkitObjectFromFile(invDir.getPath() + '/' + p.getUniqueId().toString() + ".bin");

            for (ItemStack item : is)
            {
                Bukkit.broadcastMessage(item.getType().toString());
            }
#

yes it does

#

only crashed cause i forgot to exclue null entries

#

but works now @eternal night ty for the info about Bukkit sers btw xD

eternal night
#

glad to be able to help 🙂

granite owl
#

like i asked 3 times before and no one was apparently able to inform me that bukkit has a serializer wrapper xD

#

so i started writing my own system

#

which is where the mess came from

eternal night
#

oof

#

Yea no the serializers works fine

#

idk how well it does version upgrades

#

(paper has a nice method for that, but I digress)

granite owl
#
public static void onPlayerJoin(Player p)
    {
        File invDir = new File(Utils.getOwnDir + "inv");
        
        if (invDir.exists())
        {
            if (new File(invDir.getPath() + '/' + p.getUniqueId().toString() + ".bin").exists())
            {
                p.getInventory().setContents((ItemStack[]) NonReflectables.deserializeBukkitObjectFromFile(invDir.getPath() + '/' + p.getUniqueId().toString() + ".bin"));
            }
        }
    }
    
    public static void onPlayerQuit(Player p)
    {
        File invDir = new File(Utils.getOwnDir + "inv");
        if (!invDir.exists()) invDir.mkdir();
        NonReflectables.serializeBukkitObjectToFile(p.getInventory().getContents(), invDir.getPath() + '/' + p.getUniqueId().toString() + ".bin");
    }
``` final implementation @eternal night once ive cleaned up xD
#

now i can start writing the methods to alterate the contents(used to edit offline players inventories)

eternal night
#

maybe save those files instead of re-creating it

#

urgh file api is so ugly

#

ngl paths are life

granite owl
#

^^

#

Utils.getOwnDir

#

does this

#

for me

#
public final static String getOwnDir = "./plugins/PluginMeta/" + new File(main.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getName().substring(0, new File(main.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getName().length() - 4) + "/";
#

gets a path to its own directory

#

where its supposed to write

#

based on the main classes directory

granite owl
#

theyre supposed to be applied when the player logs in and to be created when the player logs off

eternal night
#

oh

granite owl
#

as a copy to be edited

eternal night
#

you are just passing a string

#

to the file input and output streams

#

interesting design choice

granite owl
#

yea but the string

#

the plugin gets its own path by this

#

i store all plugin data in plugins/PluginMeta

#

and i use a master plugin to manage most of my directoy drama

#

which loads first and for example creates such a directory for all other plugins

#

if it doesnt exist

#

and deletes directories of non existant plugins

#

so no junk data remains

modest acorn
low temple
#

Means the data doesn’t exist in ur file

granite owl
#

@eternal night ik many call that bad practice but since i write my entire system myself, i see no problem in having a master plugin taking care of the file structure

low temple
#

“Pkers:”
Doesn’t seem to exist in the target yml

crisp steeple
#

well there’s nothing there is there

low temple
#

Cause there’s no data under pkers: then

#

Since there’s no data given to pkers: it’s considered null

modest acorn
#

but that's where the PK list will be

#

by nature it must be clean 🤣

#

then if a player kills an innocent person he enters this list

crisp steeple
#

yeah but you’re trying to get a value from it that doesn’t exist

modest acorn
#

so what should i do?

crisp steeple
#

create it first?

celest scaffold
#

i've discovered something: if i break redstone ore with holding with pickaxe (like in survival), it wont drop anything, but if i break it in creative (no time for it to activate), it will drop something according to those 2 codes

modest acorn
celest scaffold
#

so basically if i break before ore activates, first part works, if it activates, first and second not working

#

how do i cancel redstone ore activation

glossy venture
#

youre going to experience a lot of inconsitent bugs if you dont

celest scaffold
#

ah

glossy venture
#

only reason it might work now is because it is stored in a string pool

celest scaffold
#

you meants up at ==

glossy venture
#

yeah

celest scaffold
#

now i understand

glossy venture
#

wait

#

let me explain

celest scaffold
#

i dont want to change it to all 9 parts

#

so i will let like that since it works

steel swan
glossy venture
#

so == checks for identity, meaning the objects have to be the same instance, .equals(...) should check the actual content.
so if i have

String a = "hi";
String b = "hello";

System.out.println(a == b); // false
System.out.println(a.equals(b)); // false

// but...
String c = "test";
String d = "test";

System.out.println(c == b); // false (most of the time)
System.out.println(c.equals(b)); // true (always)
#

@celest scaffold

#

you defenitely should change it

celest scaffold
#

ok i will try

granite owl
#

is it possible to use this to create a player inventory?

#
Inventory inv = Bukkit.createInventory(null, InventoryType.PLAYER, ChatColor.DARK_RED + "TEST");
                ((Player)sender).openInventory(inv);
crisp steeple
#

i don’t think you can do that

granite owl
#

i mean the player inv UI, ik its bound to the PlayerInventory interface

celest scaffold
#

ah yeah i've forgot about my issue

#

so.. if the block is broken instantly before the redstone ore activates, i get the item, but if i try to break as survival with any pick, it activates and after breaking, i dont get anything, even if i have the code ready

        else if(BlockBroken.equals("REDSTONE_ORE")) {
            ItemStack item = new ItemStack(Material.REDSTONE, 1);
            event.getPlayer().getInventory().addItem(item);
        }
        else if(BlockBroken.equals("ACTIVATED_REDSTONE_ORE")) {
            ItemStack item = new ItemStack(Material.REDSTONE, 1);
            event.getPlayer().getInventory().addItem(item);
        }
#

i also have this at the end of the code so it wont double

glossy venture
#

does anyone know how minecraft furnaces work?
does it re-evaluate the recipe every tick for every block
or does it store the recipe in the nbt tag or something like that
and rematch that every time the input is modified

granite owl
steel swan
echo basalt
#

unload the world, delete the world folder

#

Bukkit.unloadWorld -> WorldUnloadEvent -> File#delete

#

world unloads aren't instant

#

also paper does IO async with no way to know when it's done

#

you can just wait like 2 seconds for it to be done

#

the folder will still be in use when you try to delete it

sacred mountain
#

is there an event for slimes/magma cubes splitting?

#

i think SlimeSplitEvent exists, but is that also for magma cubes

small lynx
#

if Entity is not equals slime return

echo basalt
#

Magma cubes should extend slime

sacred mountain
#

okay

#

ill see if that is so

echo basalt
#

I generally just play it safe and have some utils for that

sacred mountain
#

it eyup it extends slime

#

thanks

#

is there a method that returns all the newly created entities

echo basalt
#

lol the cache folder is hella useless

sacred mountain
#

i would think not since its catching the event

#

because all there is is getCount()

cyan compass
#

What event might i use to detect if a block breaks?

echo basalt
#

BlockBreakEvent

tardy delta
sacred mountain
#

i want to modify all the split entities

cyan compass
#

But that's player only

echo basalt
cyan compass
#

I want to detect if a portal gets blown up

#

but the thing is i also want to know if the portal is just destroyed in general since people could punch the obsidian

steel swan
#

guys how to i use the generatorsettings

sacred mountain
cyan compass
#

I'm already using that

#

But it does every block update to the portal

echo basalt
#

I probably have some code using those generator settings but it's clown stuff I made 3 years ago

crisp steeple
sacred mountain
#

how do i modify the baby slimes when a slmie splits into babty slimes?

echo basalt
#

making sure the world is properly unloaded

sacred mountain
#

because the event is before it spltis

#

splits*

cyan compass
echo basalt
#

my WorldUtils#unload method actually waits for the WorldUnloadEvent to get called and such

#

by doing some async latches

static pendant
#

Is there a way to display the mesh-texture of a block?

#

Green lines along the edges?

echo basalt
#

only had to suffer for 2 weeks straight to understand why

cyan compass
#

Maybe this but instead of just getblock().getlocation do getSourceBlock()?

echo basalt
#

I have some funky code for that

#

very funky

#

not proud but ok

glossy venture
#

5 quintillon fancyness points

echo basalt
#

yessir

#

Latch is a fancy CountdownLatch that throws an exception if I try to await on the main thread

#

narnia

#

whenNextUnload just puts that Consumer<World> on a collection

#

that iterates whenever WorldUnloadEvent is called

#

no

#

:)

glossy venture
#

what are you trying to do

echo basalt
#

deletin a world

glossy venture
#

ah

echo basalt
static pendant
echo basalt
#

unless there's some packet fuckery with structure blocks

static pendant
#

yes, i'm looking for that fuckery

glossy venture
#

maybe do something like

/* some method */ {

  final String worldName = ...;

  new Thread(() -> {
    while (Bukkit.getWorld(worldName));
    Bukkit.getScheduler().runTask(plugin, 
        () -> actuallyDeleteWorldOrSomething(...)
    );
  }).start();

}

public void actuallyDeleteWorldOrSomething(/* args */) {
  // ...
}
#

idk if the world is removed when its unloaded

#

bruh

echo basalt
#

yeah but why busy wait when you can wait for an event

#

if you absolutely want to

glossy venture
#

does it get called when you force unload it then

echo basalt
#

delete it 5 seconds after it unloads

#

kill the cpu

#

pretty much

glossy venture
#

wait until its unloaded

#

yeah its not a very good idea

#

didnt know there was an event

echo basalt
#

adding data to a collection and iterating it whenever the event gets called

#

aka using a latch

mossy prairie
#

Does anyone know?

midnight shore
#

Hi i have a problem! I have a private github repo and i'm using jitpack to use it. I don't quite understand how to do this...

mossy prairie
#

Its gradle and I did refresh it

glossy venture
#

@quaint mantle or do like

public CompletableFuture<WorldUnloadEvent> waitForWorldUnloadEvent(Plugin plugin, World world) {
  CompletableFuture<WorldUnloadEvent> future = new CompletableFuture<>();
  Listener listener = new Listener() {
    @EventHandler
    public void onEvent(WorldUnloadEvent e) {
      if (!e.getWorld().equals(world))
        return;
      HandlerList.unregisterAll(this);
      future.complete(e);
    }
  };
  Bukkit.getPluginManager().registerEvents(listener, plugin);
  return future;
}

/* some method */ {
  waitForWorldUnloadEvent(world)
    .whenComplete(event -> {
      // ...
    });
}
midnight shore
#

and the token

echo basalt
#

also you gotta register the listener

glossy venture
#

shit

#

wrote it in discord lmao

#

there

ivory sleet
#

well

#

its the other way around

#

listener, plugin

glossy venture
#

oh

#

yeah

#

shit

#

also there were some bugs

#

well really i fucked up the code again because i was writing it in discord

#

possible

tardy delta
#

lol why not

#

got nothin better to do

mossy prairie
#

Does anyone know?

midnight shore
#

yeah but there isn't any Jitpack discord server and also i'm using this for spigot

#

where should i ask?

ivory sleet
#

will0mane its fine to ask here

#

just keep in mind, people may not be at all knowledgeable concerning other topics

#

especially jitpack since it has a notorious reputation

ivory sleet
#

its known for not working very well per say

midnight shore
#

oh..

ivory sleet
#

I almost vomited last time I tried fiddling it into a working state with my gradle subprojects

midnight shore
#

so can you suggest something better to do that?

ivory sleet
#

maven central is nice

#

or if you have the resources, host a custom nexus repo manager

#

Im not implying you should give up on jitpack

#

but ye its far from optimal

midnight shore
#

whats this? $HOME/.m2/settings.xml?

mossy prairie
glossy venture
#

oh

#

you need to have a potential error as second argument

mossy prairie
glossy venture
#

(event, error) ->

ivory sleet
glossy venture
#

like that

ivory sleet
#

but also

#

how does your buildscript file look

midnight shore
mossy prairie
ivory sleet
#

still

#

wouldnt hurt if you could disclose your actual build script

mossy prairie
#

Hm?

ivory sleet
#

build script = build.gradle(.kts)

mossy prairie
#

Yeah

#

Ik xD I already hve sent it its on github

ivory sleet
#

ye

weary prawn
#

is there any community, tutorial, documentation, or anything that I can specifically get help for nms code?

#

there's just so much to take in with all of the thousands of classes and stuff

eternal night
#

You can generally ask here

eternal night
#

tho docs are going to be rough

mossy prairie
#

You should never use nms if there is a spigot api for it and if theres not any u should contribute creating one unless its very specific I guess

weary prawn
#

I mean I started wanting to change the default nether chunk generator and looking at all the mess that is the nms code my brain is self-imploding

mossy prairie
#

Also what is the minecraft mappings that spigot uses?

weary prawn
#

I looked at other people's rough implemntation of what I want on github and they all seem to use nms or reflection

#

so I'm trying it by myself to learn

#

I don't think there's a spigot api to change the nether chunk gen

#

or the end

#

idk about the spigot mappings but i'm using mcp mappings

ivory sleet
#

moj maps is preferred

weary prawn
#

actually scratch what I said I just cloned MinecraftForge and used their mappings which I think is mojang not sure

#

so how could I practically override the nether chunk generator, and use my own ChunkGenerator class?

sacred mountain
#

hey i an EntityTargetEvent listener, but whenever the player hits one of the mobs or dies, they start attacking again.

#
@EventHandler
    public void onTarget(EntityTargetEvent e) {
        if (e.getTarget() instanceof Player) {
            Player target = (Player) e.getTarget();
            if (SpawnPackMain.getMobOwner().containsKey(e.getEntity())) {
                if (SpawnPackMain.getMobOwner().get(e.getEntity()) == target.getUniqueId()) {
                    e.setCancelled(true);
                }
            }
        }
    }```
echo basalt
#

oh god

sacred mountain
#

it works when they are spawned, they do not attack the player. But whenver i hit one of them or i die they target me again

sacred mountain
echo basalt
#

I see at least like 4-5 things wrong with your code

sacred mountain
echo basalt
#
  • you should reuse code (not call the same getter 15 times)
  • you should name your variables properly, as e says a lot less compared to event
  • you should use return statements to keep your code as "flat" as possible
  • static abuse? you're storing a static Map<Entity, UUID> on your main class
  • use Object#equals to compare objects, and == for primitives (it compares the memory address rather than the values)
  • Store a UUID instead of an entity reference on the map, for safety (also helps with leaks)
  • Calling containsKey and get immediately after is a bit wasteful, just check if the get() value is null
#

eventhandler methods on spigot can be private (bungee will yell at you however)

sacred mountain
#

welp

#

ok

sterile token
#

How to cancel players moving items on their own inventory?

chrome beacon
#

Cancel the InventoryClick and DragEvent

sterile token
#

But that cause chest commands issue

#

🤡

chrome beacon
#

?

sterile token
#

I dont why its make issues with chest commands

#

Because chest commands uses inventory, so when i cancel the event the chest commands get the events called too

chrome beacon
#

They haven't specified to ignore cancelled events

sterile token
#

But i cannot do anything

#

😂

#

SO?

#

What i can do?

chrome beacon
#

Still not sure what the issue is

sterile token
#

I explain

chrome beacon
#

But you can always fork ChestCommands or make your own

sterile token
#

They wont pay me extra for fixing they issues

#

🤔

#

So that option its discarded

#

Hahaha

#

So i will deff do a issue report on gth to the author

chrome beacon
#

Looks intended yeah

sacred mountain
# echo basalt - you should reuse code (not call the same getter 15 times) - you should name yo...
@EventHandler
    public void onTarget(EntityTargetEvent event) {
        if (event.getTarget() instanceof Player) {
            Player target = (Player) event.getTarget();
            UUID targetUUID = SpawnPackMain.getMobOwner().get(event.getEntity().getUniqueId());

            if (targetUUID != null) {
                if (Objects.equals(targetUUID, target.getUniqueId())) {
                    event.setCancelled(true);
                }
            }
        }
    }```
any better? also can you help with my problem
echo basalt
#

targetUUID.equals(...)

chrome beacon
#

If you use Objects#equals you can skip the null check

chrome beacon
sacred mountain
#

so, when a player first spawns in the mobs they don't target the player, (the event works) but when the player dies or relogs they start attacking again.

#

or if the player hits one of them

chrome beacon
#

Put your project on github and I'll take a look tomorrow. You're probably doing something wrong

ivory sleet
#

probably implies the array itself must not be null

#

but elements inside it can be

tardy delta
#

the @NotNull ... hurts my brain

noble lantern
#

this never, has never, never will, will never, has not, has never will, ever will be

actual valid java, this is not a String like the javadocs say that the input needs to be

arctic moth
#

the moment u make one typo

tardy delta
#

just put an extra } :}

arctic moth
#

lol

noble lantern
arctic moth
#

its actually all the functions and stuff

#

everything imported from the api

#

it just decided to yeet the api

#

also my resolving dependencies bar if bugging out

noble lantern
#

i hope thats not a 1k line long class file

arctic moth
noble lantern
arctic moth
#

dont even ask why i was a dumbass and put my listeners in my main

#

xD

noble lantern
#

THATS YOUR MAIN CLASS

cyan compass
#

I don't suppose i can cancel the death event can i?

noble lantern
arctic moth
noble lantern
#

what you need to do

arctic moth
#

else no

noble lantern
#

is respawn the player

#

p.spigot().respawn()

cyan compass
#

Oh

#

ok

noble lantern
#

it will skip the respawn screen using that method

cyan compass
#

That sounds a lot simpler then all the other things i keep seeing then

tardy delta
arctic moth
noble lantern
#

May have undesired effects if you still want death event to fire

cyan compass
arctic moth
noble lantern
noble lantern
noble lantern
cyan compass
#

Oh :P

sinful tundra
#

Hey, does anyone have a tutorial regarding dat files and how to use them?

cyan compass
#

I don't have others

sinful tundra
#

I'm looking for a way to backup player's inv

arctic moth
#

oh

#

tbh u can probably just get away with mongodb

cyan compass
#

is setBedSpawnLocation() the only way to set a player spawn point btw?

noble lantern
tardy delta
#

json/ base64/ yaml?

sinful tundra
#

I was looking towards json but isn't Itemdata gonna be broken?

noble lantern
sinful tundra
#

Like, I'm getting the itemstack and writing it to the json but how do I retreive it?

tardy delta
#

derserializing

noble lantern
#

look into MemorySection's way of doing it

sinful tundra
#

Can I do the same creating a database?

arctic moth
#

i deleted the iml file it fixed smh

tardy delta
arctic moth
#

i already made baby zombies steal stuff, crops randomly die, nothing burn, phantoms spawning all the time, custom bossfights, op mobs, stuff randomly exploding, etc.

tardy delta
#

smh never did a raid

#

only dudes annoying me at my base

arctic moth
tardy delta
#

with my iron gear ::/

#

hate it when i get bad omen by just killing those intruders

noble lantern
#

This is pretty basic java

cyan compass
#
    @EventHandler
    public void onDeath(PlayerDeathEvent event) {
        event.getEntity().spigot().respawn();
        if (team_manager.getSouth().hasEntry(event.getEntity().getName()) || team_manager.getNorth().hasEntry(event.getEntity().getName())) {
            event.getEntity().addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 1000000, 0, true, false));
        }
    }```

This kills me with my original death after a few seconds of respawning
#

well

#

kind of

#

It brings up the respawn screen

noble lantern
#

might need to call it one tick later

cyan compass
#

How might i delay that?

#

Bukkit schedular?

manic bison
#

Reading a text file without crashing the server

noble lantern
cyan compass
#
    @EventHandler
    public void onDeath(PlayerDeathEvent event) {
        death = new BukkitRunnable() {
            @Override
            public void run() {
                event.getEntity().spigot().respawn();
                if (team_manager.getSouth().hasEntry(event.getEntity().getName()) || team_manager.getNorth().hasEntry(event.getEntity().getName())) {
                event.getEntity().addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 1000000, 0, true, false));                
            }
        }
        };
        death.runTaskLater(plugin, 1);
    }``` So this should run after 1 tick right?
ivory sleet
#

just use runTask

cyan compass
#

okay

#

But won't that not have a 1 tick delay?

ivory sleet
#

it will

#

because it will run the next tick aka 1 tick delay

cyan compass
#

Right

ivory sleet
#

ye

#

^

cyan compass
#

I realized that after i said it tbh

ivory sleet
#

lol

cyan compass
#

Okay how do i set a player spawn point?

weary prawn
#

how can I override the nether chunk generator with a custom one? will I need nms?

cyan compass
arctic moth
cyan compass
arctic moth
#

Don't u love the types of parents that shut off ur wifi

#

Bruh I'm not a toddlee

#

And its 6 pm

#

Wtf

crisp steeple
cyan compass
#

why

crisp steeple
#

i would check entitydamagebyentity event check if it’s a player and if the amount of hp is less or equal to 0

crisp steeple
#

it’ll try to respawn a nonexistant player and can break things

#

plus some other problems with being dead for 1 tick

sacred mountain
#

Entity killer = e.getEntity().getLastDamageCause().getEntity();

#

will that get the kliler of the entity

#

EntityDeathEvent

crisp steeple
#

i would use event.getDamager()

quaint mantle
#

hello

sand vector
#

How would you get the name of an inventory

sand vector
ivory sleet
#

InventoryView

quaint mantle
#

my server is crashing can anyone help

unreal quartz
#

Nah

quaint mantle
#

what

river oracle
#

so no

quaint mantle
#

I came here to get help if you won't write at all?

earnest forum
#

tell us what's happening

#

and then maybe

river oracle
#

god my guy

#

use fucking

#

?paste

undone axleBOT
quaint mantle
#

server crashes

ivory sleet
river oracle
#

don't paste that again either

quaint mantle
#

sorry 1m

#

i need help

#

server crashes

#

I couldn't solve it for 3 days, I wrote to paperspigota, they were not interested

ivory sleet
quaint mantle
#

ok sir thanks

earnest forum
#

what have you done to your server lmao

quaint mantle
earnest forum
#

when did this start happening

#

and did it happen when you changed something

#

server setting, plugin?

ivory sleet
earnest forum
#

yeah she w

#

sure

ivory sleet
#

thanks

halcyon mica
#

How do I set the custom name of a entity to a component?

#

Instead of a plain string

sand vector
# ivory sleet InventoryView

Back at this, I have an inv which I created. As it doesnt have .getView() how would I get the custom title I gave it? Or if anyone else knows :/

earnest forum
#

inv.getName()?

#

something of the sort

#

that is a method

sand vector
#

it isnt

earnest forum
#

?jd

earnest forum
#

1 sec

sand vector
#

I can't see any method that would give the custom name

earnest forum
#

wow

#

I swear there was a method that got the name

#

of the inventory

sand vector
#

yeah back before 1.14 I think it was .getTitle() before it changed

#

It is odd

earnest forum
#

why do you need to get the name?

sand vector
#

So I can get the correct ItemStack[] for my crates

#

I have two inventories. One is the crate opener and one is where you view the items you can get.

earnest forum
#

I swear I've used like a get title in 1.16

sand vector
#

probably with getView().getTitle()

earnest forum
#

just from directly the inventory

#

anyways

#

why do you take that item stack list from the inventory?

#

you should really store it elsewhere e

#

in a class or a config file

#

I don't think there is a way to do what you want

summer scroll
#

Is pattern variable will not work If there are multiple check?

#
if (!(event.getEntity() instanceof Player player) 
      && !(event.getDamager() instanceof Player damager)) {
  return;
}
``` I can't use the variable on there
sand vector
#

ok, I'll try creating a class to store my ItemStack list and work from there

earnest forum
#

I recommend making a Crate class

#

where it stores each item and information about them, chance, etc, and then in like onEnable you create instances of that class with information for each crate and store it somewhere so you can access it

sand vector
#

ok. I'll do that now, Thanks for the help

vocal tundra
#

that code doesn't compile because the syntax is invalid if that's what you're asking

quaint mantle
#

Hey guys,

Sorry for bothering yall, I've got a question.
How do you make an event where it detects variable cahnges / player balance changes?

I know this is a dumb question, but if someone could help, that'd be great!

summer scroll
#

anyways, nevermind about that

vocal tundra
#

if you're gonna just return like that there's no point anyway

sharp token
#

Guys I'm messing around with mojang remap NMS stuff, and I can't figure out what ResourceKey<Levels> is and how to obtain it
I'm trying to create a ServerPlayer object

lavish robin
#

Hello. Is it possible to give a inventory gui to spectator players?

vocal tundra
#

Yeah you right I realized that after

summer scroll
#

Will adding better potion effect will override the current potion effect?

noble lantern
#

Probably better to just try it

#

not too sure about it

#

i think so, though

grizzled bridge
#

Hey! Whenever I use AsyncChatEvent.message(Component) to change the chat message, I still get the players name in angle brackets in front of the message.

I’m using paper with adventure api btw

#

Is there a way to remove the player name

vocal tundra
#

use setFormat

grizzled bridge
#

Thx

#

Btw for paper it’s now renderer

#

Just for reference

noble lantern
#

For paper related questions your better asking in the paper discord

lavish robin
#

Can I bring back the hotbar in spectator?

noble lantern
vocal tundra
#

e.setFormat("%1$s %2$s"); will remove angle brackets

quaint mantle
#

deid

noble lantern
#

what are you trying to achieve?

quaint mantle
#

or can someone help with smthin else

#

its not rlly development but when i try to remove a spigot resource pack it wont let me (i know how to remove a pack) but it doesnt show that option for this 1

summer scroll
vocal tundra
#

pretty sure you just delete the url in server.properties

quaint mantle
#

it wont let me remove my resource pack its not the servers pack its my personal one

#

like when i go options resource packs

vocal tundra
#

so it's like curse of unbinding but on your texture pack

quaint mantle
#

yes

vocal tundra
#

that's crazy

lavish robin
# noble lantern what are you trying to achieve?

Working on a part of a minigame where when you die you become a ghost of sorts. You would be able to hinder alive players as a invisible creative player or a spectator player. my problem is them interacting without commands

vocal tundra
#

I'd say close mc, delete it from the folder, then reopen it

quaint mantle
#

other than the resourcepacks folder is there anywhere else it could possibly be

vocal tundra
#

unless it was some virus you downloaded no

quaint mantle
#

nope

#

its qualityarmor resourcepack

noble lantern
#

oh

#

thats a server sided resource pack

#

qualityarmor has a config for it to not send the rp

quaint mantle
#

i am dumb

#

just realized that

lavish robin
#

is a inventoryclickevent called when a player interacts with their inventory in spectator?

vocal tundra
#

most likely, but for a question like that it's better to just take 5 mins to test it yourself and get a faster definitive answer

quaint mantle
#

^

#

you're asking like every little question

#

just assume something works, if it doesnt then ask

lavish robin
#

okay sorry

summer scroll
#

How can I check If player is looking at a player?

#

Like I don't want PlayerInteractEvent and PlayerInteractAtEntityEvent can be called at the same time If player is right clicking on a player.

vocal tundra
#

You'll have to raycast if you want to tell they're looking at a player

quaint mantle
#

playerinteractevent is purely for blocks

#

thats why there are two separate events

summer scroll
#

air also

quaint mantle
#

?

summer scroll
#

right clicking entity counted as right clicking an air too somehow

quaint mantle
#

it doesnt

#

thats not how it works

worldly ingot
#

Honestly it might. Interactions are weird

quaint mantle
#

sounds like a pr to me

worldly ingot
#

I wouldn't put it past it

vocal tundra
#

They can both fire

worldly ingot
#

It's a hard thing to fix if it does call them both

quaint mantle
#

cause you cant interact with air

vocal tundra
#

with an item in hand

quaint mantle
#

right

#

oh that would make sense

#

but thats shitty

#

because you still cant interact with air

#

and that would be misleading

vocal tundra
#

He wants to see if you're looking at a player tho, not right clicking on them

summer scroll
#

what i want is

#

i want to prevent PlayerInteractEvent from being called if player is right clicking an entity

#

with item in hand yes

vocal tundra
#

Check the order in which they're called

#

Why do you want to cancel that event anyway, or prevent it from being called

summer scroll
#

i have a skill system where it can be activated by right clicking on entity and right clicking not on entity

#

because of that, both skills got called

vocal tundra
#

Fair

#

does the entity skill get called first

summer scroll
#

yes, the entity is first

#

And something weird also, the entity skill got called twice.

vocal tundra
#

If so just set a flag for 1 tick which automatically returns on PlayerInteractEvent

summer scroll
#

How can I set a flag?

vocal tundra
#

or, if they're holding an item in their hand set a flag to return on the next PlayerInteractEvent while also changing the flag when that is fired

#

by flag I just mean bool

summer scroll
#
boolean shouldFire = true;

// PlayerInteractAtEntityEvent
shouldFire = false;

// PlayerInteractEvent
if (!shouldFire) {
  shouldFire = true;
  return;
}
```Something like that?
vocal tundra
#

Exactly, but also before returning set shoudlFire to true

#

yeah you got it

summer scroll
#

Yeah forgot about that one too xd

#

Alright, thanks, I'll try it out.

vocal tundra
#

It's weird that InteractAtEntity is being called twice sometimes too

summer scroll
#

The order is

#

atEntity event got called -> interact event -> atEntity event

vocal tundra
#

is it the same entity each time

#

for both events

summer scroll
#

I'll try to use the flag first let's see If it will fixed it

#

After add a debug messages, and the flag thing, the PlayerInteractAtEntityEvent got called twice, and it's the same entity.

vocal tundra
#

@summer scroll

#

The event fires twice for each hand

#

so check their hand

#

only fire for mainhand

summer scroll
#

I thought interact at entity only for right click

vocal tundra
#

Try out what I told ya

summer scroll
#

Yeah, now the event fires for both hand, thanks!

vocal tundra
#

Yeah tricky 1.9 features

summer scroll
#

Giving someone weakness potion effect will remove strength potion effect, is it always like that?

limber mica
#

@alpine urchin Dependency 'com.github.retrooper.packetevents:api:2.0-SNAPSHOT' not found

summer scroll
vocal tundra
#

show us how you're adding them

noble lantern
#

you might be setting instead of adding potions

summer scroll
#

Oh nevermind

#

Yeah I'm dumb

warm trout
#

I'm starting out on plugin messaging in bungeecord, on the bungeecord side, I'm assuming the PluginMessageEvent is where I would listen for when I try to talk to bungeecord through spigot?

crisp steeple
#

yes

warm trout
#

Alr thanks

vocal tundra
#

is that the best way to communicate between the two

warm trout
#

I'd assume so

noble lantern
#

You implement the listener

#

not listen to an event

vocal tundra
#

I read people saying that it's not 100% reliable

warm trout
warm trout
vocal tundra
#

That's what I'm askin about rn

crisp steeple
#

im pretty sure plugin messaging is the best option unless you want to set up a complicated socket system which might have its own bugs

warm trout
#

Yeah, I really don't want to set up a socket system lmao

#

I was afraid someone would say that

vocal tundra
#

Fair enough

crisp steeple
#

plugin messaging should work fine enough

#

just add some utility methods or something to make sending data easier

quaint mantle
#

get on my level

crisp steeple
#

too pro

warm trout
#

sheeeesh

quaint mantle
#

most developers forget about encryption tho

vocal tundra
#

is that vital for plugin messaging

quaint mantle
#

no

vocal tundra
#

thoughts on cracked servers using google to authenticate

noble lantern
#

cracked server bad

vocal tundra
#

why are they bad

noble lantern
#

supports pirating the game

vocal tundra
#

does microsoft really need that money

noble lantern
#

Nope, but servers owners shouldnt be forced to run theyre server in an unsafe mode just to support people who dont want to support a game

#
  • Its not like microsoft took over completely

Mojang is still mojang and it still has the OG team when microsoft bought out

vocal tundra
#

What dangers come with turning online mode off if you know I'm curious

warm trout
#

People could link it to their bungeecord

#

And join as any name they want

#

I once made that mistake funny as fuck

#

They kept on joining as youtubers

vocal tundra
#

yeah but that aint really a problem if you have proper authentication measures

noble lantern
#

You turn off the entire authentication from your server to mojangs servers entirely

Meaning your running into the issue you talked about, authentication, having to rely on plugins for authentication rather than the built in authentication Mojang provides

warm trout
noble lantern
#

Banning people becomes a lot harder, since a vpn + name change and theyre in

#

rather than needing to buy a new account + vpn

vocal tundra
#

Gotta create a godly anti-cheat

noble lantern
#

imo I think MC anticheats are redundant

#

better to have staff that actually spectate

vocal tundra
#

but that requires lots of volunteers depending on the server scale

noble lantern
#

i mean hypixel manages to spectate people

#

just saw a vid the other day actually of mods macro checking people

vocal tundra
#

where were the mods when I needed them last bw game 😦

noble lantern
#

well it wasnt BW they did it on

#

it was skyblock haha

lavish robin
#

to make a team do I instantiate a new team object?

noble lantern
vocal tundra
#

lameee

#

But doesn't making the perfect anti cheat sound like a fun challenge to you

noble lantern
#

sounds like aids

#

would take a very long time to develop and test

sharp bough
#

does anyone know if in inventory framework when creating an event on an item and passing a value in the event, the variable gets the value when the event was created on when it was fired?

#

in that case, will lan or messages, displays, keys etc have the same value when the event is fired?

quaint mantle
#

what

sharp bough
#

in most events, when you call for a value outside the event, the value is the one at the time the event is fired

#

does that work in the same way with inventory framework item callbacks?

crisp steeple
#

?

quaint mantle
#

idk either

sharp bough
#

do you really not understand or just messing with me?

quaint mantle
#

are you asking if everything is a reference?

#

in java everything is a reference

#

i

#

dont understand what you're asking

sharp bough
#

aigt nvm im just gonna test it

tall dragon
#

Its A constant battle between cheater and anticheat developers

noble lantern
#

yep that too

#

you could never actually "finish" an anti cheat

#

its something you need to constantly commit too

tall dragon
#

Which is... a pain

marsh burrow
#

WOuld anyone know of a way for me to send kinda like a command to a server, lets say the player executes /join arena arena1 in a lobby arena, I want them to join a seperate bungee connected server and then join that arena on the server they were kicked to, any thoughts how to do this with the bungee messaging system?

#

I know you can do it, but the limitation is that each server needs to have atleast one player online, so it wont work if one doesnt have a player on, I kinda want to have the server wait until the player joins to send that command over to the server, but it wont work cause of the limitation

sharp bough
#

what did they use to add custom textures?

#

and custom items

#

i thought that wasnt possible, to add a new material to the game

noble lantern
#

one moment

#

i got an example for you

sharp bough
#

fr?

noble lantern
#

You need to modify the block state in the texture pack too

#

Youll ofc need to prevent block state changes

sharp bough
#

its not really an ore tho right?

noble lantern
sharp bough
#

i cant use Material.CobaltOre

noble lantern
#

i have a class that handles loading these ores

sharp bough
#

wow thats interesting

last ledge
#

I want to make Water buckets stackable

#

how do I do it

noble lantern
#

you cant properly manage them in your inventory

#

do /i dpick on your server if you have essentials installed

#

and try moving it around in your inventory

#

youll see what i mean by properly manage

small current
#

Use sockets

#

Or redis

marsh burrow
small current
#

What i done sockets is that
When a player wants to join an arena in another bungee server
Sends a message to the other bungee and when arena server got it, creates a cacheddata with required data. Then when a player joins, reads it and do codes, afteer that send the player to the other bungee server

#

Sorry for the grammar and spelling i just woke up and im with a phone 💀

small current
#

And, the lobby should be the socket servers
And arena servers should connect to (they both should be able to receive messages from each other and send messages to eachother)

marsh burrow
#

actually, this might be the solution, is it dependable though

small current
#

Or use redis to do this

#

I used sockets the way i explained to make a bungee mode for my bedwars pl

marsh burrow
#

ima need to read up on sockets then

small current
#

And dont forget, when you load the data remove it from the map or set or list that it was before to prevent memory leaks

marsh burrow
#

will do, thank you for pointing me in the right direction

small current
#

Yw

weary prawn
#

Hi guys, I'm trying to override / replace the nether / end chunk generators and I'm looking through nms and I'm not quite sure how I could do that, idk if I could somehow just replace it in the Registry before the world loading starts, I'm just not exactly sure how to do this (maybe I can even do this through the plugin api?), any help is appreciated 😄

kindred valley
#

Hello im currently practicing lambdas

#

Lmbd l = (Player p)-> p.getKills(); is this true?

glossy venture
#

yes, without the type declaration because a lambda has to define an anonymous functional interface, which means the types are already defined

sharp token
#

Guys I'm messing around with mojang remap NMS stuff, and I can't figure out what ResourceKey<Levels> is and how to obtain it
I'm trying to create a ServerLevel object

calm whale
#

Hey everyone, I would like to know if it's possible to use an RGB color in a team prefix or on an item name/lore. When I try to convert toString my bungee ChatColor.of(new Color(bla, bla, bla)) for exemple exmple, it will return me the closest Bukkit ChatColor...Am I doing something wrong ?

#

As you can see I is blue in game but my color should be yellow

#

Here is how I register a team```java
public void registerTeam(TeamEnum team){
Team t = scoreboard.registerNewTeam(team.getTag());

    t.setAllowFriendlyFire(true);
    t.setPrefix(team.getPrefix());
    t.setSuffix(team.getSuffix());
    t.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
    t.setOption(Team.Option.DEATH_MESSAGE_VISIBILITY, Team.OptionStatus.NEVER);
    t.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.ALWAYS);
}```

team.getPrefix() return the bungee ChatColor toString.

viral temple
#

hello!

lost matrix
calm whale
#

🤔

#

what value should I put instead of x, R,G B ?

glossy venture
#

is there a way of getting the width (and maybe height) of an inventory, or will i just have to do

int width = craftingInventory.getSize() == 9 ? 3 : 2; // crafting table/survival inv
lost matrix
calm whale
#

just divide it by 9 🤷‍♂️

#

@glossy venture

glossy venture
#

what

calm whale
#

my bad

#

I read something else

#

xDDD

glossy venture
#

oh

calm whale
#

a bit tired due to my colors problem

glossy venture
#

ah

calm whale
#

I guess your inventory can have a specific type ?

#

like HOPPER or DROPPER ?

lost matrix
glossy venture
#

but thats the capacity right

#

like width * height

#

the amount of slots

lean gull
#

does anyone know how i could use mongoDB's object ids for players? like lets say i have 3 players, and i need a specific one of them - do i have to put their uuid in the doucment of the player so i can filter it or is there a way i can use only objectid?

calm whale
#

I have something for you @lean gull

lean gull
lost matrix
calm whale
#

yup

lean gull
#

did not know that

calm whale
#

check this

lean gull
#

seems sus 😳

lost matrix
#

You can also use a property and have an additionally generated objectID but then you would need to hash index that
property to get the same performance. And thats not worth it.

lean gull
#

oh wait this is in the update section, maybe it means that you can set it at the start but not change it?

glossy venture
#
// x +1 y 0 (->)
if ((nx = x + 1) < width && (ny = y) < h) if (removeStatus[i1 = flatten(nx, ny)] == 0 || !slots.get(i1).isEmpty()) anc++;
``` lmfao
#

aids code

calm whale
#

@lost matrix so R: 247 G: 194 B: 33 should looks like this ? "\u00A7F7\u00A7C2\u00A721team color" ? 🤔

lost matrix
calm whale
#

mmmmm ok noted, I will check

lost matrix
# calm whale mmmmm ok noted, I will check
    public void write(K key, V value) {
        Bson filter = Filters.eq(key);
        ReplaceOptions options = new ReplaceOptions().upsert(true);
        this.mongoCollection.replaceOne(filter, value, options);
    }

Use upsert instead. upsert = Update if present or else insert.

#

You can also skip the parsing of json if you simply implement a Codec<V> that is based on Gson in the background.

lean gull
#

where do i put the uuid in insertOne?

#

like how do i put a specified _id instead of a auto-generated one

lost matrix
#

Bson filter = Filters.eq(key);

#

Where key is the UUID

lean gull
#

?

#

no i want to write one when making a new document, not find one with a specific one - atleast not yet

lost matrix
#
    public void persist(PlayerData playerData) {
        Bson filter = Filters.eq(playerData.getPlayerID());
        ReplaceOptions options = new ReplaceOptions().upsert(true);
        this.mongoCollection.replaceOne(filter, playerData, options);
    }
lean gull
#

can u explain to me what all this does? i don't understand

lost matrix
#

*This only works if your codec can serialize PlayerData. Otherwise you need to use Documents

#
    public void persist(PlayerData playerData) {
        Bson filter = Filters.eq(playerData.getPlayerID());
        Document document = Document.parse(gson.toJson(playerData));
        ReplaceOptions options = new ReplaceOptions().upsert(true);
        this.mongoCollection.replaceOne(filter, document, options);
    }
lean gull
#

???

gusty estuary
#

?paste

undone axleBOT
fleet pier
calm whale
#

I still don't get how do you convert the hex to a viable color. I tried few things like ChatColor.of("#f7c221") which is basically same as ChatColor.of(new Color(247, 193, 33)) so same result...
I tried "\u00A7F7\u00A7C2\u00A721" F7, C2 and 21 are the hex value for R, G and B but I get three colors differents because it takes only the first char of the hex.

fleet pier
lean gull
#

i need to go so i'll come back later and ask again

#

cause i don't understand anything that's going on in that code lol

gusty estuary
#

https://paste.md-5.net/qoyahiciyi.cs
I'm using Legacy 1.8🥲
My DoubleJump isn't working properly.

What currently happens:
The Player uses the DoubleJump. If the Player spams the Space Bar, he glides through the air.

Expected behavior:
The Player can use DoubleJump only if he touched the ground again

fleet pier
#

reading docs works perfectly

lean gull
fleet pier
#

or lets say you shouldnt

lean gull
#

i was told i could?

lost matrix
fleet pier
#

you can but mongodb stores important data like timestamps in that id

lean gull
#

oh wait, no, i'm supposed to change the objectid

#

not _id

fleet pier
#

you can basically filter everything

lean gull
#

(not like i even understand what that means)

fleet pier
#

Filters.eq ("name", "iDerpyOfficial")

#

it filters for the document that has the name value iDerpyOfficial

lean gull
#

im hungry and can not deal with this right now, cya later

calm whale
#

what is §x ? I cannot find it's definition in mc color map

lost matrix
calm whale
#

ah okay

#

gonna try this

lost matrix
echo basalt
#

You never check the cooldown map

calm whale
#

@lost matrix It still not combine RGB value

#
public String getColorText() {
        
        String color = "§x";
        
        String R = "§"+Integer.toHexString(getColor().getColor().getRed());
        String G = "§"+Integer.toHexString(getColor().getColor().getGreen());
        String B = "§"+Integer.toHexString(getColor().getColor().getBlue());
        
        return color+R+R+G+G+B+B;
    }```
gusty estuary
calm whale
#

first getColor return bungee ChatColor, second return the java Color

fleet pier
#

Can i register a command without adding it to the plugin.yml (1.8)

river spear
#

Can't somehow connect to mysql get this error in minecraft console

 
public class MySQL {
    private String url;

    private String username;

    private String password;

    String table;

    private Connection connection;

    public MySQL(String String1, String String2, String String3, String String4, String String5, String String6) {
        this.url = "jdbc:mysql://" + String2 + ":" + String3 + "/" + String4+"?useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Europe/Berlin";
        this.username = String5;
        this.password = String6;
        this.table = String1;
    }

    public void connect() throws SQLException {
    this.connection = DriverManager.getConnection(this.url, this.username, this.password);

    }

    public Connection getConnection() throws SQLException {
        if (this.connection == null || !this.connection.isValid(5))
            connect();
        return this.connection;
    }
}```
calm whale
echo basalt
#

Only works during onEnable btw

calm whale
gusty estuary
echo basalt
#

It can also be that when you jump, it immediately sets your cooldown

#

Try checking the block 0.5 below the player

short raptor
#

What's the sound for that bow hit ding?

#

I can't find it

calm whale
#

PLAYER_HIT

short raptor
#

💀

#

Thanks

#

Oh it's actually ENTITY_ARROW_HIT_PLAYER but you helped me find it so all g

calm whale
#

yeah I know I wasn't exact but that's it

gusty estuary
#

it's still the same

glossy venture
#

send code

kindred valley
# glossy venture send code
class Main{  
  public static void main(String args[]){  
    Player player = new Player("Yay", 14);
    Lmbd l = (p)-> p.getKills();
    l.getKills(player);
   
  }  
}  
#

Ah what

#

Sorry

glossy venture
#

what is Lmbd

kindred valley
#

What fhr fuck happende my main method

kindred valley
glossy venture
#

and it has a getKills(Player) method?

#

is it like

@FunctionalInterface
public interface Lmbd {
  int getKills(Player player);
}
glossy venture
#

ah k

kindred valley
#

Made normal object class(name, kills)

sour notch
#

Searching Minecraft Staff members . DM me if you want be in my staff team.

lean gull
#

wrong server lol

#

so how do i set the object id of a document in mongodb to a player's uuid?

sacred mountain
#

i'm using playerdeath event, how would i check if the player died from a fireball

#

or a tnt explosion

proper notch
lean gull
#

i don't know where though, and neither do i know how

proper notch
#

Have you use mongodb before with java?

lean gull
proper notch
#

document.append("_id", uuid)

#

When you create your mongo client make sure to set the UUID representation, e.g:

MongoClientSettings.Builder builder = MongoClientSettings.builder()
            .uuidRepresentation(UuidRepresentation.STANDARD);```
lean gull
#

?

proper notch
#

That creates a builder for MongoDB's settings, which you can use when creating a MongoClient instance. It sets the UUID representation which is required to be set to save UUID parameters via the java client.

lean gull
#

sorry but i do not understand a thing

proper notch
#

You need a MongoClient right

lean gull
#

i have that, yes

proper notch
#

These are MongoClientSettings, settings for the client.

#

In order to save a UUID you must set the uuid representation value, which this does

lean gull
#

..what's a client?

proper notch
#

When you do MongoClients.create() it can take in a MongoClientSettings value

#

MongoClient just provides you an API to interact with mongo with

lean gull
#

ok

proper notch
#

MongoClients.create(MongoClientSettings.builder().uuidRepresentation(UuidRepresentation.STANDARD).build())

lean gull
#

?

sacred mountain
#

I'm trying to decrease my jar size, bnut i currently use a lot of libraries for what im doing and its getting to quite a few mb

proper notch
#

That's an example of what you would use.

lean gull
#

again, i don't understand a thing

proper notch
#

Oke well i don't think i can literally explain it better so

proper notch
lean gull
#

you just explained what a client is, not the code you sent though

proper notch
#

When you do MongoClients.create() it can take in a MongoClientSettings value

lean gull
#

yes

proper notch
#

And as you can see, that's MonoClients.create() taking in a MongoSettings value

#

And as I explained before, MongoSettings.builder() is a builder for settings that affect the MongoClient.

#

And as I explained, in order to save UUIDs in mongodb, you must first set the uuidRepresentation setting.

lean gull
#

which does what?

proper notch
#

From their javadocs: The representation to use when converting a UUID to a BSON binary value. This class is necessary because the different drivers used to have different ways of encoding UUID, with the BSON subtype: \x03 UUID old.

lean gull
#

what

proper notch
#

if you don't set uuidRepresentation, MongoDB doesn't understand what format you want to save a UUID in.

lean gull
#

ok so where do i put that?

proper notch
#

Can you show the code for where you create your MongoClient

lean gull
#

MongoClient mongoClient = MongoClients.create(

proper notch
#

Ok so where you do MongoClients.create() that takes in a MongoClientSettings value as I showed above.

#

You can do pretty much what my example showed.

lean gull
#

no, that takes the string of the url thingie

#

how do i do both

proper notch
#

You'll need to put your address and other information into the MongoClientSettings

lean gull
#

...how do i do that

proper notch
#

See the available methods after doing MongoClientSettings.builder()

lavish hemlock
#

Have you considered the following: Utilize your IDE's code autocompletions to see if you can find a method that does the thing you want?

lavish hemlock
#

Alternatively: Google the fucking javadocs.

lean gull
#

if you want to help but you're gonna be mean: don't 🛑

lavish hemlock
#

It's common knowledge. If you want help but you're not willing to be proactive, don't ask for help.

lean gull
#

so i put applyConnectionString, but now i can't add the .uuidRepresentiation

lavish hemlock
#

You should be able to

#

The builder's methods immediately return the builder instance afterwards

#

Only way you wouldn't be able to is if you placed a semicolon after the method call :p

#

Unrelated but who the fuck named StreamFactoryFactory lmao

lean gull
#
        MongoClient mongoClient = MongoClients.create(MongoClientSettings.builder()
                .applyConnectionString(new ConnectionString("LINK"))
                        .
                .build());```
#

there's no autocomplete suggestion after the individual .

lavish hemlock
#

Okay, so?

#

Just write the method call

lean gull
#

.uuidRepresentation is not a thing?

proper notch
lean gull
#

it lets me import UuidRepresentation but not .uuidRepresentation

lavish hemlock
proper notch
#

tf lol

#

looks like dependabot + renovate are broken for mongo or something then i guess

#

either that or the javadocs are outdated

#

yep renovate and dependabot haven't been giving me mongodb driver updates

#

Oke well updated and there's still a uuidRepresentation method for me

lavish hemlock
#

@lean gull's Mongo driver might be out of date

#

yes

#

java.lang.reflect.Method

lean gull
#

i still don't know what i'm supposed to do...

maiden thicket
#

use morphia

lean gull
#

?

maiden thicket
#

morphia my beloved

lost matrix
#

The latest mongo java driver already supports UUID representation out of the box with the default settings.

maiden thicket
#

if ur wondering how to enable uuid representation u can just add it to the connection string link

lost matrix
maiden thicket
#

true yeah

maiden thicket
#

yes it is

#

uuidRepresentation=standard

lean gull
#

i'm trying to make a players collection with a document for each player and make it so the ObjectID is the player's UUID, except i have no clue what i'm doing

lost matrix
lean gull
#

w h a t

maiden thicket
#

i would assume you insert like normal but set _id equal to the uuid

#

baeldung ❤️

lean gull
#

i already watched a youtube tutorial that covers how to read, write and find with a filter

lost matrix
#

An object is just a bunch of random bytes in memory. MongoDB doesnt know how to handle that. It needs Bson data
so it can store it properly.

maiden thicket
#

have u tried putting _id to the player uuid

lean gull
#

can't i just set it to a string and then read that string and parse it as a uuid or something

lost matrix
lean gull
#
        MongoClient mongoClient = MongoClients.create(MongoClientSettings.builder()
                .applyConnectionString(new ConnectionString("LINK HERE"))
                .uuidRepresentation(UuidRepresentation.STANDARD)
                .build());
        
        MongoDatabase database = mongoClient.getDatabase("testing_database");
        MongoCollection<Document> coll = database.getCollection("cars");

        Document data = new Document("vehicleType", "Truck")
                .append("numberOfWheels", 4)
                .append("color", "red");

        coll.insertOne(data);```
#

3rd line does not work ofc

maiden thicket
#

3rd line is ur uuid representation?

lean gull
#

(i mean that .uuidRepresentation is red)

maiden thicket
#

i assume?

#

oh

#

does ur link end in ?authenticationDatabase=value or something

lean gull
#

dunno what that means but i don't see that in the link

maiden thicket
#

can u send ur connection string link but ofc censor ou the details

lean gull
#

idk how it works so i'd rather not cause i might leak it by stupidity

minor garnet
#

i have a question, when sending a message to the chat and treated as an async right? If so the server lag your message will not be delayed to be sent to the chat, but the commands are handled of formation of synchronization as well?

lost matrix
lean gull
#

how is that possible? i copied the dependency from the github earlier today

lean gull
#

3.11.3

maiden thicket
maiden thicket
lost matrix
lean gull
#

ok the thing is no longer red

lost matrix
#

Alright

lean gull
#

lemme make a quick event class for the player part

sacred mountain
#

hey im creating a pvp-based mob-spawner that will spawn mobs that do not attack you. The main concept is working, but i just realised that magma cubes and slimes deal damage to players without actually targetting them?

#

as in if you bump into a big slime it will damage you, whether its targetting or not.

#

Is there a way to fix this?

lost matrix
#

EntityDamageByEntityEvent -> cancel ?

sacred mountain
#

or prevent them dealing damage like that for certain players

sacred mountain
#

ill do some more tests

lean gull
#

ok so i made it so every time a player joins, it creates a document - now how do i make it so it checks for a document with the objectid of the uuid of the player, and if it doesn't find one then it makes a new one with the object id of the uuid of the player?

lost matrix
#

And its done like this:

        Bson filter = Filters.eq(key);
        ReplaceOptions options = new ReplaceOptions().upsert(true);
        this.mongoCollection.replaceOne(filter, value, options);

Where key is your _id key and value is the data you want to save.

sacred mountain
#

Bson? neber hear d of it

lean gull
sacred mountain
#

is registering multiple listeners of the same kind a bad practise?

#

since i have 3 of EntityDamagebyEntityEvent and it doesnt seem to have affected performance, or cpu or anything

#

exactly the same result with spark and my own checker

lost matrix
compact haven
#

actually it’s recommended

lost matrix
compact haven
#

why would that be the case

#

If the listeners are all of different purpose, by all means separate it

#

At least that’s by opinion 🤷‍♂️

sacred mountain
#

one is for player death, one is for fireball deflection and one is for slime damage cancelling

compact haven
#

mhm Id say it’s fine then, that’s what listeners are for

lost matrix
#

That violates the single responsibility principle. A listener should not have any logic in itself. It has one purpose: Listen for events and delegate them to where they are needed.

sacred mountain
#

theyre not that related i guess

compact haven
#

No it doesn’t violate the single responsibility principle

sacred mountain
#

how tho

compact haven
#

having one listener for three different purposes does

sacred mountain
#

why write a method when you are only listening for it once

#

just write the logic into the listener? or am i not getting something

compact haven
#

Well when you develop for multiple platforms that becomes a problem

#

it all depends on your situation

#

Unless it’s platform specific *

#

once again, depends

lean gull
lost matrix
# compact haven having one listener for three different purposes does

No it doesnt. The listener has one responsibility: Listen for events.
Having logic in them should be avoided:

    private final SomeManager someManager;
    private final OtherManager otherManager;
    private final ThirdManager thirdManager;

    @Override
    public void onDamage(EntityDamageEvent event) {
        someManager.handleEvent(event);
        otherManager.handleEvent(event);
        thirdManager.handleEvent(event);
    }
compact haven
#

what no