#development

1 messages Β· Page 139 of 1

grim oasis
#

aha

#

so the taskID

#

is a field variable that is not dependent on the player's name

#

What you should do is make a runnable class

#

or just store all taskIDs to a list if you wanna do this

#

I personally would make a runnable class that does everything at once

#

so one runnable that goes every 20 ticks, doing all the ability stuff

echo briar
#

ah okay, could you possibly make a small example of how that would look? using a runnable class instead?

grim oasis
#

gives armor, removes armor, etc.

#

I would also change your items to be created only once

echo briar
#

okay

grim oasis
#

create private field variables, initialize them in the constructor

#

instead of every right click

echo briar
#

gotcha, okay

grim oasis
#
public class MinerRunnable extends BukkitRunnable {
    
    private static //counter map
    
    public void run() {
    }
    
}

#

I'd say make a map per ability if you have multiple

#

and just add the player to it then they first activate

#

but that runnable should run every 20 ticks no matter what

echo briar
#

Ahhh alright, i'll see if i can get that to work

grim oasis
prisma briar
#

How can I create a system to hides players' nametag but only visually to certain players? I want to hide the nametag If the player e.g: behind a block, sneaking, etc.

wintry grove
#

I think there is a packet for that?

grand canyon
#

Regarding threads when its done how can you get the results?

dusty frost
#

CompletableFutures usually

#

and/or callbacks

icy shadow
#

poobacks

grand canyon
#

Imagine you have List<BlockPos> of different positions. What is preferable the best method to figure out which of all those locations are the closed to the player?

sterile hinge
#

a loop?

worn jasper
#

When a player is kicked, is the playerquit event called?

grand canyon
#

yea

worn jasper
#

Okay, also, do PDCs run async?

#

In the sense of taking a while to return something?

grand canyon
#

pdc?

worn jasper
#

Cause I am having issues with pdcs where if I leave when the pdc is getting changed, it resets it

#

PDC = PersistentDataContainer

grand canyon
#

ic

worn jasper
#

So....

sterile hinge
#

what does "taking a while" mean

#

everything is taking a while

worn jasper
#

Well it means that by the time it changes, I am not online anymore

sterile hinge
#

that might be ugly details of the implementation - if the event is called after the player data is saved, changes to it when handling the event won't be written anymore

pure crater
#

Seems really hacky lol

sterile hinge
#

all that versioning stuff is basically just a strategy pattern

dense drift
#

what if getTag would be a Map<ServerVersion, String> getTagMethod?

hoary scarab
dense drift
#

there's getOrDefault

hoary scarab
#

True. Wanted to stick with enums though but doesn't look like its possible in the way I want.

#

Ah... My thought process was if I do it as maps I still have to do multiple methods to check the version and add the input to the map so might as well use enums since it was basically the same. ("basically the same" in this case not all)

#

My issue is really just not being able to variablize as enum lol (Ex; Enum variable;)

dense drift
#

?

hoary scarab
#

Since I couldn't do Enum current; I went with trying to nest and use interface

dense drift
#

I mean, you still need an interface for enums, how else would you be able to call that extra getMethod() on just Enum?

sterile hinge
#

why don't you just write a strategy-pattern like implementation for each version?

dense drift
#

^

sterile hinge
#

it's the typical approach for a reason

sterile hinge
#

you have a common interface, e.g. Adapter, with methods that do what you need to do version-specific. Then, you have one implementation of that interface for each version

hoary scarab
#

Cause I didn't wanna multi-class it

sterile hinge
#

?

hoary scarab
#

Just got rid of having a class per version xD

dense drift
#

Is either what ywell suggested or reflections, there's no in between

sterile hinge
#

and what's the advantage of anything else?

hoary scarab
hoary scarab
sterile hinge
#

so you rather write more code, less understable in one class?

hoary scarab
sterile hinge
#

have fun debugging that mess ig

hoary scarab
sterile hinge
#

I mean yeah, you can do that

#

but that all looks inefficient af

hoary scarab
#

I mean its cached so...

#

Might not even do enums cause its still a bunch of them spammed with getMethod() xD

sterile hinge
#

so... you create one class per method with n objects each instead of n classes and one object at runtime

hoary scarab
high edge
#

Please don't tell me you use white theme

hoary scarab
high edge
#

burn the heretic.

hoary scarab
#

I don't have weak eyes πŸ˜‰

dense drift
#

man, this is anything but clean

hoary scarab
dense drift
#

Still

warm steppe
#

Is that eclipse?

hoary scarab
kind granite
hoary scarab
kind granite
#

try using enums appropriately πŸ˜‰

#

use a map like gaby suggested

hoary scarab
#

Read the conversation you necro posted too lol

kind granite
#

i have

#

most of it was you ignoring people

hoary scarab
#

Then you didn't read it right.

#

Carry on.

torpid raft
#

necro posted? is this a forum

lyric gyro
#

I mean that's literally what happened, you shared something and you literally asked for suggestions, then you proceeded to ignore every single response

hoary scarab
torpid raft
#

your first message is 3 hours old

lyric gyro
#

lol

hoary scarab
torpid raft
#

well it is a public chat, i can't imagine that you only wanted one person to respond

limber hedge
#
    private static void createExample() {
        ItemStack item = new ItemStack(Material.NETHERITE_SWORD);
        ItemMeta meta = item.getItemMeta();

        meta.setDisplayName(ChatColor.GOLD + "EXAMPLE");
        List<String> lore = new ArrayList();
        
        lore.add(ChatColor.translateAlternateColorCodes('&', "&7EXAMPLE LORE"));
        meta.setLore(lore);
        meta.hasItemFlag(ItemFlag.HIDE_ATTRIBUTES);
        item.setItemMeta(meta);

        Pole = item;
    }```
Why does the ItemFlag.HIDE_ATTRIBUTES not work here?
#

The item still has attributes

hoary scarab
hoary scarab
limber hedge
#

πŸ€¦β€β™‚οΈ

kind granite
amber briar
#

I wonder how young one must be to still quantify 3 hours as long... I mean I know time seems to speed up as you get older, but....

#

I mean you can kill 2+ hours easily by watching a movie or 45m-1hr TV episodes

#

Time in that case just ✨vanishes✨

hoary scarab
pulsar ferry
#

Luccy pronounced like cappuccino

kind granite
#

oh god please no

icy shadow
#

luchy

#

(Sorry for necroposting I know I'm 4 minutes late)

kind granite
#

capluccyno

#

(sorry for necro)

broken elbow
torn heart
#

i'm trying to get better at working with npcs and such, and i looked for some threads and found out how to add the top layer of a skin for example. they used this resource to figure out the id's: https://wiki.vg/Entity_metadata#Player

#

thing is because its updated for 1.19, and i'm working on 1.8, the index's aren't the same

#

so if anyone could help me understand how to get the old index from different versions that would be helpful

#

for example i know that this changes how the skin is displayed, and i understand this function fully, with 10 being the value to modify and the (byte 127) corresponding to which parts to display, but i'm not sure where the 10 is from, i know it's correct, but i can't find a page showing its value

DataWatcher watcher = npc.getDataWatcher();
        watcher.watch(10, (byte) 127);```
winged pebble
#

One option is just go to Entity -> EntityLiving -> etc -> EntityPlayer and count the order they register to the datawatcher

torn heart
#

i don't understand...?

winged pebble
#

The index represents the order in which it is registered to the datawatcher

torn heart
winged pebble
#

So for example (this is 1.16.5) this shows where they register each part of the datawatcher for Entity

#

You can see that the second is at least named so you can tell what it is

torn heart
#

idk if this is relevant but 1.8 doesn't have a DataWatcherRegistry

winged pebble
#

Yeah, it's a bit more manual

torn heart
winged pebble
#

I'm just helping you understand the general idea

#

Yes

#

And if you look on the wiki.vg for Entity, you can see it lines up (at least ignoring the newer stuff)

#

It's a bit less terse with 1.8.8

torn heart
#

yea i saw that

#

i can't find anything like that in the EntityPlayer class though

#

am i doing something wrong?

winged pebble
#

It's probably EntityHuman

torn heart
#

lemme check

winged pebble
#

yup

torn heart
#

yea you're right

#

wait so

#

sec

#

wait so okay i can see the methods now

#

but how can i figure out what each of them actually does

winged pebble
#

Your best bet is to look at wiki.vg and pick out what would exist at the time

torn heart
#

like with an older version of the wiki...?

winged pebble
#

You might be able to look at an archived version, yeah

#

But I meant the current one

#

This might help as well

#

This was for 1.16

torn heart
winged pebble
#

It's from my own library I made once

torn heart
#

well this has been really informative, thank you

winged pebble
#

