#help-development

1 messages Β· Page 127 of 1

tranquil stump
#

oh like it lets you set the radius for each axis?

echo basalt
kind hatch
lost matrix
#

I dont fiddle with documents. I can literally just create a TypedMongoStorage<UUID, CustomPlayerData> and call save and load on it.
Everything is handled by the codec in the background.

lost matrix
echo basalt
#

I really don't care

lost matrix
#

Its like a sharpened rock when it comes to libraries

echo basalt
#

I write about 100 lines of it and abstract the rest away

lost matrix
#

🀷

echo basalt
#

I kinda hate messing with databases directly

tranquil stump
#
    public void runnable() {
        new BukkitRunnable() {

            @Override
            public void run() {
                World world = getServer().getWorld("world");
                if (world == null) return;
                System.out.println(world.getNearbyEntities(new Location(world, -32.0, 23.0, -194.0), -24.0, 23.0, -201));
            }
        }.runTaskTimerAsynchronously(this, 0L, 20L);
    }

why doesn't this work?

#

Thread Craft Scheduler Thread - 6 - Dune failed main thread check: getNearbyEntities java.lang.Throwable: null

lost matrix
#

You cant use any spigot api from an async task or another thread. None.

tranquil stump
#

I don't get the point of them then if you can barley use them

lost matrix
#

I use them a lot. You'll find a lot of use cases. Just keep on tackling projects with increasing size/complexity.

echo basalt
#

I guess this is slightly better

lost matrix
#

Well... i actually use my own task system. But sometimes i still use them.

echo basalt
#

I have my own scheduler system

tranquil stump
echo basalt
#

just because bukkit's is very ugly

lost matrix
tranquil stump
#

5:12

echo basalt
#
new ScheduleBuilder(plugin)
  .every(15).ticks()
  .run(() -> {
      ...
  })
  .async()
  .during(5).minutes()
  .start()
  .onCancel(() -> {
    ... something else
  });
tranquil stump
#

hes doing async but is using getserver

lost matrix
#

He is only calling getters. Those are mostly fine being called async.

echo basalt
#

TSC's tutorials were nice back in the day

#

I used to get most of my help from his server

lost matrix
tranquil stump
echo basalt
#

I always like knowing what I'm doing which is why I'm writing netty next

lost matrix
echo basalt
#

trolling

#

taskchain actually reminds me a bunch on my old tutorial system

lost matrix
#

Reminds me of a recent quest system i wrote

echo basalt
#

am I tripping or is that kotlin

#

also Β§ codes

lost matrix
#

yeah thats kt

echo basalt
#

my expectations have lowered

tranquil stump
#

is there any real difference from running a task async or not?

lost matrix
echo basalt
#

it runs on a different thread

tranquil stump
lost matrix
echo basalt
#

except what if the assistant is faster than the "master"?

#

you can have desync issues

#

It still has benefits though

#

The "assistant" can chip away at bigger tasks while the master processes smaller, crucial tasks

#

For example, instead of lagging your server with processing chunks, you can make chunk snapshots and let parallel threads process the blocks

#

then have the main thread operate based on the outcome of those parallel threads

#

Or instead of letting your main thread stall for IO, you can make a dedicated thread for it and let your main server actually process stuff

#

But just like training an assistant or explaining the job to them, creating new threads also has overhead

tranquil stump
#

hey so I've got world.getNearbyEntities(new Location(world, -32.0, 23.0, -194.0), -40.0, 23.0, -201) right, but it's picking up on stuff at -44 -190

#

I thought -40 was the boundry

echo basalt
#

no, that's the range

tranquil stump
#

oh

#

wait

#

i think i have stupid

#

hold on

#

ok it works

#

thx

tranquil stump
echo basalt
#

it's useful for unrestricting "traffic"

#

so anything that takes time, like http requests or messing with files can benefit

#

but also just huge amounts of data

tranquil stump
#

but stuff involving actually changing something in-game has to be sync

#

right?

echo basalt
#

mostly yeah

#

there are some things that are fine to do async

#

very little, mostly just methods that send packets directly

#

Chat messages, guis, particles

tranquil stump
#

ok

#

thank you

dim palm
#

whats the best way to prevent NPE with a offline player

quaint mantle
#

check if its null

#

🀯

dim palm
#

okay letme explain

#

im creating a punishment gui for my server

#

but when the player if offline the command throws NPE

#

and i need it to be punished either if the player if offline or online

quaint mantle
thin delta
#

I take it you cannot do a dependency for a private repository in your pom.xml file?

opal juniper
#

iirc you can add username and password stuff

thin delta
#

Eh I'll just do a local jar... It's never getting updated

#

I know its bad practice, but 🀷

opal juniper
#

well, if its OS, yeah it is

#

otherwise why does it matter :)

thin delta
#

true

lost matrix
thin delta
#
        <dependency>
            <groupId>com.CorpseReborn.EaglePrideMC</groupId>
            <artifactId>CorpseReborn</artifactId>
            <version>1.0</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/src/main/resources/CorpseReborn-Acorn.jar</systemPath>
        </dependency>
lost matrix
#

I smell heretic convos

thin delta
abstract sleet
#

aren't drive letters A and B used for floppies

thin delta
#

Yeah, this bad boy is on a floppy

lost matrix
thin delta
#

Gotta keep it safe

abstract sleet
#

yeah its an outdated thing. nevermind. first time I've seen it!

thin delta
#

Halp

lost matrix
#

resources will be copied inside the jar

#

you should not do that

thin delta
#

Oh

#

bad google

#

so whats the thing for workspace?

#

${project.workspace}?

#

Or I guess I can google that

lost matrix
#

id create a folder "dependencies" and then add ${project.basedir}/dependencies/yourdependency.jar

thin delta
lost matrix
#

Oh should be project.basedir

thin delta
#

basedir only does the root for the project

#

Oh, well I guess I can do ${project.basedir}/../

rugged topaz
#

PlayerBucketFillEvent, to get what exactly the bucket was filled with which method do I use?

#

getBlockClicked, getBucket, or getItemStack

thin delta
#

