#help-development

1 messages · Page 541 of 1

sage dragon
#

When I cancel the ProjectileHitEvent, this should prevent Wither Skulls from exploding, right?

sour folio
#

?paste

undone axleBOT
sour folio
chrome beacon
#

Don't run commands

#

Use the vault api

sour folio
chrome beacon
#

Also don't load a new config every click

#

And don't detect items by their name

sage dragon
sour folio
sour folio
#

now it shows this

chrome beacon
#

Same goes for checking inventory names

pale pulsar
#

how you can to detect if the name of anvil custom are the same que “anvil custom” ? because I can to see if player are in custom anvil.

agile anvil
#

What ?

#

Check the inventory name

#

Check equals to what you want

pale pulsar
#

If is equals

agile anvil
#

Yes

#

So what's the matter ?

eternal oxide
#

Compare instance not name. NEVER compare by name

pale pulsar
#

I can dectect if the name is equal

eternal oxide
#

you can, but you'd be doing it wrong.

#

easily exploitable

pale pulsar
#

i want dectect the instance because i want to have the name of item rename in the custom anvil

eternal oxide
#

Do not compare names!

pale pulsar
#
   @EventHandler()
    public static void onClick(InventoryClickEvent event){


        Player player = (Player) event.getWhoClicked();
        ItemStack current = event.getCurrentItem();
        Inventory clickedInventory = event.getClickedInventory();
            if (clickedInventory instanceof AnvilInventory) {
                AnvilInventory anvilInventory = (AnvilInventory) clickedInventory;
                player.sendMessage("name : " + anvilInventory.getRenameText());
            }
}

eternal oxide
#

Player gets an anvil, renames it to match yours. Now your code will see their anvil as your custom one.

pale pulsar
eternal oxide
#

very exploitable

pale pulsar
#

So how I can to dectect the instance

eternal oxide
#

if (clickedInventory == anvil)

#

== is an instance check

#

checks it's the same object in memory

wet breach
#

If its just an empty inventory then you can just create it on the fly and make a copy of it for the player

pale pulsar
eternal oxide
#
AnvilInventory anvil = Bukkit.createInventory(null, InventoryType.ANVIL, "anvil");