No problem! I looked deep into this for 1.16 because I made npcs that worked with pathfinders but looked like players (and weren't EntityPlayer)

limber hedge
#

I'm trying to create a sell GUI where players place their items into a gui then click the sell button to sell them. I've come across this problem:

        if (e.getView().getTitle().equals(ChatColor.DARK_GRAY + "Ore Merchant")) {
            //if they inside of sell gui

            if (e.getSlot() == 49) { //if they click sell button
                player.updateInventory();
                for(int i = 0; i<=53; i++) {
                    if (!(inv.getItem(i) == null)) {
                        Bukkit.broadcastMessage(inv.getItem(i).getType() + "");
                        if (isGem(inv.getItem(i))) { //if its a gem
                            inv.setItem(i, new ItemStack(Material.AIR));
                            Bukkit.broadcastMessage(i + "WORKED");
                        }
                    }
                }
                }

        }```

When they place the items inside the GUI and click the button it this acts like the items don't exist and are skipping over them like they are air blocks.
#

Its ugly but gets the job done :/ (visually)

#

not sure how I could clean it up

torn heart
#

you should probably actually send the isGem function

limber hedge
#
    public static boolean isGem(ItemStack item) {
        if (item != null) {
            if (item.getItemMeta() != null) {
                if (item.getItemMeta().getLore() != null) {
                    if (item.getItemMeta().getLore().size() >= 0) {
                        if(item.getItemMeta().hasLore())
                            if (item.getItemMeta().getLore().get(0).equals(Ores.FineAmber.getItemMeta().getLore().get(0))) {
                                return true;
                            } else {
                                return false;
                            }
                    }
                }
            }
        }
        return false;
    }```
#

All the items hold the same first line of lore

torn heart
#

use nbt tags :/

limber hedge
#

I would if I knew how to but havent learnt that yet

formal crane
#

So i am trying to get "exampleCategory" from my json file but when i try this is gives a null value,

here is my json file: ```json
{
"categories": {
"exampleCategory": [
"avoir/hebben",
"etre/zijn"
]
}
}


This is what i have tried so far but gives the null value:
`JSONArray jsonArray = (JSONArray) jsonObject.get(JsonObject.get("exampleCategory"));` & `JSONArray jsonArray = (JSONArray) jsonObject.get("categories.exampleCategory");`
grim oasis
icy shadow
limber hedge
grim oasis
#

so does no arrow code πŸ˜‰

#

?plsnoarrowcode

neat pierBOT
grim oasis
limber hedge
#

The brackets were from me testing debug messages

#

The debug messages just skip over all the items I place in the GUI and just print out the glass and player heads

#
    public static boolean isGem(ItemStack item) {
        if (item != null) 
            if (item.getItemMeta() != null) 
                if (item.getItemMeta().getLore() != null) 
                    if (item.getItemMeta().getLore().size() >= 0) 
                        if(item.getItemMeta().hasLore())
                            if (item.getItemMeta().getLore().get(0).equals(Ores.FineAmber.getItemMeta().getLore().get(0))) 
                                return true;
        return false;
    }```
lyric gyro
#

oh my

#

size() >= 0
this will always be true tho

#

either the list is empty or it isn't

grim oasis
#

I see what you were saying about the brackets

#

but not what I was referring to

#

the way you're opening the inventory now, you will run into the problem that it's the same inventory for everybody

limber hedge
#

Your one is very pretty but I dont understand it

grim oasis
#

that's fine

#

when you currently run it, what debug messages are you getting?

limber hedge
#

Its just all GLASS and HEADS but the items I place in it are COAL

grim oasis
#

so it never said WORKED right?

limber hedge
#

Yea never said it

grim oasis
#

add more debug messages back to isGem

limber hedge
#

When I put in Bukkit.broadcastMessage(inv.getItem(i).getType() + "");
It doesnt notice the items I place in the GUI at all

#

So it never accepts isGem because all it is checking is the Background items and the button itself

grim oasis
#

where do you have room to put items?

limber hedge
#

Inside of the GUI where I place AIR

limber hedge
#

I guess I dont need to put anything there since nothing is air anyway

grim oasis
#

hmm

#

get the clicked inventory items

#

instead of the field variable inv

limber hedge
#

Bukkit.broadcastMessage(e.getCursor().getType() + "");

grim oasis
#

take a look at mine

#
final Player p = (Player) e.getWhoClicked();
    if (e.getRawSlot() >= 45 && e.getRawSlot() <= 53)
      e.setCancelled(true);
    if (e.getRawSlot() >= 45 && e.getRawSlot() <= 48) {
      p.getOpenInventory().close();
    } else if (e.getRawSlot() >= 50 && e.getRawSlot() <= 53) {
      double totalValue = 0; //items to sell
      double totalAmount = 0; //value of items

      for (int i = 0; i <= 44; i++) { //loop through inventory
        ItemStack currentItem = e.getClickedInventory().getItem(i); //Current Item in the slot of the CLICKED inventory

        if (currentItem == null) {
          continue;
        }

        String itemName = currentItem.getType().toString().toLowerCase();
        if (!allItems.containsKey(itemName)) {
          continue;
        }
        double sell = allItems.get(itemName).getSell(p); //gets the sell price
        ItemStack blankItem = new ItemStack(Material.getMaterial(itemName.toUpperCase())); //retrieves a blank copy of the item I'm checking
        if (currentItem.isSimilar(blankItem)) { //checks if the current item is the item to compare to
          int amount = currentItem.getAmount();
          e.getClickedInventory().setItem(i, null);
          DeluxeShop.getEconomy().depositPlayer(p, sell * amount); //sells the item
          totalAmount += amount; //adds item amount
          totalValue += (sell * amount); //adds sell value
        }
      }
      if (totalAmount == 0) {
        p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8Nothing to sell!"));
      } else {
        p.sendMessage(ChatColor.translateAlternateColorCodes('&',
            "&6Successfully sold &a" + totalAmount + " items &6for &a" + DeluxeShop.DECIMAL_FORMAT.format(totalValue)));
      }
      p.getOpenInventory().close();
#

you see I get the actual inventory the player is using, from the event

#

instead of the field variable

#

no, I guess I sent a lot

limber hedge
#

How does your one work?

#

Mine works by loading all the items into the GUI then clicking the sell button

#

Then it for loops through all the slots, checks if its a gem then if it is it broadcasts WORKED

#

I cant visualize yours, that is what is making it difficult for me to understand what is does or how it works

grim oasis
#

I added some comments

#

The big difference between me and you

#
        ItemStack blankItem = new ItemStack(Material.getMaterial(itemName.toUpperCase())); //retrieves a blank copy of the item I'm checking
        if (currentItem.isSimilar(blankItem)) { //check
#

is this

#

because I compare it to another item

#

you use an isGem(currentItem) method

#

basically, just try changing it to #getClickedInventory and use that

#

just see if it works

#

if you're confused still send your class

limber hedge
#

I understand yea

#
        if (e.getView().getTitle().equals(ChatColor.DARK_GRAY + "Ore Merchant")) {
            //if they inside of sell gui

            if (e.getSlot() == 49) { //if they click sell button
                player.updateInventory();
                for (int i = 0; i <= 53; i++) {
                    ItemStack currentItem = e.getClickedInventory().getItem(i);
                    Bukkit.broadcastMessage(currentItem.getType() + "");
                    if (currentItem == null) {
                        continue;
                    }
                    if (isGem(currentItem)) { //if its a gem
                        Bukkit.broadcastMessage(i + "WORKED");
                    }
                }
            }
        }```
It says worked now
#

Thank you for your help

#

and thank you for being patient

grim oasis
#

I still recommend making a new inventory every time you open it though

#

@limber hedge

limber hedge
#
        SellGUI gui = new SellGUI();
        gui.openInventory(target);```

this runs when they do the cmd
grim oasis
#

also try some for loops for items vs 1 for loop and a bunch of ifstatements

grim oasis
#

when do you register the listener?

#

ohhhh\

#

I think I know why it wasn't working earlier

limber hedge
grim oasis
#

with a new instance of SellGui

#

every time you run the command, you make a new instance of it

#

which is NOT the listener

#

instead you should store it when you register it, then just use gui.openInventory(target)

limber hedge
#

I use to do that but when two players had the same GUI open they could see what each other were putting in it

grim oasis
#

exactly what I said

grim oasis
#

so what you want to do is make a new inventory in the openInventory part

#

not make a new SellGui in the command

#

basically just gotta move the itemsetup to the openInventory part

limber hedge
#

I have it set up with init() then init() is inside of openInventory

#
    public void initializeItems() {
        createSell(0);
        createBackgroundItem();
        createInformationBook();

        for (int i = 0; i <= 53; i++) {
            if (i == 49)
                inv.setItem(i, SellItem);
            if (i == 4)
                inv.setItem(i, InfoBook);
            if (i == 0 || i == 1 || i == 2 || i == 3 || i == 5 || i == 6 || i == 7 || i == 8 || i == 9 || i == 12 || i == 13 || i == 14 || i == 17 || i == 18 || i == 26 || i == 27 || i == 35 || i == 36 || i == 39 || i == 40 || i == 41 || i == 44 || i == 45 || i == 46 || i == 47 || i == 48 || i == 51 || i == 52 || i == 53 || i == 54 || i == 50) {
                inv.setItem(i, BackgroundItem);
            }
        }
    }

    // You can open the inventory with this
    public void openInventory(final HumanEntity ent) {
        initializeItems();
        ent.openInventory(inv);
    }```
#

Wait really I've been doing it wrong all this time

#

so the create part i put in open as well

grim oasis
#

remove the field variable inv

limber hedge
#

inv = Bukkit.createInventory(null, 54, ChatColor.DARK_GRAY + "Ore Merchant");

grim oasis
#

yep

#

if you remove the field variable first the IDE will start yelling at you

#

easy to see where you have to make other changes imo

limber hedge
#

So what do I put int SellGUI()

#
public class SellGUI implements Listener {

    public ItemStack SellItem;
    public ItemStack BackgroundItem;
    public ItemStack InfoBook;

    //(X/100)x15 MINING FORTUNRE EQUATION

    public SellGUI() {

    }
    // You can open the inventory with this
    public void openInventory(final HumanEntity ent) {
        Inventory inv = Bukkit.createInventory(null, 54, ChatColor.DARK_GRAY + "Ore Merchant");
        ent.openInventory(inv);
        createSell(0);
        createBackgroundItem();
        createInformationBook();

        for (int i = 0; i <= 53; i++) {
            if (i == 49)
                inv.setItem(i, SellItem);
            if (i == 4)
                inv.setItem(i, InfoBook);
            if (i == 0 || i == 1 || i == 2 || i == 3 || i == 5 || i == 6 || i == 7 || i == 8 || i == 9 || i == 12 || i == 13 || i == 14 || i == 17 || i == 18 || i == 26 || i == 27 || i == 35 || i == 36 || i == 39 || i == 40 || i == 41 || i == 44 || i == 45 || i == 46 || i == 47 || i == 48 || i == 51 || i == 52 || i == 53 || i == 54 || i == 50) {
                inv.setItem(i, BackgroundItem);
            }
        }
    }```
#

And do I still use:

        SellGUI gui = new SellGUI();
        gui.openInventory(target);```
Inside of my command?
grim oasis
#

no, do not make a new SellGui

#

you have to use the one you originally create in onEnable

#

all you do is gui.openInventory(target) (probably plugin.sellGui.openInventory(target) or something similar)

limber hedge
#

And what do I put in onEnable?

#

Since SellGUI() is completely empty in the SellGUI Class

grim oasis
#

send your main class and your command class

#

I gotta go get some food here

limber hedge
#

I use an API for Command Class

grim oasis
#

idk how to help you man

#

it's honestly all over the place

#

idk why you have a StartUp class and a startup method outside of your main class and outside of onEnable

#

basically you should be instantiating the command class with an instance of your plugin that you can later call back to to access the SellGUI listener instance you create

leaden sinew
grim oasis
#

better than my idea

torn heart
#

so right now i'm trying to create custom pathfinding npcs for 1.8. basicly the idea is that they can follow and fight eachother. https://www.spigotmc.org/threads/tutorial-creating-custom-entities-with-pathfindergoals.18519/ i tried to follow this tutorial, but i don't believe EntityPlayer has pathfinding goals, and i don't know how to get around this other than creating my own pathfinding logic, which would be difficult and most likely inefficient. could anyone help? thanks

rigid mountain
#

Question, so i have this command and im making a bitcoin farm type thing. But when i add it to the players inventory it doesnt do anything. im in 1.8, but that shouln't matter as i add stuff to inv multiple times elese where.

                    System.out.println(args.length);
                    if(args.length < 2) {
                        new FarmGui().makeGui(player);
                    } else {
                        if(args[1].equalsIgnoreCase("give")) {
                            org.bukkit.inventory.ItemStack gpu = new org.bukkit.inventory.ItemStack(Material.matchMaterial(main.getConfig().getString("farm.gpu.material")), main.getConfig().getInt("farm.gpu.amount"));
                            ItemMeta im = gpu.getItemMeta();
                            im.setDisplayName(Utils.color(main.getConfig().getString("farm.gpu.name")));
                            im.setLore(Utils.color(main.getConfig().getStringList("farm.gpu.lore")));
                            gpu.setItemMeta(im);
                            if(args.length == 2) {
                                System.out.println(player);
                                System.out.println(gpu);
                                player.getInventory().addItem(gpu);
                            } else {
                                if(Bukkit.getPlayer(args[2]) == null) {
                                    player.sendMessage(Message.INVALID_PLAYER.getMessage());
                                } else {
                                    Player t = Bukkit.getPlayer(args[2]);
                                    t.getInventory().addItem(gpu);
                                }
                            }
                        }
                    }
                } ``` Everything souts as it should
pine flax
#

Try with Player#updateInventory after adding the item

rigid mountain
#

i tried that but that didnt change anything

west socket
#

I'm having a really bizarre issue where some entities won't spawn unless the world has been loaded by a Player since restart (using Bukkit.getWorld.spawnEntity) Anyone know why this might be the case?

pure crater
#

you sue that the chunk you are spawning the entity in is loaded?

west socket
#

Does it have to be?

pure crater
#

Yes

west socket
#

Because I have other entities closer to the world's spawn point that load in fine

#

Either way, there is no player in the world

#

Thats strange, I guess I'll force load it

pure crater
#

try force loading it

#

d;spigot World#spawnEntity

uneven lanternBOT
#
@NotNull
Entity spawnEntity(@NotNull Location loc, @NotNull EntityType type, boolean randomizeData)```
Description:

Creates a new entity at the given Location.

Parameters:

loc - the location at which the entity will be spawned.
type - the entity type that determines the entity to spawn.
randomizeData - whether or not the entity's data should be randomised before spawning. By default entities are randomised before spawning in regards to their equipment, age, attributes, etc. An example of this randomization would be the color of a sheep, random enchantments on the equipment of mobs or even a zombie becoming a chicken jockey. If set to false, the entity will not be randomised before spawning, meaning all their data will remain in their default state and not further modifications to the entity will be made. Notably only entities that extend the Mob interface provide randomisation logic for their spawn. This parameter is hence useless for any other type of entity.

Returns:

the spawned entity instance.

west socket
#

Wow, that was really the solution to the bug I've been tearing my hair out about for 2 days

#

I really appreciate that

#

That's slightly embarassing

stuck hearth
#

That is embarrassing 😳

#

Jk, you're doing great

torn heart
#

i'm following this tutorial for 1.8: https://www.spigotmc.org/threads/tutorial-creating-custom-entities-with-pathfindergoals.18519/
and it's working fine, but i'm trying to make it go to a set location with this: ```java
public class PathfinderToLoc extends PathfinderGoal {

private double speed;

private EntityInsentient entity;

private Location loc;

private NavigationAbstract navigation;

public PathfinderToLoc(EntityInsentient entity, Location loc, double speed)
{
    this.entity = entity;
    this.loc = loc;
    this.navigation = this.entity.getNavigation();
    this.speed = speed;
}

public boolean a() {
    return true;
}

public void c()
{
    PathEntity pathEntity = this.navigation.a(loc.getX(), loc.getY(), loc.getZ());

    this.navigation.a(pathEntity, speed);
}

}```thinig is, this just isn't working. the zombie just isn't moving to the position at all

#

it's implemented in the actual custom class and all: java this.targetSelector.a(new PathfinderToLoc(this, new Location(world.getWorld(), 0, 82, 0), 1.0D));

torpid raft
#

how about just

Set<T> backgrounds = new HashSet<>(Arrays.asList({0,1,2,3,5,6,...}));
if (backgrounds.contains(i) ) {
  inv.setItem(i, BackgroundItem);
}
#

(you would actually want the list of backgrounds as a final static variable but you get the gist)

stuck hearth
#

Idk

halcyon ermine
#

Hello everyone, I recently started developing plugins, so I still don’t know much, so I immediately apologize for the stupid questions. Is there any way to keep track of when a mob enters and exits (this must be checked) from a certain player radius? When the mob enters the radius (you can check .getNearbyEntities) and when it leaves it. I want that when a mob enters the player's radius, he was given a glow effect, and when he left, the effect was removed. And the radius values are static

lyric gyro
lyric gyro
#

Far from it, just simple problem solving!

errant pilot
#

found it!
had to use TextComponent.fromLegacyText()

pulsar ferry
#

?not-discord

neat pierBOT
#
FAQ Answer:

Looking for discord support?
HelpChat is a Minecraft plugin and development support server and is not affiliated with discord in any way.
If you require support from discord, we recommend you to visit their official support website at https://support.discord.com
On this website, you can read their FAQs, or open a support ticket if necessary.

elfin depot
#

yeah, the camera is on, but my friends can't see my video, my video just buffering

elfin depot
#

okay thanks

torn heart
#

like the zombie just isn't doing anything

#

omg i just got it to work

#

let's fricking go!

hoary scarab
#

So in 1.18.2 I used ChatComponentText but it looks like it was removed in 1.19 Any one know its replacement?

winged pebble
#

Seems like before you had IChatBaseComponent, but now it's just Component as the interface and MutableComponent is the only class that implements it

#

They probably changed things up because of the whole preview thing

hoary scarab
#

Saw that but can't figure out how to get text -> IChatBaseComponent which is still used to set an entities custom name

#

I was using setCustomName(new ChatComponentText("Entity Name"));

winged pebble
#

I was comparing non mojang mappings to mojang mappings, hold on a sec haha

hoary scarab
#

πŸ‘ I could use IChatBaseComponent.ChatSerializer.fromJson(String) I think but what was the component changed to if not {TextComponent=}

winged pebble
#

Huh, it looks like there really is only one class that implements that interface now

#

Oh okay I think I get it now

#

(I'm back in mojang mappings for this explanation btw) So Component has getContents() which returns ComponentContents which is where the text lives

#

It seems a bit different than before though, as the interface ComponentContents doesn't have methods to interact with the innards

#

You'd have to get the implementation to do that

#

LiteralContents seems to be what you're looking for though

hoary scarab
#

Really you can't say "fuck" anymore?

#

Why did that post???

high edge
#

fuck up

icy shadow
#

it's "to.fuck"

#

presumably that is more of an active action rather than a casual expletive

lethal wadi
#

Do I need to constantly update my placeholders within a task or something or are they automatically updated by papi

#

Like if I have them in a scoreboard and the value updates from my plugin, will papi automatically detect the change

icy shadow
#

that is not papi's responsibility

#

it's the responsibility of whatever's using the placeholders

lethal wadi
#

So then run a task to update?

icy shadow
#

i.e if your scoreboard updates every 1 second, the placeholder will "update" too

#

no

lethal wadi
#

Ahhh

#

ok

icy shadow
#

yes...?

hoary scarab
#

to <Blank> or not to <Blank> ... Something alot of people quote

lyric gyro
#

lol

hoary scarab
#

@winged pebble

// 1.18.2
setCustomName(new ChatComponentText("Text"));

// 1.19
// Unmapped
setCustomName(Component.literal("Text"));

// Mapped
setCustomName(IChatBaseComponent.a("Text"))
winged pebble
#

Hmmm, interesting I didn't see a static literal method

#

Weird, it's there now

#

Maybe I was looking at the wrong version lol I've got like 4 pulled up

hoary scarab
winged pebble
#

Yeah I must have pulled up the 1.18 on accident

hoary scarab
#

Yeah took me a few hours to find xD

tardy cosmos
#

Does anyone have any idea what would cause this exception to happen? Somebody reported it for one of my plugins and I've never seen anything like it before https://paste.helpch.at/yafokujuda.sql

#

I'm somewhat inclined to blame AuthMe for not relocating their custom mysql driver

broken elbow
#

you could ask them to remove authme and test without and then if it does work just blame authme :))

tardy cosmos
#

They have my plugin on another server and it's working fine so I asked them if AuthMe is also installed on that one. I'll have them try that if they're willing, ty for input

broken elbow
#

yes very useful input from me. I am very useful. ||I know I'm not||

tardy cosmos
#

I wonder if I could just put a loadbefore for authme KEKW

hoary scarab
#

sigh Gotta new issue.... IChatBaseComponent removes hex color

#

Any ideas about this? It works on spawned armorstands but not packet based armorstands

#

Would prefer to not have to go into editing the DataWatcher

winged pebble
#

You shouldn't have to because setCustomName() and getCustomName() interact with the datawatcher I thought

hoary scarab
#

Looking into it

#

Hmmm.... Actually it might be reflection

#

If a class has multiple methods named the same and have the same parameters but return different types which does reflection use?

public String a(String s) {}
public IChatMutableComponent a(String s) {}
public void a(String s) {}
icy shadow
#

thats not possible lol

#

you cant have 2 methods with the exact same name and signature

stuck hearth
#

😱

hoary scarab
icy shadow
#

mapping error then presumably

#

but that would definitely not compile as source code

hoary scarab
#

🀷

#

Thats what I got xD

#

I just used buildtools 20 minutes ago

winged pebble
#

There is something similar that happens when you try to extend an EntityInsentient

#

And intellij throws a fit about it (rightly so)

icy shadow
#

definitely doesnt compile

stuck hearth
#

Thanks BM

icy shadow
#

yw

hoary scarab
icy shadow
#

god knows lmao

stuck hearth
#

Cry

icy shadow
#

something like that

stuck hearth
#

I would

hoary scarab
#

Might have to edit the datawatcher directly then...

lyric gyro
# icy shadow

I mean that's definitely valid at class file level, just not in source lol

icy shadow
#

yeah true

hoary scarab
#

Not finding any, does reflection have any way to get a method based on name and return type?

sterile hinge
lyric gyro
#

MethodHandles 😌

icy shadow
#

i guess it's a decompiler error then?

lyric gyro
#

those are spigot mappings πŸ₯΄

sterile hinge
#

if you just change the mappings of the jar, it's still a valid class file but you can't decompile it to correct java code anymore

icy shadow
#

i dont know nor care what mappings are

sterile hinge
#

but you can also mess with most decompilers by just writing something like

class A {
  static {
    class B {};
    new B();
  }
  static {
    class B {};
    new B();
  }
}
lyric gyro
#

fiend

sterile hinge
#

(this is art)

hoary scarab
#

I'm just gonna search the methods and cache the right one.

#

Welp even when its using the right method hex colors are removed...

lyric gyro
#

are you shoving legacy codes into components?

#

because legacy formatting never supported hex colouring, that's a spigot invention that happens only in legacy -> component deserialisation

hoary scarab
lyric gyro
#

that tells me literally nothing but okay

#

how are you turning that into a component

hoary scarab
#
// 1.18.2
setCustomName(new ChatComponentText("Text"));

// 1.19
// Unmapped
setCustomName(Component.literal("Text"));

// Mapped
setCustomName(IChatBaseComponent.a("Text")) //<---------- This
lyric gyro
#

that still isn't showing how you're actually deserialising it

#

because if you're just shoving that text into that method then it will show the text literally as-is

hoary scarab
#

oh like how I color it 🀦 ?

lyric gyro
#

How are you turning that literal text you sent above into a component

#

not what method you're using

#

the actual code

#

the actual process

hoary scarab
lyric gyro
#

no it's not

hoary scarab
#

Then I'm still not understanding...

lyric gyro
#

you're doing .a("Text"), not .a("#084cfb-#2165fb-#3a7efc-#5297fc-#6bb0fc-#84c9fd-#9de2fd-#a9eef6-#9bdee0-#8ececa-#80bfb5-#73af9f-#659f89-#588f73-#547f72-#556f7a-#565f82-#574f8a-#583e93-#592e9b-#5a1ea3-")

#

because that will print that exact text

#

the actual real code you have written right in front of your eyes

#

how are you turning this literal text
#084cfb-#2165fb-#3a7efc-#5297fc-#6bb0fc-#84c9fd-#9de2fd-#a9eef6-#9bdee0-#8ececa-#80bfb5-#73af9f-#659f89-#588f73-#547f72-#556f7a-#565f82-#574f8a-#583e93-#592e9b-#5a1ea3-
into a component exactly

#

well see?

#

that's different

hoary scarab
lyric gyro
#

and yes you're shoving legacy shit inside components, which is confirmed the client will one day stop supporting, and which again that thing never worked with hex codes

#

I mean you don't "colour" a component but sure

hoary scarab
#

So what would you suggest?

lyric gyro
#

Deserialize from legacy in the CraftChatComponent class I think it's called

hoary scarab
#

Found it (I hope)

lyric gyro
#

yes fromString/fromStringOrNull

torn heart
#

So right now i'm attemping to use PathfinderGoals with npcs. I got it to work with zombies and right now i'm not doing any navigation but just trying to turn the npc's head. here is the npc's code: ```java
public class Bot extends EntityPlayer {

public Bot(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) {
    super(minecraftserver, worldserver, gameprofile, playerinteractmanager);

}

}
}``` with the zombie i could just create a new CustomZombie and bam, that works, but that doesn't work with this, probably because it's an EntityPlayer. could anyone help with spawning this entity in? would i have to do it with packets or some other way

#

i haven't gotten to adding the pathfinding goals yet because i'm still trying to spawn a bot in like this

winged pebble
#

At least not any existing ones

torn heart
#

i'm writing my own

#

but i'm just strying to spawn the bot in right now

torn heart
torn heart
winged pebble
#

You're most likely going to have to use packets btw

torn heart
#

yea i figured it out

#

i'm obviously doing something wrong but i can't figure out what. here is my bot class rn: ```java
public class Bot extends EntityPlayer {

public Bot(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) {
    super(minecraftserver, worldserver, gameprofile, playerinteractmanager);

    PathfinderGoalSelector goalSelector = new PathfinderGoalSelector(this.u().methodProfiler);
    goalSelector.a(0, new PlayerGoalLookAtPlayer(this, EntityHuman.class));
}

}``` and the PlayerGoalLookAtPlayer is this: https://www.toptal.com/developers/hastebin/uroyufagun.kotlin

#

thing is in the goal not even the system outputs are printing anything, so i'm obviously doing something wrong with the goalSelector, but i can't figure out what

winged pebble
#

Doesn't seem like you're storing it as a field or anything to be used later

#

You have to add the logic that cycles through goalSelectors too

torn heart
winged pebble
#

the goalSelector

#

You're just creating a local variable and then it goes away basically

torn heart
#

i mean i'm using it in the line right after that

winged pebble
#

Yeah you're adding a goal, but then right after that, they both go away

torn heart
#

i see what you mean

winged pebble
#

goalSelector doesn't do its job on its own, it needs to be told what to do basically

#

Look in EntityInsentient for the method that actually handles that logic

#

You'll have to reimplement that

torn heart
#

alright thanks

torn heart
# winged pebble Look in EntityInsentient for the method that actually handles that logic

hmm.. the thing relating to goalSelector in EntityInsentient are these 3 lines:java // in constructor this.goalSelector = new PathfinderGoalSelector(world != null && world.methodProfiler != null ? world.methodProfiler : null); and ```java
//in the doTick() method
this.world.methodProfiler.a("goalSelector");
this.goalSelector.a();

goalSelector.a() just returns true or false, not void. also methodProfiler is used quite a bit but looking at the class it's just an abstract class with empty methods, so i'm not really sure what to make of that
winged pebble
#

remind me what version you're in?

torn heart
#

1.8

#

i'm trying to figure out how EntityInsentient handles the goals and navigation and such but i'm struggling

winged pebble
#

In 1.8.8 it's eN()

torn heart
#

can i ask how you figured that out

winged pebble
#

Well I found it on 1.19 and when I opened it on 1.8.8 it took me to the exact same place luckily πŸ˜›

torn heart
#

is that in the EntityInsentient class?

winged pebble
#

Yes

torn heart
#

hmm i gues 1.8.8 is slightly different thatn 1.8.9. anyway, i still don't understand where the logic is being handled in this method

torn heart
winged pebble
#

Here is the mojang mapped version from 1.19 (makes it easier to parse)

torn heart
#

i'm looking at the method profiler class, and obviously it's being overriden somewhere because all i see is this: ```java
public class MethodProfiler {
public boolean a;

public MethodProfiler() {
}

public void a() {
}

public void a(String s) {
}

public void b() {
}

public List b(String s) {
    return null;
}

public void c(String s) {
}

public String c() {
    return null;
}

}```

winged pebble
#

It shouldn't be anything you'd need to implement yourself, is it?

#

I see, but you're just trying to understand what it does

torn heart
#

i'm confused why a is being called when a doesn't do anything

winged pebble
# winged pebble

Ignore this btw, I was opening the unmapped 1.19 version on accident

#

Took me too long to notice haha

torn heart
#

i understand why my code isn't working but i don't understand why mojang's code works and how it works

winged pebble
#

It's probably just a decompilation issue tbh

#

It's also possible that it was a work in progress thing

#

That they hadn't finished implementing it

torn heart
#

what

#

but the pathfinding works

#

so how does this work

winged pebble
#

Long story short, the profiler seems to be more of a monitoring thing, than a behavior thing

#

I don't think you need to worry about it too much right now

torn heart
#

then how does the goalSelector work

winged pebble
#

The doTick() is run every tick

#

And it calls the .a() method on the goalSelector which is basically it's tick method

torn heart
#

isn't .e() supposed to be the tick method?

torn heart
winged pebble
#

Potentially, yeah

#

Another option you could do is actually just make your class extend EntityInsentient and fiddle with a few things to make it look like a player to the client

#

I don't know how to do this in 1.8 though

torn heart
#

i feel like adding a tick method is a lot easier than looking through 900 lines of code, though i might have to do it anyway

#

anyway i'll try to implement this, thanks for the help!

#

i wonder how i'll make that work with Navigation though...

pseudo yacht
#
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/bukkit/craftbukkit/bootstrap/Main has been compiled by a more recent version of the Java Runtime (class file version 60.0), this version of the Java Runtime only recognizes class file versions up to 52.0

Someone can help? i keep receiving this trying to run my local server (Spigot 1.18.1), i changed the java env path, tried to run it from java 8 folder, nothing worked so far

sterile hinge
#

you can't run 1.18 with java 8

quasi wigeon
#

is there a library or something to parse a formatted string like 1k to an int like 1000?

robust flower
torn heart
#

So i'm trying to work with Navigation and Pathfinding and all that right now, and i'm trying to figure out how this all works (1.8.9 btw). I've been staring at this code for hours now and i just don't understand how Navigation causes entities to move. i have a test custom goal right where inside the e() method this is run: ```java
PathEntity pathEntity = this.navigation.a(loc.getX(), loc.getY(), loc.getZ());

this.navigation.a(pathEntity, speed);

echo briar
#

Does anyone know what the best way to handle enabling and disabling worlds for a plug-in?

broken elbow
#

you want to disable plugins in a world?

torn heart
#

wouldn't you just have an if statement or something checking the name of the world?

echo briar
torn heart
#

like disable code being runwhen an event happens?

broken elbow
echo briar
#

Ahhh okay I’ll try that

echo briar
broken elbow
#

I mean it really depends on your event really.

#

can you send one of your event handler methods you want to do this for in a paste bin?

dense drift
#

if enabledWorlds !contains world, return / if disabledWorlds contains world, return

broken elbow
echo briar
#

ah okay, thank you

echo briar
#

^ is this done correctly?

broken elbow
#

no

#

getUID returns a UUID not a string

#

you could use UUID#toString tho

echo briar
#

oh should i getName()

broken elbow
#

well depends how you want the config list to work

#

with world names or with world UUIDs

#

if you want it to work with world names then yeah change it to getName

echo briar
#

kk

#

if ((plugin.getConfig().getStringList("blocked-worlds")).contains(e.getPlayer().getWorld().getName())) return;

#

so like this?

winged pebble
#

Some of the names will be different because it uses the Mojang Mapping name, (ie Mob -> EntityInsentient, Level -> World) but it should help a little bit

torn heart
#

ill check again but not rn, but when i was checking i still didn't really understand how it caused movement but it's 31 C rn and opening intellij causes my hands to start sweating because of this mac and i just wanna take a break

winged pebble
#

The MoveController is what actually moves the mob

lyric gyro
#

does MMV work? thonk

winged pebble
#

It's not updated, no. Pretty much only reliable for 1.14.4 -> early 1.16's

lyric gyro
winged pebble
#

I can read minidiggers a bit better

lyric gyro
#

yeah and mini's is unmaintained and outdated lol

winged pebble
#

Half the time I just need to know the Mojang class name anyway lol

lyric gyro
#

which may have changed in newer versions

#

ss is up to date, maintained and also has other mappings too

winged pebble
#

Yeah, but I also don't use it often at all anymore

echo briar
#

umm anyone else having the issue of glow on items not showing up in 1.19?

proud pebble
#

well 1.19 isnt ready for production yet so imma assume its just a bug thats gunna be squashed at some point

torn heart
#

i'm looking at the class

#

it's just changing its own values

#

meaning that something else is calling it every tick or something like that, and idk what

winged pebble
#

The tick method probably

torn heart
#

wait where is that

#

like in EntityInsentient?

#

because the tick method in that just calls a method inside The ControllerMove, but i'm not exactly sure what that does

#

the solution for this that i can think of is to write an entirely new movement controller for the entity but that would be really difficult, and i would much rather understand how the current ControllerMove works and then modify that to suit my needs

dusky harness
#

Anyone know why custom enchantments aren't appearing on the pickaxe, and they get removed on server restart?
Here's the code in onLoad: kt val field = Enchantment::class.java.getDeclaredField("acceptingNew") field.isAccessible = true field.set(null, true) for (enchant in Enchants.values()) { Enchantment.registerEnchantment(enchant.getEnchantment()) // A new NamespacedKey gets created in getEnchantment and is stored in memory } field.set(null, false) and the code to enchant: ```kt
pickaxe.addUnsafeEnchantment(enchant.getEnchantment(), newLevel)

broken elbow
dusky harness
#

oh :/

#

alr, ty

#

but why does it reset on server restart?

broken elbow
dusky harness
#

this is for 1.18

wait now its not removing itself

Uh
nice
Thanks

#

πŸ₯²

broken elbow
#

lol. anyways check pinned messages. bm made a pretty nice example for custom enchantments on 1.13+ which I've used before.

dusky harness
#

oh, didn't know πŸ˜ƒ

#

Thanks

broken elbow
#

πŸ‘

quasi wigeon
#

If I have to drop a huge amount of items I saw that the best way is splitting it in multiple synchronized threads. How can I do it?

winged pebble
#

If you have multiple threads, they aren't synchronous

quasi wigeon
#

Do you know another way to do it without causing lag?

west socket
#

Anyone know if theres a unicode placeholder for Β§

sterile hinge
dense drift
west socket
#

Yeah I tried that, It didnt like it

#

Oh Wait

#

I was using aa07

#

\ua007 returns whatever this is

#

ꀇ

dense drift
#

Ah

#

\u00A7

west socket
#

There we go

#

Thank you

shell moon
#

Cancel creeper being ignited by flint and steel? (1.8.8)

#

PlayerInteractAtEntityEvent#setCancelled(true) doesnt seem to be working

warm steppe
#

Did you register the event?

#

Try this, idk

shell moon
#

ofc i did

#

That prevent entities from exploding

#

not from igniting, sadly

#

(afaik)

#

yeah, confirmed

#

ExplosionPrimeEvent#setCancelled

#

make it stop before explode

#

but it's (ofc) white and about to explode

warm steppe
#

Hmmmm

#

Maybe playerinteractevent?

shell moon
#

where is the target entity there

hoary scarab
#

Debug? Check if when the event is ran if the creeper is primed and after canceling see if it's still primed.

shell moon
#

i'll need NBTAPI then (i believe)

#

1.8.8 doesnt even have getFuseTicks

hoary scarab
shell moon
#

yeah

#

in newer versions only

pine flax
#

Does the other player interact entity event exist in 1.8?

#

PlayerInteractEntityEvent

shell moon
#

afaik yes

#

the normal and t he atEntity

torn heart
#

why does everyone work in 1.8.8 instead of 1.8.9

pulsar ferry
#

There is no 1.8.9 server

#

The version was client side only, even though there is a Mojang server jar all it does is change the startup message, so there is no Bukkit for 1.8.9

shell moon
high edge
#

How stupid would it be to call Location#distance every time a player moves (working with 8 players max, so not that many calls) but I'm assuming still a fairly costly operation?

icy shadow
#

distance bad, distanceSquared good

#

unless you cant avoid it

high edge
#

Probably can avoid it

sterile hinge
#

It's costly for a math operation, but you probably won't even notice a difference if it's only 8 players

icy shadow
#

yeah it's gonna be fine at that scale

high edge
#

Thought so

spiral prairie
#

Guys is there a way to read a text and then check if it is or contains a java exception or is a minecraft log?

stuck hearth
#

I mean, technically yes, but what are you trying to do?

icy shadow
#

if text.contains(minecraft) or text.contains(java)

spiral prairie
icy shadow
#

that sounds familiar

stuck hearth
#

Yeah BM basically hit the nail on the head

icy shadow
#

hahaha

#

Yeah

stuck hearth
#

Like, more nuance is required, but that's more or less the idea

icy shadow
#

I (and others) did this a while ago, just with a regex checking for the ```

#

or with files by file extension

spiral prairie
#

thats smart, ill just check for files or '` ``'

icy shadow
#

πŸ™Œ

spiral prairie
#

Now last question, bot in python or kotlin

icy shadow
#

Up to you

#

lol

spiral prairie
#

yes ik

#

but im not sure

stuck hearth
#

Kotlin bot is nice, never used py

spiral prairie
#

i think ill use kotlin

#

les go

icy shadow
spiral prairie
#

Why is the regex so complicated? Did i miss something?

#

oh i see

#

my bad

icy shadow
#

ours is much more sophisticated, it'll convert each different codeblock into a single message, and the surrounding text

So

hello

Blah

Some more text

Blah2

Will become

Hello
Paste link
Some more text
Paste link 2

spiral prairie
icy shadow
#

Yes

spiral prairie
#

ah

stuck hearth
#

BM is a tyrant

pulsar ferry
#

Brainwashed by the functional programming elites

high edge
#

BM is a godsend

stuck hearth
icy shadow
spiral prairie
#

I love problems

#

Does anyone know why this is happening?

icy shadow
#

kotlin bad

#

update your compiler version i suppose

spiral prairie
#

nono

#

kotlin compiler is too new

wintry grove
#

update the plugin lmao

stuck hearth
#

Kt 1.7 is beta isn't it?

pine flax
stuck hearth
#

Oh yesterday, nice

spiral prairie
# icy shadow Yes

What if the user adds 9 characters of code and fills the rest to the max limit, and the bot replaces it by a 10 long link, some text will be lost, won't it?

icy shadow
#

It doesn't convert blocks less than 15 lines long

tender thicket
#

Does anyone have any idea if it's possible to get a collection of all entities which are targeting a specific player?

spiral prairie
dusky harness
# dusky harness this is for 1.18 wait now its not removing itself Uh nice Thanks

neverrrmind it is being reset :/

Anyone know why custom enchantments aren't appearing on the pickaxe, and they get removed on server restart?
Here's the code in onLoad: kt val field = Enchantment::class.java.getDeclaredField("acceptingNew") field.isAccessible = true field.set(null, true) for (enchant in Enchants.values()) { Enchantment.registerEnchantment(enchant.getEnchantment()) // A new NamespacedKey gets created in getEnchantment and is stored in memory } field.set(null, false) and the code to enchant: ```kt
pickaxe.addUnsafeEnchantment(enchant.getEnchantment(), newLevel)

And the enchant code: https://pastes.dev/CjqNVmnMPd

The key used for the enchant is the same every time, so I don't know why it keeps resetting itself...

#

Okay well now it's not resetting

#

What

tender thicket
#

Thanks Deerjump

#

wont ping

#

but thanks

stuck hearth
#

@winged pebble

winged pebble
#

πŸ‘

dense drift
#

@dusky harness you need to display the enchantments trough lore I believe

icy shadow
#

^

proud pebble
#

personally when i implemented custom enchantments i didnt go through adding enchants through the regular means, just created a custom compound tag with my data, and then in the compoundtag add another compound tag that has enchant_id:short

daring gust
#

hey

#

i have problem on registering placeholders

#

%playercount%

#

not working

#

`` @Override
public String onRequest(OfflinePlayer player, String params) {
if(params.equalsIgnoreCase("playercount")) {
return "s";
}

    return null;
}``
#

@topaz gust

hushed badge
#

let's not ping people randomly please

daring gust
#

ok sorry

hushed badge
#

but a papi placeholder will be in the format of %identifier_placeholder%

#

so whatever uve put in getIdentifier() for the identifier

daring gust
#

thx

mystic gull
#

Hello is it possible to get a list from my spigot plugin and use it on my bungeecord plugin??

high edge
#

yes

mystic gull
#

I know it is possible with Messaging channel but what sould i write on the data output stream to send a list ?

prisma briar
#

Can someone tell me why Bukkit#getScoreboardManager is nullable?

dense drift
#

d;spigot Bukkit#getScoreboardManager

uneven lanternBOT
#
@Nullable
public static ScoreboardManager getScoreboardManager()```
Description:

Gets the instance of the scoreboard manager.

This will only exist after the first world has loaded.

Returns:

the scoreboard manager or null if no worlds are loaded.

prisma briar
#

nice

#

thanks

queen plank
#

How do I copy data from a file included in the .jar to a file in the plugin directory? Files.copy only gives me a java.nio.file.AccessDeniedException:, also I'm on 1.8.

dense drift
#

d;spigot Plugin#saveResource

uneven lanternBOT
#
void saveResource(@NotNull String resourcePath, boolean replace)
throws IllegalArgumentException```
Description:

Saves the raw contents of any resource embedded with a plugin's .jar file assuming it can be found using getResource(String).

The resource is saved into the plugin's data folder using the same hierarchy as the .jar file (subdirectories are preserved).

Parameters:

resourcePath - the embedded resource path to look for within the plugin's .jar file. (No preceding slash).
replace - if true, the embedded resource will overwrite the contents of an existing file.

Throws:

IllegalArgumentException - if the resource path is null, empty, or points to a nonexistent resource.

queen plank
#

Thanks :>

dusky harness
odd prawn
hoary scarab
odd prawn
#

Yeah but the player would still be high in the air. So the seat is lowerd into the ground

#

The only problem atm is that I can't get it to move.

#

the 2 stands work fine with rotating ect..

grim oasis
#

just not going forwards?

odd prawn
#

Yes, I got it to rotate.

grim oasis
#

I see backwards hasn't been tested yet

odd prawn
#

Doesn't work as well

grim oasis
#

figured

grim oasis
odd prawn
#

Yes, that works. I tried broadcasting it when I move forward and that works

grim oasis
#

hmk

odd prawn
#

It's just the armorstand not moving

grim oasis
#

if you set the gravity to false

#

you can't set velocity

broken elbow
#

:))