Maybe it just absolutely doesn't want me to use ${project.basedir}

thin delta
#

looks like the correct is ${project.baseUri}

rugged topaz
#

thanks

lost matrix
# lost matrix

If only there was a documentation for such questions...

rugged topaz
#

there sure is

lost matrix
#

but discord is faster

rugged topaz
#

yep

thin delta
#

Nevermind, it doesn't recognize ${project.baseUri}

hybrid spoke
thin delta
hybrid spoke
lost matrix
#

Best practice would be to define a local maven repository in your project and mvn install:file your dependency in it

thin delta
#

I'm a bad boy and am going to just leave it hardcoded 😈

lost matrix
#
<repositories>
    <repository>
        <id>local-maven-repo</id>
        <url>file:///${project.parent.basedir}/project-maven-repo</url>
    </repository>
</repositories>

Then

mvn install:install-file \
    -Dfile=/some/path/on/my/local/filesystem/felix/target/dependency-0.9.0-SNAPSHOT.jar \
    -DgroupId=org.apache.felix -DartifactId=org.apache.felix.dependency \
    -Dversion=0.9.0-SNAPSHOT -Dpackaging=jar \
    -DlocalRepositoryPath=${master_project}/project-maven-repo
thin delta
#

Ok my goodness it looks like I've finally resolved all my dependencies....

lost matrix
#

But meh

thin delta
#

Yeah, I'm gonna be a bad boi

#

I'll sleep now, and try and work with shading tomorrow....

lost matrix
#

All of this wouldnt happen if you wouldnt use some bootleg dependency written by someone that doesnt know how
to support any build tools.

thin delta
#

Well

#

I am that person

#

🀣

lost matrix
#

What? Then you dont need to do any of this

#

Just run install on your other project and then you can depend on it because its installed in your local maven repo

thin delta
#

I was just exporting through native eclipse, but my server blew up when my code used FileUtils

#

And I was using the .jar for commons.io as a java Build Path for my project

faint frost
#

I have some code that displays a scoreboard under the players name. The score board contains each player's "level" if you will. The issue I'm having is; when the player levels up in the menu I made, it will set their level but not update it below their name.

faint frost
hybrid spoke
lost matrix
#

Update it. And add debug messages.

#

Or show some code

faint frost
wet breach
#

if you are not using teams, then you need to update it manually

faint frost
#

im using teams. i think i got it now

lost matrix
#

I really dislike the whole scoreboard api.
I just abstracted away all that nonsense with packets so that
i can use it by simply appending lines and accessing them by index.

faint frost
#

ngl i might cave on reweighting thats just a huge mess tho.

#

i agree

stray halo
#

How can I make a snowball invisible

faint frost
#

i fixed it

#

i smart

lost matrix
stray halo
#

I could do It fine with nms in 1.15/1.16

#

Doesnt seem to work now

lost matrix
#

Why do you need an invisible projectile? Because snowballs can be changed to display any item.

#

You should be able to do this with nms

wet breach
#

what is the purpose of having the projectile invisible ?

stray halo
#

Im creating a sort of magic wand, and i Need the snowball to be invisible cause It has a Trail of particles

wet breach
#

if it was me, I wouldn't make projectiles invisible. I would just do the math to make it look like there is one invisible

#

not like anyone can see it anyways so why have an entire entity consuming resources for this

lost matrix
#

I would def use a virtual projectile for magic

#

always done it that way

wet breach
stray halo
wet breach
#

I would think it would be much easier

#

since you don't have to resort to nms for it

hybrid spoke
#

but does your magic have a curve?

stray halo
hybrid spoke
#

f.e. yes

stray halo
#

Yes It has

#

It follows the snowball, but I can have the snowball going in a straight line with nms

hybrid spoke
#

then just do the maths yourself

#

why waste the resources if you could just do it native

#

and print a line

wet breach
#

all the information you need is available with some research, gravity/weight velocity

#

everything you need to calculate the math yourself

#

without having an entire entity for it

hybrid spoke
wet breach
#

you need gravity for the curve

#

if you want the curve that is

hybrid spoke
#

going in a straight line

wet breach
#

well yeah if you want it to just fly straight gravity isn't needed

stray halo
#

Do you have any link that could help me

wet breach
#

for the relevant numbers to do the math?

stray halo
#

Yeah i Guess so

wet breach
#

give me a bit, in a game and I will grab some links

#

You would probably use the values that are for a fireball since that is what would be similar in regards to a snowball

stray halo
#

Thx

#

How would I detect if this hits a player

#

Or an entity

wet breach
#

you get the trajectory

#

this is where some trig or calculus comes in πŸ™‚

#

you know where the players are at any given time

#

you just have to look at the trajectory of both, do some math and you will know if it should hit or not

#

the reason this is more optimal then spawning an invisible entity, is because all of this math stuff can be done in its own thread that doesn't affect the server

#

where as that spawned entity even invisible, the server has to keep track of it now and everything else

thorn isle
#

Speaking of ballistics

#

I'm trying to figure out the velocity and direction to launch a player in to reach a given target

#

But all of the algorithms I've found ignore drag and hence undershooting at greater distances

torn oyster
#

how would I remove an NMS NPC from the tablist without removing their skin

tardy delta
#

packets

torn oyster
#

i know that

hybrid spoke
#

hide the name

torn oyster
#

what