@EventHandler()
public static void onClick(InventoryClickEvent event){
if (event.getClickedInventory() != anvil) return;```
wet breach
#

That is an itemstack not an inventory

#

ElgarL has an example for you

pale pulsar
#

okay

#

thx

native ruin
#

anybody got any tips for protocollib "subfields"

it is the only thing i'm really struggling with and i have no idea how to
link to sc https://wiki.vg/Protocol#Update_Teams

in this example int is probably the mode
string is the team name
collection is probably the subfields
no idea what optional stands for

how would i build up the "subfields" within a list

wet breach
#

Mode is the what is shown below in that list

#

Depending on the mode chosen. Which is the int for you dictates the rest

#

Typically protocollib keeps the order of the packet the same

native ruin
#

how would i build that collection?
make a list with values?

wet breach
#

You should be able to set the values of the mode from inside the method

native ruin
#

i don't get it so if i set the mode? i change the mode with the values?

echo basalt
chrome beacon
#

You should be aware that you don't need packets for teams

echo basalt
#

I generally just look at the nms impl

native ruin
echo basalt
#

So you'd go there and write like

#

0 for ADD

#

and then write the params for that

chrome beacon
#

Because you can do per player teams with the api

native ruin
echo basalt
#

just let xceing learn packets

native ruin
#

^^

chrome beacon
echo basalt
#

probably not the right way to do it

#

and there's 9/10 times existing API for it

#

but I didn't learn how to mess with packets by using the API

wet breach
#

Probably still good practice regardless

native ruin
#

but i don't want to use api's man

wet breach
#

Well they are there so you dont have to struggle like you are

echo basalt
#

You won't get as much help but like

wet breach
#

But its fine, getting some practice with packets will benefit you

native ruin
#

also being api dependent seems unreliable when versions change

echo basalt
#

it's the opposite

native ruin
#

or the owner of the api's stop updating them

wet breach
#

Spigot api doesnt change wildly lol

echo basalt
#

you'll have to rewrite all your packet logic the moment that minecraft updates lmao

#

but in general you seem to know enough about java and packets and all so I won't stop you

#

that's how I learned

#

I started with client-sided blocks and entities and eventually dove deeper

wet breach
#

Also spigot api is part of the spigot server so not like its goin anywhere either

native ruin
#

but if you use an api you need the wait till the owner updates it

echo basalt
#

the spigot api has a decent enough scoreboard api

#

we're not talking about a third-party

native ruin
#

oh you're not?

echo basalt
#

no

wet breach
native ruin
#

there goes my argument ig

echo basalt
#

you're still good to play with packets just don't expect people to be happy and willing to help

wet breach
#

Yep as said good practice regardless. In the case of spigot you should only resort to nms and packets if the api isnt able to do something you need or want

echo basalt
#

or if the existing api is garbage

#

like for client-sided blocks

#

sendBlockChange is a disgrace lmao

wet breach
#

Well minus some edge case scenarios of course lol

#

I think we should get a group of us devs and overhaul some code in the server

echo basalt
#

or we can just work on our own stuff instead

#

only way I'm touching spigot is if md personally pays me

wet breach
#

Lol

#

That isnt going to happen unfortunately

flint coyote
#

I doubt there's that many devs here that have enough knowledge to confidently work on spigot

echo basalt
#

true but usually the people chilling in this channel are pretty proficient

echo basalt
#

I've been doing spigot for like 6ish years now, frosty probably more

eternal oxide
#

I could but all my PR's would be rejected due to formatting 😛

wet breach
#

Most of them just dont chat often but are actually active

echo basalt
#

elgar probably wrote spigot in pen & paper

#

back in 78

flint coyote
#

lol probably

wet breach
echo basalt
#

well

flint coyote
#

Spigot servers running from floppy disks

echo basalt
#

those 4 years were enough

#

and my 6 years are probably the equivalent of 3-4 real-world years because I was like 12

wet breach
#

But then i have a lot of people beat in terms of working with java as well even if i didnt touch spigot

echo basalt
#

I started coding when I was 6, my brain cells were probably made of the sand I ate

wet breach
#

I been working with java since 1999 and java was a thing starting in 1998 lmao

flint coyote
#

I only started when I was 16 o.o

#

frostalf still knows the shitty GC from the early java versions

wet breach
#

You all should be happy with modern java and never got to experience 1.6 and below

echo basalt
#

I started on java 1.6

#

it was not nice

hazy parrot
#

i started in 2021 😭

echo basalt
#

late 2016 gang

flint coyote
#

I've heard a lot of "good" things about the GC back in the day - that it was pretty much entirely useless

#

And that it was pretty much unable to detect a lot of things that weren't in use anymore

wet breach
echo basalt
#

mem leaks are so fun

flint coyote
#

Manual nulling was the way from what I've heard

native ruin
#

anyway thanks for the advise and info

echo basalt
#

caught a memory leak a couple days ago because I was adding a single row of transparent pixels every time I did an operation on an image

wet breach
eternal oxide
#

I still catch myself manually null now and then

echo basalt
#

I usually manually null on my dispose() methods

wet breach
#

Well its proper form even if the language doesnt strictly require it

flint coyote
wet breach
#

Well it would make it more readable if anything

flint coyote
#

having a block of var = null; at the bottom of each function?

wet breach
#

They are not always suppose to be at the bottom

flint coyote
#

Oh you meant to null asap

wet breach
#

Its suppose to be done when you know you dont need it anymore

#

If its done like that it makes it clear when you have no use for the object very handy in large code blocks

flint coyote
#

I'd still feel like bloating my code with those statements and therefore I'd then reuse variables that therefore have bad names etc.

wet breach
#

Well if you reuse the object obviously you werent done with it lol

flint coyote
#

well lets say you have a list and you iterate it and then you are basically done with it

#

a few statements later you need a list of the same type

wet breach
#

Also on some circumstances nulling out sooner lets the gc work sooner too

flint coyote
#

then you could reuse that one but the name won't match

#

But it saves you an additional variable and two additional = nulls

#

That would surely be bad practice but it would kinda push me to do that

wet breach
#

Lol its still not bad practice but borderline unnecessary unless you managed to structure your code in a way to invoke gc to your needs

#

As i said if you null out objects fast enough and have enough of them you can trigger the gc to run

flint coyote
#

Does it even have to run when the objects are null?
What does it do? Just free up the memory again since it's empty?

#

Also with manual nulling you can never use final - kotlin would lose one of its core features lol

wet breach
flint coyote
#

How is that achieved in languages without GC then?

#

or is the = null; "more powerful" there?

wet breach
#

Null in other languages means you are absolutely done with it remove its pointer

wet breach
flint coyote
#

I see. So you can basically never assign null to a variable as it would delete the pointer?

#

or are there different types of null?

wet breach
#

It depends in which language really

flint coyote
#

Well C and C++ for example

wet breach
#

In c it means get rid of this, in c++ it keeps the pointer around because you might want that object still and that is why you have free methods or functions whose purpose is to get rid of objects that are null

#

There is objective c but its slightly different

flint coyote
#

What if I want to set null as a placeholder on a new variable in C?

#

Or isn't that of use there?

#

Like you would set a variable in java to null before running a try that sets its value. Or a loop.

#

Isn't that a thing in C?

wet breach
#

You have what is called defaults or empty values

#

But c is more functional programming then it is object programming

hazy parrot
#

Yeah you can't set null to variable which is not pointer

wet breach
#

So that being the case typically you create your variables when you need them and they only stay as long as you need them

hazy parrot
#

As null is basically defined as 0 in c and cpp

wet breach
#

But yeah usage of null is more strict in c and cpp in that you dont use it unless you are done with that thing

flint coyote
#

I see. Thanks for the explanation

wet breach
#

Java is more about keeping you safe and thus isnt as strict with it

#

C and cpp dont care about safety and you know you made a mistake because everything is hitting the fan without warning

sour folio
#

I have the economy api installed, can someone give me a basic code on how I would give money to a player in an external class

wet breach
#

Java isnt script and not entirely sure what you mean external class

sour folio
terse ore
#

any post on spigot on how to configure a bungeecord properly?

eternal oxide
#

yes

humble tulip
#

?di

undone axleBOT
merry viper
#

can i dm you to show you the problem i has in ss? becasue i cant upload images

eternal oxide
#

?img

undone axleBOT
eternal oxide
#

!verify

undone axleBOT
#

Usage: !verify <forums username>

merry viper
#

oh i get verifed?

#

oh

#

!verify Derpy_Engineer

undone axleBOT
#

This account is already verified!

quaint mantle
merry viper
#

oh right

merry viper
#

my old acc was disabled

terse ore
#

being in the lobby

merry viper
#

how i removing that text that i mark?

https://prnt.sc/f9FV0eoGXrKX

        if(message.contains("[item]")) {

            message = "<" + player.getDisplayName() + "> " + message;

            String[] parts = message.split("\\[item\\]", -1);

            BaseComponent[] messageComponents = new BaseComponent[0];

            for (String part : parts) {
                TextComponent textComponent = new TextComponent(part);

                ItemStack itemStack = player.getInventory().getItemInMainHand();
                if (itemStack.getType() != Material.AIR) {
                    ItemMeta itemMeta = itemStack.getItemMeta();
                    if (itemMeta != null && itemMeta.hasDisplayName()) {
                        TextComponent itemComponent = new TextComponent(ChatColor.DARK_GRAY + "[" + ChatColor.YELLOW + itemStack.getAmount() + "x " + ChatColor.RESET + itemMeta.getDisplayName() + ChatColor.DARK_GRAY + "]" + ChatColor.RESET);
                        BaseComponent[] hoverTextComponents = getItemHoverTextComponents(itemStack);
                        itemComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverTextComponents));

                        messageComponents = TextComponentUtil.append(messageComponents, itemComponent);
                    }
                }

                messageComponents = TextComponentUtil.append(messageComponents, textComponent);
            }

            for(Player p : plugin.getServer().getOnlinePlayers()) {
                p.spigot().sendMessage(ChatMessageType.CHAT, messageComponents);
            }

            event.setCancelled(true);
        }
storm scaffold
#

Is there a way to access ticked entities to perform actions on them randomly? e.g. to make goats regrow horns like sheep regrow wool - is there a less laggy way to do it than looping all players and all nearby entities?

quaint mantle
#

GOOD MORNING GUYSS

#

actually my time 14:44

zealous osprey
#

heya, I wanted to ask if there's a way to call a function like String.format(...) in an annotation. All values that are parsed in are constant values, I just want the method to format it more neatly.
Otherwise I'd need to do smth like: Class.someConstantStringValue + " " + Class.someConstantStringValue + " " + Class.someConstantStringValue

scenic onyx
#

how i get Player Location with bungeeecord?

eternal oxide
#

Bungee has no idea what a Location is

scenic onyx
agile anvil
#

Send request to get from the backend server

#

From backend send location to bungee

#

From bungee receive

agile anvil
scenic onyx
#

can you give me a example

zealous osprey
eternal oxide
scenic onyx
eternal oxide
#

Doesn't answer the question

#

Why do you need the players location in your bungee plugin?

zealous osprey
#

sadge

agile anvil
worldly ingot
#

Right. I think you're misunderstanding what a bungee plugin actually is. Bungee is the proxy. It has no knowledge of what actually happens on the world of a server. It's just a way for players to be sent from one server to another behind the same proxy.

#

If you want world information, you need to have some server plugin that sends it to the proxy. But at that point... just write a server plugin

agile anvil
scenic onyx
agile anvil
#

What's a SS?

worldly ingot
#

Create a what? aPES2_WTF

agile anvil
#

Oh

#

Please no

worldly ingot
#

Listen, man. 1940s Germany tried that and failed

scenic onyx
agile anvil
#

Then it shouldn't definitely be on the proxy

worldly ingot
#

Yeah, that's a server plugin

scenic onyx
eternal oxide
#

we still have no idea what SS is

scenic onyx
eternal oxide
#

oh screen share

#

Why are you making a plugin which already exists and is open source?

agile anvil
#

All the functions are literally server side or am I missing smth ?

scenic onyx
#

yessss

scenic onyx
eternal oxide
#

EnderSS is open source, just fork it and contribute

scenic onyx
agile anvil
#

Fact is: you'll still have to do a server side plugin in anyways if you want to act on the player in world

scenic onyx
eternal oxide
#

I see it's not really a screen share, it's allowing an admin to take over teh players connection and operate as if they were logged in as that player

quaint mantle
#
                    if (e.getAction() == Action.RIGHT_CLICK_AIR && item1.getType() == Material.IRON_HORSE_ARMOR && itemd1.getCustomModelData() == 1){
                        Block tblock = player.getTargetBlockExact(5, FluidCollisionMode.ALWAYS);
                        if (tblock != null && tblock.getType() == Material.WATER) {
                            itemd1.setCustomModelData(2);
                            world.playSound(block.getLocation(),Sound.ITEM_BUCKET_FILL_LAVA, SoundCategory.BLOCKS, 5,2);
                            world.playSound(block.getLocation(),Sound.ENTITY_SQUID_AMBIENT, SoundCategory.BLOCKS, 5,2);
                            item1.setItemMeta(itemd1);
                            Bukkit.broadcastMessage("test");
                        }
                    }``` i used this
#

still can't find anything

#

what can i click water

#

i try with item material.glass_bottle

#

vcs glassbottle have interact with water

#

but don't worked

#

is this for cauldron ?

agile anvil
flat crescent
#

Some plugin for crates keys or /pv 1/2/3

flat crescent
#

I'm starting to create my server but I can't find good ones for the version to 1.19.2

agile anvil
quaint mantle
#

ah sry mb

#

I've tried already

quaint mantle
eternal oxide
#

teh code from yesterday was fine

quaint mantle
#

but only works if i click block in water

eternal oxide
#

show that old code again, it shoudl work without a target

quaint mantle
#

w8

#
                    if (item1.getType() == Material.IRON_HORSE_ARMOR && itemd1.getCustomModelData() == 1) {
                        if (e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR) {
                            List<Block> los = e.getPlayer().getLineOfSight(null, 5);
                            for (Block b : los) {
                                if (b.getType() == Material.WATER) {
                                    Bukkit.broadcastMessage("test");
                                    break;
                                }
                            }
                        }
                    }```
quaint mantle
#

tried again

#

can i use this ?

#

does not see water as a block

eternal oxide
#

one sec I'm going to test

worldly ingot
#

Anything prefixed with LEGACY_ you should avoid

eternal oxide
#

yes don;t use legacy, you have an api version set

quaint mantle
#

can i use two version with api ?

#

i mean for to use stationary water

eternal oxide
#
@EventHandler
public void onInteract(PlayerInteractEvent event) {

    if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) {
        List<Block> los = event.getPlayer().getLineOfSight(null, 5);
        for (Block b : los) {
            Bukkit.broadcastMessage(b.getType().name());
        }
    }
}```
#

works just fine, detects water with no block targeted

quaint mantle
#

is this not for cauldron ?

eternal oxide
#

teh above code works just fine

quaint mantle
worldly ingot
#

Cauldrons are a different condition. You would need to check for water cauldrons

eternal oxide
#

yes that was looking into deep water

worldly ingot
#

And for waterloggable blocks, you'd have to check block data

quaint mantle
#

oke i will try levelled

eternal oxide
#

he is tryign to detect water block when looking into deep water, or he was yesterday unless something has changed

#

are you no longer trying to fill your watercan in deep water?

quaint mantle
#

yes i try

eternal oxide
#

So you ARE trying to fill your watercan just looking into deep water? Then that code from yesterday as I just posted works fine.

quaint mantle
#

wait i will give video again

eternal oxide
#

I just showed you it working

#

that exact code I just posted

quaint mantle
quaint mantle
eternal oxide
#

THAT exact code I just posted, looking into deep water with no target block. It works

quaint mantle
#

but

#

wait

eternal oxide
#

you on 1.19.4?

quaint mantle
#

no 1.16.5

quaint mantle
#

my code do this without equals

worldly ingot
#

I think the issue is that right clicking a non-block with horse armour doesn't actually call an event

eternal oxide
#

sedc I'll check with horse armour

eternal oxide
#

I used a stick

worldly ingot
#

Right but glass bottles actually have a right click action

quaint mantle
#

let me give a time

#

i try levelled

eternal oxide
#

works with horse armor

worldly ingot
#

Without looking at a block? Just water?

#

Shallow water, that is?

eternal oxide
#

deep water

#

no target block, just looking into deep water

worldly ingot
#

Then yeah. Unsure what the issue is

eternal oxide
#

I'll test it on 1.16.5

#

have to buidl spigot, don;t have that version at teh moment

quaint mantle
#

wait i tried ur code

#

and im confused

eternal oxide
#

my code exactly as shown works using horse armor

#

My bet is your code is a spiders web and it's never reaching the correct test

#

no need

#

no thats the point

quaint mantle
#

i was try

eternal oxide
#

he's trying to click on NO block, just water

#

so he has no target block

#

there is no block

#

no theres not

#

when there is no targetable block in click range it's treated as a click on AIR

#

You just tested using my exact code and it detected water

#

that video is not using my exact code

#

my code detects water no matter if you have a target block or not.

#

add debug

#

very first line

quaint mantle
#

i was think

chrome beacon
eternal oxide
#

you are only allowing it in if you clicked a block

quaint mantle
#

yes i was think omg

worldly ingot
#

This is why context matters and we ask for whole snippets KEKW

eternal oxide
#

This is why you should post the code you are actually using, not code you think you are

quaint mantle
#

but i think
Count the last actions done in java

#

I FEEL STUPID

eternal oxide
#

also if (block != null) { you are only allowing the code to run if a block is clicked

quaint mantle
#

alright i try to fix my code

#

i need create new player interact event for water

#

?

eternal oxide
#

why?

quaint mantle
#

or

#

if i create new interact event
Will it overwrite my old code?

eternal oxide
#

no they both run

vast ledge
#

no

#

both run

#

like elgarl said

quaint mantle
#

and so i don't need use loop for control water now ?

vast ledge
#

no?

eternal oxide
#

what?

vast ledge
#

i dont understand

#

why would you loop

#

how

#

what is control water?

eternal oxide
#

you have two functions for your object...

quaint mantle
#

oke i try something

eternal oxide
#

if it has water and you click on farmland, you set the land watered and empty the can.
if it doesn't have water you should see if you clicked looking at water and fill it.

#

also instead of nesting if statements you shoudl early exit

quaint mantle
eternal oxide
#

and ignore if clicking a block later

quaint mantle
#

bcs i got this warnings

#

u guys said don't but i wonder how can i fix this warnings ?

tawdry echo
#

nullable

eternal oxide
#

teh code to fill teh watercan needs to not care if a block was clicked. Watering land needs a block

late sonnet
#

yep like show @tawdry echo that method is annotated with Nullable then can return null.

hazy parrot
# quaint mantle

@SuppressWarnings("ConstantConditions") if you sure it will never be null

#

if it may be null, add check

quaint mantle
#

alright ty gys

eternal oxide
#

why are you requiring an item in both hands?

#

oh either or?

quaint mantle
eternal oxide
#

?

quaint mantle
#

player.swingmainhand
player.swingoffhand

eternal oxide
#

you only ever do checks on item2 but you allow that code to run if item2 is null

quaint mantle
#

i has video

eternal oxide
#

if (itemd1 !=null || itemd2 != null) {

quaint mantle
#

see if horse armor in offhand

eternal oxide
#

item2 could be null

quaint mantle
#

my mainhand swinging

worldly ingot
#

PlayerInteractEvent has the hand used to interact iirc

quaint mantle
#

u mean e.getitem ?

worldly ingot
#

No, e.getHand()

#

But yes, e.getItem() as well

#
ItemStack itemStack = event.getItem(); // Check this for the horse armour

if (event.getHand() == EquipmentSlot.HAND) {
    player.swingMainHand();
} else {
    player.swingOffHand();
}```
quaint mantle
#

i will do with e.gethand

#

yep

#

ty

eternal oxide
#

your code is such a mess, sorry. You do the same thing if your model data is 1 or 2

#

which is the empy can, 1 or 2?

quaint mantle
#

1

eternal oxide
#

so you can only water if its 2

quaint mantle
#

yes i saw

#

fixing

#

and i do with e.getitem

vast ledge
#

t

quaint mantle
#

u

regal scaffold
#

Any AWS users here?

quaint mantle
#

aws is amazon servers ?

#

@eternal oxide

#
    @EventHandler
    public void fillWateringCan(PlayerInteractEvent e) {
        if (e.getAction() == Action.LEFT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR) {
            ItemStack item = e.getItem();
            if (item == null) return;
            ItemMeta itemd = item.getItemMeta();
            Block block = e.getClickedBlock();
            if (block != null && itemd != null){
                if (item.getType() == Material.IRON_HORSE_ARMOR && itemd.getCustomModelData() == 1 &&
                        block.getType() == Material.WATER){
                    World world = block.getWorld();
                    itemd.setCustomModelData(2);
                    world.playSound(block.getLocation(), Sound.ITEM_BUCKET_FILL_LAVA, 5, 2);
                    item.setItemMeta(itemd);
                    Bukkit.broadcastMessage("test");
                }
            }
        }
    }```
#

my syntax is good now ?

eternal oxide
#

no you are still requiring a block

#

and you are not searching for water

flat ruin
#

is <FileConfiguration>.getConfigurationSection ment for doing this?:

  - list item 1 <- scans to see if item is in the list with .getBoolean()
  - list item 2```
or am I misunderstanding something
quaint mantle
tardy delta
#

no

eternal oxide
#

?paste

undone axleBOT
tardy delta
#

thats a getList()

#

section is

xyz:
  a1
  a2```
flat ruin
#

oh I see

#

thank you, still new to this

eternal oxide
tardy delta
#

dan discord fixed pressing tab

tardy delta
#

smh always fun wheen youre working on a vm, it randomly powers off and you dont know the passwd

eternal oxide
#

12345

#

password

tardy delta
#

i will never get used to vmware

#

had 9 vms open (network architecture) and two hours later, two were gone

vast ledge
#

Would this still work or would it commit unalive?

river oracle
#

You're not doing that sync right??

vast ledge
#

the profile writing is async

remote swallow
#

the mongo stuff

#

as long as thats async it shouldnt die

eternal oxide
#

use teh AsyncPlayerLoginEvent

vast ledge
#

The Profiles are also saved in a hashmap until server restart

tardy delta
#

orcs player join event?

vast ledge
#

ocs**

tardy delta
#

orsosilrcore

vast ledge
#

ocsolircore

tardy delta
#

wait

quaint mantle
#

@eternal oxide why u don't use "||" equal at here ?

vast ledge
#

|| means

quaint mantle
#

yep ?

vast ledge
#

that thres another option

#

so if first is wrong

tardy delta
#

go google for or and and

vast ledge
#

and second is write

#

correct*

#

it will still execute

#

a way to have mutliple ifs in one if

quaint mantle
#

ah alright

eternal oxide
remote swallow
#

you check that its not what you want and return

quaint mantle
#

oke

vast ledge
#

Or should i terutn a runnable

#

ic oculd also just have it execute that

#

thats probably simpler

remote swallow
#

futures be like

tardy delta
#

just block the async player pre login event

#

but ew why not returning a lambda

vast ledge
#

I forgot how to execute a runnable 💀

tardy delta
#

.run()

vast ledge
#

found it

tardy delta
#

just look at the impl

remote swallow
#

iirc the deafault runnable impl doesnt have a way for async

#

default

vast ledge
remote swallow
#

use bukkit runnables or futures

#

futures are better

tardy delta
#

you say

vast ledge
#

I dont want to read on them tho 😠

remote swallow
# vast ledge

bad, if you are doing that new BukkitRunnable() {}.runTaskAsync

tardy delta
#

love it how this channel is like "hey i got a question" and five people say ten different things

remote swallow
#

if you still want to use Bukkit.getScheduler() use lambda

#

read this

echo basalt
#

ping

remote swallow
#

oh yeah

#

that happens doesnt it

vast ledge
#

Happy with ur lambda?

remote swallow
#

yeah

vast ledge
#

I must say, i havent used lambda before but i like it, it looks alot more clean

remote swallow
#

lambdas are nice

wise mesa
#

Is there a way to get an offline player by name without doing a blocking web request

remote swallow
#

@echo basalt are you doing anything atm

wise mesa
#

Like for example just using the last name they had on this server

echo basalt
#

not rly

wise mesa
zealous osprey
echo basalt
#

it does check the local file cache

remote swallow
echo basalt
#

fml sure

#

bit weird to explain but sure

wise mesa
#

Oh I guess I could just make a (yml) database of the name of every player who joins and their uuid

echo basalt
#

I should probably just make a uuid cache repo on git

#

did it once at work

remote swallow
zealous osprey
vast ledge
wise mesa
#

Wdym dawg

#

It’s just a list

echo basalt
#

fuckin

vast ledge
#

Thats what i said

#

use binary

wise mesa
#

Idk man because I’m lazy

echo basalt
#

Illusion Search Index - Lambdas

Lambdas in java are incredibly useful but a bit tough to learn. This guide aims at simplifying the concept so it's a little easier to understand.

The backbone of lambdas are interfaces. An interface can be seen as a sort of "template" of a class, with no implementation. It represents a schema that
must be overriden and implemented accordingly.

Lambdas in turn, create an anonymous temporary class that implements the required interface given it has one and only one method requiring implementation.

Let's break down the Runnable interface: void run();
The main points of interest are:

  • The return type: void
  • The parameters (empty in this case)

Now, facing a method that requires a Runnable parameter, we're faced with three choices:

  • Create a class that implements Runnable, override its method and create a new instance
  • Create an instance of an anonymous class, overriding its method
  • Creating a lambda (shortened version of the method above)

Let's assume we have this interface:

public interface MessageSender {
  
  boolean sendMessage(Player player, String message);

}

We start by creating a lambda expression, with the given parameters and return type:

MessageSender implementation = (player, message) -> { // parameters
    player.sendMessage(message);
    return true; // return type (boolean in this case)
};

This is a valid replacement to either:

MessageSender implementation = new MessageSender() {
    @Override
    public boolean sendMessage(Player player, String message) {
        player.sendMessage(message);
        return true;
    }
};

or

public class SampleMessageSender implements MessageSender {

    @Override
    public boolean sendMessage(Player player, String message) {
        player.sendMessage(message);
        return true;
    }
}

You can embed lambdas directly as any other variable, without the need to specify it's a new instance of a class.

Edge-case scenarios:

  • When dealing with a single parameter, the ()'s are irrelevant (Example: player -> player.sendMessage("Hi");)
  • Braces are optional if you're doing one-liners
  • When dealing with a method that matches your exact parameters and return type, you can use the :: syntax (Example: this::sendMessage)
wise mesa
#

And ymlconfiguration is easy

eternal oxide
#

lol json is a subset of yaml

wise mesa
#

And I’m going to have like 15 players on this server

vast ledge
wise mesa
#

So it really doesn’t matter

subtle folio
#

Use JSON

wise mesa
#

If I had 100 players it might matter more

#

I’ll probably use json though

eternal oxide
#

no difference in using yam or json for data, only yaml is better human readable

vast ledge
#

Is there a way i can Pass variables into a task?

subtle folio
#

Json is faster..?

eternal oxide
#

no

echo basalt
#

I mean

subtle folio
#

I thoguht it was hang on

wise mesa
#

Maybe for saving and reading

echo basalt
#

reading json is easier than reading yml

wise mesa
#

But it’s not like I’m reading it every time I need a players uuid

echo basalt
#

because it specifies when a block ends instead of converting indentation

vast ledge
#

I NO LIKE FUTURE

eternal oxide
#

yaml is must easier to read than json, for an end user

wise mesa
#

Im just going to store it in memory

#

And read it at startup

remote swallow
#

you can run stuff when they complete like notify a player

wise mesa
#

Futures are awesome

subtle folio
vast ledge
#

Futures seem complicated, and my 2 braincells cant comprehend

subtle folio
#

json is 30x faster

keen ferry
#

How do I get the server ip from code?

eternal oxide
wise mesa
vast ledge
wise mesa
#

As they are the two things most spigot users used

vast ledge
subtle folio
#

gson is a wrapper for json..

wise mesa
#

Now he’s just joshin

cobalt thorn
#

Hi if i use crontab for running a task every monday it should work even if the server goes down a day before and run it as should be?

wise mesa
eternal oxide
wise mesa
#

And it needs to be benchmarked on its own

subtle folio
#

Why is optic recommending yaml config over json

vast ledge
eternal oxide
#

because it's readable to the end user

subtle folio
#

its slow af

eternal oxide
#

not for a config

quiet ice
vast ledge
wise mesa
subtle folio
eternal oxide
#

a coinfig consists of infewequently changing data

subtle folio
#

not make a config

vast ledge
#

Yea

wise mesa
#

Well anyways

vast ledge
#

JSON is better

wise mesa
#

Speed doesn’t really matter

#

Because I’m storing it in memory

eternal oxide
#

if it's infrequently changing then the only thign you need to decide is if you have to serialize or not

vast ledge
#

But efficienty

wise mesa
#

And only saving infrequently and reading once during startup

quiet ice
#

For storing data I have my own solution then: DataOutputStream/DataInputStream

subtle folio
#

you're saving it in memory.. then reading it during statup

eternal oxide
#

If the end user needs to read/edit it then yaml, if it it not to be edited by hand then json

subtle folio
#

after the memory is cleared..?

eternal oxide
#

if it uses Bukkit objects yaml

wise mesa
vast ledge
wise mesa
#

Im not reading the file every time I need to get a user is the important part

#

I read it during startup

#

And save when a user is added

vast ledge
#

Why not add the user to cache and write onshutdown

subtle folio
#

^

wise mesa
#

Because servers crash from time to time

eternal oxide
#

what kind of data do you need for this player?

subtle folio
#

onDisable still gets called during a crash,

wise mesa
#

And new users join very infrequently because like I said my server had like 15 players

subtle folio
#

I think

vast ledge
#

yea

subtle folio
#
  • if ur server crashs, that should be a bigger issue..
eternal oxide
#

depending on what you need for the player you may not need a database at all

vast ledge
#

Ye, if u only want the name

#

idk why

#

just use uuids

#

then you can save in file

eternal oxide
#

even simple data can be thrown in the players PDC

#

saves in the players dat file

vast ledge
#

I only use a database when the data is shared across multiple servers

#

Or when its just alot of data like a Rank, there Level, and other stuff

eternal oxide
#

spigot should add a PDC access for offline players

remote swallow
#

yes

eternal oxide
#

not hard to do

remote swallow
#

coll did it a while ago but didnt pr it iirc

vast ledge
#

Could you not manually do this, by navigating to the folder and reading from the files?

eternal oxide
#

yes

#

but if it were available via the OfflinePlayer Object it would be so nice

#

land ownership plugins would become so simple

sour folio
#

How do i make a command work but not show up in that autofill box?

eternal night
eternal oxide
#

I've seen implementations

eternal night
#

yea, none really complete

#

or like, bullet proof for dummies

eternal oxide
#

mostly because they tried to do all nbt not just PDC

zenith gate
#

?paste

undone axleBOT
zenith gate
undone axleBOT
echo basalt
#

there you go @remote swallow

vast ledge
echo basalt
#

what's next? Interfaces and abstract classes?

remote swallow
#

whatever u feel like KEKW

echo basalt
#

I've also edited the future guide to reference this one

#

I'm gonna start charging 20 bucks for custom guides this is getting annoying

zenith gate
echo basalt
#

I've been trying to fucking hard to keep the search index immaculate

#

delet this pepe_guns

echo basalt
#

@ivory sleet 20 bucks

torn shuttle
#

@echo basalt btw that'll be 2k usd for the guide on magmaguy

flat ruin
#

apparently, <player>.sendMessage has been marked as obsolete, what's the new one to use? Context is a PlayerInteractEvent

sour folio
echo basalt
flat ruin
#

lmao

echo basalt
#

also you mean Player#sendMessage

#

yeah it's deprecated because of paper

flat ruin
#

wicked

torn shuttle
echo basalt
#

yeah they're clowns

flat ruin
#

¯_(ツ)_/¯

echo basalt
flat ruin
#

thats the only way I know of

#

to send a message to a player without

echo basalt
#

they want you to wrap it in a component

flat ruin
#

but why

#

its an event

echo basalt
#

¯_(ツ)_/¯

flat ruin
#

editor: THIS SHIT IS DEPRECATED
me: ok and

eternal oxide
flat ruin
#

dang no embed

#

:(

echo basalt
#

not verified

eternal oxide
#

why not just NOT give the command permission to those should should not be using it?

flat ruin
#

oh

zenith gate
#

can namespacekeys have underscores or capital letters?

echo basalt
#

underscores pretty sure they can

#

capitals I don't think so

eternal oxide
#

no capitals

echo basalt
#

[a-z0-9/._-]+

#

if you know regex then you're good

echo basalt
flat ruin
#

lol

echo basalt
#

or just be me and take a 30 minute regex course

#

back in 2020

flat ruin
echo basalt
#

you gotta wait for the bot to do its thing

flat ruin
#

I think its because my old account got hacked

echo basalt
#

or actually

#

since you switched accounts just ping choco or something

flat ruin
#

ok

fluid river
#

jree

#

fava

quaint mantle
#

i was afk

#

i will do water farmland at other fun

#

i need add returns to last ifs ?

eternal oxide
#

no

#

you just need to put your code to water teh farmland where the comment says

flat ruin
#

how the fuck are you sposed to color messages?????????????????????????

eternal oxide
#

Components have color

eternal oxide
#

but this is not a Spigot issue

flat ruin
#

we are just memeing lol

#

I'm using the deprecated method

#

¯_(ツ)_/¯

eternal oxide
#

Not in spigot

flat ruin
#

ok

eternal oxide
native ruin
#

beds have 2 parts just add both

eternal oxide
#

place top half, set facing, get other half, change to bed and setPart

echo basalt
#

it's bed as well

#

just a different state

eternal oxide
#

depends on facing and part

#

use BlockData

#

Material.BED.createBlockData()

native ruin
#

googled "spigot place a bed" and got several results

quaint tapir
#

thanks

native ruin
#

maybe check em out

quaint tapir
#

but thanks anyways

#

i'll try this method

sour folio
#

why is the run button grey?

echo basalt
#

you don't have like auh

#

profile

#

configuration

sour folio
echo basalt
#

depends on your goals

sour folio
echo basalt
#

yeh sure

sour folio
#

ty

agile anvil
#

It could be literally anything

eternal oxide
quaint tapir
# eternal oxide use BlockData

block.setType(Material.RED_BED.createBlockData( Bed.Part.FOOT ));
I'm probs being stupid but I'm still having issues with setting a bed
could you give example code of how to set the head and foot of the bed

quaint mantle
#

is my code fine ?

eternal oxide
#

no

quaint mantle
#

yes i see

#

i got error in console

eternal oxide
#

|| e.getClickedBlock().getType() != Material.FARMLAND

quaint mantle
#

ah yes thx

eternal oxide
#

your logic is not good. You should allow watering on any moisture level that is not zero

quaint mantle
#

i understandd

#

ahhh im shamingg omg

lucid gazelle
#

what's the best way of storing some data in a block? i don't care about it being persistent, its only temporary data

carmine mica
#

just create some sort of map from either a location, or a key to a location to whatever data you want to store then

lucid gazelle
quaint mantle
#

ah understood

lucid gazelle
carmine mica
#

how often is that happening on your server?

lucid gazelle
lucid gazelle
#

crystal pvp, anchor pvp

#

it all happens a lot

carmine mica
#

probably not enough to worry about changing a map

lucid gazelle
#

even on 100 player events?

carmine mica
#

a tick?

lucid gazelle
#

no i meant like

#

100 player count

#

and event as in ingame events, not the spigot ones

carmine mica
#

yeah, I don't think you're gonna run into performance issues with something as simple as this

#

you might want to set a max size for the map tho, so it doesn't get too large with they key size

lucid gazelle
carmine mica
#

like how are you removing stuff from the map

#

the metadata map just uses a map behind the scenes

#

so you could use it sure

#

but you still have to remove the values, just like map

lucid gazelle
#

the keys won't be removed when the block is removed?

carmine mica
#

no

#

the "block" is just a wrapper for a location really

#

it just holds a world and a position, and any method calls on it fetch the blockstate at that position in the world

#

so there's no concept of "breaking" that it is aware of

lethal coral
#

I'm not sure how to implement it well

west pollen
#

how do i play with my friends without port fowrwing

twin venture
#

Hello i have a question why this does not work ?

#

entity == player .

west pollen
#

thank you

lethal coral
#

then cast to LivingEntity

#

because LivingEntity has that method because it implements Attributable

#

not entity

twin venture
lethal coral
#

now you gotta use target instead of entity

twin venture
#

i tried

lethal coral
#

player is already livingentity

#

so no need to make a new variable

twin venture
#

well i tried but i still get this error ,-,

lethal coral
#

yes

#

0.chance is fine

eternal oxide
#

numbers as keys in configs are troublesome

twin venture
#

it just not works

#

no import

#

its like the method does not exist ..

shadow night
#

I'm not even sure if I can ask for help with almost the same thing the third day in a row 💀

twin venture
#

someone told me i need to use LivingEntity ..

lethal coral
hasty prawn
#

Doing event logic with Monitor priority NotLikeThis

lethal coral
#

well if I was going to follow the enum route like I was going to originally

#

I would have to create an interface for enum commonality

hasty prawn
#

@twin venture what version of Spigot are you on

lethal coral
#

a core

#

for my servers

twin venture
#

1.19.4

lethal coral
#

it would be handled in the main plugin of the server that's in communication with the core

hasty prawn
# twin venture 1.19.4

Your IDE is depending on 1.19.4 too right? Player#getAttribute and Player#getPotionEffect should both exist.

lethal coral
#

but I also want the core to have a base enum for ranks like staff ranks

#

you're telling me to do what I want to do essentially

#

not how to go about doing it

#

😐

pseudo hazel
#

whats the issue with using an enum

lethal coral
#

how would I go about permissions

#

🤨

pseudo hazel
#

I would just have permissions for each rank or whatever

#

and then just using those

#

maybe putting in an enum to easily compare ranks or whatever

#

if thats what you mean by using an enum

lethal coral
#

I thought about having like a rank hierarchy with an integer of permission level or whatever

pseudo hazel
#

yes thats fine

lethal coral
#

but then in every command I would have to check that when in my command system I already have it checking for the permission stuff

pseudo hazel
#

well then why check it again

lethal coral
eternal oxide
#

you add the permission on the command in plugin.yml. It then gets checked automatically

lethal coral
#

no

#

I'm not using the plugin.yml for the commands

worldly ingot
#

Well see that's your first mistake lol

eternal oxide
#

thats your first error then

lethal coral
#

no it is not

#

what I'm getting at is

#

if I'm already doing all this shenanigans in an enum

eternal oxide
#

use the API correctly and 90% is done for you

lethal coral
#

it feels a bit silly to have the permissions in a config file

eternal oxide
#

its not a config file

lethal coral
#

bro you are literally not following along

eternal oxide
#

its a plugin description file

lethal coral
#

it's for the permissions on each rank

#

storing the permissions that each rank has access to

#

then assigning them via the rank system

#

I did read it

#

it tells me how to set permissions using the api

#

that's not my problem

eternal oxide
#

ranks and permission groups are what permission plugins are for

lethal coral
#

I'm not having that problem????

pseudo hazel
#

I still dont get how using an enum adds double work

#

can you provide a code example?

lethal coral
#

ok how the fuck are you guys confused

#

let's start again

#

so I'm creating a rank system right using enums

pseudo hazel
#

yes

eternal oxide
#

another mistake

#

hard coded ranks

lethal coral
#

what are you talking about dude

pseudo hazel
#

just ignore him

lethal coral
#

it's for my server

eternal oxide
#

an Enum is fixed at compile time

lethal coral
#

YES

#

ok moving on

eternal oxide
#

so hard coded

lethal coral
#

that's how an enum works

eternal oxide
#

Exactly what I just said

lethal coral
#

and since in the enum I'm going to define data like

torn shuttle
lethal coral
#

rank color

#

etc.

#

it seems like it would make sense to handle permission stuff there

pseudo hazel
#

then also define a list of permissions for each rank

torn shuttle
#

man making these have modular decoration elements is a pain

lethal coral
pseudo hazel
#

idk

#

what do you call ugly

#

thats the best way

lethal coral
#

you're right I need to be more inclusive

#

🚎

#

do you have any alternatives

#

other than

#

luckperms

pseudo hazel
#

its either ugly or you dont use an enum and add way more code around it

lethal coral
#

I'm saying like alternative ideas

#

not plugins

eternal oxide
#

why not luckperms?

lethal coral
eternal oxide
#

Simple question

lethal coral
#

you clearly are the kind of person who wants me to use pre-existing stuff

#

which is not what I want to do

eternal oxide
#

you are literally tryign to do everything a permission plugin does, hard coded IN your plugin

lethal coral
#

because it's for my network

#

🤯

eternal oxide
#

doesn;t matter

hazy parrot
lethal coral
#

it does matter

lethal coral
eternal oxide
#

if you want to make ANY changes you have to recompile, just to change a colour setting or permission

lethal coral
#

bro why do I need to be interrogated on why I'm doing something

#

this is not why I came here

hazy parrot
#

Gl with that attitude

pseudo hazel
#

its fine to start out using an enum

vital sandal
#

for some reason now I got it harder to join my localhost server
I keep getting the error of Authentic Server?

lethal coral
eternal oxide
#

We are trying to disuade you from re-inventing the wheel when it's a pointless task

pseudo hazel
#

like I said, if you want an enum, I would save a list of strings alongside each rank

#

if didnt use enums I would do that too i guess

lethal coral
pseudo hazel
#

and then just have a method like hasPermission etc..

#

I wouldnt make an interface but thats another way I guess

lethal coral
#

so you think each rank should be its own class?

pseudo hazel
#

well assuming each rank will just have different properties

lethal coral
#

I mean if I'm storing permission data it would be less ugly that way

pseudo hazel
#

an interface is kinda annoying since you are just using a slurry of getters

#

I would just create instances of a rank for each rank you have or something

lethal coral
#

I don't want a command in-game to create ranks or whatnot though

#

I just want it to be done

#

so everything is final

#

no

pseudo hazel
#

the best way is to make a config for it

lethal coral
#

experience

#

problem solving

eternal oxide
#

no, hard coding is easy

lethal coral
#

this wouldn't even be in question if my command system didn't already utilize regular permissions

shadow night
#

Uh, what does that mean?

[19:41:42 WARN]: Excessive velocity set detected: tried to set velocity of entity #378 to (6.574896471116735,-2.4675344695432244,-3.9350362178400293).
[19:41:42 WARN]: java.lang.Exception: Stack trace
[19:41:42 WARN]:     at java.lang.Thread.dumpStack(Thread.java:1341)
[19:41:42 WARN]:     at org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity.setVelocity(CraftEntity.java:213)
[19:41:42 WARN]:     at me.andreasmelone.gunstop.GunEvents.onPlayerShoot(GunEvents.java:69)
``` (Code: <https://github.com/RaydanOMGr/GunStop/>)
lethal coral
#

I would just make a rank priority system and be done

eternal oxide
#

you can store multiple values under an enum key

#

enums are not just keys

lethal coral
#

I would just have an enum like originally planned

#

but in my command system I already handle not having the permission in subcommands and whatnot

#

RANKS

eternal oxide
lethal coral
#

permissions has to do with both

#

ranks have permissions

#

commands require permission

pseudo hazel
#

well then you need to adjust your command system to use the rank enum

lethal coral
#

we're not going back to this

lethal coral
#

vine boom

#

not really

#

experience with hard coding

#

👍

#

ok no but like

#

the ranks are literally never going to change

#

ever

#

so it makes sense to have them finalized in this scenario

#

which is why I was opting for an enum

eternal oxide
#

yeah I remember devs before 2000 never though about the date changing and to use more than 2 digits

twin venture
lethal coral
#

I'm not planning on using other plugins really

pseudo hazel
#

well

#

so what are you asking again?

#

if you are already using another plugin for commands, then there is no way to only have 1 way of permission checking, unless you feed into that somehow

#

at which point you would probably use the enums in a different way

#

but whether or not its an enum can be debated over until the heat death of the universe

#

it doesnt really matter for the rest of the code structure

lethal coral
#

well

#

I suppose I could just like not use the permission annotation

#

and then an enum would be feasible

#

idk why I didn't realize that

#

ok so I'm going to go the enum route and have a rankhandler singleton

#

now I have to do the rank weight

#

thanks steaf

quaint mantle
#

how do i get the perimeter of the block ?

#

wait

#

no i wanna get block around of block

#

ahh

#

i can't explain this wait i will show u with picture

#

example i have sponge block

#

and sponge it will scan the blocks around

eternal oxide
#

for loop -1 +1

quaint mantle
#

how can i get granite?

#

example this is stardew valley
sprinklers watering the around

#

how can i do this i mean which event ?

#

blockform ?

pseudo hazel
#

idk

quaint mantle
#

and i need use scheduler for the moisture farmlands?

pseudo hazel
#

when you want to get the block

eternal oxide
#

when do you want to water?

quaint mantle
pseudo hazel
#

wdym

#

we are talking about at what point in time

#

like all the time?

river oracle
#

Then start a timer task

quaint mantle
#

i don't need event for do this ?

pseudo hazel
#

what event do you want to use

river oracle
eternal oxide
#

if it's farmland you could listen to teh moisture change event and trigger when it goes below a certain level

#

if it's near a watering block

river oracle
quaint mantle
#

ah yes

eternal oxide
river oracle
#

Mmm that's what I meant

#

Phones are a pain