#development

1 messages · Page 15 of 1

somber gale
#

Like the moment you Supress a deprecation you should ask yourself "Why was it deprecated?"

lyric gyro
#

but im already doing this

sly barn
proud pebble
#

the repo for 2.11.2 does exist

lyric gyro
dense drift
#

.

#

iirc the event has a getFinalDamage method?

grand zodiac
#

Hi! How do I get the root path of a server?

sterile hinge
#

What do you mean with root path?

grand zodiac
#

The directory everything is stored in

#

The root directory

merry knoll
#

not sure if there is a direct method but you can just do ../ to your plugin path twice

dense drift
#

Bukkit#getWorldsDirectory and then get the parent file

lyric gyro
merry knoll
lyric gyro
#

the one of the listener

merry knoll
#

the class that you called that from

lyric gyro
#

everything is working fine in that class

#

aside this part of the code

lyric gyro
#

can I make the result of an operation equal the value of an integer

#

for example

#
int coolInt;
45 - 30 == coolInt;
#

I believe this would solve my problem

grand zodiac
#

Does anyone know how I could convert this {d2f6c64e-0034-400f-9ea6-4b47367d51a7=1} into this d2f6c64e-0034-400f-9ea6-4b47367d51a7 and this 1

icy shadow
#

coolInt = 45 - 30 ...?

grand zodiac
lyric gyro
lyric gyro
#

this is really basic

grand zodiac
#

lol i made mistakes like that when picking up java again after a year of not using it

#

i forgot how to public static void main args etc

icy shadow
grand zodiac
#

Yeah using a BufferedWriter

icy shadow
#

i.e could you use a different format if need be

grand zodiac
#

yup

lyric gyro
#

if i can solve this

icy shadow
#

right well easiest option is probably just to use Gson to write

#

rather than writing manually

#

and then that handles reading too

lyric gyro
icy shadow
#

currentHP == blah is a boolean

grand zodiac
lyric gyro
#

why

icy shadow
#

wdym why

#

thats what == does

stuck hearth
#

You're performing a boolean check

icy shadow
#

^

lyric gyro
#

oh

icy shadow
#

now

lyric gyro
#

yeah yeah

icy shadow
#

why are you even changing the event damage

#

if you're just replicating vanilla behaviour

#

just leave the event alone and it'll handle the health reduction for you

lyric gyro
#

you don't understand what I want to do

#

it's not about reducing health

#

it's about custom names

icy shadow
#

that looks like you're reducing health

lyric gyro
#

I wanted to have both current hp

#

and max hp

#

in a custom name

#

but the current hp part is giving me trouble

icy shadow
#

ok so do that? ```java
on damage event {
set name to getHealth and getMaxHealth
}

#

you shouldnt need to be changing the health yourself at all

lyric gyro
#

insted of displaying like 49/50

#

it just displays 50/50

#

all the time

icy shadow
#

yeah cuz the event happens before the damage

#

so run it a tick later

merry knoll
#

and run the event with high prio

lyric gyro
icy shadow
#

yes

merry knoll
icy shadow
#

^

#

events usually get triggered before the actual action to support cancellation

stuck hearth
#

Cancel the event after the damage 🤔

icy shadow
lyric gyro
#

so you want me to run this code

#

1 tick later

merry knoll
#

i mean scheduler is probably mroe effort

lyric gyro
#

after the damage

icy shadow
#

just update it 1 tick later

#

you shouldnt need to recreate vanilla behaviour here

#

while also potentially breaking compatibility with other plugins

#

if anything else modifies the event

#

EventPriority.MONITOR may also be an option

merry knoll
#

highest > monitor

icy shadow
#

frankly you shouldnt be modifying an event just to render some UI

#

especially when you dont need to modify it

merry knoll
#

true enough

lyric gyro
#

no one answered this question though

#

which was my original problem

merry knoll
#

you need to show the whole class structur

lyric gyro
#

it's in my github

merry knoll
#

no idea which instance you are calling the method from

merry knoll
lyric gyro
merry knoll
#

lemme check the javadocs for it

merry knoll
#

bukkit goat class implements this

merry knoll
#

get the bukkit entity then setCustomName

#

and customNameVisible

#

no need to use the nms methods for it

lyric gyro
#

oh shit @merry knoll just realised what i was doing wrong

#

all the time

merry knoll
#

?

lyric gyro
#

i was creating a method called updateName for no reason

merry knoll
#

nah its good

lyric gyro
#

but

merry knoll
#

seperating functionality into smaller methods is quite nice

#

allows for modular usage if needed

lyric gyro
#

sometimes I also tried to use only setname

#

but when I did this

#

I didnt add goat.setname to the event

merry knoll
#

call update from setName

#

but keep it seperate

#

in case you need to update the name for whatever reason

#

i would make it take a string or component though

proud pebble
merry knoll
#

and set the name to that

lyric gyro
#

will this now display the current name with the current health now

proud pebble
#

you check if the entity is instanceof goat, but then cast the entity as goatsoldier

lyric gyro
#

because instanceof goatsoldier

merry knoll
#

he fixed it

merry knoll
#

in the github

proud pebble
#

from the image they posted earlier asking how to fix xit

merry knoll
proud pebble
#

ic

lyric gyro
merry knoll
lyric gyro
merry knoll
#

see no issues

#

you are checking if its a goatSoldier

lyric gyro
#

really?

merry knoll
#

then casting into goatSoldier

#

what luna said was

lyric gyro
merry knoll
#

you were checking for goa

#

goat*

#

then casting into soldier

#

which is not always true

lyric gyro
#

goat.setCustomName(); is basically not needed

#

but if I dont use it

#

then it wont work

lyric gyro
#

setCustomName is already a method

merry knoll
#

what

#

just use updateName

#

but you cant use getHealth for it

#

you need to pass the text to it

#

from its parameters

#

since health will be full

#

if you just getHealth

lyric gyro
#

if i use updatename

#

the custom name never shows up

#

for some reason

merry knoll
#

use bukkit methods for it

#

no need for nms

#

also oh

#

i got your issue

lyric gyro
#

hm

merry knoll
#

your custom goat is an nms goat

#

not sure if the one event returns is an nms one

#

it returns bukkit goat entity

#

so its probably not passing the "is goatSoldier" check

lyric gyro
merry knoll
#

where are you spawning these goats?

lyric gyro
#

when he plays a goat horn

merry knoll
#

in the code

lyric gyro
#

ok

proud pebble
#

yeah event.getEntity() doesnt return custom entities

lyric gyro
merry knoll
merry knoll
#

where are you spawning it

lyric gyro
merry knoll
#

okay

#

you need to get the nms entity

#

of the bukkit entity

#

and compare to it

#

not sure if its the same reference i think bukkit entity is the same reference but not sure honestly

#

altho code above would work

#

if it was the same reference

lyric gyro
#

you mean comparing myself

merry knoll
#

instanceof does it for you

lyric gyro
#

so thats what instanceof means

grand zodiac
# icy shadow right well easiest option is probably just to use Gson to write

okay so I have

    public static void saveData() {
        File file = new File ("plugins//Masteries//data.json");
        file.getParentFile().mkdirs();
        try {
            BufferedWriter writer = new BufferedWriter(new FileWriter(file));
            new Gson().toJson(BreakCobblestoneListener.cobbleBroken, writer);
            writer.close();
            loadData();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }```