#
sendPacket(sp, new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER, npc));```
#

i'm using that

#

but it removes their skin

#

too

hybrid spoke
#

oh i thought you want to keep the head texture in the tablist

torn oyster
#

no like

#

remove it from tablist

#

but it still shows in person

#

so how would i do this?

torn oyster
#

doesn't look like it to me

hybrid spoke
#

i said take a look, not copy&paste it

torn oyster
#

wasn't planning on doing that

swift mauve
#

Is there a method to check if the gui was updated?

odd wedge
#

wdym

#

If someone moves something in an inventory?

swift mauve
#

I have this one input slot at 19, and whenever you click next/previous page, the gui updates and the input item gets lost

#

I want to have the input item stay if the gui updates

odd wedge
#

InventoryClickEvent and then cancel the event

pulsar parcel
#

I don't know what is wrong with my code, but my updateperline method is not updating scores in socreboard. I have test if this method is event triggering and this test is positive. I have teams in my scoreboard and I wont to show number of players in team. I also have join command, so I can join to team and I can see myself in team, but in scoreboard still 0. And this method is working because every time it is triggered it print int LOL (idk why LOL) to console. And sorry for my English.
Here is my code: https://pastebin.com/RuHmE0n6

swift mauve
severe marsh
#

Does FileConfiguration#get actually reads the file or?

eternal night
#

no

swift mauve
severe marsh
#

It has its instance fetched?

eternal night
#

Well

odd wedge
# swift mauve

When you open the inventory save the item and place it in the new inventory?

eternal night
#

YamlConfiguration is the only implementation of it rn

#

and it parses the entire file into memory

severe marsh
#

The thing I am wondering is if I use it within move event, will it cause lag

swift mauve
odd wedge
swift mauve
#

this is how I get the tempitem

#

And I tried putting it somehow into this pagination stuff

#

I use an inventory framework btw

#

view line 5, thats what I'm gonna try now

wet breach
swift mauve
#

like look at this i put it everywhere and it won't work

wet breach
#

a custom tablist would probably be the easiest method

odd wedge
swift mauve
#

how could I do what I want to do with basic spigot api then?

torn oyster
#

I don’t wanna do that

#

Is there a different way?

#

I don’t particularly mind if it is more challenging

odd wedge
#
public void onInventoryClickEvent(InventoryClickEvent event) {
ItemStack placedItem = ...;

nextInventory.addItem(placedItem);

player.openInventory(nextInventory);
}
swift mauve
#

I'll try this

#

yea but how to get the nextinventory lol

#

there's no onGuiUpdate() or similar

wet breach
#

in other words accomplish what you seek

odd wedge
#

There are multiple ways

swift mauve
#

Don't do me dirty I started coding plugins a week ago

odd wedge
#

Do you have basic java knowledge?

swift mauve
#

yea

odd wedge
#

I'm not going to spoonfeed you code

swift mauve
#

πŸ’€ rip me

odd wedge
#

Creating a new inventory shouldn't be hard for you

#

You already created one

#

Why can't you create another

swift mauve
#

i use this framework i don't wanna break stuff lol

odd wedge
#

That's on you

#

I don't know what framework you use etc

swift mauve
#

Inventory Framework by stefvanschie if this helps

#

im gonna try around now

swift mauve
#

ik and I already asked on his discord but no answer

#

i don't even know if its possible to code within that framwork

tardy delta
#

wtf have i done

#

copilot kinda helpful tho

#

atleast someone who understands what im doin πŸ₯Ί

river oracle
#

Damn your still working on that?

tardy delta
#

yessir

#

now and then

river oracle
#

Ahh are you parsing just simple stuff or going to do calc level stuff

tardy delta
#

im going to let the user define its own functions

#

next thing to do is properly implementing operator priority cuz sucks so hard now and parentheses too

ivory sleet
#

Fourteen

#

Why dont you use regex

#

You can use regex to identify groups and operations

#

then ofc iirc regex doesnt support recursion

tardy delta
#

cuz regex slow and would only become worser when the expressions are longer

ivory sleet
#

But yeah still

#

Well you can compile it

#

Making it reasonable slow only

hybrid spoke
tardy delta
#

would be less flexible to use regex instead of my switch rn ig

#

ill see

#

creating operands char by char now lol

vital sandal
ivory sleet
#

they might be as well, but primarily just a fundamental math expression

tardy delta
#

only big numbers seems to give problems lol

#

me constantly changing my code :(

vital sandal
#

Mind change the object to long type or double

tardy delta
#

its double

vital sandal
#

Or string

tardy delta
#

might use a bigdecimal to hold the precision but im wondering if using a bigdecimal has overhead

vital sandal
#

Use string*

tardy delta
#

cant just do "1" + "1" lmfao

tardy delta
#

need to make it a number anyways

ivory sleet
#

For instance its on heap partly 😦

tardy delta
#

brr

vital sandal
#

You can convert it into single number and add up step by step

eternal night
#

gimme valhalla for big decimal on stack

ivory sleet
#

πŸ™πŸ™

tardy delta
#

bruh if i have "1.4573937282" * "2.93836282" and convert those to a number, would still have rounding issues

vital sandal
#

For example 111+ 12 -> 1+2 , 1+1 -> 123

tardy delta
#

tell me how to do "1.4573937282" * "2.93836282"

ivory sleet
#

Probably wanna use big decimal

#

And invoke the multiply method

vital sandal
#

Put the . Away and then add it later ?

ivory sleet
#

Ofc configure precision first

#

And then take the result and format it appropriately

vital sandal
#

Big decimal cant be as long as string :> for sure

ivory sleet
#

Not sure what ya mean

vital sandal
#

1.12* 1.12 = 112x112/(100x100)

ivory sleet
#

Im still bewildered

hybrid spoke
#

just multiply 2 doubles

#

and if its a big double, make it a big decimal and take the precision loss like a man

vital sandal
#

Double cant hold 10^6 length

ivory sleet
#

BigDecimal tho

#

And yeah also what god cipher said

tardy delta
#

decimal in c# doesnt have precision loss right?

vital sandal
ivory sleet
#

No

ivory sleet
#

You can set its scale and stuff

tardy delta
#

smh it holds a bigint internally

eternal night
#

Well yea it just stores the int and decimal part seperatly

lost matrix
vital sandal
#

Hmm i see big decimal doesnt have a limit the only thing is the memory :d

eternal night
#

or well

#

it does not really store them seperatly but like

#

scaled

wet breach
# tardy delta smh it holds a bigint internally

here is something to help you in regards to bitshifting since it was discussed some time ago, for every bitshift to the left, its 2 to power n(being the amount being shifted over). so lets say its 5 for the start number. its 5*(2^N) and if its a right shift, we divide instead. In case you want to try optimizing at some point πŸ˜›

wet breach
#

also

#

in regards to bitshifts

#

if you are shifting between 0-31 places, an int works, if its higher you need a long up until place 63

#

after that you need a BigInteger

tardy delta
#

hmm BigDecimal(char[] in, int offset, int len, MathContext mc) has some nice parsing

grizzled oasis
#

Hi someone used XParticle how i can do the image to particle by this lib

kind hatch
#

Alright, so I am trying to find a way to shorten my config files a little bit. Right now, if I want to give each list a unique state in the lore, I need to have a list of sections proportional to the length of the list. I really don't like this as it just adds unnecessary length to the config file. Especially when the list contents are identical except for the additional styling.

So what do I have in mind? A placeholder of sorts. However, this isn't without issue. The two problems I have with this are:

  1. Finding a way to replace the placeholder with a list of strings.
  2. Applying the styling to each unique case.

I have no clue how to approach the second one since the styling is variable. As it stands, they do share a common format. (<Indicator> <Text>) So maybe I could take advantage of this somehow?

The config problem can get bad quickly. Here's two example configs to show the difference that I am trying to achieve.
Example 1 (18 Lines Reduced)
Before: https://paste.md-5.net/ecuwojigep.sql (67 Lines)
After: https://paste.md-5.net/loyenafuwo.sql (49 Lines)

Example 2 (79 Lines Reduced)
Before: https://paste.md-5.net/ovonopinux.sql (160 Lines)
After: https://paste.md-5.net/qiyutaduca.pl (81 Lines)

drowsy helm
#
particle_quality:
  indicator:
    selected_format: "%colour_prefix%->%display_name%"
    deseleced_format: "%colour_prefix%%display_name%"
  states:
    - off:
      display_name: "Off"
      colour_prefix: "&c"
      description: "&7No particles will be displayed"
    - low:
      display_name: "Low"
      colour_prefix: "&e"
      description: "&7Very few particles will be displayed"

why not format it something like this?

#

right now you have heaps of boilerplate which can just be put into one variable

#

then that same format could also be carried over for all the other ones

kind hatch
drowsy helm
#

yeah it's just a list of objects

#

iirc its getConfigurationSection

#

for the key set

oak raven
#

hey guys, i want to add it to my discord server, can anyone help how to?

oak raven
#

the voice chat bot

drowsy helm
oak raven
#

?

drowsy helm
#

ask there

#

if its not about coding

oak raven
#

oh ok

serene sigil
#

hi, i wanted to make the dragon egg invulnerable to everything but the void, but it gives me an error if i drop it..

@EventHandler
   public void damageCancellation(EntityDamageEvent event) {

       Item item = (Item) event.getEntity();
       Location eggLocation = item.getLocation();

       if (event.getEntity() instanceof Item) {
           if (item.getItemStack().getType().equals(Material.DRAGON_EGG)) {
               if (event.getCause() == EntityDamageEvent.DamageCause.VOID) {
                   System.out.println("RIP!");
                   event.setCancelled(false);
               } else {
                   event.setCancelled(true);
               }

           }
       }

   }```