grim oasis
#

sorry blitz is my alt

odd prawn
#

Ah

#

Well, if I don't set the gravity to false the seat wouldn't be at the correct hight

broken elbow
#

you'll just have to deal with NMS tho

odd prawn
#

ohw god haha πŸ˜…

#
        EntityArmorStand nmsBody = ((CraftArmorStand) body).getHandle();
        EntityArmorStand nmsSeat = ((CraftArmorStand) seat).getHandle();
        nmsBody.setNoGravity(true);
        nmsSeat.setNoGravity(true);

Like this with NMS?

#

Or like creating a custom entity?

hoary scarab
#

If the entity is in a block it won't move

#

Gotta teleport it

odd prawn
#

I enabled noclip on it via refelection

#

it allows to move it through blocks

hoary scarab
#

In text* (I don't click links)

odd prawn
#
    public void applyNoClip() {
        EntityArmorStand nmsBody = ((CraftArmorStand) body).getHandle();
        EntityArmorStand nmsSeat = ((CraftArmorStand) seat).getHandle();
        
        nmsBody.setNoGravity(true);
        nmsSeat.setNoGravity(true);

        Class nmsClass = net.minecraft.server.v1_16_R3.Entity.class;
        try {
            Field noClip = nmsClass.getDeclaredField("noclip");
            noClip.setBoolean(nmsBody, true);
            noClip.setBoolean(nmsSeat, true);
        } catch (Exception  e) {
            e.printStackTrace();
        }
    }
hoary scarab
odd prawn
#

tbh, I found this on the internet I don't really know what that means πŸ˜…

hoary scarab
#

Go check the remapped method names

odd prawn
#

The noclip works tho

hoary scarab
dusky harness
hoary scarab
#

For 1.16.5?

dusky harness
#

yea

#

pretty useful

hoary scarab
#

k then yeah need him to take a vid

dusky harness
#

alr

odd prawn
hoary scarab
dense drift
#

Field#setAccessible(true) maybe ?

hoary scarab
#

@odd prawn ^^^ and debug it. Is it set to true?

sharp hemlock
#

It uses Orientable my bad

lyric gyro
#

You can check the Material entry in the enum to see what BlockData it "uses"

sharp hemlock
tardy cosmos
#

Anyone know if there's a way to get the items dropped by a sweet berry bush or composter when it's right clicked? Obviously PlayerInteractEvent exists but I'd hope there's something more generic I could use for when one of those types of blocks drops an item so I can modify it. A Paper event would be fine if one exists

dense drift
#

PlayerHarvestEvent might work for both

molten wagon
#

Is it way to prevent this happen? https://pastebin.com/EHzerbDU I know the issue. I think is the while loop some donΒ΄t get stopped as it should. is way I not like mess with while loop and use for loop (I know the compiler often make it to while loop but not get this issues).

I mean some way to check before it goo 100% bananas (if I can check if the loop start to run endlessly)?

broken elbow
#

not really no. what you should do, is make sure your loop is running correctly instead.

hoary scarab
zinc island
#

does anyone know if theres a way to loop through all players, whilst having a slightly delay between each player? (Im looping through 100 players tping them all to different locations throughout the map so am worried about lag)

this is what ive tried but no luck

for (Player p : Bukkit.getOnlinePlayers()) {
                BukkitScheduler scheduler = Bukkit.getScheduler();

                scheduler.runTaskLater(plugin, () -> {
                    // code
                }, 20L);
            }
stuck hearth
#

You have the right idea, but I wouldn't schedule each player, but rather make 1 task to schedule on repeat and then cancel when the list is empty.

tardy cosmos
zinc island
shell moon
#

can you set style using:

const span = document.createElement('span');
span.textContent = "a";
span.style.color = "084cfb";```
hoary scarab
molten wagon
hoary scarab
dusky harness
#

Anyone know why custom enchantments aren't appearing on the pickaxe, and they get removed on server restart?
Here's the code in onLoad: kt val field = Enchantment::class.java.getDeclaredField("acceptingNew") field.isAccessible = true field.set(null, true) for (enchant in Enchants.values()) { Enchantment.registerEnchantment(enchant.getEnchantment()) // A new NamespacedKey gets created in getEnchantment and is stored in memory } field.set(null, false) and the code to enchant: ```kt
pickaxe.addUnsafeEnchantment(enchant.getEnchantment(), newLevel)

And the enchant code: <https://pastes.dev/CjqNVmnMPd>

The key: `NamespacedKey(plugin, "enchant_${name.lowercase()}")` and only 1 instance is created (until the server restarts)

And sorry for keep saying that this is fixed and it isn't - I got confused sometimes and this time I recorded a video

https://streamable.com/ifn9za

#

The command /pickaxe test is just looping through Enchants.values() and running ItemStack#getEnchantmentLevel on them

shell moon
#

this is weird then, i'm using that exactly and its still <span>a</span>

strange remnant
#

Hello There

#

I need some help

torn heart
#

does anyone know how nms actually handles player movement? Only thing i've found is the ControllerMove but all it changes are some internal values, which doesn't really tell me much

strange remnant
#

Where can I add a permission so you can use the command cuz with the permission now you can only see the message

shell moon
#

Fixed: After 8 hours it required a # before the hex code cryIgnore

strange remnant
#

Am I getting some help or what?

neon wren
#

It'll return a BOOLEAN based response.

#
if (!playerObject.hasPermission("permission.name")) {
  // send message of no permission.
  return true;
}
// run stuff like checking arguments, etc.
strange remnant
#

Where should I set this line in my methode

#

Oke I fixed that

#

But there is another bug now

#

Shit man

lyric gyro
#

shit-man

strange remnant
#

@neon wren

#

I got the permission working

#

But then the stringbuilder broke

neon wren
#

Test it and look up the documentation for it, as I am not home, or see if someone else knows

craggy zealot
#

I get this issue when trying to connect to my data base

#

thats my create table

stuck hearth
#

Are Ints and doubles supposed to take a number input?

rigid mountain
#

Hello everyone, iv been stuck trying to figure out a way to do this, but yet i havent found one. If you have any ideas please let me know πŸ™‚

So im creating a scoreboard and i want to add a placeholder to display a players party. This is the api im using https://github.com/MrMicky-FR/FastBoard. So say i have the placeholder {party} i want to replace that with each player of their party. So if my config looks like:

  - "&e&lParty"
  - "  &f{party}"```

I want to replace `{party}` with their party members, if they have none leave it empty, and depending on how many they have add a new line for each member. So if they have say 3 members it would look like:

```Scoreboard:
  - "&e&lParty"
  - "  &fMember1"
  - "  &fMember2"
  - "  &fMember3"```

Anyone have any ideas?
neon wren
#

while looping through the lines, make a simple check:

#
for (String line : lines) {
  if (line.contains("{party}") {
    // Loop through players and add to scoreboard lines.
  }
}
dusky harness
# dusky harness > Anyone know why custom enchantments aren't appearing on the pickaxe, and they ...

Hmm
Since I can't find a reason why this is happening, what if I did this:

  • Generate a random int value on server start
  • If a PDC value on an item doesn't equal above, then set the enchants to what the pdc key has
  • Every 10 ticks or so, add a PDC value to the item with that int value and enchants so that on the next server restart, it will be updated

πŸ₯² Is there another option?
Tomorrow I'll check if making a new NamespacedKey also resets the enchant values 🀷 but I'm going to sleep for tonight

dense drift
#

Any idea how to make it use the right components method? p.p
Edit: Solved, project.components

limber hedge
#

i can break it

#

i figured out

high edge
#

Was about to say yea, you could just break the loops

torpid raft
dusky harness
torpid raft
#

why are you doing it 'often' at all πŸ€”

limber hedge
torpid raft
#

why not only update it when the enchant updates

dusky harness
limber hedge
#
for(Block b : getNearbyBlocks(player.getLocation(), 15)) {
                        if(b.getType() == Material.NOTE_BLOCK) {
                                    int distance = (int) e.getPlayer().getLocation().distance(b.getLocation());
                                    if (distance <= 15) {
                                        Bukkit.broadcastMessage("Distance = " + distance);
                                        if (distance <= 12 && distance <= 15) 
                                        if (distance >= 8 && distance <= 11)
                                        if (distance >= 4 && distance <= 7)
                                        if (distance >= 2 && distance <= 4) 
                                        if (distance >= 1 && distance <= 2)

                            }
                        }
                        break;
                    }```
dusky harness
torpid raft
# dusky harness what event is it?

not sure if there is an event specific to enchants or not, but you can probably make your own with an inventoryinteractevent for whatever the player uses to enchant

high edge
limber hedge
#

It doesnt play the sound at that point

#

It does say the distance though

#
for(Block b : getNearbyBlocks(player.getLocation(), 15)) {

                        if(b.getType() == Material.NOTE_BLOCK) {
                                    int distance = (int) e.getPlayer().getLocation().distance(b.getLocation());
                                    if (distance <= 15) {
                                        Bukkit.broadcastMessage("Distance = " + distance);
                                        if (distance <= 12 && distance <= 15) {
                                            player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 0.5f);
                                        }
                                        if (distance >= 8 && distance <= 11) {
                                            player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 0.7f);
                                        }
                                        if (distance >= 4 && distance <= 7) {
                                            player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 1.2f);
                                        }
                                        if (distance >= 2 && distance <= 4) {
                                            player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 1.6f);
                                        }
                                        if (distance >= 1 && distance <= 2) {
                                            player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 0.5f);
                                        }
                                        break;
                            }
                        }
                    }```
worn jasper
#

In which cases is it better to use a database instead of PDC? Is it a good idea to use both? (For example I am making a generator plugin and I want to store generator data on the chunks PDC but I also want to be able to modify it and get all generators from a user where I would store the locations in SQLite for example. In this case I would store gen data with pdc and the location and owner of it in sqlite for easier sorting, etc.)

#

Hello btw lol

#

Oh sorry, you guys were already speaking

#

I will wait.

dusky harness
#

Or ig you can combine it

worn jasper
#

Now I am confused lol

#

With your sentence

worn jasper
dusky harness
# worn jasper With your sentence

you could either have all the data in the database

or you can have the player and chunk in the database, then the rest of the data in the chunk PDC

dusky harness
#

Hmm

worn jasper
#

Oh okay ye then its what I had in mind

#

Although unsure if its practical

#

Also, would it be too heavy to like loop through a list of locations of the generators and get their PDC? Unsure how heavy PDCs are

#

Are they even cached?

junior fable
#

Hello everyone, can anyone help me with a problem that im having with WorldEdit?

#

Im trying to get a selection of the player using Selection sel = getWorldEdit.getSelection(); but it gives me a error that says that .getSelection() doesnt exist
The worldedit is "imported" perfectly, it just doesnt work.
Maybe the API changed, but on every docs/tutorial i find the same way being used

dusky harness
#

Is there anything in the Paper/spigot api that returns if a server is fully started?

#

except for ServerTickStartEvent

dense drift
#

I think tasks start when the server is loaded

dusky harness
#

oh right

#

ty

dense drift
#

paper also has ServerLoadEvent

#

d;paper ServerLoadEvent

uneven lanternBOT
#
public class ServerLoadEvent
extends ServerEvent```
ServerLoadEvent has 4 methods, and  1 extensions.
Description:

This event is called when either the server startup or reload has completed.

dusky harness
#

oh, didn't see that either

#

πŸ₯² ty

dense drift
#

np

high edge
#

Figured it out again I assume? :3

limber hedge
#

yer

#

I released it would take way to many resources

#

the server would be to laggy so I gave up

high edge
#

Not necessarily, what exactly are you trying to do?

limber hedge
#

Just find the nearest jukebox within a 10 block radius

high edge
#

On what event

limber hedge
#

Interact event on a cooldown

#

Basically making a metal detector for jukeboxes

high edge
#

Would the jukeboxes be underground or?

limber hedge
#

Yea

high edge
#

How deep

limber hedge
#

0 -> 256

high edge
#

ew

#

And how are the jukeboxes spawned?

limber hedge
#

You mean searching radius or where have I ptu them?

limber hedge
high edge
#

Ah shame

limber hedge
#

So resource intensive?

high edge
#

Well I mean doable but not really preferable

limber hedge
#

Was the way I did it a very bad way of doing it?

high edge
#

Didn't even fully see how you did it

limber hedge
#

Getting the lowest value of a hashmap was my only problem

#
    public static List<Block> getNearbyBlocks(Location location, int radius, Player player) {
        List<Block> blocks = new ArrayList<Block>();
        for(int x = location.getBlockX() - radius; x <= location.getBlockX() + radius; x++) {
            for(int y = location.getBlockY() - radius; y <= location.getBlockY() + radius; y++) {
                for(int z = location.getBlockZ() - radius; z <= location.getBlockZ() + radius; z++) {
                    blocks.add(location.getWorld().getBlockAt(x, y, z));
                }
            }
        }
        return blocks;
    }```
#

I cannot manage to sort it by distance

high edge
#

by distance how?

limber hedge
#

Distance from Player to the Juke Box

#

So that this can happen:

                        if (distance <= 15) {
                            Bukkit.broadcastMessage("Distance = " + distance);
                            if (distance >= 12 && distance <= 15) {
                                player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 0.5f);
                            }
                            if (distance >= 8 && distance <= 11) {
                                player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 0.7f);
                            }
                            if (distance >= 4 && distance <= 7) {
                                player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 1.2f);
                            }
                            if (distance >= 3 && distance <= 4) {
                                player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 1.6f);
                            }
                            if (distance >= 1 && distance <= 2) {
                                player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 2f);
                            }
                        }```