but the file doesnt get changed
proud pebble
#

ive just googled it and i think its ((CraftEntity) event.getEntity()).handle() instanceof GoatSoldier

merry knoll
#

ah you gotta get the handle

proud pebble
#

which should pull the NMS version of entity

lyric gyro
#

what exactly is getHandle in java

#

i dont understand it

merry knoll
#

its a bukkit bs

#

dont worry about it

#

not a java thing

#

(but imho just use the bukkit entity instead of the nms version for names)

lyric gyro
#

k then

merry knoll
#

you just need the nms version for ai

#

so its enough to have it on spawn only

lyric gyro
#

so the only thing I got to change is that instanceof part in my event

merry knoll
#

((CraftEntity) event.getEntity()).handle() instanceof GoatSoldier

#

use this

#

and you are fine

proud pebble
#

you got 3 levels because of bukkit bs

Bukkit/Spigot Entity
CraftBukkit Entity
NMS Entity

you can cast bukkit to craftbukkit, and craftbukkit has the link to the nms entity, which you have to get to beable to tell if its instance of goatsoldier

merry knoll
#

honestly dont know why they dont just add on top of each other instead of wrapping like this

#

meh

proud pebble
#

so you got your entity, which you cast to craftEntity to get the craftbukkit version of entity, which .getHandle() gets the nms entity

icy shadow
proud pebble
#

why they do this idk either aki, its so much bs for some reason i dont know at all

grand zodiac
icy shadow
#

and does it create the file?

grand zodiac
#

nope

merry knoll
#

the whole inventory clone thing is also quite stupid

#

so many bad choices

grand zodiac
#

It did back when I used a FileWriter saving it as a txt, but now it doesnt for some reason

icy shadow
#