drowsy helm
#

what error

tardy delta
#

check instanceof first, then cast

serene sigil
#

oh ok

drowsy helm
#

if you're using later versions of java you can also do
if(event.getEntity() instanceof Item item)

serene sigil
#

alr

vocal cloud
#

Based versions of java*

serene sigil
#

tysm it works now!

#

also another quick question:

vital sandal
#

i use this for Inventory Click Event for chest UI

#

any improvement ?

drowsy helm
#

not giving us much information lol

dire bluff
#

hello can someone help me why iron golems doesnt spawn on air

drowsy helm
#

EventListeners is quite vague, maybe make a bettre name for that

drowsy helm
dire bluff
#

what code

sterile token
#

Sendyljr clse

dire bluff
#

ive no code

drowsy helm
#

the code you are using to spawn the iron golem

#

this is help dev

sterile token
dire bluff
#

uhhhhh

#

somene told me to come here

#

srr

sterile token
#

I mean programming questions this channels and for related question use #help-server

dire bluff
#

ok sorry

sterile token
#

Na dont worry

serene sigil
# serene sigil also another quick question:

i want to detect if a player has the dragon egg in their inventory, i have 2 ways to do that, the first is to listen to all events relating to inventories and items, the other way would be to make a custom event which i actually wanted to do, but im not that good in it

tardy delta
#

detect whenever they pick one up?

drowsy helm
#

if its on demand just scan the inventory

serene sigil
#

the event should just scan the inventories of all players and see if they have the egg

drowsy helm
#

wait do you want to detect whether they have it

#

or call an event when they get it

#

two different scenarios

serene sigil
#

oh

drowsy helm
#

yeah just iterate over their items and check

serene sigil
#

and how do i do that?

tardy delta
#

wanna check every player on the server?

serene sigil
#

ye

#

maybe even offline players if its possible

tardy delta
#

loop thro Bukkit.getOnlinePlayers() and call player.getInventory().contains(Material.DRAGON_EGG)

serene sigil
#

alight

#

ill try

#

like this?

#

public static void scan() {
for (Player player : Bukkit.getOnlinePlayers()) {
player.getInventory().contains(Material.DRAGON_EGG);
player.sendMessage("u have egg!!!!");
}
}

vital sandal
#

u forgot if statement

serene sigil
#

what if statement?

vital sandal
#

if(player have the egg) say it

serene sigil
#

oh

#

alright

wind rain
#

I want to run code when someone says myWord in chat. How would I go about doing that?
I haven't made plugins in like 2 years but if I remember correctly, there's an event system. If there is, then is there an event that triggers when a chat message gets sent?

vital sandal
#

AsyncPlayerChatEvent

wind rain
iron glade
#

yup

wind rain
#

should I be using the normal one or the async one? What's the difference?

#

something related to threads?

iron glade
#

Normal one makes chat wait for stuff iirc

#

so if you just wanna do stuff if a message contains something I'd use async

fluid river
#

99% devs use AsyncPlayerChatEvent

wind rain
#

alright

fluid river
#

Default one is deprecated since like 1.13

#

isn't it?

echo basalt
#

pretty sure it's since 1.8 lol

fluid river
#