high edge
#

I mean you could just add that into your loops

#

And what kind of distance is that, just x distance or

limber hedge
#

wdym? Distance as an int I guess

high edge
#

Which kinda distance

limber hedge
#

B

#

Honestly whichever is the easier one

#

OH

#

The first picture has X Y Z

#

It has to be A then

high edge
#

So you're only checking 15 within the player then?

limber hedge
#

Yea

high edge
#

Why don't you just loop in a sphere and get the blocks in there, instead of from 0-256

limber hedge
#

I tried that in the above function

high edge
#

that'd work in a cube, but yea probably good enough

#

Then just loop through them, and get the Location#distance, however you might want to use Location#distanceSquared since performance

limber hedge
#
                    for(Block b : getNearbyBlocks(player.getLocation(), 15)) {

                        if(b.getType() == Material.NOTE_BLOCK) {
                                    int distance = (int) b.getLocation().distanceSquared(player.getLocation());
                                    if (distance <= 15) {
                                        Bukkit.broadcastMessage("Distance = " + distance);
                                        if (distance >= 12 && distance <= 15) {
                                            player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 0.5f);
                                            break;
                                        }
                                        if (distance >= 8 && distance <= 11) {
                                            player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 0.7f);
                                            break;
                                        }
                                        if (distance >= 4 && distance <= 7) {
                                            player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 1.2f);
                                            break;
                                        }
                                        if (distance >= 3 && distance <= 4) {
                                            player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 1.6f);
                                            break;
                                        }
                                        if (distance >= 1 && distance <= 2) {
                                            player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 2f);
                                        }

                            }
                        }
                    }```
#

I tried that here but for some reason it would not return the closest block

high edge
#

Well you cause that'd loop until it find the first block, then stop

#

You'd have to get all the noteblocks, then sort them by the distance

limber hedge
#

Should I put them into a HashMap?

high edge
#

When you're looping through the blocks, you could have a map with an int for the distance and the block, and then just sort the map

limber hedge
#

This is a general java question but how do I get the first value in a sorted map?

#

Map<Block, Integer> unsortMap = new HashMap<Block, Integer>();

#
sortByValue(unsortMap).get(0)```
Returns the first in the list?
stuck hearth
#