try something like this instead ```java
public static void saveData() {
Path file = yourPlugin.getDataFolder().resolve("data.json");

try {
Files.write(file, new Gson().toJson(BreakCobblestoneListener.cobbleBroken).getBytes());
} catch (IOException e) {
throw new RuntimeException(e);
}
}

lyric gyro
#

did what you said

grand zodiac
icy shadow
#

oh whoops

#

edited

lyric gyro
grand zodiac
#

thanks, i get the error Non-static method 'getDataFolder()' cannot be referenced from a static context

icy shadow
#

yeah you need an instance

proud pebble
# lyric gyro
Entity entity = ((CraftEntity) event.getEntity()).getHandle();
if (entity instanceof GoatSoldier) {
    GoatSoldier goat = (GoatSoldier) entity;
}
#

Entity is the net.minecraft.world.entity

#

not the bukkit one

lyric gyro
#

k

grand zodiac
icy shadow
#

no absolutely not

#

you can't create a new instance

#

if you're doing this in the plugin class just use this, otherwise use dependency injection

grand zodiac
#

ohh alright thanks

proud pebble
lyric gyro
grand zodiac
proud pebble
icy shadow
#

ofc if you're using this then you cant have the method static

grand zodiac
#

ah yeah true, i now get the error Cannot resolve method 'resolve' in 'File' though

icy shadow
#

ah add .toPath() after getdataFolder

#

tryna code from memory

grand zodiac
#

ahh, so like that Path file = this.getDataFolder().toPath().resolve("data.json");?

#

intellij isnt throwing errors at me so I think im doing something right lol

icy shadow
#

looks right

grand zodiac
#

okay i have a small problem, since im using this i cant make it static, but that makes it so i cant access it in another class, which is necessary for what im trying to do

merry knoll
#

does anyone know which theme this is ?

#

someone else posted it on another discord but they are no longer there

icy shadow
#

alternatively you could take the plugin in as a method parameter and then make it a static utility method

grand zodiac
#

oh, wait then what does this mean non-static method saveData() cannot be referenced from a static context

#

context is Masteries.saveData(); being ran from the BreakCobblestoneListener class

merry knoll
#

you want one of it regardless so its effectively a singleton

icy shadow
icy shadow
merry knoll
icy shadow
#

well if we're talking about testing, using injection would be much much more testable as you could pass in a mocked plugin that returns a specific data folder

lyric gyro
#

i mean bukkit doesn't guarantee there will be a single instance

icy shadow
#

not that testing IO operations is a good idea

#

plus you could probably argue passing an entire plugin just to get a Path is anti-DI

lyric gyro
#

just pass the Path lol

icy shadow
#

yeahh

lyric gyro
merry knoll
#

also unrelated, but is there a way to get the player from the ip in velocity? (without looping all players that is)

lyric gyro
#

There could be multiple players under the same IP but you'd probably want to keep your own Multimap, I don't think it has anything for that not even internally

merry knoll
grand zodiac
icy shadow
#

that will throw an error

#

?di

neat pierBOT
icy shadow
#

please consult this

#

or just use a static getter for your plugin if you're feeling lazy

#

but FWIW you should really have a good understanding of OO principles (such as DI) before doing any serious plugin stuff

grand zodiac
#

thanks

#

im sorta like half braindead atm cause its quite late and ive been working all day so im gonna go to bed then do that tomorrow so i can actually understand what im reading haha

tight junco
#

to be honest most of plugin development happens while im completely braindedad

grand zodiac
#

same but then when i have to debug i try for 6 hours then give up and try again when im not braindead

merry knoll
proud pebble
lyric gyro
#

wait ill do that

proud pebble
#

because it wont autoupdate the name id you dont

lyric gyro
#

like you start the server and you do something

#

(like in my case play a horn)

fervent rampart
#

%votesreceived% NOT WORKING on voteparty pls help

lyric gyro
#

and it doesnt do whats supposed to do

lyric gyro
fervent rampart
lyric gyro
#

if i run on updateName

#

it simply doesnt display the custom name

lyric gyro
# fervent rampart plugin for votes
package me.systemoutprintln.dev.hornspawn.customentity;

import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal;
import net.minecraft.world.entity.ai.goal.MeleeAttackGoal;
import net.minecraft.world.entity.ai.goal.RandomLookAroundGoal;
import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal;
import net.minecraft.world.entity.animal.goat.Goat;
import net.minecraft.world.entity.monster.Monster;
import net.minecraft.world.level.Level;
import org.bukkit.ChatColor;
import org.bukkit.Location;

//Goat Soldier made by MouBieCat

public class GoatSoldier extends Goat {

    public GoatSoldier(Level level, Location loc) {
        super(EntityType.GOAT, level);
        this.setPos(loc.getX(), loc.getY(), loc.getZ());
        
        this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(50.0f);
        this.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(10.0f);
        this.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.2f);
        this.setHealth(50.0f);

    }

    public void updateName() {
        this.setCustomName(Component.Serializer.fromJson(
                "{\"text\":\"" + "Soldier Goat" + "(" + ((int) getHealth()) + "/" + ((int) getMaxHealth()) + ChatColor.RED + "♥" + ChatColor.WHITE + ")" + "\"}"
        ));
        this.setCustomNameVisible(true);
    }


    @Override
    protected void registerGoals() {
        this.goalSelector.addGoal(1, new LookAtPlayerGoal(this, Monster.class, 16.0F));
        this.goalSelector.addGoal(2, new RandomLookAroundGoal(this));
        this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.0, false));
        this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, Monster.class, true));

    }



}
tight junco
#

yeah that's not what they're after

fervent rampart
#

def not a placeholder

tight junco
#

they're in the wrong channel

lyric gyro
#

oh see

#

now it works

#

but it doesnt display it all the time

lyric gyro
fervent rampart
#

ik but def not a placeholder

#

lol

lyric gyro
#

what placeholder

#

thats a custom entity

fervent rampart
#

yk what nvm

lyric gyro
#

oh I see

#

I mentioned the wrong person

#

sorry

#

replied to i mean

lyric gyro
#

it does work

#

but not all the time

#

only when I hit a mob

#

I think that

#

If I just put another custom name without the methods

#

it will work

#

ITS WORKING

#

OMG

proud pebble
lyric gyro
tight junco
#

"its working"
"what did you change"
"i made it work"

lyric gyro
#

probably not the most effective solution but it will work for now

proud pebble
#

i know its working, im asking what you changed to make it work

lyric gyro
tight junco
#

that is exactly what they are asking though

proud pebble
lyric gyro
#

so notice how before

#

their names didnt appear

#

but they appear when i hit them

#

so i thought

#

this was because of entity hit event

#

because it was only updating after an entity was damaged

#

so I just added another line of code that was just another custom name

#

but instead of having getHealth() and getMaxHealth()

#

i have two strings

#

each one of them are "50"

proud pebble
#

just send a screenshot of what you changed

lyric gyro
proud pebble
#

why dont you remove setcustomnamevisable() from updatename

#

since it only has to be set oncee afaik

lyric gyro
#

i dont think so

dense drift
#

Why do you use fromJson btw

proud pebble
#

tbh i was wondering that too

lyric gyro
#

I couldnt use it properly

#

then I tried to re import it

#

and shazam

#

gone

#

like it was never there

#

so the workaround we found was fromJson

#

works the same

proud pebble
#

type that in, it should find it

#

ive had to do that when looking for pair

merry knoll
icy shadow
#

kinda hard to tell with only 3 colours lmao

merry knoll
#

quite a unique one though

proud pebble
# merry knoll bump

if they arent on the server anymore, why dont you try friending them and asking them directly

stuck hearth
#

💩

dense drift
#

Brigadier is only available on 1.13+, right?

broken elbow
#

I believe so yeah

vernal quail
#

any tutorial and useful lib for sqlite?

merry knoll
#

if you want serializers for it then probably check out hibernate etc, but its probably overkill

icy shadow
#

considering hibernate adds about 30MB to your jar it's almost always overkill

merry knoll
#

you could write a basic serializer for it yourself

#

its really not that difficult

#

especially if you just need insert - update - select - delete

lyric gyro
#

is there a way to disable the fire caused by lightning bolts?

#

like do method .strikelightningbolt

#

but without any fire

#

Ah wait

merry knoll
#

you can just play the animation of it

#

instead of cancelling the fire

lyric gyro
#

I think that when you summon a lightning with commands it doesnt generate any fire

merry knoll
lyric gyro
#

you didnt let me finish

broken elbow
#

World#strikeLightningEffect summons the lightning without doing damage or setting things on fire right?

lyric gyro
#

so I think it might be this way for spigot as well

merry knoll
#

then apply the damage yourself

lyric gyro
#

I want the damage

#

just not the fire

broken elbow
#

oh

merry knoll
lyric gyro
#

what's the base damage of a lightning

merry knoll
#

google is your friend

lyric gyro
#

you now I dont think ill disable this

#

changed my mind

#

since whoever got struck also caughts on fire

#

it will be pretty op at first but meh

lyric gyro
#

how do I register the time a certain event begun

#

to limit how long it will last

broken elbow
#

what type of event?

lyric gyro
broken elbow
#

you can get the current time in java using System#currentTimeMillis

lyric gyro
#

to limit how long the code i added will last

lyric gyro
#

but is this really the only way

#

isnt there an alternative in spigot?

#

best suited for this stuff

broken elbow
#

I mean, what's wrong with that one?

lyric gyro
#

not so sure about it

merry knoll
#

time in general is not that simple in genereal

lyric gyro
#

I think I'll just create a method using this

#

cause I'll use it again

lyric gyro
#

someone mentioned it

merry knoll
#

no

#

runnable is for running something x ticks later

#

or every x ticks

#

what you want is something to work for a duration

#

meaning that you can easily achieve it by checking when it "works" to see if duration passed

#

if yes, disable

#

for which you want the start time and end time

lyric gyro
#

@merry knoll

#

is this good enough?

#

its not finished

merry knoll
#

its not seconds

#

its millis

lyric gyro
#

oh right

merry knoll
#

1 second = 1000 millis

#

currentTimeMillis gives the total amount of millis that has passed

#

since epoch

lyric gyro
#

1970

#

why that specific date though

merry knoll
#

so you can calculate a duration by just substracting one from another

lyric gyro
#

i dont understand this stuff

#

like why an iphone bricks if you set date to 1969

merry knoll
#

guess why

lyric gyro
#

because its before epoch

#

?

merry knoll
#

yes but why?

lyric gyro
#

i dont know

merry knoll
#

it goes into negative

lyric gyro
#

oh

#

yeah makes sense

merry knoll
#

and the way the number is stored in memory usually does not support it

#

(sometimes does)

#

so it usually wraps around

lyric gyro
#

before I started programming I always wondered why these things were stored in variables

#

like money in a video game

#

in most games when you have more than 2 billion and 147 hundred it stops counting how much you have

#

now I know that its to add and subtract

merry knoll
#

it just has to do with how numbers are stored in memory

lyric gyro
#

yeah

lyric gyro
#

I add 15000 millis (15 seconds)

#

and I make it so when it reaches that value

#

it stops running?

merry knoll
#

all you gotta do is store when you started or when you want it to end

#

then when an action happens

#

lets say damage event

#

you check if you are still in the time

#

if not, dont do it and clear from memory

lyric gyro
#

hmmmm

#

i see

merry knoll
#

its just a basic < > operation

lyric gyro
#

HashMap?

merry knoll
#

ideally yes

#

might want to use concurrent hashmap as well if you got multiple threads accessing it

lyric gyro
#

so I just do all that inside my method?

merry knoll
#

cooldown object there is a hashmap

#

[] is just the .get method

lyric gyro
#

kk

#

thanks for the help

#

this was surprisingly easy to understand

merry knoll
#

better version

lyric gyro
#

dont know if this is an easy topic or its me whos getting better lol

merry knoll
#

and when you want to put someone on cooldown

dense drift
#

= is better imo

merry knoll
merry knoll
#

so in cases like do this x ticks later or do that every y ticks

#

(or millis if you use the Timer version)

lyric gyro
#

mhm

#

I wanted to do it with ticks but idk how ticks are calculated so I cant

merry knoll
#

each tick is technically 1/20 of a second

#

under ideal circumstances

#

but this is not guaranteed

lyric gyro
#

so its easier to do with millis

merry knoll
#

well depends, you can argue that ticks is more fair since when server lags player cant really act

#

so its more consistent with minecraft time

#

so it depends on if you want irl time accuracy or in game time accuracy

lyric gyro
#

ok

#

now changing subject

#

since you are here

#

could you explain to me why sometimes my plugin just refuses to work

merry knoll
#

you are fucking some parts of it up

lyric gyro
#

like I play the horn and absolutely nothing happens

#

then I play it again and it works

#

sometimes it works and other times it doesnt

#

its really random

merry knoll
#

is it updated on your github?

lyric gyro
#

yeah

#

i updated it yesterday

#

when i finished coding version 0.08

merry knoll
#

you are adding a cooldown to it

#

is probably why

lyric gyro
#

i think its the server but idk

merry knoll
lyric gyro
#

40 second cooldown

merry knoll
#

thats probably why

#

well its not 40 seconds

#

its 800 ticks

merry knoll
lyric gyro
#

i thought it was for the item itself

#

like in game it has this 800 tick cooldown

lyric gyro
merry knoll
#

in ideal circumstances yes

#

but if a tick takes longer than 1/20 of a second

#

aka server is lagging

#

then no

lyric gyro
#

yeah so thats the reason

#

my pc has 4 gigs of ram only

merry knoll
#

check tps and see

lyric gyro
#

i was right

merry knoll
#

800 ticks is equal to 800 ticks

#

it will wait for that amount to pass regardless of how slow those ticks are

#

so if each tick is 1 second then 800 seconds it is

lyric gyro
#

there isnt much i can do ig

merry knoll
#

yep

#

but the millis approach avoids this issue

#

since it does not know nor care about the ticks happening

lyric gyro
#

i don't think its worth changing it

merry knoll
#

no it's not

lyric gyro
#

is there a way to make a mob despawn with a certain particle effect?

#

like dying/explosion particles

dense drift
#

spawn particles at their location

lyric gyro
#

what method is used to spawn particles

dense drift
#

world#spawnParticle

lyric gyro
#

javadocs dont really help

dense drift
#

is probably just cloud

lyric gyro
#

I can't refer goat outside the for loop because its and object from that loop

dense drift
#

if you open a curly bracket after the -> you can add more lines

#

and press control + c (or p, cant remember) to see the other parameters

dense drift
#

yeah not add a semicolon at the end of remove()

lyric gyro
dense drift
#

remove();

lyric gyro
#

the way you put your phrase made me confused

#

what do I do inside of here

#

ok I think i figured it out

#

im just a bit slow

#

I just needed to put goat

#

outside the loop

#

still cant get location tho

#

goat.getBukkitEntity().getLocation

#

I think

#

yeah now IDK

dense drift
#

d;world#spawnParticle

uneven lanternBOT
#
void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ)```
Description:

Spawns the particle (the number of times specified by count) at the target location. The position of each particle will be randomized positively and negatively by the offset parameters on each axis.

Parameters:

particle - the particle to spawn
location - the location to spawn at
count - the number of particles
offsetX - the maximum random offset on the X axis
offsetY - the maximum random offset on the Y axis
offsetZ - the maximum random offset on the Z axis

dense drift
#

use this

lyric gyro
#

oh shit

#

it's the count

dense drift
#

T is a generic

#

some particles can have additional data

lyric gyro
#

i think this is correct

#

is it?

dense drift
#

looks like

lyric gyro
#

cant believe I actually did something correctly in java

#

im evolving

dense drift
#

nice

#

😄

ebon whale
lyric gyro
ebon whale
proud pebble
#

i think they are making summonable goats to fight for them

#

or just goats to kill idk

lyric gyro
proud pebble
#

do the goats fight for you?

lyric gyro
#

yeah

#

they attack hostile mobs

proud pebble
#

so i was mostly right?

lyric gyro
#

yeah

ebon whale
#

Interesting

formal crane
wheat carbon
#

@formal crane put all the cards in the same row/column

lyric gyro
# lyric gyro

Maybe try using a lambda instead of an anonymous class?

#

They’re pretty neat things, you should look them up

formal crane
mystic gull
#