ez

#

i only coded for 1.5.2 and 1.12+

wind rain
#

what's the naming convention with listeners? do I just name the class AsyncPlayerChatEventListener?

fluid river
#

no convention

echo basalt
#

<purpose>Listener

fluid river
#

ChatListener

echo basalt
#

ChatListener, PlayerChatListener

#

etc

wind rain
#

ah

#

alright

iron glade
#

setamount, setlore, setname ☠️

#

naming convention happened

fluid river
#

some method like toItemStack

#

In BuildItemStack

rancid elm
#

hey can anybody help me with a plugin?

iron glade
#

?ask

undone axleBOT
#

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

fluid river
reef lagoon
#

where does this get saved and how do I access it in another class (The YamlConfiguration)

fluid river
#

Wtf is this

eternal night
fluid river
#

You want to save your stack to config?

reef lagoon
#

well I want to save an item stack

fluid river
#

to where

reef lagoon
#

let's say for this example test.yml

fluid river
#

how do u cast BuildItemStack to ItemStack then

fluid river
#

File f = new File(plugin.getDataFolder(), "test.yml");

#

f.createNewFile();

reef lagoon
#

alr thanks

fluid river
#

Then to get it's wrapper you do var contents = YamlConfiguraion.loadConfiguration(f);

#

contents.set("item-on-cursor", yourItem);

#

and contents.save()

reef lagoon
#

so what's the difference between YamlConfiguration and just a normal file

fluid river
#

Idk what is this BuildItemStack class

#

What is API

#

You are using

fluid river
fluid river
iron glade
#

^^

fluid river
#

JITC will carry it out anyways

#

use .build() method

#

inv.setItem(slot, item.build());

dire bluff
#

pls can someone help me in help-server

#

its need

fluid river
#

So you don't have to write 9999 lines of code to work with YML yourself

rancid elm
# eternal night what is your question

So basically I'm using EconomyShopGUi to sell vehicles right but,
for some reason it messes it up so the vehicle doesn't work after I buy it, unfortunately I can't attach a screenshot.

fluid river
#

Are you sure you store ItemStack with all NBT tags saved

#

to your gui

rancid elm
fluid river
#

why can't you send it here

rancid elm
#

I don't have permission

fluid river
#

verify

rancid elm
#

wait

fluid river
#

!verify <YourSpigotMCName>

undone axleBOT
fluid river
#

thanks cafebabe

queen apex
#

How can i shoot a fireball to the player?

iron glade
#

#launchProjectile

rancid elm
fluid river
#

and?

rancid elm
#

it's not supposed to look like that, it's supposed to look like this and they don't work when I buy them

reef lagoon
eternal night
#

you should probably ask in their discord @rancid elm

#

this seems like a very plugin specific issue

queen apex
fluid river
#

what is wrong

fluid river
#

read it with YamlConfig... and save

reef lagoon
#

pain alr

fluid river
#

i mean

#

You can store everything in one file

#

list of items

#

and boolean true/false values

#

and ints and strings

#

like in essentials config

iron glade
fluid river
#

You just need to use .set() multiple times

#

and don't save 2 values on one path @reef lagoon

#

new value gonna replace old one

iron glade
fluid river
#

and never forget to use .save()

#

after manipulations

reef lagoon
#

I'm just storing other stuff on the same file, such as uuids

fluid river
#

then just store

#
contents.set("N-line-uuid", NplayerUUID.toString());```
reef lagoon
#

I made some methods to set stuff myself, I never touched YamlConfiguration

fluid river
#

Well if you plan to use yml

tardy delta
fluid river
#

It's better if you use included YamlConfiguration class

rancid elm
tardy delta
#

well do you have the resourcepack applied?

fluid river
#

Well you need to store ItemStacks with customModelData in your GUI

#

And have resourcepack on

rancid elm
tardy delta
#

and the itemmeta has thhe custom modeldata?

reef lagoon
#

the path is item: in this case right

fluid river
#

without :

#

it's automatically placed

reef lagoon
#

so just item?

fluid river
#

yes

#

"heal-amount"

tardy delta
#

hmm looks a bit hotter already

fluid river
#

you need "previous-item.material"

#

and so on

#

separated by .

#

If you store a list of strings, it would look like this

fluid river
#

Can you show

#

config of your shop gui plugin(where actual items are stored as values)

#

I bet it doesn't store itemmeta(custommodeldata, nbt tags)

rancid elm
#

sure wait

tardy delta
# rancid elm

is that the same menu as when you open it the first time?

worldly ingot
# rancid elm

slightly unrelated, you know you can hit the tab key to complete the current completion suggestion, right? You don't have to use your mouse?

tardy delta
#

then no custommodeldata is applied to those items

worldly ingot
#

I've never seen anybody use their mouse for that lol

tardy delta
#

lmao

fluid river
#

yeah

rancid elm
fluid river
#

your plugin doesn't support

#

CustomModelData

rancid elm
#

that sucks

fluid river
#

if you have an hour we can go to discord and i will make a small plugin for your vehicles shop

tardy delta
#

dutch lol

fluid river
#

add me

tardy delta
#

FREE JAVA LESSONS hehe

iron glade
quaint mantle
#

if so please do

tardy delta
#

i can but that would just work the same way as i'm doing and would be slow

quaint mantle
#

a compiled regex isn't that slow

#

but slower ye

#

it looks kinda awful rn tho

tardy delta
#

then take a look at how a BigDecimal parses a string

quaint mantle
#

yeah ik

#

I guess a parser is kinda low level so you're allowed to do that verbose shit

tardy delta
#

kinda ye

#

also wondering how to make it as efficient as possible

#

but thats for a later time

quaint mantle
#

yeah please leave that for a later time

#

lmao

#

totally not my pitfall

tardy delta
#

frostalf talking bout bitwise calculations which i dont even understand lmfao

vital sandal
#

Where does persitantdataholder store data ?

#

Nbt tags ?

eternal night
#

yes

vital sandal
#

Not so well :l

eternal night
#

πŸ€”

vital sandal
#

If i create a backpack with store data with persistentdataholder it mind create a big trouble when server load that

eternal night
#

I mean

#

not more than a bundle /shulkerbox ?

wet breach
wise leaf
#

Bit wise is very useful

tardy delta
#

have never used it

wet breach
#

most people haven't

#

but in regards to doing calculations without taking up processing time though is where it comes in handy

tardy delta
#

is the whole bitwise code to perform a multiplication actually faster than doing a * b?

echo basalt
#

bitmasks, using some funky properties like OR

#

basically if you're messing with bytes and doing fancy trickery, you want to do bitwise stuff

tardy delta
#

mmh

wet breach
#

bitmasking is also handy too

echo basalt
#

stuff like "the first 15 bits are for ..."

#

it optimizes protocol :)

wet breach
#

mc protocol uses bitmasking if I recall

echo basalt
#

entity metadata

wet breach
#

so make them correct

tardy delta
#

i dont know to mistake

wet breach
#

did you add the repository?

#

to the pom that is

#

if you didn't it isn't going to find that dependency unless its on maven central

vital sandal
#

@EventHandle cannt access previous value ?

hasty prawn
#

Wdym previous value

#

Like previous events that were called?

vital sandal
#

i have this
private HashMap<Integer,AbilityData> data=new HashMap<>();

junior flicker
#

except that you can't, adventure can be used in other places the api provides, inventories aren't one of them and will never be because it's provided by paper
so in spigot there is no way to do it because of outdated inventories
I thought maybe there was another maybe funky way to set the font but I guess not

vital sandal
#

after that
@EventHandler
public void InventoryEvent(InventoryClickEvent event){
System.out.println(this.data);
}

hasty prawn
vital sandal
#

this.data return empty although i already put data to it

hasty prawn
#

You didn't put anything in it though

tardy delta
#

πŸ€”

vital sandal
#

oh i'm dump

#

the listener is called in another class

#

@_@

tardy delta
#

did something weird again

hasty prawn
#

1+1 = 0 yes

tardy delta
flint coyote
#

just redefine 1 -> 0 and it's about right

tardy delta
#

yessir

#

first try actually

vital sandal
#

how can i unregister an event listener ?

knotty meteor
#
java.lang.NoSuchMethodError: 'org.bukkit.configuration.file.FileConfiguration nl.stefanokeizers.vehicles.utils.data.VehiclesConfig.getConfig()'
        at nl.stefanokeizers.vehicles.Main.onEnable(Unknown Source) ~[?:?]```