That will return the first element, but it may not be the first element that was inserted.

limber hedge
#

Its returning null

stuck hearth
#

Nothing in it then

mint summit
#

Hi!

#

Can somebody help me with a question?

icy shadow
#

only 1 way to find out!

mint summit
#

I tried to create separated inventories using this way, i think it works, somehow, but what can I do to open them 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]));

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];

#

sorry for my bad english

high edge
#

Can I suggest using something like triumph gui

#

Brister, can I suggest you to go suck a chicken

icy shadow
#

tee hee

mint summit
#

do u mean like this? List<Inventory> itemsMenuGui;

high edge
#

A map would probably best so you can keep track of which inventory is which

mint summit
#

oke oke, let me try

hoary scarab
mint summit
# hoary scarab yes.

well.. i think im doing something wrong then

    List<Inventory> itemsMenuGui;

    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.set(Integer.parseInt(ID), Bukkit.createInventory(null, 36, "Β§8Β§oEditing " + menuName + " menu..."));
        });
    }

cuz i get this error

 null
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.List.set(int, Object)" because "this.itemsMenuGui" is null
hoary scarab
mint summit
#

ooohhh

#

i see

#
itemsMenuGui.add(Integer.parseInt(ID), Bukkit.createInventory(null, 36, "Β§8Β§oEditing " + menuName + " menu..."));

