#help-development

1 messages · Page 2212 of 1

chrome beacon
#

I saw :C

iron palm
#

It just takes too much time when you use spigot mappings you just need a tool for help...

chrome beacon
#

You'll have to deal with stuff like that when you're on old versions

#

You can always update

tender shard
#

1.16.3 definitey doesn't have --remapped, just checked

chrome beacon
#

or tell the server owner to update

tender shard
iron palm
atomic niche
#

I wonder just how painful it would be to make a library that detects when other plugins use nms or mca to modify blocks...
How would one even go about that? Is it even possible? How resource demanding would it be.

tender shard
chrome beacon
atomic niche
lunar schooner
#

If it can be a library I'd say do it

atomic niche
#

Would it be sustainable though? Making libraries is one thing, but maintaining them is another.

We already have needed to make two libraries to get our stuff to work, but they are sufficiently general that they are likely to be self sustaining
(i.e. other projects depend on them, and they are now large enough that people will keep them up to date via prs)

Not sure if this is sufficiently general to be of use for other projects

chrome beacon
atomic niche
#

😮

sand sphinx
#

I tried something like this
But when my dropped any item, console gives a error

chrome beacon
#

What error

sand sphinx
#

Oh
Sorry

chrome beacon
#

Well somethings null on ManHunt line 41

sand sphinx
#

Oh
Right

#
    @EventHandler
    public void getReady(PlayerInteractEvent e){
        if(e.getPlayer().getWorld().getName().equals("world")) {
            ItemStack item = new ItemStack(Material.REDSTONE_BLOCK);
            ItemMeta meta = item.getItemMeta();
            meta.setDisplayName(ChatColor.RED+"hazırsın mı");
            item.setItemMeta(meta);
            if (e.getItem().getItemMeta().equals(meta))
                e.getPlayer().sendMessage(ChatColor.RED + "bu sadece bir test ve galiba doğru çalışıyor");
        }
    }
    ```
#

41: if (e.getItem().getItemMeta().equals(meta))

chrome beacon
#

getItem or getItemmeta is null

sand sphinx
#

But which :/

chrome beacon
#

You should null check them both

sand sphinx
#

Both of them seems correct..

tardy delta
#

void getReady hmm

sand sphinx
# chrome beacon You should null check them both
    @EventHandler
    public void getReady(PlayerInteractEvent e){
        if(e.getPlayer().getWorld().getName().equals("world")) {
            ItemStack item = new ItemStack(Material.REDSTONE_BLOCK);
            ItemMeta meta = item.getItemMeta();
            meta.setDisplayName(ChatColor.RED+"hazırsın mı");
            item.setItemMeta(meta);
            if(meta == null){
              do something
            }```
Are you talking about like this?
sand sphinx
tardy delta
#

dont think you should give the player something on every interact lol

tardy delta
#

whats what

river oracle
#

your logic is flawed

river oracle
#

it doesn't matter what you do

#

if they are in hte world world

#

they will get an item

sand sphinx
river oracle
#

but every time they perform an action

#

they get that item

#

is that what you want

desert tinsel
#

you can do if (e.getAction().equals(Action.LEFT_CLICK_BLOCK)){}

#

or something else

vocal pine
#

Vehicle Move Event -> https://paste.md-5.net/liguhazadu.cpp
Relevant AbstractMinecart -> https://paste.md-5.net/puvuyodeso.cs

Was hoping to bypass the hardcoded 2block-per-tick momentum cap by applying it to the entity
But it seems no matter what I give to the entity it doesn't change what gets applied to the cart the next tick.

Seems like player entity movement resets itself between this tick and the next - I need it to persist so it's given to the Minecart early next tick at that point in AbstractMinecart.moveAlongTrack - Waiting one tick using the scheduler to set it early does not work either :/

desert tinsel
#

oh ok