Someone knows why after obfuscation my custom config with getconfig method doesnt work anymore?
eternal night
#

something is calling the not obfuscated method ?

#

best solution is to not obf πŸ‘

knotty meteor
#

Yeah thats probably why xD
But yes i need to obfuscate this one because skids are on the hunt for this lol

flint coyote
tardy delta
#

ah yes 1 + 1

#

why the heck is it 0

remote swallow
#

magic

tardy delta
#

2+2 gives 1+1 wtf

#

probably my parsing method

#

ah yes new Operand(value: 1).getValue() gives 0 :/

#

aah did setValue(currentChar - '1') instead of '0'

eternal night
#

those are lowercase

serene egret
#

how can i detect if a player sits on a armorstand (which event and which methods)

eternal night
#

players cannot normally sit on armor stands πŸ€”

serene egret
#

ik but with my plugin it is possible

#

and i dont know how to detect

tardy delta
eternal night
#

VehicleEnterEvent

#

should work

boreal seal
#

i got an question

#

is there even any event

serene egret
#

k thx

boreal seal
#

when button falls

#

or redstone

#

or sand

#

and breaks?

#

i want to change the itemstack that drops

eternal night
#

yes

boreal seal
#

since its not break event

#

what event is that?

eternal night
#

artifactid should be lowercase

boreal seal
#

when blocks collapse

serene sigil
#

hi, i wanted to make it so if u have the dragon egg in ur inventory u get 100+ levels and if u remove it will remove you those 100, but in my program i never stop gaining levels when i have the egg.