but i get the same error

hoary scarab
#

or remove it from the method call

mint summit
#

i did it

#

with map

#

thank u

hoary scarab
#

Np

brittle thunder
high edge
#

That'd be too vulgar, hence he can go suck a chicken

mint summit
#

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 πŸ˜…

echo briar
torn heart
#

rn i'm tryna spawn a villager facing a direction, problem is that i can set the pitch, but not the yaw. i'm doing this with just location.setYaw(), but it's not doing anything

pine flax
#

Can villagers look up/down apart from specific behavior actions?

torn heart
#

what?

#

i'm setting the yaw not the pitch

pine flax
#

Oh I got it flipped

#

Did you set yaw before spawning the villager?

torn heart
#

yes

#

i've tried setting it after by getting the nms Entity and setting the yaw like that but that doesn't work either

pine flax
#

What if you set it after without nms? getLocation().setYaw()

torn heart
#

you can't getLocation on a Villager

winged pebble
#

Are you trying to set the head yaw? I feel like I remember something when I messed with this

winged pebble
torn heart
#

head and body

torn heart
winged pebble
#

Every Entity has getLocation()

torn heart
#
Location loc = new Location(Bukkit.getWorld("world"), -1.5, 114, 12.5);
        loc.setYaw(90);
        loc.setPitch(45);
        Villager perks = (Villager) Bukkit.getWorld("world").spawnEntity(loc, EntityType.VILLAGER);```
#

perks doensn't have .getLocation()

#

i'm in 1.8.9 btw

#

wait

#

what

#

i swear it wasn't showing up earlier

winged pebble
#

getLocation() is from Entity and basically everything inherits from Entity

torn heart
#

i know, but i wasn't seeing it for some reason

#

i guess i'm just blind

#

yea it doesn't work

#

.setYaw just doesn't do anything

#

i'm too tired, ill solve it later

echo briar
winged pebble
echo briar
winged pebble
#

What if you do it twice?

echo briar
winged pebble
#

wym they don't register?

echo briar
#

one of my events checks for the material, when i reload it gives me the new item with the corrected material, however now the event doesn't recognize the material until i restart the server and or rejoin

winged pebble
#

So the issue to me seems to be in those events listeners, not this class

echo briar
winged pebble
#

Show me the events

winged pebble
#

So what part in here doesn't work like you expect?

echo briar
#

this is the event that isn't working after reloading

winged pebble
#

What part isn't working though?

echo briar
#

the right click?

winged pebble
#

Where is sword defined?

echo briar
#

e.getAction() == Action.RIGHT_CLICK_BLOCK) && isSimilarButNotNull(sword, e.getPlayer().getInventory().getItemInHand())

winged pebble
#

No, where was it defined

#

Not used

echo briar
winged pebble
#

Yeah, so when you reload the config, this event still holds the old item

echo briar
#

ohhh alright that actually makes a bunch of sense

#

how would i reload/refresh it?

winged pebble
#

You would have to reference the config more than just one time

#

Currently you're only looking at the config when you initialize that class

#

But in order to stay up to date, you'd have to look at the config every time you want to compare to that sword

echo briar
#

okay