Hello, i have a question in this plugin : https://www.spigotmc.org/resources/crackshot-guns.48301/ . When we're shooting with their guns there are ammo, but when we i restart the server the same amount of ammo are here where did they store the ammo of the specific gun ? (i dont see any yml file for this)

nimble vale
#

if there isn't any db or anything related ^

lyric gyro
lyric gyro
lyric gyro
#

you are using a lambda in your forEach method btw

#

so you probably have some idea on the syntax

#

I didn't really wrote that part

#

What do a lambda do

lyric gyro
lyric gyro
lyric gyro
#

watched a tutorial on lambdas and got pretty confused

edgy lintel
lyric gyro
#

java doesnt use functions

#

is it just another name for something?

edgy lintel
edgy lintel
#

like for me lambda is good for intensive storing/using/customizations and its flexible for using/modifying it on a fly

like you have
Function<Integer,Integer,Integer> in an interface or a class where you can port functions to it
you can assign it to be a sum function where two integers will be summed to result
or you can assign it to be a multiplying function where two itnegers will be multiplied for result

you can port/invoke the right methods/functions to it depending on your choice

lyric gyro
#

or vice versa

edgy lintel
#

for me it is

lyric gyro
#

oh ok

#

never heard someone call methods functions

edgy lintel
#

methods is a word heavily used in java maybe thats why