Bukkit.getScheduler().runTaskTimer(this, runnable -> {
            for (Player player : Bukkit.getOnlinePlayers()) {
                player.getInventory().contains(Material.DRAGON_EGG);
                if (player.getInventory().contains(Material.DRAGON_EGG)) {
                    player.giveExpLevels(100);
                } else {
                    player.giveExpLevels(-100);
                }
            }
        }, 1, 1);```

this is in onEnable()
tardy delta
#

no need for runnable, just put ()

serene sigil
#

wdym?

boreal seal
#

(BlockPhysicsEvent?

tardy delta
#

this, () -> {}

serene sigil
#

alr

eternal night
#

can you post the error

serene sigil
#

for example if i add like a boolean it gives me an error

iron glade
eternal night
#

gains

tardy delta
#

thats a quick way to gain xp

#

πŸ€“

eternal night
#

what is that character after the st

iron glade
#

turkish i

#

I guess

eternal night
#

ah

#

yea you don't get to use dat

#

oh its there agin

#

after the last s

iron glade
#

What is your goal?

onyx fjord
#

are there any nms tutorials (reflection)?

iron glade
#

run it once

onyx fjord
#

gradle btw

serene sigil
iron glade
#

you can still run it once

#

?scheduling

undone axleBOT
eternal night
#

what does reflection have to do with the build system πŸ€”

iron glade
#

Just loop through only players in your onEnable and check if they have that item, yes -> add levels, no -> remove levels

onyx fjord
eternal night
#

for reflection ?

eternal night
#

the entire point of a reflective access to NMS is to not depend on the server impl isn't it ?

iron glade
serene sigil
#

like that?

for (Player player : Bukkit.getOnlinePlayers()) {
                player.getInventory().contains(Material.DRAGON_EGG);
                if (player.getInventory().contains(Material.DRAGON_EGG)) {
                    player.giveExpLevels(100);
                    asdasdasdasdasdasdasd=false;
                } else {
                    player.giveExpLevels(-100);
                }
            }
#

@iron glade

eternal night
#

you'd have to move that logic into a listener

#

and listen for the player inventory changing

serene sigil
#

there is no such event tho

eternal night
#

I guess not really no

#

so yea, potentially a runnable would be easier to code

iron glade
#

player.getInventory().contains(Material.DRAGON_EGG);

eternal night
#

literally the line below that dude xD

tardy delta
iron glade
#

/ remove it

serene sigil
iron glade
#

this does nothing

serene sigil
#

alr

iron glade
#

you're checking in the next line

serene sigil
#

btw that ignore that boolean

iron glade
#

If a player has 50 levels removing 100 just sets them to 0 I suppose?

serene sigil
#

ye ig

iron glade
#

alternatively you could remove those levels when he drops the item

#

or moves it to another inventory

serene sigil
#

yes, but those are a lot of events to listen to, its i think better if i just scan the entire inventory

iron glade
#

Then maybe a task timer that checks that every minute or so?

#

and some boolean hadItemOnLastCheck or smth like that

#

so that you don't keep adding 100 xp levels

serene sigil
#

nvm

#

u dont understand

#

the egg is like visual levels, so if u have it u get 100levels and if not, u dont have those 100 levels

eternal night
#

that is the plugin name in the plugin.yml

#

not the pom

onyx fjord
#

its kinda first time me actually using reflection, could someone help me figure out how to get rid of "Not Secure" thingy in that method?

    private void broadcastChatMessage(PlayerChatMessage playerchatmessage, Predicate<ServerPlayer> predicate, @Nullable ServerPlayer entityplayer, ChatSender chatsender, ChatType.Bound chatmessagetype_a) {
        boolean flag = this.verifyChatTrusted(playerchatmessage, chatsender);
        this.server.logChatMessage(playerchatmessage.serverContent(), chatmessagetype_a, flag ? null : "Not Secure");
...
eternal night
#

you cannot

#

not with reflection at least

onyx fjord
#

cant i set flag just to true

iron glade
eternal night
#

reflection can do fields

onyx fjord
#

rip

#

then what would help here?

eternal night
#

I mean, a log4j2 config to filter that out ?

#

you are not running your server with the poper java version

tardy delta
#

hmm i'm wondering how to properly clear a linkedlist? would setting the head and the tail to null be enough?

#

singly linked nodes

eternal night
#

calling the clear method on the linked list ?

#

your java version is too old

tardy delta
#

nah made my own linkedlist like class

eternal night
#

but basically yes

tardy delta
#

lets hope i dont create too many memleaks

eternal night
#

the jdk does remove intermediate connections tho

#

for GC purposes

tardy delta
#

figured out why my expressionparser wasnt working, it was working with the previous expression lol

eternal night
#

yes but you compiled your plugin to java 9

#

yea πŸ‘ it should be defined in your pom.xml

tender shard
#

"how to change java version in your pom" ^

tardy delta
#

hmm seems to work now

#

actually just impelemented multiple operators

tender shard
#

oh you finally switched it to floats? that's nice

tardy delta
#

doubles lol

tender shard
#

erm yeah

#

thats what I meant πŸ˜„

#

sorry

tardy delta
#

might want to use bigdecimals eventually to not loose precision

#

or some way in between

#

yet to implement op priority

#

and my exception are the best thing

wind rain
#

so I have figured out the event and config stuff and whatever but I want the code to run when the first word of the chat message is a string contained in a string array form the config. I think I should use config.getStringList(...).contains(firstWord) but I'm not sure how I would get the first word of it. I guess split at or smt

fluid river
#

what

#

String firstWord = AsyncPlayerChatEvent.getMessage().split(" ")[0];

quiet ice
fluid river
#

Bank workers enter chat

#

Java EE devs basically enter chat

wind rain
eternal night
quiet ice
quiet ice
iron glade
fluid river
#

AsyncPlayerChatEvent.getMessage().replaceFirst(firstWord + " ", "");

#

or

#
AsyncPlayerChatEvent.getMessage().substring(firstWord.length + 1 /*, maybe AsyncPlayerChatEvent.getMessage().length*/);
wind rain
#

alright, thanks! I'lll use substring

fluid river
#

i don't remember substring parameters

JavaDocs bless you

wind rain
#

I'll figure it out

worldly ingot
#

start (inclusive), end (exclusive)

wind rain
#

I only need the start tho, right?

iron glade
#

yup

wind rain
#

and firstword.length() + 1 because there's a

undone axleBOT
tardy delta
#

maybe i shouldnt delegate Validate.isTrue to isfalse(!condition) lol

wind rain
#

how do I send a message to the chat? So that everyone can see it

cobalt thorn
#

hi a question how i can run a command without the player having the permission like /craft from essentials

wind rain
#

Thanks a lot!

white root
#

Is there a way to make a spawned mob have no ai, and have it be affected by gravity, knockback, etc?
I tried messing with LivingEntity.setAI(false) but that disables gravity

#

^^
Without diving into NMS

tardy delta
iron glade
tardy delta
#

more debugging

wind rain
#

ah, AsyncPlayerChatEvent runs before the message is sent

fluid river
#

yeah

wind rain
#

can I somehow have code run after it

undone axleBOT
fluid river
#

run task 1 tick later

wind rain
#

alright

fluid river
#

yez

wind rain
#

I wanna send a chat message

white root
#

Could they not listen to it with event priority monitor?
I thought that was the whole point of the monitor priority, just there to observe the events effects

fluid river
#

still

#

before message

wind rain
#

oh, does monitor run after?

chrome beacon
#

No

#

It's still before

wind rain
#

so what do I do

fluid river
#

point is that if you don't override anything and just want to know what plugins changed

white root
#

ah

fluid river
#

you should use MONITOR

wind rain
#

all I want to do is send a message after a player sends a message, using the contents of what the player sent

vocal cloud
#

Use the scheduler

wind rain
#

I will

tardy delta
wind rain
#

do I have to run ```java
Runnable sendMessage = () -> Bukkit.broadcastMessage(String.format("...", restOfMessage));

chrome beacon
#

Yeah

wind rain
#

alright then

tardy delta
#

luckily those tests cover alot of methods

#

only two wrong cases

wind rain
#

do I use runTaskLater() or runTaskLaterAsynchronously()?

