#help-development

1 messages · Page 2064 of 1

grim ice
#

methods should start with a lowercase

#

nest() not Nest()

desert musk
#

oh rip

#

ok

glossy venture
#

can you print the uuid?

desert musk
glossy venture
#

it looks like you are creating the entity using nms

fossil lily
#

Send block change changes the block client side, but is there a way to reset it?

desert musk
smoky oak
#

cant you just track the locations of those block changes and update them then @fossil lily

mortal cedar
#

Anyone knows if theres a good library for clientside world borders?

glossy venture
fossil lily
glossy venture
#

and then check if your entities uuid is in there

fossil lily
#

I get all these weird ghost blocks

desert musk
#

see Nest->getNestEnt()

#

did not work

glossy venture
#

then you can check if it registered your entity

glossy venture
desert musk
#

here

#
        System.out.println("Debugging shit: ");
        System.out.println(this.getBukkitEntity() == Bukkit.getEntity(this.getBukkitEntity().getUniqueId()));
        System.out.println(this.getBukkitEntity().getUniqueId());
        System.out.println(nestExists(this.getBukkitEntity().getUniqueId()));
#

[15:59:22 INFO]: [HearthNest] [STDOUT] Debugging shit: [15:59:22 INFO]: false [15:59:22 INFO]: 65c9fcbc-79bc-4306-aa91-198b148cbc80 [15:59:22 INFO]: true

young knoll
#

Don’t use ==

desert musk
#

r u sure

glossy venture
desert musk
#

that's the whole point

#

if i change it to .equals and that works

young knoll
#

Evidently not

desert musk
#

then i formally curse Java

#

for not doing operator overloads

glossy venture
#

i dont think the entity uuids are always the same

desert musk
#

oh nvm you double negatives

desert musk
glossy venture
#

so idk if saving them in the config by entity uuid will work

desert musk
#

how would they change?

#

i thought the entire point was that they persisted

glossy venture
#

theyre randomly assigned iirc

desert musk
#

uniqueId

glossy venture
#

when they are loaded, could be wrong

desert musk
glossy venture
desert musk
glossy venture
#

doesnt say getPersistentUniqueId()

fossil lily
#

when I do block.getBlockData.getMaterial it doesnt copy the type of block. Like if the block is a spruce slab, it will just show an oak slab. If you have brown concrete, it will spawn bright concrete.

fossil lily
#

How can I copy more specific data?

glossy venture
#

lemme look it up

desert musk
#

it definitely stays forever

#

cause in the banned-players shit

#

you can find their UID

#

UID would be useless to assign to players

#

if it changed.

glossy venture
#

ah nvm

#

entity id isnt persistent

desert musk
#

so am i using an entityId?

glossy venture
#

idk

#

are you

desert musk
#

let's see

smoky oak
#

check your method calls

#

anyways

#

is it possible to force an @override without making the class abstract or an interface?

desert musk
#

can you derive the entityId from uniqueId?

glossy venture
#

no

fossil lily
smoky oak
#

can't u do 0b instead of (byte) 0 ?

young knoll
#

No

#

0b is a Boolean

glossy venture
smoky oak
#

there a postfix for byte?

desert musk
smoky oak
smoky oak
glossy venture
#

yeah

smoky oak
glossy venture
#

dont think so

#

but most people do that anyways i think

smoky oak
#

urgh see thing is
i want to not copy paste the code for a runnable over and over again, but i want to make sure the method it in turn calls is implemented

desert musk
#

Ok i think i've come to the conclusion then

#

so how do i contact mojang that their method doesn't work

#

or spigot or whoever

#

???

young knoll
#

?jira

undone axleBOT
desert musk
#

ty

quaint mantle
#

hey there so im trying too implement my own chat renderer for my server however i cant workout how to assign it so that it is used how would i go about doing this?

young knoll
#

Chat renderer?

quaint mantle
#

ive been told i need to do it in the eventhandler but not sure what to do after that

#

yeah the method that gets called when a message is sent

young knoll
#

This sounds like paper API

quaint mantle
#

ahhh ok i'll try their discord then

tardy delta
#

a

tardy delta
#

a