edgy lintel
#

but its basically just a nameless function that only recognizes parameters and return type
and its best used when you want to use it for a short time

lyric gyro
#

i think ill have to use lambda again for what im doing rn

edgy lintel
#

im not really that much of a lambda user so i cant tell more cases of how it can be used

#

but thats the best ive got for you

lyric gyro
#

maroon be typing the entire bible tho

edgy lintel
#

expect the text bomb

#

1GB of coding bible

lyric gyro
#

if we were to write the entire bible in notepad

#

how much would the file weight

lyric gyro
# lyric gyro watched a tutorial on lambdas and got pretty confused

Okay so I'm guessing you have a basic understanding of interfaces and how to implement them. Basically there are some interfaces called 'Functional Interfaces', which are pretty much just a regular interface with a single method. Kind of like the BukkitRunnable interface.

interface BukkitRunnable implements Runnable {
   void run();
}

To make a runnable, you wanna have a class that implements this interface. So kind of like this

class myCoolRunnable implements BukkitRunnable {
    public void run() {
     // run some cool thing here.
    } 
}

That's all good an dandy, but it gets tedious to do this every time you want to run something simple or want to access other things inside your class. That's where 'anonymous classes' are used. You can basically just do a new BukkitRunnable implementation inside wherever. You won't be able to reference it anywhere but usually that isn't necessary. So the syntax evolved to look something like this:

methodWhichNeedsRunnable(new BukkitRunnable {
  public void run() {
    // run something cool here. 
  }
}

That's easier than having to make a whole new class to implement your thing in most cases. Now, lambdas came around and made this even shorter. So now you end up writing something like this:

methodWhichNeedsRunnable( () -> {
  // run something cool here.
}

The empty () are basically the parentheses in the run**()** method. That means there are no parameters or anything you have to pass.

edgy lintel
#

it would weight roughly a trillion electrons and thats 20 usd in total what payment method do you prefer? paypal?

#

OMG

lyric gyro
#

the effort

edgy lintel
#

praise maroon

dusky harness
lyric gyro
#

rn im messing with really hard stuff

#

the more difficult part of java

edgy lintel
lyric gyro
edgy lintel
#

concerning what data type would be used to store the lambda functions you are messing with please refer to this graph
its lambda bible for me

the stuffs on the left is parameter
the stuffs on the top is return value

lyric gyro
edgy lintel
#

because bukkitrunnable implements runnable in the green box

#

and runnable can be simplified to ()->{} thing without return value

lyric gyro
edgy lintel
#

maroon bible stays strong

lyric gyro
#

amen 🙏

dusky harness
merry knoll
#

what is the best way to make a function with a lot of parameters smaller?

dense drift
#

builders?

merry knoll
#

it just builds an object, but builder pattern doesnt really fit my use case

merry knoll
#

since i can just set the fields directly

pulsar ferry
#

Can you show an example of the function you have?

merry knoll
#

for example this is the class being built

#

it gets serialized into sql hence the size being this big

#

dunno it just feels not great, but not sure how i would go around making this smaller

#

thought about combining the player stuff into a separate object

#

that holds uuid - name - ip

pulsar ferry
#

Oh dear

merry knoll
#

so that would decrease this mess by 6

#

but still way too much

pulsar ferry
#

Hmm yeah if that's serializable then idk what you can do to make it smaller

merry knoll
#

i will just write a wrapper i suppose

#

so at least creation is easier then

shadow raft
#

I'm trying to automate the whole compile to server thing for my plugin which is taking a lot of time from me, and someone recommended this way. What I am trying to achieve is to just push the plugin to my GitHub and make my remote server build and put it in the server, if anyone knows a better method, feel free to share your experience

sterile hinge
#

for your remote (production?) server, you shouldn't use hotswap or similar to update plugins. Those features are mainly meant for development

shadow raft
lone saddle
#

How you create NBT Tags with spigot 1.17.1 for ItemStacks?

somber gale
#

What's the easiest way to override the tab completion of a bukkit command (In my case /pl)?
I want to insert new args for the command

dense drift
somber gale
#

Ok. How could I check what command triggered the event? getBuffer?

lyric gyro
#

yeah getBuffer and get the string until the first whitespace

#

what the fuck is this spacing lmao

sterile hinge
#

I think there's a symbol normally as it's an external link?

#

yeah that's what it looks like for paper

lyric gyro
#

spigot moment

somber gale
dense drift
#

why dont you register a new command?

somber gale
#

I do have a command.

#

Tho, I can't just override the plugin command from my testings

dense drift
#

there's gotta be a way

somber gale
#

PlayerCommandPreprocessEvent

hoary scarab
hoary scarab
somber gale
#

I recall trying it but Spigot just ignored it

hoary scarab
#

You can but it's kinda "hacky". I'm pretty sure I do it with aliases. I'll check when I get on PC later.

turbid jewel
#

Yo, stupid question, how do I send a title to a player on a runnable but a title that doesn't glitch and all?

#

fadeIn/fadeOut at 0, and stay on waht?

#

Too braindead atm

lyric gyro
#

stay is for how long the title will be shown on the player's screen

turbid jewel
#

OOH

#

lmfao, ty

#

My bad lolz

lyric gyro
merry knoll
#

?

lyric gyro
#

guess what

#

i need help

neat pierBOT
#

There is no time to wait! Ask your question @lyric gyro!

lyric gyro
#

yesterday you told me what i need to do to do that thing i wanted to do

#

but idk how ill do it

merry knoll
#

i remember giving you example code

lyric gyro
merry knoll
#

whats the issue

lyric gyro
#

the issue is

#

i dont understand kotlin

merry knoll
#

that barely has any kotlin

#

not gonna spoon feed you

lyric gyro
#

you said i need to make a hash map

#

that stores the current time

#

right?

merry knoll
#

no

#

it needs to store when cooldown ends

lyric gyro
#
  • 15000
merry knoll
#

yep

lyric gyro
#

cool

#

why isnt method .add not working

merry knoll
#

its put afaik

#

for hashmap

lyric gyro
#

what

dusky harness
#

also note that every time you run that method, timeMap will be empty since you're creating it each time

lyric gyro
#

outside the hashmap

#

thats why its there

#

outside the map

#

the method**

merry knoll
#

put it as a field

lyric gyro
merry knoll
#

make it a class variable

fiery pollen
#

When using the addItem(ItemStack... items) Method, it will return a Hashmap<Integer, ItemStack> with the key the index of the paramter, what do they mean with the key?

dusky harness
#

d;spigot Inventory#additem

uneven lanternBOT
#
@NotNull
HashMap<Integer,ItemStack> addItem(@NotNull ItemStack... items)
throws IllegalArgumentException```
Description:

Stores the given ItemStacks in the inventory. This will try to fill existing stacks and empty slots as well as it can.

The returned HashMap contains what it couldn't store, where the key is the index of the parameter, and the value is the ItemStack at that index of the varargs parameter. If all items are stored, it will return an empty HashMap.

If you pass in ItemStacks which exceed the maximum stack size for the Material, first they will be added to partial stacks where Material.getMaxStackSize() is not exceeded, up to Material.getMaxStackSize(). When there are no partial stacks left stacks will be split on Inventory.getMaxStackSize() allowing you to exceed the maximum stack size for that material.

It is known that in some implementations this method will also set the inputted argument amount to the number of that item not placed in slots.

Returns:

A HashMap containing items that didn't fit.

Parameters:

items - The ItemStacks to add

Throws:

IllegalArgumentException - if items or any element in it is null

dusky harness
#

index of the parameter array

fiery pollen
#

yeah because it couldn't get added

#

oh ic

#

thanks

lyric gyro
dusky harness
#

okay so

merry knoll
#

the hashmap needs to be out

#

not the time

dusky harness
#

think about it like this:
when you run the method, you create a new HashMap<>()

#

a new HashMap

#

every time you run the method

#

if it's outside of the method, you create it only once

#

however, for time, you want to create that every time the method is ran, right?

merry knoll
#

with your setup

#

chances are you want that hashmap static as well

#

each instance is one cooldown right?

dusky harness
lyric gyro
dusky harness
#

🚨

merry knoll
lyric gyro
#

I dont get it

merry knoll
#

you want the hashmap to be shared between instances

dusky harness
#

?di

neat pierBOT
merry knoll
#

lmao no

#

you are not passing it

#

its a perfect use of static

lyric gyro
#

if I put the hashmap outside the method, i cant use variable time

dusky harness
#

thats known as static abuse

#

making variables static when you can use DI instead

merry knoll
#

its a perfect use of static

dusky harness
#

it can be used for that, but it's also known as static abuse

#

can't really show google example rn since im in the middle of a game

#

and am typing since I'm dead 💀

merry knoll
#

nah, not really

#

it would be abuse if he was using it from another class

#

its internal to that class

#

its just shared between its instances

dusky harness
#

Oh wait thats true

merry knoll
#

its a perfect case of static

lyric gyro
#

🍿

merry knoll
#

although its breaking single responsibility principle if you care about it

#

but its really not a big deal

lyric gyro
#

^

dusky harness
#

woah ur pfp

icy shadow
#

what

#

did u just ping me

#

@lyric gyro

#

@lyric gyro

#

@lyric gyro

lyric gyro
#

what

#

did i just ping u

icy shadow
#

yes

brittle thunder
#

^^

lyric gyro
#

what

brittle thunder
merry knoll
brittle thunder
lyric gyro
#

so

icy shadow
#

you mother fuckers

lyric gyro
#

uh

icy shadow
#

what

lyric gyro
#

what do i do

brittle thunder
icy shadow
#

fuckers

#

lol

#

the singular is blocked but the plural isnt

lyric gyro
#

motherfuckers

#

lol

lyric gyro
merry knoll
#

meh

brittle thunder
#

jk

#

Let me check your previous message

merry knoll
lyric gyro
#

i wanted to do like a thing that runs code for 15 then stops

icy shadow
#

static mutable 😦
static immutable 🙂

lyric gyro
#

using system.currenttime

dusky harness
merry knoll
lyric gyro
#

what

merry knoll
#

just is really bad with explaining it

brittle thunder
lyric gyro
#

i do?

icy shadow
#

static im

merry knoll
lyric gyro
merry knoll
#

you want to enable something for x seconds

lyric gyro
#

play the horn gain the ability for 15 then go back to normal

brittle thunder
lyric gyro
icy shadow
brittle thunder
merry knoll
#

it doesnt get simpler than that honestly

icy shadow
lyric gyro
merry knoll
merry knoll
#

its just a variable

icy shadow
#

im gonna beat you up

merry knoll
lyric gyro
#

computers were a mistake

#

TRUE

icy shadow
#

kotlin was a mistake

brittle thunder
brittle thunder
lyric gyro
merry knoll
#

its just showing how to check if an amount of time has passed or not

icy shadow
#

ok jokes aside maybe showing kotlin to someone who (no offence) barely knows java is not a great idea

merry knoll
#

was the most convenient screenshot

lyric gyro
#

so

merry knoll
#

gimme a sec

lyric gyro
#

val (whatever the fuck that means)

#

is a variable equal to current time

#

the second line i dont understand

#

i dont understand this language

#

good

icy shadow
#

hope it stays that way

lyric gyro
#

i have a few options of what language i should learn next

#

h

#

and kotlin isnt one of them

#

good good

#

maybe C, C++, Python or Lua

#

idk

icy shadow
#

h

#

a

merry knoll
#

you made me code in java

icy shadow
#

good

#

hope it stays that way

merry knoll
#

here full implementation

#

it doesnt matter much, but clean up after yourself on player quit as well

icy shadow
#

not really necessary if ur using UUID

lyric gyro
#

oh god

merry knoll
#

meh, just good practice overall

lyric gyro
#

what is an uuid

merry knoll
#

unique id

#

player.getUniqueId afaik

merry knoll
icy shadow
#

sorry to hear that

lyric gyro
#

(when I say 'so lets see' it means I want you to help me understand this)

#

theres a lot of keywords that I dont understand

#

like containskey

icy shadow
#

those are not keywords

#

just method names

lyric gyro
#

what ever

icy shadow
#

you should really look into how the Map type works

#

containsKey pretty much does what it says in the name... it checks if the map contains the given key

merry knoll
lyric gyro
merry knoll
#

maps hold key - value pairs

#

where keys are unique

lyric gyro
#

how do I use this now

merry knoll
#

i mean its there, not sure how to answer

lyric gyro
#

make it do what I want it to do

#

do I write it here

merry knoll
#

you run addBuff when you want to activate

lyric gyro
#

ok

merry knoll
#

and you check isActive

#

when something happens that requires checking it

lyric gyro
#

ill do that tomorrow

#

for some reason saturdays are cursed for me

#

i cant code properly on saturdays

dark garnet
#

what?

     Searched in the following locations:
       - https://hub.spigotmc.org/nexus/content/repositories/snapshots/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > org.spigotmc:spigot-api:1.19.2-R0.1-SNAPSHOT:20220904.115031-14```
somber gale
#

I so far only know the PlayerCommandPreProcess event tactic

dark garnet
marble nimbus
#

making action bars (the one above the hotbar) stay is achieved using a repeating task right or is there a better way?

dense drift
#

yes

latent remnant
#

Is deluxe menu open source?

wheat carbon
whole yacht
#

I need help

neat pierBOT
#

There is no time to wait! Ask your question @whole yacht!

whole yacht
#

I want to make a discord bot but I don't know how to code and I have 0 money so can anyone help me

lyric gyro
#

how can i use the <red> tags and so? in deluxe menus

lyric gyro
merry knoll
#

but you wont be able to edit

wheat carbon
#

pretty sure there's one on steam

lyric gyro
#

?colors

neat pierBOT
#
FAQ Answer:
whole yacht
#

Name

#

Ok I got it

keen root
#

Hi i have some problems to control if an item has custom model data... It gave me problems when the cmodeldata is null (i use getCustomModelData() != null)

lyric gyro
#
 private final HashMap<UUID, Long> activeUntil = new HashMap<>();

    public boolean isActive(UUID uuid) {
        return activeUntil.containsKey(uuid) && System.currentTimeMillis() <= activeUntil.get(uuid);

    }

    public void addBuff(UUID uuid, Long duration) {
        activeUntil.put(uuid, System.currentTimeMillis() + duration);
    }

    public void onPlayerQuit(UUID uuid){
        activeUntil.remove(uuid);
    }
#

why is UUID needed here

dense drift
#

because uuids are unique

lyric gyro
#

what

dense drift
#

you need something to identifier the player, and their uuid is unique

lyric gyro
#

how to implement it in my code

dense drift
#

To get someone's UUID, you use Player#getUniqueId

#

UUID = Universally Unique Identifiers

lyric gyro
#

lol

dense drift
#

SHH I knew I was wrong while I sent it lol

lyric gyro
#

im saying that idk how ill use that code

#

to do what i want to do

proud pebble
#

what dont you understand with using it?

lyric gyro
#

but idk if i put it where i want the code to be run or in my listener

proud pebble
lyric gyro
warm steppe
proud pebble
#

i assumed that the code above is related to figuring out the cooldown

lyric gyro
lyric gyro
#

i just dont dont know what im supposed to do

proud pebble
#

what do you want to do?

lyric gyro
#

So like strike them when you hit them?

#

yes

#

That’s pretty simple. You need 3 event handlers and a map

lyric gyro
#

Wait no 2

#

You’d listen to the goat horn event (probably just player interact ), add the player to a map that consists of the UUID and the current time in milliseconds

#

Then when they hit an entity, check if the player is in the map, if they are then get the time that you saved and compare it to the current system time