sand sphinx
# desert tinsel oh ok
    @EventHandler
    public void ChangeWorld(PlayerChangedWorldEvent e){
        if (e.getPlayer().getWorld().getName().equals("world")){
            ItemStack item = new ItemStack(Material.REDSTONE_BLOCK);
            ItemMeta meta = item.getItemMeta();
            meta.setDisplayName(ChatColor.RED+"hazırsın mı");
            item.setItemMeta(meta);
            e.getPlayer().getInventory().setItem(3, item);

        }
    }
    @EventHandler
    public void getReady(PlayerInteractEvent e){
        ItemStack item = new ItemStack(Material.REDSTONE_BLOCK);
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName(ChatColor.RED+"hazırsın mı");
        item.setItemMeta(meta);
        if (e.getItem().isSimilar(item))
            e.getPlayer().sendMessage(ChatColor.RED + "bu sadece bir test ve galiba doğru çalışıyor");

    }```
How is this?
desert tinsel
#

use ```java
@EventHandler
public void ChangeWorld(PlayerChangedWorldEvent e){
if (e.getPlayer().getWorld().getName().equals("world")){
ItemStack item = new ItemStack(Material.REDSTONE_BLOCK);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(ChatColor.RED+"hazırsın mı");
item.setItemMeta(meta);
e.getPlayer().getInventory().setItem(3, item);

    }
}
@EventHandler
public void getReady(PlayerInteractEvent e){
    ItemStack item = new ItemStack(Material.REDSTONE_BLOCK);
    ItemMeta meta = item.getItemMeta();
    meta.setDisplayName(ChatColor.RED+"hazırsın mı");
    item.setItemMeta(meta);
    if (e.getPlayer().getInventory().getItemInMainHand().equals(item)){
        e.getPlayer().sendMessage(ChatColor.RED + "bu sadece bir test ve galiba doğru çalışıyor");
    }
```
#

instead e.getItem()use e.getPlayer().getInventory().getItemInMainHand()

chrome beacon
#

But why

#

It's not going to solve anything

#

And it will function worse

crisp steeple
#

also please make a function for creating the item if you’re going to reuse it in multiple places

desert tinsel
tardy delta
#

what is he even tryin to do

desert tinsel
#

I don't know

river oracle
vocal pine
# vocal pine Vehicle Move Event -> https://paste.md-5.net/liguhazadu.cpp Relevant AbstractMin...
        this.setDeltaMovement(Vec3.ZERO);
        this.tick();
        if (this.isPassenger()) {
            this.getVehicle().positionRider(this);
        }

    }```

So I found the issue - Entities riding get their movement reset every tick
Is there any way to avoid this? Like override rideTick fn? Or set it again after this but before this.tick kind of thing
Was hoping not to have to use NMS stuff but I guess I need to to force this off
desert tinsel
dark arrow
#
@Override
    protected void addBehaviourGoals() {
        this.targetSelector.addGoal(2, new NearestAttackableTargetGoal(this, Player.class, false));
        this.targetSelector.addGoal(3, new NearestAttackableTargetGoal(this, Pig.class, true));
    }```It is suppose to make zombie not to fight players and make zombie attack pig but the pig part does not work
vocal pine
#

So my issue; I'm trying to set DeltaMovementTick of an entity in a VehicleMoveEvent so it begins the next tick with that movement
However it's reset by Entity.moveTick() to Zero at the beginning of every tick
If I use scheduler to do it one tick later, it's too late
Anyone know how I could set movement AFTER the reset but before anything else without NMS ideally... Kind of a mess
Or just some kind of workaround, yk - It's to bypass a momentum cap in Minecarts - Without NMS it's theoretically possible to give 10x velocity to player and it'll be added to the cart AFTER the momentum cap - but the reset of player movement on a new tick when in a vehicle makes it not work

granite owl
#

why is Player
playSound(Location location, String sound, float volume, float pitch) not chaning the volume?

#

not beyond 1.0

sand sphinx
#

The same error

tardy delta
half ferry
#

Can anyone Help me? ;/

tardy delta
#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

half ferry
#

is it possible to add knockback on hand using java?

vocal pine
near crypt
#

when a line in a config doesnt exist is it a empty string or a null object?

tardy delta
#

null

near crypt
#

thx 🙂

desert tinsel
tardy delta
#

throw new NoobDevException

#

:kekw:

#

ah sad no nitro

desert tinsel
#

gud job

tardy delta
#

thank

hybrid spoke
tardy delta
#

im sorry to have summoned you

dark arrow
#

@Override
    protected void addBehaviourGoals() {
        this.targetSelector.addGoal(2, new NearestAttackableTargetGoal(this, Player.class, false));
        this.targetSelector.addGoal(3, new NearestAttackableTargetGoal(this, Pig.class, true));
    }```
It is suppose to make zombie not to fight players and make zombie attack pig but the pig part does not work
hybrid spoke
#

no problem, im here to help you out.

tardy delta
#

😌 🙏🙏

near crypt
#

when i write a player uuid in a config there is a expression because of the !! at the beginning of the uuid...

tardy delta
#

do uuid#toString

#

for setting it

dapper harness
#

Why does this disables explosions completely and not only block damage ?

    @EventHandler
    public void onBlockBoom(BlockExplodeEvent event) {
        if(!event.getBlock().getWorld().getName().equals("spawn")) return;
        event.blockList().clear();
        event.setCancelled(true);
    }
    
    @EventHandler
    public void onEntityBoom(EntityExplodeEvent event) {
        if(!event.getEntity().getWorld().getName().equals("spawn")) return;
        event.blockList().clear();
        event.setCancelled(true);
    }```
near crypt
tardy delta
#

is there a blockdamage event?

half ferry
#

How can i add knockback on Hands

dark arrow
dapper harness
#

omg yes i'm so dumb

trail lintel
#

When registering custom item recipes with NamespacedKey, is there a point to keeping a reference to that key? I'm having a few different varieties of my custom item for different Material types, and im wondering if it would be easier to identify which version it is by just having a PersistentData string of the material, rather than checking each possible key?

dapper harness
#

lmao

#

thanks

tender shard
#

np 😄

#

just clear the blocklist

half ferry
dapper harness
#

I know I just copy pasted the cancel then forgot about it

dark arrow
tender shard
half ferry
tender shard
#

btw take a look at MaterialChoices if you have "variants" of your recipes

trail lintel
tender shard
#

the keys, definitey

#

oh wait I didnt meant MaterialChoices

dark arrow
tender shard
#

let me check what I meant

half ferry
tender shard
#

okay I meant the groups. for example, oak_boat, birch_boat, ... all appear as one "group" in the crafting recipe book. you can do the same by setting the same "group" to all your "similar" recipes

#

ShapedRecipe#setGroup

trail lintel
#

woahhhh

#

I'm def gonna do that, awesome feature ty

#

well, actually it might not be applicable in this case

tender shard
#

MaterialChoice is for stuff like barrels or chests - it takes oak plank, birch pank, ... (and you can even mix them) but it all results in the same item

trail lintel
#

since the dif varieties are gonna have different strengths

#

so not exactly "variants"

dark arrow
trail lintel
#

good info ty alex, you helped me about a year ago as well 😉

#

I think it was on forge modding though

tender shard
#

np 🙂 erm tbh I cant remember lol

trail lintel
#

yeah haha I just recognize the name 😉 was a trivial thing in the end haha

half ferry
lethal roost
#

um what is a plugin instance? i feel a bit dumb
i'm trying to make a bukkit runnable

dark arrow
#

then you can create a command and get the sender wait i sec i will send you an example code

tender shard
#

if you're in the class that extends JavaPlugin, than it's "this"

lethal roost
#

Ah i see, ty

dark arrow
# half ferry i wanna do it in a command 🙂
 @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

        if(sender instanceof Player){
            Player player = (Player) sender;
            player.getAttribute(Attribute.GENERIC_ATTACK_KNOCKBACK).setBaseValue(<Your number>);
        }



        return true;
    }```Its untested but it should set teh knockback to the number you want
#
@Override
    protected void addBehaviourGoals() {
        this.targetSelector.addGoal(2, new NearestAttackableTargetGoal(this, Player.class, false));
        this.targetSelector.addGoal(3, new NearestAttackableTargetGoal(this, Pig.class, true));
    }```

It is suppose to make zombie not to fight players and make zombie attack pig but the pig part does not work
lethal roost
#

wait so i tried putting this and HeavyWeapons in the spot but it's still giving me an error, what am i doing wrong?

chrome beacon
#

You need to pass an instance of your plugin

#

(your main class)

#

?di You can use di for this

undone axleBOT
quaint mantle
#

question i’m using saber factions as my main factions part but how does f top even work? cause i placed spawners in my claim and my f top didn’t go up is this because i need a separate plugin for that and if so can someone suggest the one i need or is it something instead saber i need to turn on if so where cause i could t see it

tender shard
lethal roost
#

i'll take a look at that, thank you

tardy delta
#

?di

undone axleBOT
near crypt
#

can i send a player a message when he contacts a block the first time in the playerMoveEvent?

tardy delta
#

lets not contact blocks lol

#

you would have to store a collection of all blocks he has walked on lol

near crypt
#

i mean the player contacted the block in a way XD

tardy delta
#

my brain is already thinking bout optimisations lol

near crypt
#

lOl

tardy delta
#

i assume that means that the player walked on the block

near crypt
#

yes

tardy delta
#

store the locations

near crypt
#

and then?

tardy delta
#

if there were tuples in java i'd just store the x y z

#

dunno what you even trying to achieve

dark arrow
#

I have created a nms class with custom entity and u have overrided the addbehaviur goal but i am unable to make zombie passive towards players

tardy delta
#

little bit expensive storing all the locations

golden turret
#

where is that in the obfuscated version?

near crypt
#

just if the player walks on the block the event is triggered everytime the player walks on the block but i want it to only be on the first walking action on the block @tardy delta

eternal night
#

su

#

or do you mean spigot obfuscated

near crypt
#

yk?

tardy delta
#

hashset with 2k elements lets goo

near crypt
#

yeaaahh

#

but thx 🙂

paper viper
#

well lets get the reason tho

tardy delta
#

lmao

paper viper
#

why are you doing this

#

lol

#

maybe there is a better way

humble tulip
paper viper
#

to achieve what you are trying to get

humble tulip
#

Quick lookups

paper viper
#

lol

tardy delta
#

no duplicate elemnts lmao

humble tulip
#

It's not ordered

#

Why would duplicates matter

tardy delta
#

cuz memory lol

#

if player is walking in circles

near crypt
#

the thing is i am working on a jump and run plugin wich should send the player a message when he first reached a checkpoint

tardy delta
#

bruh

paper viper
#

LOL

tardy delta
#

like parcour thing?

near crypt
#

ye

tardy delta
#

just store the waypoints things

near crypt
#

that i did

tardy delta
#

instead of all blocks they walked on

near crypt
#

i did that but the event is triggered on every walk action

#

not just on the first

paper viper
#

then just.. store a boolean or something

#

to check if the player walked on it already

near crypt
#

yes i thought of this too ill try it

paper viper
#

...

#

Walking on a block vs actual players

tardy delta
#

sounds like xy problem

paper viper
#

Yep lmao

ivory sleet
#

x)

tardy delta
#

and then conclure comes in

paper viper
tardy delta
#

classic

paper viper
#

you could just use a hashset

#

and store uuid

#

if they already stepped on it

tardy delta
#

i'd store block locations of those pressure plate things

#

tuples when

ivory sleet
#

Set::of (:

#

List::of

#

What more can I say

quaint mantle
#

run and jump plugin

tardy delta
#

hmm youre right

dark arrow
#

I have made zombie a neutral mob so now it no longer attack anyone but how can i make it passive

ivory sleet
#

(r instanceof Rectangle(ColoredPoint(Point p, Color c), ColoredPoint lr)) java 19 pog?

tardy delta
#

my brain is too tired to think

lethal roost
#

so i have a runnable set up that gives the player a mining fatigue every 5 seconds whenever they have a wooden axe in their hand.
the thing is, i want to cancel this runnable whenever they switch something in their hand
how do i do this? idk how i would implement another listener in this if statement

paper viper
ivory sleet
#

Record deconstruction/matching

paper viper
#

Oh lol

ivory sleet
#

Yeeee

#

Supports nesting as wel

#

Crazy stuff

tardy delta
#

no runnable

lethal roost
#

hmm that is a better way, i guess i was just overthinking the possible ways of losing the effect without having to switch items, thank you!

dark arrow
#
public NewWarden(Location location) {
        super(((CraftWorld) location.getWorld()).getHandle());
    }```why it gives error even it works fine for aombie
tardy delta
#

what error

dark arrow
# tardy delta what error

'Warden(net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.monster.Monster>, net.minecraft.world.level.Level)' in 'net.minecraft.world.entity.monster.warden.Warden' cannot be applied to '(net.minecraft.server.level.ServerLevel)'

tardy delta
#

it needs an entitytype and level thro the constcutor ii gues

golden turret
#

why my npc does not have a cape or hat?

#

the 2nd ss is me

dark arrow
tardy delta
#

that doesnt look valid java at all but idk

#

nnever extended an entity thing

dark arrow
#

hm

tardy delta
#

what class are you extending

dark arrow
#

warden

near crypt
paper viper
#

Use a set instead

dark arrow
#

this mob is so new that there are no threads about it

eternal oxide
undone axleBOT
dark arrow
near crypt
dark arrow
# eternal oxide ?paste the full error trace

Warden(net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.monster.Monster>, net.minecraft.world.level.Level)' in 'net.minecraft.world.entity.monster.warden.Warden' cannot be applied to '(net.minecraft.server.level.ServerLevel)'

#

the error is in ide not in consolee

eternal oxide
#

?paste yoru class and I'll take a look

undone axleBOT
near crypt
dark arrow
#

ok

#

there is nothing in the class tho

paper viper
eternal oxide
#

that sok, its mainly so I have the same imports etc

paper viper
#

and if they step over it again, check if its in the set

near crypt
#

okay

#

wdym?

dark arrow
#

?paste

undone axleBOT
near crypt
tardy delta
paper viper
near crypt
#

or is it UUID from java.util?

lethal roost
#

um

why is it that whenever i switch to something other than a wooden axe i get the effect? shouldn't it be the other way around? i tried != and it worked vice versa

eternal oxide
#

There is non for a single arg

lethal roost
#

i mean it works if i just flip it around but i kinda wanna know why it's backwards

humble tulip
#

That's why u can cancel it cuz events tend to be called before the thing happens

dark arrow
lethal roost
#

ohhhhh i see

near crypt
dark arrow
humble tulip
#

To get the new item

eternal oxide
#

odd thing is there doesn;t seem to be an EntityType.WARDEN

humble tulip
#

And vice versa

dark arrow
#

wait what

lethal roost
#

i got it, thank you so much!

eternal oxide
#

net.minecraft.world.entity.EntityType I see nothing for WARDEN

dark arrow
#

import net.minecraft.world.entity.monster.warden.Warden;

#

are u suing 1.19 nms?

eternal oxide
#

Yes, but theres no EntityType

#

I shoudl be, else there would be no net.minecraft.world.entity.monster.warden.Warden

#

let me clean my project as I did just update it from 1.18

dark arrow
#

when i typeEntitytype it recommends warden

golden turret
eternal oxide
#

I don;t get that option. However yoru constructor shoudl be super(EntityType.WARDEN, ((CraftWorld) location.getWorld()).getHandle());

dark arrow
#

i tried that alrady

#

maybe i did'nt

#

it works 🙂

#

thanks

eternal oxide
#

Super wierd. its missing from mine

dark arrow
#

have you updated the ide?

#

i mean the build tools and mappings

eternal oxide
#

I'll run BT again. I havn't run it in a few days

dark arrow
#

oh

dark arrow
eternal oxide
#

lol

dark arrow
#

Btw i just remembered that on the next day of 1.19 release i was not able to use warden but today i was able to maybe this type og glich happened with you

eternal oxide
#

odd, still not showing up for me

dark arrow
#

hmm

lethal roost
#

how do i get rid of this error?

iron glade
#

let helditem not be null

humble tulip
#

Items can be null if there is none

#

Check if it's null before you check how many

lethal roost
#

i did but it still throws that error which i dont' understand

humble tulip
#

You didn't check if it's null

#

Because it is null

lethal roost
#

well how do i check if it's null

humble tulip
#

if heldItem==null

iron glade
#

?java

lethal roost
#

yeah that's what i did, lemme try again perhaps i screwed something up the first time lol

humble tulip
#

Send a scc of what u did

#

Sc*

lethal roost
#

ye i'll test once more i deleted the line assuming that wasn't the solution before haha

#

it would be like this, right?

humble tulip
#

Ye

lethal roost
#

it works now! i have an idea on what i did wrong the first time, you kinda pointed that out indirectly. tysm again!

humble tulip
#

np

#

Did u not return?

lethal roost
#

nah i think i did if (heldItem.getType == null) before

#

which is kinda obvious isn't gonna work now that i think of it haha

humble tulip
#

Ah ye

limpid bronze
#

Hey, I have a list of ItemStack and I want to get the itemStack with the highly amount, how can I do that?

river oracle
#

ItemStack#setAmount(int amount);

opal raven
#

np, he means get the itemstack with the highest amount value

river oracle
#

🤷‍♂️ no clue can be different based off the conditions he wants

echo basalt
#

you'll need to add items together (duplicate entries wont work)

opal raven
limpid bronze
echo basalt
#

Which is why I avoid them

river oracle
#

for loops look fine 🤷‍♂️ no reason to use streams

opal raven
#

oh, maybe, don't know a much about them, just used to use stream syntax in Kt

echo basalt
#

¯_(ツ)_/¯

mighty pier
#

is it possible to get an entity by its entity id?

echo basalt
#

I only recommend streams when they turn a 200 line for loop into like 10 lines

sage patio
#

What is wrong with this? when i manually put the material type in runnable setType it works

echo basalt
tall lance
#

Anyone know how I could be getting Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug! for a plugin that should be compiling to 1.19 via Gradle? Trying to check if the players holding a stick and it keeps giving me LEGACY_STICK and it's kinda annoying

mighty pier
#

ok

echo basalt
echo basalt
sage patio
tall lance
tall lance
echo basalt
tall lance
#
@EventHandler
    public void onPlayerInteract(PlayerInteractEvent event) {
        Bukkit.getLogger().info("interact");
        Player player = event.getPlayer();

        Bukkit.getLogger().info(player.getInventory().getItemInMainHand().getData().getItemType().name()); // < Gives "LEGACY_STICK"
        if(!player.getInventory().getItemInMainHand().getData().getItemType().equals(Material.STICK)) return; // < Doesnt' pass here
        Bukkit.getLogger().info("it's a stick");

        Entity chicken = player.getWorld().spawnEntity(player.getLocation(), EntityType.CHICKEN);
        chicken.setVelocity(player.getEyeLocation().toVector().multiply(8));
        Bukkit.getLogger().info("chickeeennn");
}```
echo basalt
#

pain

#
ItemStack item = event.getItem();

if(item == null)
  return;

Material type = item.getType();

if(type != STICK)
  return;

issa stick
sage patio
golden turret
echo basalt
#

issa pain in the ass

#

You gotta send an Entity Metadata packet containing all the skin layers

tall lance
echo basalt
#

1 | 2 | 4 | 8 | 10 | 20 | 40 | 80 for all the skin layers

#

or Byte.MAX_VALUE for short

rain echo
#

I tried to create separated inventories using this way, i think it works, somehow, but what can I do to open using a command
that's my idea:

    Inventory[] itemsMenuGui;

    public ItemsMenu() {
        itemsMenuGui = new Inventory[0];
        createItemsMenu();
    }

    public void createItemsMenu() {
        itemsListConfig = new ItemsListConfigFile(plugin);
        Objects.requireNonNull(itemsListConfig.getItemsListConfig().getConfigurationSection("Inventories")).getKeys(false).forEach(ID -> {
            String menuName = itemsListConfig.getItemsListConfig().getString("Inventories." + ID + ".menu_name");
            itemsMenuGui[Integer.parseInt(ID)] = Bukkit.createInventory(null, 36, "§8§oEditing " + menuName + " menu...");
        });
    }

    public void openInventory(Player player, int ID) {
        player.openInventory(itemsMenuGui[ID]);
    }

command class:

                itemsMenu = new ItemsMenu();
                itemsMenu.openInventory(player, Integer.parseInt(args[0]));

sorry for my bad english

golden turret
rain echo
#

if somehow I could give the size for Inventory[] itemsMenuGui; as the numbers of the inventories in my config like Inventory[] itemsMenuGui = new Inventory[inventories_list];

echo basalt
#

you can start by understanding it's a bitmask

#

so you gotta add the bits together

#

instead of setting them 15 times

golden turret
#

so 0x01 & 0x02?

#

idk bitwise lol

echo basalt
#

& is a bit AND

#

| is a bit OR

#

you want the OR

#

A bitmask is just a set of 8 booleans represented as bits on a byte

#

11110000 can both mean a number, but you can also look at the bits and say that there are 4 values set to TRUE, and 4 set to FALSE

golden turret
#

so it will look like this?

echo basalt
#

Yah

golden turret
#

same error

echo basalt
#

What version?

golden turret
#

1.17.1

echo basalt
#

index might be a little different

#

let me have a look at the 1.17 code

golden turret
#

alr

echo basalt
#

What's line 65

mighty pier
#

why expression expected

golden turret
mighty pier
#

nvm

quaint mantle
undone axleBOT
mighty pier
#

i know

quaint mantle
#

that is not how you cast 🧐

mighty pier
#

it sometimes takes a second

opal juniper
#

very close though

quaint mantle
#

also dont cast

#

thats still blind casting

quaint mantle
mighty pier
#

I KNOW

quaint mantle
#

Ok

mighty pier
#

stop the making fun

golden turret
#

how do i see a specific mc version on wiki.vg?

echo basalt
#

still byte 17

rain echo
dark arrow
#

how can i give effects to mobs in nms cuz there is no addPotionEffect

dark arrow
#
if(sender instanceof Player){
Player player = (Player) sender;
player.openInventory(player, Integer.parseInt(args[0]))
}
golden turret
sage patio
#

when i shift click on this in my inventory plugin runes this 4 times player.sendMessage(Utils.getColorizedConfig("messages.crafting"));

dark arrow
echo basalt
#

honestly calling set is for replacing objects

upper tendon
#

How would one clear unlocked recipes from a player? (to essential remove use of the recipe book)

golden turret
echo basalt
#

are you sending the packet

golden turret
#

of course

echo basalt
upper tendon
golden turret
#

1: i send the PlayerInfo packet
2: i send the EntitySpawn packet (addEntity)
3: i send the metadata packet
4: send the PlayerInfo packet with REMOVE

quaint mantle
#

hey does anyone know how I can place a bed in 1.8.8? I've tried the regular stuff I found googling the issue but nothing seems to work

#

I got 2 locations I would want the bed to be at

echo basalt
echo basalt
quaint mantle
#

exactly

echo basalt
#

I've only messed with entity metadata with protocollib

#

and it took a lot of pain

opal juniper
echo basalt
#

beds existed on 1.8.8

#

so it is possible

#

just likely not via the API :)

quaint mantle
#

Yeah. I've been spending so many hours trying to find a way to get this done

#

yall got any idea?

echo basalt
#

haven't touched 1.8 in months

opal juniper
#

Again, not what i meant. but whatever

quaint mantle
misty current
#

if I have a method that takes in parameters like public <T> T myMethod(Something<T>, T) and i have Something<?>, what should the second parameter be?

quiet ice
#

In theory it would be object, but it is likely that there is no valid type given that ? is a wildcard

quaint mantle
misty current
quiet ice
#

I'd recommend casting it to Something (no types), at which point T would be the upper bound (usually Object)

misty current
quiet ice
#

huh odd

#

Well then, go with the completely nuclear option: Manually cast it to the upper bound

misty current
#

can I safely cast PlayerStatistic<?> to PlayerStatistic<Object>?

quiet ice
#

Depends on what ? can be

#

For example if you have PlayerStatistic defined as public class PlayerStatistic<T extends Number>, then you'd need to cast it to Number

golden turret
#

well

#

everything is an Object

quiet ice
#

But javac will complain about unchecked casts either way

misty current
#
public class PlayerStatistic<T> {

    private final Class<T> clazz;
    private final String name;

    public PlayerStatistic(Class<T> clazz, String name) {
        this.clazz = clazz;
        this.name = name;
    }

    public Class<T> getValueType() {
        return clazz;
    }

    public String getName() {
        return name;
    }
}
``` this is the entire class
quiet ice
#

Oh, then it is Object

misty current
#

i should've not designed player statistics like this

#

its pretty awful to deal with

#

but i cba to make a field for each statistic and update my serializer methods each time i need to add a new statistic

quaint mantle
#

that's actually crazy... the fact that I can't place a bed in my server even though i got the 2 locations needed.

#

how tf can it be that hard to get an API properly done

quiet ice
#

Multi-block blocks are a complicated thing, regardless of how the API is

quaint mantle
#

@echo basalt helppp

quaint mantle
#

its crazy

golden turret
#

🤔

quiet ice
#

Probably BlockStates vs BlockData

sacred mountain
#

hey how would i create a completable future for a player on their login?

golden turret
echo basalt
#

😤

quiet ice
#

Whatever, they are stupid either given that they are using 1.8.8

sacred mountain
#

i'd like to create a message that the plugin can send to the player once they login, like an announcement or something if they miss it

quaint mantle
quiet ice
#

It makes sense however

sacred mountain
#

that i used

#

for a while

golden turret
quaint mantle
sacred mountain
#

that gives loads of useful blockstate methods for multiblock and block facing stuff

quiet ice
echo basalt
#

3 or 4

#

you're underestimating it

quiet ice
#

Yeah, probs

misty current
sacred mountain
echo basalt
#

I don't see why y'all say 1.8 doesn't support beds

sacred mountain
golden turret
#

you would need to store every message sent then

misty current
sacred mountain
#

would i though>?

#

what about completeablefuure

#

i thought thats how it worked

misty current
#

what do completable futures have to do with that

sacred mountain
#

when the player is online, then send it?

#

im not really sure

misty current
#

you need to log somewhere the message and the time it was sent at

quaint mantle
misty current
#

then when a player joins check when they left last time and send all the messages that have been sent after the last logout

quaint mantle
#

i thought theres was a whole blockstate thing to go through

echo basalt
# quaint mantle how do i place it with my locations though
Block head = ...;
Block foot = ...;

Bed headBed = new Bed(head.getFace(foot)); // you might need to reverse this
headBed.setHeadOfBed(true);

Bed footBed = new Bed(foot.getFace(head)); // you might need to reverse this
footBed.setHeadOfBed(false);

head.getState().setData(headBed);
head.getState().update();

foot.getState().setData(footBed);
foot.getState().update();
#

pain in the ass but it's just what happens with multiblock

misty current
#

do I have to shutdown thread pools when my plugin is disabled or are they automatically shutdown if there are no more references to them?

quaint mantle
#

i'll try it out

#

thx

echo basalt
#

Make sure the threads are set as daemon threads for that extra safety

misty current
echo basalt
#

uhh

misty current
#

if i have to shut them down myself, can I make sure that all the tasks have ended before my plugin disables?

echo basalt
#

honestly running threads might cause memo leaks

misty current
#

i saw there's shutdownNow but i remember last time i used it, it just deadlocked my server

echo basalt
#

I'd put them all on a completablefuture and join it

echo basalt
#

messing with threads in general can cause so many deadlocks

fickle crater
#

how do i check if a term in config is in a players name?

quaint mantle
native gale
#

Is there a way to change treasure chests loot tables?

echo basalt
#

wrong import most likely

echo basalt
misty current
ivory sleet
#

But assume your pool is configured with a daemon thread factory then you’re basically good to go in conjunction with a shutdown

#

You can then await termination for like 20 seconds perhaps?

sacred mountain
#

whats the best way of getting a random online player

native gale
misty current
#

unless my wifi goes out 😛

ivory sleet
#

But yes ExecutorService kinda sucks as it’s basically unstructured concurrency at its core

echo basalt
#

end city loot has elytras and enchanted stuff

#

other stuff has other loot

#

also all the loot might be configurable via datapack not sure

#

it's all keyed

#

check org.bukkit.loot.LootTables

misty current
ivory sleet
#

No, but java 19 we get structured concurrency api

#

So that’s nice

misty current
#

hmm aight

#

anything i should pay attention to when using ExecutorService ?

deft rain
#

hello i nead help whit exelentcrates cant find itf for 5 days

sacred mountain
#

hey when taking something randomly from a collection/list, how do i do that easily? without having to use Random.nextInt(0 or 1, colection)

sacred mountain
#

because i remember prevoiulsy i had to do collection.size() - 1 for some reason

ivory sleet
#

You just have to deal with it, I mean executor services work fine

#

But for instance we have no control over parent and child tasks

#

being able to unit certain futures etc

#

You can use join

#

But that becomes unstructured

echo basalt
misty current
ivory sleet
#

Yes if you’re not creating something scalable the Bukkit scheduler’s async methods will suffice

echo basalt
#

completablefuture go br

#

Ayo conclure quick question

misty current
#

i kinda like how what i coded turned out tho

ivory sleet
#

Ye

echo basalt
#

what changed in 1.18 to completely lock up servers whenever I try to load any world

ivory sleet
#

Completely lock up?

misty current
echo basalt
#

crap deadlocks for 15 seconds and stops trying

sacred mountain
ivory sleet
#

I haven’t experienced that

sacred mountain
#

since collections dont allow you to select with an index

sacred mountain
#

i think apache commons can do that but idk how it manages

sacred mountain
echo basalt
#

I just have a fun method that loads worlds

#

very funky

ivory sleet
#

Is that what locks it?

echo basalt
#

yes

#

loads on 1.17

#

but freezes on 1.18

sacred mountain
echo basalt
#

toArray

ivory sleet
echo basalt
#

yes

#

but it goes to main thread for the worldcreator

sacred mountain
#

RandomGenerator.getRandomElement(new ArrayList<>(BukkitUtils.getOnlinePlayers()));

echo basalt
#

you pain me

sacred mountain
#

lmao

echo basalt
#

you can just

#

like

#

call array[index] instead

sacred mountain
#

toArray converts to Object[] for some reason

echo basalt
sacred mountain
#

oh thats what you mean

#

what's the + 1 for here then? because 0 is included?

echo basalt
#

random.nextInt is generally not inclusive

#

so nextInt(5, 10) will return a number between [5,6,7,8,9]

#

the +1 makes the 10 belong

sacred mountain
#

so doesnt that mean that the getRandomElement will return something between the start value and the second to last value?

echo basalt
#

no

#

because get(index) starts at 0

sacred mountain
#

right

#

ok

#

thanks

#

is that the only exception?

echo basalt
#

not sure what you mean by only exception

#

collection indexes start at 0

ivory sleet
#

imillusion it works perfectly fine for me

echo basalt
#

and random upper values are exclusive

ivory sleet
#

rly odd

echo basalt
#

could be something about the mca file

#

that issue has been plaguing me for like 2 months now

ivory sleet
#

yeah, I used paper weight mojmapped server thingy

misty current
#

conclure i did what you told me but the server seems to deadlock and awaitTermination returns false

echo basalt
#

I only have a 1.17 mca file for now

misty current
#

but i'm unsure about why that's the case

echo basalt
#

let me see

green prism
#

?paste

undone axleBOT
upper tendon
#

How would one display values on the tab list for each player?

green prism
misty current
#

packets

echo basalt
#

PlayerInteractEvent is called twice, one for each hand

misty current
green prism
misty current
#

so check the event hand and return if the hand is the offhand

echo basalt
#

uhhh

upper tendon
green prism
#

ik the code quality is so bad i'll fix it

echo basalt
#

got distracted by all the nesting

#

lowercase constants

green prism
#

amogus

upper tendon
#

tablist

echo basalt
#

I can't tell if spigot is just weird today or if I'm too sleep deprived to figure out a fix

misty current
echo basalt
#

seen the wildest stuff

green prism
misty current
upper tendon
#

you can display a scoreboard on the tablist

misty current
green prism
#

look at my code

#

ln 14

#

it is called twice

misty current
#

i am trying to help you debug the issue

#

if the event is registered twice, a broadcast above the hand check will be sent 4 times

green prism
#

it is sent 2 times

misty current
upper tendon
#

yesss

misty current
#

ah that makes sense

#

what's your code right now?

green prism
#

ooohh okayy I understand what u meant now

#

that's quite funny

#

i did what u said

misty current
green prism
#

sent the printLn 3 times before and 2 later

misty current
#

kinda weird ngl

#

not really sure, try to do more debugging

green prism
#

I’ll need to be debugged too soon

#

oK kill05

#

i debuggegged

#

the event is called 3 times

upper tendon
green prism
#

2 arms and 1 => I think this is correct

#

ohhH now only 2 times

ornate patio
#

what's the name of the "click" sound

#

it's usually used when a player selects an item from a GUI

#

oh wait this sounds better

#

but i just found the sound

#

it was BLOCK_DISPENSER_DISPENSE

pastel juniper
#

what should getOwner return???

misty current
#

UUID.fromString() or similar

pastel juniper
misty current
#

np

echo basalt
quartz basalt
#

Cannot resolve symbol 'PacketPlayOutSpawnEntityLiving' why am i getting this error is there a certain repo i need to add or somethifn?

chrome beacon
#

What version are you using

echo basalt
#

add spigot instead of spigot-api

quartz basalt
#

1.18

#

.2

#
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.18.2-R0.1-SNAPSHOT</version>
            <scope>provided</scope>

        </dependency>```  ```Unresolved dependency: 'org.spigotmc:spigot:jar:1.18.2-R0.1-SNAPSHOT'```
chrome beacon
#

?bt Run BuildTools

undone axleBOT
quartz basalt
#

i need to install it for it to work?

chrome beacon
#

Yes

quartz basalt
#

how can i fix this error *** The version you have requested to build requires Java versions between [Java 17, Java 18], but you are using Java 16 i need to use java 16 soooo and i cant download an older version of btools because the link is just a download

chrome beacon
#

Why do you need Java 16?

quartz basalt
#

1.18 plugin java 16 server

chrome beacon
#

1.18 needs Java 17

#

You cannot run it with Java 16

misty current
#
    public void savePlayerSync(UUID uuid) {
        MongoHandler.getCollection(Collection.PLAYERDATA)
                .replaceOne(getFilter(uuid), getPlayerDocument(uuid), new ReplaceOptions().upsert(true));
    }


    private Document getFilter(UUID uuid) {
        return new Document("_id", uuid.toString());
    }

    private Document getPlayerDocument(UUID uuid) {
        CosmicPlayer cosmicPlayer = getPlayer(uuid);
        if(cosmicPlayer == null) {
            throw new CosmicException("There is no player to save with uuid " + uuid + ".");
        }

        Document document = new Document("_id", uuid.toString());

        for(PlayerStatistic<?> statistic : PlayerStatistics.getStatistics()) {
            document.append(statistic.getName(), cosmicPlayer.getStatistic(statistic));
        }

        return document;
    }
``` hey, for some reason the `savePlayerSync` method seems to block the thread it's executed in for an indefinite amount of time, i've added a debug message above and below the call to the method and in 10 minutes only the first message was sent
river oracle
#

or the regular one

misty current
#
        <dependency>
            <groupId>org.mongodb</groupId>
            <artifactId>mongo-java-driver</artifactId>
            <version>3.12.11</version>
        </dependency>
#

this is my maven import

#

am I supposed to use another one?

river oracle
#

use the mongo streams driver it can run async safely

#

it should also stop the blocking

#

granted you take full use of the features provided

river oracle
#

good rule of thumb don't run DB calls main thread its going to end up blocking if the requests don't take long

river oracle
#

you will need to change your code up for the rest of the project, but it should help if you implement it correctly

misty current
# river oracle good rule of thumb don't run DB calls main thread its going to end up blocking i...

i'm aware, this is the method that was invoking savePlayerSync

    public CompletableFuture<Void> saveAll() {

        CompletableFuture<Void> completableFuture = new CompletableFuture<>();

        threadPool.submit(() -> {
            for(UUID key : cosmicPlayerMap.keySet()) {
                Bukkit.broadcastMessage("next!");
                savePlayerSync(key);
                Bukkit.broadcastMessage("done next!");
            }

            Bukkit.broadcastMessage("completed!");

            completableFuture.complete(null);
        });

        return completableFuture;
    }
river oracle
#

there is also a mongo async driver, but its deprecated in favor of the reactive streams driver

green prism
#

why use a db?

river oracle
#

yaml files is ok for smaller things

misty current
#

how different is the syntax compared to the driver i am using now?

river oracle
#

but you always want the scalable option at the disposal

misty current
#

so why not use a db which is a better option compared to yml files

river oracle
misty current
#

that's gonna be annoying

#

aight thanks

river oracle
green prism
river oracle
misty current
#

if you want to sure

misty current
green prism
#

no pain no carrots, I'll do it

misty current
#

if that's what you meant

#

the issue is not that the method makes the thread stop a bit, it completely freezes it

#

it's been 20 minutes now and it still didn't run once

quartz basalt
#

am i supose to put buildtools in my project to be able to use packets orrr? the spigot link doesnt really say and i jsut ran it and it started creating folders

chrome beacon
#

No just run it somewhere

river oracle
quartz basalt
#

i did and i still cant use <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot</artifactId> <version>1.18.2-R0.1-SNAPSHOT</version> <scope>provided</scope> </dependency> same error

misty current
#

it installs in your local repo

#

then you import with maven

green prism
#

what does that means? strictfp

granite owl
#

is it possible to play a sound for one player that doesnt have a location using packages?

#

so a sound that "always stays in the center"

#

regardless of actual positioning

tardy delta
#

play it at the cloned player position maybe?

#

i guess the sound follows if you play it at the players loc

chrome beacon
#

I believe it has to have a position

granite owl
#

hm

#

will try tomorrow

granite owl
#

however it doesnt for playback music

#

hm?

green prism
#

Olivo i belive in u

tardy delta
#

both hands?

green prism
misty current
#

how can I get a static field with reflections?

green prism
# misty current how can I get a static field with reflections?

        for(Field field : getClass().getDeclaredFields()) {
            if(field.getType() == String.class) {
                field.setAccessible(true);
                System.out.println(field.getName());
                try {
                    String value = Colors.parseColor(langConfig.getString(field.getName()));
                    field.set(this, value);
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
        }

    }```
granite owl
#

delta time it for the player to not fire twice within like 1sec

#

the same player

green prism
#

bruhhh that's not normal

granite owl
#

it is

#

also happens for npc interactions

green prism
#

so i need to do a runTaskLater and remove the player from the array after 1 sec

#

kydoky

misty current
#

you copy pasted something that's barely related to my question

granite owl
green prism
granite owl
#

well but yea

#

i deltatime it using the items cooldown

#

however i use rightclick abilities bound to items which u dont so yea id suggest to use a backend list

subtle folio
#

what is event for drinking milk

green prism
#

PlayerMorningCookieEvent

subtle folio
#

ty

green prism
#

no sorry ahah

subtle folio
#

hey man

green prism
#

xd

subtle folio
#

idk why it aint wearking

#

so weird

green prism
#

we need md5 for that

subtle folio
#

mwah

green prism
#

report

granite owl
#

i want my PrepareGrindstoneEvent

#

like frl

#

why isnt that a thing yet

quartz basalt
#
            EntityArmorStand stand = new EntityArmorStand(s);``` why am i getting this error ```Cannot resolve constructor 'EntityArmorStand(WorldServer)'```
granite owl
#

because

#

youre obviously

#

as the error tells u

#

instantiate it incorrectly

#

wrong parameters

green prism
#

hey timinator

quartz basalt
#

i found it on a post

green prism
#

thanks, it works!! (The countdown)

granite owl
quartz basalt
#

and when i hover over it it says the paramater is a world

subtle folio
#

world or worldserver

quartz basalt
#

what

#

ohg

#

says world but when i put the world there instead i get Cannot resolve constructor 'EntityArmorStand(World)'

subtle folio
#

what parameter does it require?

quartz basalt
#

says world

granite owl
subtle folio
#

spigot already has a class for armor stands, do you really need packets?

quartz basalt
#

yeah i need only 1 person to be able to see it

subtle folio
#

Try (CraftWorld)

quartz basalt
#

Cannot resolve constructor 'EntityArmorStand(CraftWorld)' EntityArmorStand stand = new EntityArmorStand((CraftWorld) p.getWorld()); if thats what you ment?

subtle folio
#

.getHandle()

quartz basalt
#

its already has (CraftWorld)

subtle folio
#

OHH

quartz basalt
#
            EntityArmorStand stand = new EntityArmorStand(s);```
subtle folio
#

wait I got it it needs a nms world variable.

#

(net.minecraft.server.v1_8_R3.World)((CraftWorld)b.getWorld()).getHandle()

#

replace import with wtv verison you're using

granite owl
#

u want 1 player to see the armorstand?

#

player.getWorld()..

rain echo
#

hey, can somebody help me with this question

granite owl
#

and pass that as param

quartz basalt
subtle folio
rain echo
# rain echo hey, can somebody help me with this question

how could I use the same inventory across all my classes, like, for example Inventory 1 is created in my class ItemsMenu from my config file:

public class ItemsMenu {

    public ItemsListConfigFile itemsListConfig;

    private final Map<Integer, Inventory> itemsMenuGui = new HashMap<>();

    public ItemsMenu() {
        createItemsMenu();
    }

    public void createItemsMenu() {
        itemsListConfig = new ItemsListConfigFile(plugin);
        Objects.requireNonNull(itemsListConfig.getItemsListConfig().getConfigurationSection("Inventories")).getKeys(false).forEach(ID -> {
            String menuName = itemsListConfig.getItemsListConfig().getString("Inventories." + ID + ".menu_name");
            itemsMenuGui.put(Integer.parseInt(ID), Bukkit.createInventory(null, 36, "§8§oEditing " + menuName + " menu..."));
        });
    }

    public void openInventory(Player player, int ID) {
        player.openInventory(getInventory(ID));
    }
}

then i wanna open this same inventory it with a command

itemsMenu = new ItemsMenu();
itemsMenu.openInventory(player, Integer.parseInt(args[0]));

then i wanna get exactly the same inventory in another class,
so i did this:

    @EventHandler
    public void checkInventory(InventoryOpenEvent event) {
        itemsMenu = new ItemsMenu();
        Map<Integer, Inventory> inventoryList = itemsMenu.getInventoryList();
        Inventory openedInventory = event.getInventory();

        if (inventoryList.containsValue(openedInventory)) {
            itemsMenuGui = openedInventory;
        }
    }

but the problem is with itemsMenu = new ItemsMenu(); wich creates a "new inventory" for every class

So, what i have to do to create a single inventory for all my classes, like a static one, but without using static keyword? 🥺

I hope I have explained what I meant, my english is not the best 😅

granite owl
quartz basalt
#
            EntityArmorStand stand = new EntityArmorStand((CraftWorld) p.getWorld());``` im getting a load of errors from the (net.m) thing ```Cannot resolve symbol 'v1'``````Not a statemen``` ```Cannot resolve symbol 'R0'``` ```Cannot resolve symbol 'SNAPSHOT'```
subtle folio
#

you are not properly importing it,

#

v1_18_2-R0.1-SNAPSHOT.World

#

etc

quartz basalt
#

o h

#

Cannot resolve symbol 'v1_18_2'

            EntityArmorStand stand = new EntityArmorStand(s);```
granite owl
subtle folio
#

type out world and do the net.minecraft.world.level

rain echo
granite owl
#

first off u could make it static

quartz basalt
#

Cannot resolve symbol 'v1_18_2' same error

granite owl
#

or

subtle folio
quartz basalt
#
            EntityArmorStand stand = new EntityArmorStand(s);```
granite owl
#

the better alternative

chrome beacon
quartz basalt
granite owl
#

keep it referenced although the problem is

subtle folio
#

try tahat

chrome beacon
rain echo
granite owl
#

that inventories get "deleted" when the viewer count goes to 0

quartz basalt
granite owl
#

as long as someone is viewing that inventory for example itll never get deleted from memory

subtle folio
#

in the ()

granite owl
#

but thats not the solution here

chrome beacon
quartz basalt
#

its a redundent cast

#
            EntityArmorStand stand = new EntityArmorStand(s);```
chrome beacon
#

Ntdi gave you some outdated info

subtle folio
#

im running outdated software 😛

granite owl
#

player backpack?

#

or what is it

chrome beacon
quartz basalt
#

what class for what

rain echo
#

no, its a menu with items that can be given to all players

#

menus*

chrome beacon
quartz basalt
#

oh

granite owl
#

trading post

#

creative menu

#

interface

rain echo
#

im working on a giveall plugin

granite owl
rain echo
#

wich later can be give to all online players

granite owl
#

so interfaces?

rain echo
#

/giveall gui 1/2/3/4

granite owl
#

but everyone can

#

take them

#

?

quartz basalt
granite owl
#

everyone can get 1 set

rain echo
#

not exactly, i mean somehow yes, but they cannot open the menu, they just recieve the item from the menu

#

directly in their invetories

#

only the admin can open the menu to add items

granite owl
#

okay so

#

im not gonna do ur homework

#

but

#

id suggest you read into serialization

#

instead of keeping it in memory at all times

#

id keep it serialized on the harddrive

#

and instantiate it from the harddrive when needed

granite owl
chrome beacon
granite owl
#

oh and ofcourse if u wanna hand out the items to the players

#

create an instance for everyone each

#

so everyone can receive their set instead of grabbing from the same inv pool

chrome beacon
#

?

granite owl
#

modding nms entities for custom behavior on vanilla level?

#

plugin*

#

not mod

ornate patio
#

can i like post my code here and ask for a code review

hybrid spoke
#

sure

#

go ahead

ornate patio
#

I have something that works but its got duplicate code and idk how to clean it

#

just gimme a sec gonna finish up some feature

granite owl
#

basically theres a reason why inventories get removed from memory. so instead of forcing them to stay there id just store them to the harddrive while not needed activly

#

and reload them into mem when needed

#

if u want them to be persistent

#

once serialized theres like thousands of ways to store them

rain echo
#

okay, thanksss

granite owl
#

np 😛 thank me when its working

ornate patio
#

this is submenu for a GUI created with InventoryFramework

#

the main problem is the duplicate code, i'm repeating the same thing for both Color and Style

hybrid spoke
#

alright

ornate patio
#

I have a ColorSelector enum and a StyleSelector enum

#

two methods which are almost identical

modest garnet
#

hey does anyone know how to cash data, for example only save the data the the db when the player leaves or the server is shut down. looking to make a small eco plugin

ornate patio
#

instead of cache

#

if the server is shut down unexpectedly (for example a power outage), all the data is lost

modest garnet
#

saving the balance of a player to the database when the balance is constantly changing will cause mass lag

#

thats why i dont want to do it

ornate patio
#

i'm sure it'll barely make a dent in performance. but if you want to go that route, just store an array in the plugin or part of the plugin

#

where each element stores information about a player and their balance

modest garnet
#

i cant save data multiple times a min with 100+ players

#

when there bal is changing from mining etc

spiral cape
#

it won't cause lag, unless you have 10000 of players on mysql

ornate patio
#

chances are you'll be fine

granite owl
#

like stated before, unexpected shutdowns will cause data loss but tbh

#

crashes always will

spiral cape
#

I've had a server 8 years ago with 200-300 players with mysql

spiral cape
#

constant reading/writing

#

and never had an issue

ornate patio
spiral cape
#

if you feel like mysql is not enough, go for mongoDB

modest garnet
#

ty tho

granite owl
ornate patio
#

yeah ik no rush lmao

hybrid spoke
# ornate patio https://mystb.in/BuildersUniversalPerhaps.java

package me.screescree.SuperiorSteed.superiorhorse.horseeditor.submenus;

there's too many private static classes

    private static Mask MASK = new Mask(
        "1111111",
        "0000000",
        "0111110"
    );

thisun make it final

final the enum variables

for (ColorSelector colorSelector : values()) {

i would not iterate everytime over the values of an enum. even if its small its more efficient to use a internal hashmap

remove the getByName methods, they will probably not work

that's just the enums

ornate patio
#

uh btw i dont think you can use final enums

hybrid spoke
#

also i would not use the ordinal() method of enum

ornate patio
#

and for iterating over all the values of the enum, what's an alternative?

subtle folio
#

event on campfire lighting?

hybrid spoke
#

its not really an item index. also the order can change. easily misunderstandable as well

ornate patio
#

also getByName actually does work

ornate patio
#

but i guess your right its confusing

#

but what can I do about the duplicate code?

hybrid spoke
#

since it seems to be the exact same code you can just inline it into a method and use that

ornate patio
#

what do you mean inline it into a method

hybrid spoke
#

for the enum duplicate code i would probably go generic with a Selector superclass

granite owl
#

put it in a function

#

call the function twice

spiral cape
#

checkColor checkStyle could be one function

ornate patio
#

i tried doing that at first

hybrid spoke
#

do you really explicit need an enum

ornate patio
#

well not really

#

i guess ill find a way to turn it into a class

#

generics is a good idea

#

thanks

golden turret
#

@echo basalt

#

i just wanted to say that

#

i just spent hours on this

#

some minutes making this:

#

to see that the problem

#

was this motherfocker here

echo basalt
#

lol

golden turret
#

i changed it to true

#

and

#

it worked

echo basalt
#

the false seems to reset the tags after they get sent or something