last ledge
#
        Player player = (Player) sender;
        if(!(player.hasMetadata("initiated"))){
            player.sendMessage(ChatColor. + "[ArenaLocker] " + ChatColor.GOLD + "Correct Usage: /arena create");
        }
            if(command.getName().equalsIgnoreCase("pos1")){
                String world = player.getWorld().getName();
                player.sendMessage(world);
                player.removeMetadata("initiated", plugin);
            }
        return true;
    }
}```

The plugin is getting confused if it has meta data or not
#

So after Player inputs /arena create

tardy delta
#

unchecked casting always nice

last ledge
#

they get initiated metadata

#

and then they put /pos1 command

#

after they put /pos1 inititated meta data should be removed

#

and its removing sucessfully still

#

it gives this message player.sendMessage(ChatColor.YELLOW + "[ArenaLocker] " + ChatColor.GOLD + "Correct Usage: /arena create");

modern valley
#

suppose I have a item named shard with custom properties and I want that shard in a crafting recipe for another customised item. How can I do this? (pls ping if you reply)

fossil lily
#

How can I edit the entity packet before sending it with protocol lib?

#

I want to summon a nametagged armorstand

desert musk
#

how can i make an entity with no ai able to be hit by arrows?

fossil lily
desert musk
#

it's not invulnerable

#

as in it can still take damage

#

but is that a separate thing?

fossil lily
#

That doesn't make sense

desert musk
#

oh probably it's because of setCollidable(false)

crisp steeple
last ledge
crisp steeple
#

getServer().getPluginManager().getCommand(<command name>).setExecutor(new <command executor>)

#

some of the names or arguments might be wrong since i’m on mobile

#

but intellisense should probably show the right ones

last ledge
crisp steeple
#

if you haven’t done that it won’t ever be called

#

assuming you’ve set the executor of “arena” to that

modern valley
quasi patrol
#

Does like... no one know the answer?

crisp steeple
last ledge
crisp steeple
#

ok well then try it now

modern valley
oak mica
#

i havent coded plguins in a year e why doesnt this work

quaint mantle
#

import it

oak mica
#

whats the import e intellij isnt showing for some reason

quaint mantle
#

click on it then press ALT + TAB

oak mica
quaint mantle
#

well whats the error

modern valley
oak mica
#

aight working thanks

quaint mantle
#

bruh

modern valley
#

sometimes intellij might be frozen

quaint mantle
#
import me.axure.bangui.utils.BanMenuUtils;
import org.bukkit.BanList;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;

public class BanInventoryListener implements Listener {

    @EventHandler
    public void onMenuClick(InventoryClickEvent e) {

        Player p = (Player) e.getWhoClicked();

        if(e.getView().getTitle().equalsIgnoreCase(ChatColor.AQUA + "Ban GUI")) {
            if(e.getCurrentItem().getType() == Material.PLAYER_HEAD) {

                Player toBan = p.getServer().getPlayerExact(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()));

                BanMenuUtils.confirmBanMenu(p, toBan);

            }
        } else if (e.getView().getTitle().equalsIgnoreCase(ChatColor.RED + "Ban This Player")) {
            if(e.getCurrentItem().getType() == Material.BARRIER) {
                BanMenuUtils.openBanMenu(p);
            } else if (e.getCurrentItem().getType() == Material.WOODEN_AXE) {
                String name = ChatColor.stripColor(e.getClickedInventory().getItem(4).getItemMeta().getDisplayName());
                p.getServer().getBanList(BanList.Type.NAME).addBan(name, "Banned By a Moderator", null, null);

                p.sendMessage(ChatColor.GREEN + "Banned Player");
            }
        }

        e.setCancelled(true);

    }

}```
Error:
```yml
java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getType()" because the return value of "org.bukkit.event.inventory.InventoryClickEvent.getCurrentItem()" is null```
kind hatch
#

You don’t have any null checks.

river oracle
kind hatch
#

If the player clicks on anything other than an item, it’s considered null.

quaint mantle
#

so a player head is considered null

kind hatch
#

No, a player head is an item and it won’t be null, but if the player clicks on another slot or outside the inventory, the “item” they clicked will be null.

That being said, other things about the head could be null. ItemMeta is an example of this.

quaint mantle
# kind hatch No, a player head is an item and it won’t be null, but if the player clicks on a...

well heres the code which makes the gui and the head

        ArrayList<Player> list = new ArrayList<>(p.getServer().getOnlinePlayers());

        Inventory bangui = Bukkit.createInventory(p, 45, ChatColor.AQUA + "Ban GUI");

        for (int i = 0; i < list.size(); i++) {

            ItemStack playerHead = new ItemStack(Material.PLAYER_HEAD, 1);
            ItemMeta meta = playerHead.getItemMeta();

            meta.setDisplayName(list.get(i).getDisplayName());
            ArrayList<String> lore = new ArrayList<>();
            lore.add(ChatColor.GOLD + "Player Health: " + ChatColor.RED + list.get(i).getHealth());
            lore.add(ChatColor.GOLD + "XP: " + ChatColor.AQUA + list.get(i).getExp());
            meta.setLore(lore);
            playerHead.setItemMeta(meta);

            bangui.addItem(playerHead);
        }
        p.openInventory(bangui);```
patent horizon
#

would anyone know of a good scoreboard api that's actively being supported?

ivory sleet
#

Perhaps helper

eternal needle
tardy delta
#

there is something as if else

ivory sleet
#

assert?

#

nah

tardy delta
#

he null checks it but doesnt do an early return wha-

ivory sleet
#

oh right

#

ye that assert there is questionable

#

well assert in general is

tardy delta
#

also that contains check can be replaced with #remove

tardy delta
ivory sleet
#

hm?

tardy delta
#

then its useful

ivory sleet
#

nah

patent horizon
ivory sleet
#

Objects::requireNonNull does the job

#

cuz assert will literally do nothing

#

unless u enable it with a jvm flag

tardy delta
#

🙄 it will suppress the compiler warning iirc

ivory sleet
#

yes but I mean a //noinspection nullableproblems would also disable the warning

#

Objects::requireNonNull does as well

sharp bough
#

how could i get all walls arround a block

ivory sleet
#

and even just using the correct @SuppressWarnings would do the trick

tardy delta
#

idk my compiler says that that noinspection thing is redundant

#

same with annotation

ivory sleet
#

screenshot?

tardy delta
#

so i just did @SuppressWarnings("all") kek

sharp bough
#

i tried getting the corner and adding a 9 but i get issues with negative cords etc

ivory sleet
sharp bough
tardy delta
#

i know lol🥲

#

lemme find that code

#

ah here we go

ivory sleet
#

mye wrong one

tardy delta
#

same for the noinspection thing

ivory sleet
#

it was constantconditions

tardy delta
#

ah right i used it and i forgot it

ivory sleet
#

and if not ::requireNonNull is superior

#

like perhaps if you're testing assert is useful

#

but then we still got junit

#

which is is just so much more sophisticated

tender shard
#

OOP is so awesome

ivory sleet
#

yesnt

tardy delta
#

yesnt?

#

;-;

tender shard
#

I can now easily add whatever amount of new game modes I want, by just moving stuff from CompetitiveContest / CompetitiveGameLoop into abstract classes. took 2 hours but will save tons of hours in the future

tardy delta
#

nice

wide coyote
#

oh no white theme

tender shard
quaint mantle
#

yea how do i fix it

tardy delta
#

null check the inventory

quaint mantle
#

it shouldnt be null

tender shard
#

don't call any methods on stuff that's null

tender shard
ivory sleet
tardy delta
#

if you click outside of the inventory, the inventory is null

quaint mantle
#

i havent

tardy delta
#

or the clicked item is null

#

alex knows

#

im getting old and forgetting things

#

;-;

tender shard
#

you definitely clicked on something that made getCurrentItem return null, you can't deny that

ivory sleet
quaint mantle
#

oh so java is kind of like javascript

ivory sleet
#

ughj

#

Ig

#

well Java came first

#

but the concept of null has been around for ages

quaint mantle
#

i know i mean like return

tardy delta
ivory sleet
#

well even C had that

quaint mantle
#

good to know

tardy delta
#

conclure dont let him switch to C now ;-;

ivory sleet
#

🥲

hasty prawn
#

Anyone who actually uses C is a psychopath

ivory sleet
#

myueah C is quite atrocious

tardy delta
#

or is writing a linux kernel ;-;

static hollow
#

hey, i'm pasting schematic with location loc.clone().add(0, 5, 0) and i want to remove it later
As i see there is getMinimumPoint() and getMaximumPoint(), but I have no head for such mathematical things, can sb help?

fossil lily
#

How does one use the Protocol Lib Packer Wrapper?

#

I cant find any info

quaint mantle
ivory sleet
#

well provide some context

quaint mantle
#
        Inventory confirmMenu = Bukkit.createInventory(p, 9, ChatColor.RED + "Ban This Player");

        ItemStack ban = new ItemStack(Material.WOODEN_AXE, 1);
        ItemMeta ban_meta = ban.getItemMeta();
        ban_meta.setDisplayName(ChatColor.DARK_GREEN + "Ban");
        ban.setItemMeta(ban_meta);
        confirmMenu.setItem(0, ban);

        ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1);
        ItemMeta player_meta = head.getItemMeta();
        player_meta.setDisplayName(toBan.getDisplayName());
        head.setItemMeta(player_meta);
        confirmMenu.setItem(4, head);

        ItemStack cancel = new ItemStack(Material.BARRIER, 1);
        ItemMeta cancel_meta = cancel.getItemMeta();
        cancel_meta.setDisplayName(ChatColor.RED + "Cancel");
        cancel.setItemMeta(cancel_meta);
        confirmMenu.setItem(8, cancel);

        p.openInventory(confirmMenu);```