fluid river
#

depends on what you need

tardy delta
#

first runs later and second later and async

fluid river
#

just use sync

wind rain
#

the normal one?

fluid river
#

yes

wind rain
#

alright

#

and delay of 1?

fluid river
#

yes

tardy delta
#

ah my famous parser.parse("1+ - 1") returns 2

wind rain
#

so the final product is ```java
Bukkit.getScheduler().runTaskLater(this, () -> Bukkit.broadcastMessage(String.format("...", restOfMessage)), 1);

fluid river
#

just test it

wind rain
#

I will

fluid river
#

nobody cares about the process)

tardy delta
#

your mom does

wind rain
#

ha

vocal cloud
wind rain
#

didn't work :D

dim palm
#

loop for all players and send the message

wind rain
#

huh?

fluid river
hazy parrot
wind rain
#

what's depricated?

#

nothing shows as depricated

fluid river
chrome beacon
vocal cloud
#

@EventHandler

wind rain
dim palm
#

for me appears as deprecated lol

vocal cloud
#

Cause ur probably a paper user

fluid river
#

maybe bukkit version

#

or paper

chrome beacon
dim palm
wind rain
#

runTaskLater using BukkitRunnable is depricated

tardy delta
#

ahh found error

#

only one failed test now πŸ₯Ί

fluid river
#

new BukkitRunnable() {blah}.runTaskLater(plugin, 1L);

wind rain
#

oh?

#

alright then

#

can I use a lambda there somehow?

wind rain
#

instead of the whole ```java
@Override
public void run() {

}

tardy delta
#

people still instantiating damn bukkitrunnables instead of using scheduler smh

chrome beacon
#

You can use the scheduler

wind rain
#

but I was just doing that πŸ€”

#

alright then

chrome beacon
#

Yeah delay it a bit more I guess

fluid river
#

I'm not saying it's what you should use lel

chrome beacon
#

Chat isn't sync so using ticks isn't perfect

wind rain
#

how do I do it then

chrome beacon
last swift
#

How do I calculate the default damage? I’m recreating damage for my plugin and want to learn how the default damage works for attacking players. For example, set a player’s health based on the armor they have, the item the attacker has in their hand, then send the damage animation.

wind rain
#

so do i just use like 10?

chrome beacon
#

Yeah I guess

wind rain
#

alright

chrome beacon
#

The Minecraft wiki probably has something useful too

fluid river
#

event.getFinalDamage()

chrome beacon
#

Well that's not calculating it yourself

#

but yes it would probably be smarter to just use the damage events

wind rain
#

YOOOO! it works

fluid river
#

now what was the point

#

of doing it

elfin atlas
#

Is there a way to check if the command executor is a CommandBlock?

fluid river
#

no

serene sigil
#

hi, im making a plugin where if you have the dragon egg in your inventory you get +100 levels, but if you drop or remove it, those 100 levels will disappear. my question is what are all the events that i need to listen to?

elfin atlas
fluid river
#

And EntityDropItemEvent

#

probably

serene sigil
#

and what if u like put it in a chest?

tardy delta
#

bruh my test fails, i put the test into its own method and it doesnt longer fail

#

:/

serene sigil
#

or drag it out of ur inventory

fluid river
#

which checks if there is or there is no egg in player's inv

#

Otherwise 999 events related to inventory

serene sigil
#

how do i do that?

serene sigil
#

wait

#

actually i tried that already, but the issue was that i kept gaining more and more levels

robust light
#

whenever I run a custom command, in chat it says the command I just ran. Is there a way to not show that?

fluid river
#

If they now don't, remove 100 levels and remove from the list

#

If they have and not on the list, add 100 levels and put them

#

add to the list on join

serene sigil
#

idk if im able to do that :/

fluid river
#

remove on leave

#

LeArN jAvA

serene sigil
#

alright, ima try 1 sec

fluid river
#

(checkmybio)

hazy parrot
#

😬

serene sigil
fluid river
#

just a list

serene sigil
#

ohhhhh

fluid river
#

or a map who cares

chrome beacon
#

or a Set

fluid river
#

or a Stack

chrome beacon
#

A stack wouldnt be ideal

fluid river
#

or a Collection<?>

fluid river
#

not in this situation ofc

serene sigil
#

List?

fluid river
#

i think LinkedList would be alright

eternal night
#

Set<UUID>

chrome beacon
#

^

eternal night
#

HashSet should be a good implementation for this

tardy delta
#

f state doesnt want to reset to prepare for new expression

serene sigil
tardy delta
#

hmm if user decides to catch syntax exception, the tokens are corrupted

fluid river
#

your list should be a field

tardy delta
#

should probably reinstantiate tokenlist on every expression

fluid river
#

outside of the method

tardy delta
#

it is

#

lets call call ::clear before parsing new expression

serene sigil
#
List<Player> hadDragonEgg = new ArrayList<>();
    public void fun() {
        
        for (Player i : Bukkit.getOnlinePlayers()) {
            if (i.getInventory().contains(Material.DRAGON_EGG)) {
                hadDragonEgg.add(i);
            } else {
                hadDragonEgg.remove(i);
            }
        }

    }```
#

`?

tardy delta
#

Set<UUID>

#

whatever youre trying to do

serene sigil
#

@fluid river

tardy delta
#

and add the player.getUniqueId()

fluid river
#

like this yea

chrome beacon
#

Uh no

#

This is a very bad idea

serene sigil
#

and how would i do the exp gain/remove part?

fluid river
#

well bukkit methods lol

serene sigil
#

...

chrome beacon
serene sigil
#

and the fun() method should be in a scheduler loop?

#

in the main class?

fluid river
#

yez

serene sigil
#

k

undone axleBOT
tardy delta
fluid river
chrome beacon
#

Why store the player multiple times

#

Also don't forget to remove the player when they leave

#

Also just use a Set rather than an array list

tardy delta
#

thats why you should store uuids, im 100% sure youll forget

tardy delta
#

^^

#

Set::contains

#

might waant to read smth more about collections

fluid river
fluid river
#

and remove even if not in collection