tardy delta
#

the Bukkit.getPlayerExact returns null

#

that code isnt showing it

ivory sleet
#

where do you declare the variable to_ban?

ivory sleet
tardy delta
ivory sleet
#

ye listen to FourteenBrush here

quaint mantle
#

this?

#

or the other
Player toBan = p.getServer().getPlayerExact(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()));

ivory sleet
#

the return of getPlayerExact can be null

crisp steeple
# tardy delta

does chatcolor.stripColor actually remove all the color codes or just the \u00a7

ivory sleet
#

removes \u00a7 + consecutive color code identifier char

tardy delta
tardy delta
ivory sleet
#

for instance it may look like (not exactly but just do demonstate)

Player getExactPlayer(String name) {
  return playerMap.search(name).orElse(null);
}``` @quaint mantle
tardy delta
#

or you provided the wrong name

#

oh god

#

why

ivory sleet
#

in which even tho its not a variable it may (still) be null

ivory sleet
#

the read me goes thru it

#

altho it presupposed you use gradle/maven

#

so if you dont, a good start is to do it with maven/gradle

fossil lily
#

What the heck

#

Thats not the page I was on

#

Oh okay

#

Thanks

ivory sleet
#

good luck fingerguns

golden turret
#

any ideas on why it causes the server lag until it crashes if the gun.getBullets() is like 10?

static hollow
# static hollow hey, i'm pasting schematic with location loc.clone().add(0, 5, 0) and i want to ...

I'm pasting schematic like this:

Location loc = spawnLocations.get(i);
pasteSchematic(loc.clone().add(0, 5, 0));

private static void pasteSchematic(Location loc)
{
    Clipboard schematic = Main.instance.loadSchematic(schemPath.toFile());

    try (EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(BukkitAdapter.adapt(loc.getWorld()), -1))
    {
        Operation operation = new ClipboardHolder(schematic)
                .createPaste(editSession)
                .to(BlockVector3.at(loc.getX(), loc.getY(), loc.getZ()))
                .ignoreAirBlocks(false)
                .build();
        Operations.complete(operation);
    } catch (Exception e)
    {
        Bukkit.getConsoleSender().sendMessage("§8[§3NSkyWars§8] §cError while pasting schematic: " + e.getMessage());
    }

}

I want to remove it later (building)

As i see in there:

Clipboard schematic = Main.instance.loadSchematic(schemPath.toFile());
schematic.

I have getMinimumPoint and getMaximumPoint in schematic.

fossil lily
#

Oh no wait

#

The wrapper is different from the api

tranquil iron
#

When i run the bat file to put in my version it doesnt work anyhelp?

ancient plank
sharp bough
civic needle
#

so me and my friend are trying to collaborate on a plugin, im using vscode whereas and he is using intellij, how would we efficientely share our classes and such

static hollow
#

uh, vsc is almost a plain text editor, you shouldn't use it to write a plugin

lavish hemlock
#

Or just

#

Git in general

tardy delta
#

isnt there a code together thing in ij?

desert musk
#

holy shit ok actual devs are online now

#

can someone help me understand how to use Bukkit.getEntity(UUID)??

lavish hemlock
#

Yeah but code together is pointless

#

Just use Git

tardy delta
#

if he's just sharing it then its useless

lavish hemlock
#

Also sessions are limited with code together aaand it's not exactly the best for sharing classes

chrome beacon
#

Code together is great for teaching :)

desert musk
tardy delta
#

could you teach me something?

#

👉👈

desert musk
#

feel free to bully me about my shitty code

lavish hemlock
#

oooh

civic needle
lavish hemlock
#

shitty code?

#

don't mind if I do

desert musk
#

lol

#

ok so basicallu

civic needle
tardy delta
#

and its nullable

civic needle
#

should i just put our classes folder in the git?

tardy delta
#

what class

desert musk
#

go to entities->entityNest

#

and tell me why the line

tardy delta
#

ah lol

lavish hemlock
#

I mean it's not the worst code

desert musk
#

System.out.println(this.getBukkitEntity() == Bukkit.getEntity(this.getBukkitEntity().getUniqueId())); is always false

desert musk
lavish hemlock
#

Different instances, probs

tardy delta
#

dont compare with ==

#

use equals

desert musk
#

ok and then i tried .equals

#

still doesnt work

lavish hemlock
#

You can (and should) compare stuff like enums and primitives with ==

desert musk
#

but anyhow == should work

lavish hemlock
#

As well as InventoryViews

desert musk
patent horizon
#

is there a way to see how much time ive spent in intellij in total?

ancient plank
#

without a plugin no

#

with a plugin yes

#

wakatime

tardy delta
#

this man is going for the stats

ancient plank
#

but it only counts after you installed it so

#

no

patent horizon
desert musk
#

This all starts here

#

yes i've been trying to figure this out for 5 hours

tardy delta
#

what is getBukkitEntity returning?

desert musk
#

an entity

tardy delta
#

just an entity?

#

ah

grizzled pollen
desert musk
#

yeap

tardy delta
#

lol

grizzled pollen
#

I'm a little late

desert musk
#

lmfao

tardy delta
#

why do you even need it

desert musk
#

a little

civic needle
desert musk
#

i'm storing a "nests" entity UID in a yaml file

tardy delta
#

dont know if there is a CraftEntity class and what its equals implementation is

lavish hemlock
desert musk
#

i need to convert it back into the entity

tardy delta
#

make it persistent or something?

#

never worked with entities tbh

desert musk
#

isn't it persistent?

tardy delta
#

they always scare me

desert musk
#

isn't UID persistent or no

#

or how do i make it persistant

lavish hemlock
#

For an entity?

#

Probably not

#

I would imagine all entities are randomly assigned a new UUID when they're loaded but

#

Actually I have no idea

desert musk
#

there's an entityId and an entityUniqueId

tardy delta
desert musk
#

the entityUniqueId is persistent

#

that's what i'm using in the Bukkit.getEntity() I think

#

but if it's the entityId then i have no idea how to get that

#

how do you derive the entityId from the uniqueId

tardy delta
tardy delta
#

ah wait

desert musk
#

well it spawns

#

it changes everytime it spawns

tardy delta
#

bro this man is saying something else

desert musk
#

but its persistent?

tardy delta
#

im going to believe him

desert musk
desert musk
#

both are true

lavish hemlock
#

I mean I would think it would be saved in the NBT

desert musk
#

the first is just implying the second is false

#

but its not incorrect

#

🤷

#

i just think it shouldn't be this hard

desert musk
#

OK

#

i just got good information

#

i think it is a problem with entityId vs uniqueId

#

watch

tender shard
#

not really, Bukkit.getEntity requires a UID

desert musk
#
        addMember(this.getBukkitEntity().getUniqueId(), placer, "leader");
        setNestSpawn(this.getBukkitEntity().getUniqueId(), placer.getUniqueId(), this.getBukkitEntity().getLocation());
        System.out.println("Debugging shit: ");
        System.out.println(this.getBukkitEntity() == Bukkit.getEntity(this.getBukkitEntity().getUniqueId()));
        System.out.println(this.getBukkitEntity().getUniqueId());
        System.out.println(nestExists(this.getBukkitEntity().getUniqueId()));
        System.out.println(getNestEnt(this.getBukkitEntity().getUniqueId()).getUniqueId());

#

[18:58:58 INFO]: [HearthNest] [STDOUT] Debugging shit: [18:58:58 INFO]: false [18:58:58 INFO]: dfbc8a5e-6a05-45d8-b2f4-67d0b4eea6fd [18:58:58 INFO]: true [18:58:58 INFO]: b71ef53e-6026-45d6-96fd-4292b59bfd16

#

two different Ids!!!!

desert musk
#

an entityID and a uniqueID

tender shard
#

yes, as said, getBukkitEntity() creates a new BukkitEntity

desert musk
#

i have no idea which is the input to getEntity()

desert musk
#

why 😭

#

that makes no sense

tender shard
#

yes it does

#
    public CraftEntity getBukkitEntity() {
        if (this.bukkitEntity == null) {
            this.bukkitEntity = CraftEntity.getEntity(this.level.getCraftServer(), this);
        }

        return this.bukkitEntity;
    }
desert musk
#

yeah that don't make a new entity

tender shard
#

no, it creates a new BukkitEntity though

desert musk
#

ohhh

tender shard
#

(if there isn't one existing yet for this NMS entity)

desert musk
#

ok i have no idea what the differences are between a bukkit entity and a craftentity

#

pls explain

tender shard
#

those are the same

desert musk
#

oh?

tender shard
#

CraftEntity is the class that implements the bukkit entity

#

list ArrayList implements the List interface

tardy delta
#

entity is an interface

desert musk
#

holy shit i just found something

nimble escarp
#

Hello, how could I know if, for example, "DIAMOND ORE" is within a certain zone x y z?

desert musk
#

ok imma try "this.getUUID()" instead of the bukketentity uuid

#

🤦‍♂️

desert musk
#

i'm very very confused.

#

it worked when other nests existed

#

and then i killed all of them and it no longer works when spawning a new one

crisp steeple
desert musk
#

this is absolutely the most convoluted shit i've done so far

#

would be very grateful for a solution

crisp steeple
#

yeah entities are pretty weird since theres always like 3 different classes for them

#

what are you trying to accomplish

nimble escarp
desert musk
crisp steeple
#

like the java docs for a for loop?

desert musk
#

would really love some help this is my 5 hour mark of working on this small problem

crisp steeple
desert musk
grim ice
#

finally

#

i can eat now

desert musk
#

pog

desert musk
grim ice
#

why ru using Allman style

desert musk
#

tfs an Allman

#

?

desert musk
grim ice
#

Allman:
void o()
{
}
K&R:
void o() {
}

desert musk
#

oh

grim ice
#

as you can see K&R looks awesome

desert musk
#

yeah i try not to use Allman

#

lol

grim ice
#

opposite to Allman

desert musk
#

where do i use it

#

(probably IDE made me do it)

grim ice
#

and modern IDEs like Intellij stop you from using Allman

desert musk
#

hehehe

grim ice
#

and by default uses K&R

desert musk
#

istg it made me do it one time

#

actually multiple times

grim ice
#

Nope

desert musk
#

when importing methods

grim ice
#

btw

#

right click ur directory

#

Ur biggest directory

desert musk
#

ok

grim ice
#

and search for format

#

thing

#

itll fix

desert musk
#

wut

grim ice
#

indents and optimize imports

#

right click t and shhow me

desert musk
#

i'm scared of that

#

i will not do that rn

#

lol

grim ice
#

sir just read what it says

desert musk
#

not when my code is broken

grim ice
#

and u have it on github anyways?

desert musk
#

yep

grim ice
#

it doesnt do shit it makes it more readable for ppl helping u

desert musk
#

okok

#

"reformat code" ?

grim ice
#

yea

crisp steeple
#

@desert musk bukkit.getentity is never going to return the exact same object as this.getbukkitentity

desert musk
#

ticking all the boxes?

grim ice
#

leave it as it is

#

just click confirm

desert musk
#

and maybe detail my recourse

#

||ok so how should i go about this: a nest is a structure that exists in a yaml file and is tied to a world entity through its UID. I want to find the entity from its UID in these methods.||

desert musk
grim ice
#

makes no sense

desert musk
#

that's what ive been saying for FIVE HOURS

crisp steeple
#

this.getbukkitentity is going to return the bukkit equivalent of your nms object

#

bukkit.getentity is going to return the bukkit entity of the entity in the world

grim ice
#

OH WAIT

#

I GOT IT

#

I KNOW WHY

desert musk
#

???

grim ice
#

its cuz

desert musk
#

WHY

grim ice
#

getBukkitEntity

#

doesnt necessarily mean

#

its spawned into the world

desert musk
#

but it did

#

4hed

grim ice
#

not always

desert musk
#

explain

grim ice
#

u can get it even without spawning

grim ice
#

the entity

desert musk
#

does the entity take time to spawn??

#

cuz if so then how did i apply all of these effects to it??

grim ice
#

but Bukkit.getEntity() takes the entity that is spawned from the world
getBukkitEntity() give you an entity object with the information of ur NMS Entity not the spawned one which might not exist

desert musk
#

ok uhhh

#

so.

#

what do i do?

grim ice
#

what are you trying to do?

desert musk
#

||ok so how should i go about this: a nest is a structure that exists in a yaml file and is tied to a world entity through its UID. I want to find the entity from its UID in these methods.
||

crisp steeple
#

so you're trying to get a world entity from a uuid stored in a yml file?

desert musk
#

yess

grim ice
#

u want to find the entity from its uuid?

desert musk
#

yeap

grim ice
#

spawn it then get the uuid

#

simple

desert musk
#

how get uuid

#

which method

grim ice
#

.getUniqueId()

#

in Bukkit's Entity

desert musk
#

ok but what if i have the uid

#

how do get its entity

crisp steeple
#

well, i honestly dont know if entity uuids change on server restart or not

desert musk
grim ice
#

EntityID is a UUID tho?

desert musk
#

and only the UUID

desert musk
#

a UniqueID and an EntityID

grim ice
#

Bukkit.getEntity(UID)

desert musk
#

i have NO IDEA which is which

#

all i know is that

#

EntityID changes

grim ice
#

UID is UniqueID i assume

desert musk
#

UniqueID does not

desert musk
#

dear god i hope

#

but ALSO

#

System.out.println(this.getBukkitEntity().getUniqueId()); // RETURNS SOME VALUE System.out.println(nestExists(this.getBukkitEntity().getUniqueId())); // RETURNS TRUE System.out.println(getNestEnt(this.getUUID())); // RETURNS DIFFERENT FROM LINE 58

#

so this does not imply that

#

i don't think

#

this.getUUID is different than this.getBukkitEntity().getUniqueId()

grim ice
#

getting unique id on the bukkit entity wont work

grim ice
#

u have to spawn it first

#

i think

desert musk
#

i spawned it using super()

#

at the top of the method

grim ice
#

cuz ur getting the uid of something that doesnt exist, which makes no sensee

desert musk
#

i think

#

`super(EntityType.VILLAGER,((CraftWorld) loc.getWorld()).getHandle());

    this.setPos(loc.getX(),loc.getY(),loc.getZ());

    CraftLivingEntity ent = (CraftLivingEntity) this.getBukkitEntity();`
crisp steeple
#

constructing a nms entity doesnt spawn it into the world

desert musk
#

uhh

grim ice
desert musk
#

ok i see

grim ice
#

getBukkitEntity().getUniqueID() will never work

desert musk
#

so an NMS entity's UID

#

can i use that instead?

#

for all of these features?

grim ice
#

prob not

#

ok show me ur entity spawning code

grim ice
#

ok store the new EntityNest(e.getClickedBlock().getLocation().add(0.5,1,0.5),e.getPlayer())

crisp steeple
#

are you trying to spawn the nms entity into the world?

grim ice
#

in a variable

#

then spawn it

#

then get its uniqueid

desert musk
#

hold on finding that

grim ice
#

addFreshEntity, does this method return something?

desert musk
#

thats what i was just about to paste in

#

does that spawn the entity?

grim ice
#

it does

#

but what does it return

desert musk
#

ok.

#

uhh

#

OK OK

#

so i just do all of this in placeNest instead

#

instead of EntityNest

desert musk
grim ice
#

if u wanna access the spawned entity uuid then yeah

desert musk
#

POG

#

also not pog

#

that's kinda stinky

grim ice
#

lol

desert musk
#

🤷

grim ice
#

a not yet spawned entity cant have a uuid so

desert musk
#

yeah

#

...

#

that makes so much more sense now btw

#

ok yeah

#

NMS makes more sense noww

grim ice
#

i mean thats what my logic tells me

#

im not a nms professional or smth

#

u prob should try it

desert musk
#

ok but yeah now how do i find the unique id of the "fresh entity"

grim ice
#

the new EntityNest(e.getClickedBlock().getLocation().add(0.5,1,0.5),e.getPlayer())

#

store it in a variable

desert musk
#

tried that

#

was red

#

hold on

#

oh

#

do i store it as an EntityNest?

#

or an Entity?

#

huh

#

can i convert it from EntityNest to Entity?

grim ice
#

wait

#

dont u use

crisp steeple
#

entitynest already is an entity

grim ice
#

((CraftWorld)loc.getWorld()).getHandle().addEntity(nmsEntity, SpawnReason.CUSTOM);

desert musk
grim ice
crisp steeple
#

if you can get the entityid from an nms entity yeah

desert musk
#

ok

#

nmsentity.getUUID

#

let's try that

grim ice
#

if that doesnt exist

desert musk
#

it does exist

#

however

grim ice
#

then ONLY after you spawn it

desert musk
#

i'm skeptical

grim ice
#

getBukkitEntity().getUniqueId()

#

just try it

crisp steeple
desert musk
#

nest is

#

i just wrote shitty example

#

hold on

crisp steeple
#

well then do nest.getuuid

desert musk
#
                EntityNest nest = new EntityNest(e.getClickedBlock().getLocation().add(0.5,1,0.5),e.getPlayer());
                world.addFreshEntity(nest);
                UUID nestID = nest.getUUID(); ```
#

ew

#

that formatting

#

anyways

#

i'm highly skeptical of that nest.getUUID(); method

#

let's see if it works though

grim ice
#

do it after u spawn tho

desert musk
#

yeah

#

didn't i?

noble lantern
#

why no space in constructor arguments :((

desert musk
noble lantern
desert musk
#

burchard!!

#

hello

grim ice
#

Reformat Code fixes it btw

desert musk
#

i've come to torture you again

desert musk
#

PogO

#

eh i'll try it again later

noble lantern
#

Dont compare Entity objects

#

compare UUIDs

grim ice
#

he is

desert musk
#

yeah yeah

#

but the entity is null

#

every time

grim ice
#

even though entities should be singletons

#

so u can instance compare them

#

but ok

desert musk
#

brb

noble lantern
#

same with ItemStacks

crisp steeple
noble lantern
#

so i always just found it easier to compare with UUID's

crisp steeple
#

itemstacks dont stay the same object forever

noble lantern
#

indeed same with entities too

#

I like to add a PDT ID with my ItemStacks

desert musk
#
@EventHandler
    public void onPlaceNest(PlayerInteractEvent e) {
        Player player = e.getPlayer();

        if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
            if (e.getItem() == null) return;
            if (e.getClickedBlock().getType().isInteractable()) return;
            if (Objects.equals(Objects.requireNonNull(e.getItem()).getItemMeta(), ItemManager.nest.getItemMeta())) {

                ServerLevel world = ((CraftWorld) player.getWorld()).getHandle();
                EntityNest nest = new EntityNest(e.getClickedBlock().getLocation().add(0.5,1,0.5), e.getPlayer());
                world.addFreshEntity(nest);
                //  write to data

                UUID nestID = nest.getUUID();
                int unnamed = 0;
                while(!NestYML.nest(nestID,"Unnamed Nest "+Integer.toString(unnamed), 1)) {
                    unnamed++;
                    System.out.println("Found unnamed nest with the same name, iterating");
                }

                nest.setCustomName(new TextComponent(ChatColor.GOLD + "" + ChatColor.BOLD + "Unnamed Nest" + Integer.toString(unnamed)));

                addMember(nestID, player, "leader");

                e.setCancelled(true);
                player.getInventory().getItemInMainHand().setAmount(player.getInventory().getItemInMainHand().getAmount()-1); // -1 nest
            }
        }
    }```

here's what i have people
#

can't test it rn though brb 3 mins

crisp steeple
#

using Integer.toString is pointless

#

also you should probably cancel the event before doing those other things, just in case one of them causes an exception

desert musk
#

testing now

#

LET'S FUCKING GOOOOOOOO

#

IT WORKED

#

STOP THE TIMER

#

5 HOURS EXACTLY

#

ALMOST

crisp steeple
#

neat

desert musk
#

🥲 👍

#

ok ty you guys 😙

#

see you again in 20 minutes

echo basalt
#

nest

desert musk
#

lol

#

ok i'll unwrap the shit and return its negation

echo basalt
#

and name your event variable something other than e

desert musk
#

no! 😄

echo basalt
#

looks like garbage

desert musk
#

true

echo basalt
#

reuse variables

#

like your iteminhand

desert musk
#

ty for giving me tips though

#

i see nobody else nagging me about how to make it better

#

not sarcastic

echo basalt
#

it's fine

#

I coded like that like 4 years ago

desert musk
#

lol

#

yeah these are my first plugins

echo basalt
#

sometimes we need someone that knows what they're doing, to show us what's wrong in order to improve

desert musk
#

my first java programming actually

desert musk
#

lul

desert musk
#

🤷

#

lemme find him

#

so u can place a hit

echo basalt
#

most of my work nowadays is for youtubers so I can probably find my ways

desert musk
#

In this episode, I give you a brief overview of what you can expect in this MC Plugin coding series. #Spigot #MCPlugins #PluginTutorial

Java Tutorial: https://www.youtube.com/playlist?list=PLfu_Bpi_zcDPNy6qznvbkGZi7eP_0EL77
How to Setup a Test Server: https://www.youtube.com/watch?v=58MZ4THF73g&ab_channel=KodySimpson

Discord: https://rebrand.l...

▶ Play video
grim ice
desert musk
#

this guy i think

desert musk
grim ice
#

i alr gave a few tips and i thought giving more would be rude

desert musk
#

i appreciate it

grim ice
#

thats the first time ive seen a person like this pog

#

ur the same as me

echo basalt
desert musk
#

pog

grim ice
#

lol

desert musk
#

ok so now

#

ok good nvm

kindred valley
#

how can i correctly use an object as a constructor parameter

echo basalt
#

what

kindred valley
echo basalt
#
private final Object object;

public WhateverMyClassIs(Object object) {
  this.object = object,
}
echo basalt
#

then what

kindred valley
#

i have contry and president object

#

ah wait

#
public Country(double gun_pl, String name, President president, int population)```
#
public President(int iq, String isim, int yas, int experiment, String country)```
dapper ether
grim ice
#

ii mran

#

i mean

#

the country object should have the president object inside of it

dapper ether
kindred valley
#

im defining the constructor variables and trying to reach it but it shows null

quaint mantle
#

what would be the best database to store userdata for a plugin in, im thinking of mysql but never done anything like this before so hoping there is something simpler than that.

dapper ether
dapper ether
#

in your case replace object with president

desert musk
#

wait why is this

#

in a Commands file

echo basalt
#

you're probably checking the args before

desert musk
#

why is args[0] always null

desert musk
dapper ether
#

cause its a string

#

ig

#

use .equals()

desert musk
#

strings are always null?

#

why's that

dapper ether
#

args[0].equals("test")

#

no

#

but == does different to strings

desert musk
#

simply checking if a string is == null

#

i genuinely think the ide is buggin

dapper ether
#

no

desert musk
#

rare intellij L?

dapper ether
#

its always null

desert musk
#

just curious

echo basalt
#

show full code

desert musk
#

and it could help me later

#

ok

#

?paste

undone axleBOT
desert musk
echo basalt
#

fyi

dapper ether
#

== checks references to objects in strings

echo basalt
#

bukkit never passes null strings

desert musk
#

ohhh

#

thank you

echo basalt
#

targetLocation.setYaw(sourceLocation)

#

setPitch

desert musk
#

intelliJ never takes the L

#

once again

echo basalt
#

don't cancel the event

#

also if you want to cancel movement

#

just set movement speed to 0

#

:)

#

then set it back to 0.2

#

you can then cancel that

#

but only if they jump

#

looks less buggy

#

you can also cancel jumps by sending a fake barrier block above the player

#

using sendBlockChange

visual tide
#

or give them jump boost 128

#

then you cant jump

echo basalt
#

yeah something lik that

vale veldt
#

Hello,

I have set an option to show if there are updates available in my plugin but I see that it doesn't work as it should.

Here we can see that when my plugin starts it shows that there is an update available:

https://i.gyazo.com/e1ac4000af88eb5b89639567ec26d255.png

The website shows that the last update is the current one I have so I don't know why it shows me that there is a version available:

https://i.gyazo.com/151e807ef0421a3b5febe98557681ca7.png

And you'll say it's because of the -SNAPSHOP but I already use a split so it doesn't read that:

@Override
    public void load() {
        try {
            HttpURLConnection con = (HttpURLConnection) new URL(
                    "https://api.spigotmc.org/legacy/update.php?resource=100875").openConnection();
            int timed_out = 1250;
            con.setConnectTimeout(timed_out);
            con.setReadTimeout(timed_out);
            String latestversion = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine();
            String[] version = plugin.getDescription().getVersion().split("-");

            if (version[1].equals("BETA")) {
                CoreLogger.warn("You are using a BETA version. Some functions may not be stable, be careful and use at your own risk.");
            } else if(!version[0].equals(latestversion)){
                CoreLogger.warn("There is a new version available.");
                CoreLogger.warn("You can download it at: https://www.spigotmc.org/resources/100875/");
            } else {
                CoreLogger.info("You are using the latest version: " + plugin.getDescription().getVersion());
            }

        } catch (Exception ex) {
            CoreLogger.severe("Error while checking update...");
        }
    }```
#

So I have tried to see what values are returned and it tells me that on the web the latest version in spigot is 0.0.8 when I just updated 1 hour ago and as you can see in the following image the value is 0.0.9 in reality... what is happening?

https://i.gyazo.com/3633ddae936426c3529bc118d85ed32a.png

echo basalt
#

cache or something?

vale veldt
#

I don't know... that's why I ask, to me what I find strange is that on the web appears 0.0.9 and the plugin reads 0.0.8... wtf

desert musk
#

?paste

undone axleBOT
desert musk
#

the command /rewake "Unnamed Nest 0" doesn't count as passing in 1 argument

#

so...

#

how do i combine it into one argument?

smoky oak
#

you cant

desert musk
#

cuz i can't compare it to strings

smoky oak
#

what you can do is reformat the args in the command

#

look for the locations of the first two "

desert musk
#

ok

#

can i just append the args

#

with spaces inbetween

smoky oak
#

correct

#

and go from there

desert musk
smoky oak
#

as for why im here, what's the event called when the wither breaks blocks?

#

also

#

do entities have PDC?

chrome beacon
hasty prawn
viral temple
#

What file format should I use to be both readable and have support for comments?

smoky oak
#

for what exactly?

#

bc i just use yml for configs

chrome beacon
#

Yeah use yml

viral temple
#

Yaml doesn't support comments by default

smoky oak
viral temple
#

By default

chrome beacon
smoky oak
#

yea but youre using bukkit

viral temple
#

Yaml doesn't support comments

ivory sleet
smoky oak
#

FileConfiguration parses # as comments

ivory sleet
#

As their convention is that comments are merely present to enrich the understanding and context of a node

viral temple
ivory sleet
#

Snakeyaml

#

Eo yaml

smoky oak
#

even my file editor that has nothing to do with bukkit already says # is yml comment

ivory sleet
#

If we talk about java

viral temple
ivory sleet
#

Uh yes?

viral temple
ivory sleet
#

What

#

Snakeyaml literally support comments for both sink and source

#

And spigot does as well

#

Idk what you’re talking about

viral temple
smoky oak
#

problem solved with this too

FileConfiguration getBakedConfig(String configFile){
        return YamlConfiguration.loadConfiguration(getResourceReader(configFile));}```
viral temple
#

When you write to a file

ivory sleet
#

Only if you set them to

#

Literally not

#

Well maybe if you use a legacy version

#

But that’s your issue then

viral temple
#

1.18 is legacy*

ivory sleet
#

?

#

Nah it isn’t legacy if that’s what you meant

ivory sleet
#

Else it will

#

Both when you source and sink

#

Literally

viral temple
#

Again, not the parser

desert musk
#

?paste

undone axleBOT
desert musk
#

i'm trying to parse the input to /rewake

#

it's not going well

ivory sleet
#

Again that thing is a switch state for the save/load function to know if they should invoke comment support behavior for the PARSER

vale veldt
desert musk
viral temple
#

Let me reformulate, does anyone know any file format and library that supports comments both when parsing the file and when writting to a file?

ivory sleet
#

yaml conventions don’t but yaml parsers do

#

So yes yaml

viral temple
#

That doesn't remove comments when you write to a file

ivory sleet
#

bruh

#

Spigot’s YamlConfiguration supports comments both for source and sink which means read / write

viral temple
ivory sleet
#

That’s literally untrue

viral temple
ivory sleet
#

you fucking realize thats 2014-2016

viral temple
#

Spigot haven't update snakeyaml in a decade

ivory sleet
#

literally has

chrome beacon
#

^^

#

Which is why newer versions support comments

desert musk
viral temple
#

Because I'm literally now seeing it in the javadoc

ivory sleet
#

some months ago in coordination with 1.18

viral temple
#

:|

#

So 1.18

#

Literally won't go back to lower versions anyway

ivory sleet
#

myes, but it isnt terribly hard to reinstate support for older versions from your side

viral temple
#

Anyway, thanks for the info

ivory sleet
viral temple
#

Sorry I was such a bummer

ivory sleet
#

should apologize for screaming at you as well

#

but yeah that solves that now Ig, dope

desert musk
#

lole

#

now make up over solving my noob question

viral temple
#

Been scratching my head for over 3 days now and couldn't find a way to put comments in a yaml file 😅

desert musk
#

i've been scratching my head for 5 hours about doing some stupid yaml shit as well

#

but the problem was actually about entity IDs

viral temple
#

Well, gl

desert musk
#

yeah thank you

ivory sleet
#

ah, spigot got your back now :] tho otherwise I believe toml, strictyaml and hocon support it

desert musk
#

its fixed now but i have to figure out how to parse command args

ivory sleet
#

(officially)

desert musk
#

which idfk how to do

river oracle
#

Uhm my yaml files hold comments just fine?

viral temple
#

I can't remember tho how to get custom objects now, but I'll figure it out

river oracle
#

Wow that was a while back smh

ivory sleet
#

yeah, might hint you at ConfigurationSerializable then if you wanna use spigot's way of dealing with it

desert musk
#

@ivory sleet do u know much about command args?

desert musk
#

pog

#

tell me what i'm doing wrong 🤷

ivory sleet
#

first of all, mind sending me the entire function?

desert musk
#

sure

ivory sleet
#

and how do you register it?

#

when using setExecutor etc

desert musk
#

Objects.requireNonNull(getCommand("rewake")).setExecutor(commands);

#

commands: hearthnest: description: Gives a nest to a player usage: /<command> rewake: description: Respawn at a Hearth usage: /<command> <nestname>

#

it says "Invalid Hearth Name"

#

ALSO

#

the uh

viral temple
ivory sleet
#

^

desert musk
#

o

#

was taught to do otherwise

#

will it make a functional difference rn though?

ivory sleet
#

nah it gets extremely messy if you share an executor instance between multiple command instances

desert musk
#

I will switch it though dw

ivory sleet
#

especially breaking single responsibility principle for instance

#

yeah

desert musk
smoky oak
#

well

#

ttheres a rule of thumb

desert musk
#

mhm

smoky oak
#

'one function one reason to change'

ivory sleet
viral temple
desert musk
smoky oak
#

other words, make one class for each command

desert musk
#

makes sense

smoky oak
#

MUCH easier to debug and simpler to write

normal isle
#

wrong channel

ivory sleet
desert musk
#

anyways how am i parsing wrong?

#

cause the givenNestName is always blank

ivory sleet
#

Invalid Hearth Name

ivory sleet
#

that isnt in your Commands.java as of now

#

"Invalid Hearth Name"

desert musk
#

wym

viral temple
#

As the command grows larger, is hard to maintain it

desert musk
ivory sleet
#

it says "Invalid Hearth Name"

viral temple
#

Wish spigot would fix the issue with commands

desert musk
#

or not null

viral temple
#

Adding more nesting to them

desert musk
#

just blank

#

idk if its null

grim ice
#

im literally using my pc with one eye closed

desert musk
grim ice
#

cuz it became red

ivory sleet
#

so what exactly does not work as intended pricedown?

grim ice
#

i didnt drink water at all today cuz im fasting sooo

desert musk
ivory sleet
#

fasting in terms of water? 😮

grim ice
#

fasting ramadan

#

for 30 dys

#

days

ivory sleet
#

ah

#

gl

desert musk
#

dam

grim ice
#

ty ill need it

desert musk
#

private String trackersToString(Map<String, String> trackers) { List<String> trackerList = new ArrayList<>(); for (Map.Entry<String, String> entry : trackers.entrySet()) { trackerList.add(entry.getKey() + ": " + entry.getValue()); } return String.join(", ", trackerList); }

#

is this what i need?

viral temple
#

Hmm?

desert musk
#

cause basically i'm trying to do /rewake "Nest Name"

#

and parse the "Nest Name"

viral temple
#

It transform a map<string, string> into a single string

desert musk
#

o

viral temple
#

Something like key: value, key: value, etc..

ivory sleet
#

@desert musk

#

strings are immutable

desert musk
#

wsup

ivory sleet
#

so you'd have to do

desert musk
#

oh what??