#help-development

1 messages · Page 271 of 1

tender shard
#

?billyjoel

#

?billyjoel

#

?billyjoel

#

sth like this

remote swallow
#

we dont need it

tender shard
#

?1.8

undone axleBOT
tender shard
#

we do

remote swallow
#

we dont

tender shard
#

everyone likes billy joel

remote swallow
#

we do?

tender shard
#

if you don't like him, your music taste is shit

remote swallow
#

ah

tender shard
#

damn what a tiny rooster

#

I meant cock

main dew
#

basically modifies it in runtime using ByteBuddy

//MyClass
public static boolean interact(BlockFlowerPot var0, World var1, BlockPosition var2, IBlockData var3, EntityHuman var4, EnumHand var5, EnumDirection var6, float var7, float var8, float var9) {
        System.out.println("A");
        ((EntityPlayer) var4).getBukkitEntity().updateInventory();
        return false;
    }``` but I want something like this
```java
//NMS
public boolean interact(World var1, BlockPosition var2, IBlockData var3, EntityHuman var4, EnumHand var5, EnumDirection var6, float var7, float var8, float var9) {
        return MyClass.interact(this, var1, var2, var3, var4, var5, var6, var7, var8, var9)
    }```
tender shard
#
String theTruth = "You still haven't found what you're looking for"; //U2
#

here's proof that billy joel is nice

remote swallow
#

its red

#

so wrong

tender shard
#

I am just using a weird theme

remote swallow
#

no you arent

tender shard
#

I am

#

Darcula

remote swallow
#

yes

#

but that doesnt make class names red

tender shard
#

no idea why everyone thinks that dark mode is awesome

#

if I could vote for one thing...

#

I would not choose world peace

#

I would choose a world where light mode and dark mode users can live together without dark mode users hating on white mode users

#

I mean

#

it's kinda racist

#

"dark" people hating on "white" people

#

that's racist

#

also I am supposed to use "light" mode, I only wheigh 60kg

#

that's only 130 pounds

#

next time someone calls me out for using light mode, I'll call them out for being fat

#

how does that sound

remote swallow
#

i use dark mode

#

fuck you for using light

tender shard
#

it's called "African American mode" nowadays

remote swallow
#

i also only weight like 40gb

#

i weight 40gb?

#

what

#

i weigh 40kg

tender shard
#

40gb, that's half of GTA 5, damn

#

you don't wheigh 40kg

#

if you'd wheigh 40kg you'd be either disabled or dead

remote swallow
#

would i?

tender shard
#

well unless your size is only 1.2 meters

remote swallow
#

im like 5'4

tender shard
#

are you really that small?

#

are you female or sth

remote swallow
#

yes

#

no

#

i am a guy

tender shard
#

you must be very cute

remote swallow
#

just short

remote swallow
tender shard
#

anyway there's no chance that you only weigh 40kg

#

you'd be dead

remote swallow
#

do i have to find some scales

tender shard
#

40kg is 88 lbs

fathom carbon
#

lol

tender shard
#

what's your fist name?

#

if you call me by my first name, I am entitled to know your first name too

remote swallow
#

oh yeah just remembered

#

im underweight

tender shard
#

ok I'll just call you Heinrich then

remote swallow
#

hmmm

#

i might guess zackens name is zack tbh

tender shard
#

everyone's so afraid of getting doxxed

#

exactly

remote swallow
#

swat team enroute

#

(joke)

tender shard
remote swallow
#

they would barge it open

tender shard
#

but the SWAT isn't even allowed to do anything outside of the US

#

okay lemme rephrase

#

everythin the SWAT would do in germany would be forbidden

#

maybe they are allowed to do stuff in panama, idk

#

but not in germany

#

a judge would not approve the swat to smash my door though

#

and even if he would, then it'd be the city who'd have to buy me a new door

#

so whatever, I'd definitely get my door replaced

#

but the chances that this would ever happen are very very low

#

federal police knocked at my door 2 years ago because I got accused of selling organs

#

and they searched my fridge for kidneys

#

(yes, that really happened)

#

and they just knocked at the door

#

didn't smash any doors

#

I also once got sued by Horst Seehofer

#

kidneys are worth about 100k €

#

no

#

how much do you think they are worth?

#

and also nobody's gonna storm your apartment just because someone claimed "yo zacken02 has TNT in his apartment"

#

the police would probably just hang up

#

maybe, if it's a proper kidney

#

we are talking about black market kidneys

#

they first of all will ask you "where did you get this information from"

#

what would you reply?

river oracle
#

?paste

undone axleBOT
river oracle
#

yes

eternal oxide
#

3.3.0

river oracle
#

oh okay what version should I use?

tender shard
eternal oxide
#

I believe

river oracle
#

thanks

tender shard
#

so in the end of this video I had to clarify that he only looks like a garbage can, but that he actually is not one

river oracle
#

still erroring???

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:3.4.1:shade (default) on project miner: Unable to parse configuration of mojo org.apache.maven.plugins:maven-shade-plugin:3.4.1:shade for parameter relocation: Cannot find 'relocation' in class org.apache.maven.plugins.shade.mojo.PackageRelocation -> [Help 1]```
undone axleBOT
river oracle
#

wrong pomg

#

mb

tender shard
#

was about to say

river oracle
tender shard
#

that pom looks fine

#

it's not <relocate>

#

but <relocation>

river oracle
#

🤦🏽‍♂️

tender shard
#

basically just remove the whole <relocate> thing

#

it's supposed to be like this:

#
<relocations>
  <relocation>
    ...
river oracle
#

?paste

undone axleBOT
dim sandal
sterile axle
#

what exactly do you mean it doesn't target items on the floor

sterile axle
#

@dim sandal ```java
final RayTraceResult result = player.getWorld().rayTraceEntities(
player.getEyeLocation(),
player.getEyeLocation().getDirection(),
50d,
2d,
entity -> !entity.equals(player)
);

    if (result != null && result.getHitEntity() != null) {
        final Entity hitEntity = result.getHitEntity();
        if (hitEntity instanceof Item hitItem) {
            player.sendMessage(String.format("Player is looking at an item on the ground. Item is: %s", hitItem.getItemStack().getType()));
        } else {
            player.sendMessage(String.format("Player is looking at an entity. Entity is: %s", hitEntity.getType()));
        }
    }

Not sure what you mean, but it works for me.
remote swallow
#

you need to leave

#

playing on gui size 3

#

4

#

sorry

#

actually either

sterile axle
#

i just installed mc to test that

remote swallow
#

2x is the only reasonable

sterile axle
#

🤷 prob agreed, i just dont play mc anymore really. very rarely boot it up. had to install it just to test this and now its closed again for months probably

quaint mantle
#

Would it be possible to have setter methods as well in the API?

sterile axle
#

Unlikely

quaint mantle
#

Why that?

sterile axle
#

The sound is part of the client itself, the server can't change that

#

That's mod territory

#

You'd want to make a client mod w/ something like Fabric rather than a server plugin

quaint mantle
#

I mean, using another value of the ENUM

#

Is that really client side?

sterile axle
#

I mean you can just play any sound at any time you want

#

The server just sends a packet saying "hey client play dis sound"

#

I think there is a general sound playing function in the World class? Or Player

#

Not sure, let me see

#

So just call that with any sound enum entry

#

Hopefully that's what you wanted

#

If you wanted to change an entity's sounds to some other enum entries and such, it's a little bit involved. But you'll call setSilent on the entity so it doesn't make its own noises, then you'd use listeners to react to events like the entity getting hit/killed/moving whatever and just playing your own sounds instead.

#

Would be easier with a mod maybe? but it's doable on the server i guess

sterile token
#

Its an amazing library for those situations, when you need to test something

sterile axle
#

cool

sterile token
#

Its allows you to reproduce a fully server and client for making unit testing

#

But specific for mc related stuff

remote swallow
#

but isnt that something you would need to control on the client

sterile token
#

You know make me ask it myself

sterile axle
#

just quicker for me to spin something up and see it myself than figure out a new framework to mock it

#

but thats cool

quaint mantle
#

Jitpack is down

#

Anybody knows an alternative?

#

I just want to be able to use my github repos as maven repositories.

sterile axle
#

You don't need jitpack for that.

sterile token
sterile axle
#

if you just want to use a github repo as a maven repo you dont need anything special

sterile token
sterile axle
#

You don’t need jitpack ….

#

Fucks sake

#

Yes you can

#

Read the gist before talking out of your ass

sterile token
sterile axle
#

I’ll respect you when you can learn to fucking read

#

Open the gist. It works. You don’t need anything like jitpack.

remote swallow
#

github hosts the repo

#

its as simple as that

sterile axle
#

Yeah. That’s hard to understand.

sterile token
remote swallow
#

jitpack isnt github

#

jitpack is different

remote swallow
#

jitpack was down, simple said to use github packages instead

sterile axle
#

Not even gh packages it’s just using a regular repo and their raw file cdn

remote swallow
#

didnt know you could do that

sterile axle
#

Maven is stupid. If the proper file structure exists it doesn’t care

#

It will use it

remote swallow
#

ive seen the packages but thats cool

sterile axle
#

You can even put a basic web server up that has the correct file structure

#

It will still work

remote swallow
#

damn

sterile token
#

yeah, java and derivated (Kotlin, Groovy, Scala) artifacts are simple static files served in a url

sterile axle
#

So jitpack/nexus/whatever else are software packages on top of that basic idea that provide security and other features

#

But none of it is strictly needed

sterile token
#

Yeah indeed

#

How do they do the auth via settings,xml file

#

I never could make then use the credentials from there on my custom repository app

sterile axle
#

A GitHub repo acting as a maven repo is implied 100% public. Deployments can only be done via the basic deployment system on a local machine and then you commit it

remote swallow
#

that gist just seems weird, i get the concept would probably have to find something else online to use it

sterile token
#

Their wikis are really high level to read

remote swallow
#

doesnt have the best of instructions

sterile axle
#

What’s so weird about it? You just deploy to a local folder and then add, commit, push just like you do code

#

I’ll have to write an easier to understand tutorial I guess

#

It’s not difficult

remote swallow
#

well yeah but how do i setup the github part of it

sterile axle
#

Just make a repo

remote swallow
#

is it just creating the repo?

sterile axle
#

Yes

sterile token
#

Im being respectful man

sterile axle
#

Every repo can be accessed via the raw file cdn

#

How is that shitting on you?

sterile token
#

I wasnt unpolite with you

sterile axle
#

Grow up

#

No wonder you were banned

#

But whatever I don’t care. If you think you’re the smartest person here then you go do that. Waste your time and resources. Tell people whatever you want. I have no time for this anymore.

sterile token
#

Nice bro, you look like you came from paper comm, where they all toxic and when ever you say smth wrong without realize they shitty you. Talks amazing from you

jagged monolith
#

Got to love finally building up the motivation to finally start working on an update for your plugins, an you open the ide up and it's like heres 100 errors, 50+ needs an update

remote swallow
#

we love that

#

also where arent you mod

#

i saw you as mod in help chat the other day

river oracle
#

He's mod on luck perms

remote swallow
#

then i joined lucko's discord to check something and boom

jagged monolith
#

I'm Mod in a few different discords.

sterile axle
#

That’s me with the thing I’m trying to work on rn omega

#

Opened ide and I have 70 todos from months ago

#

Closed ide

remote swallow
#

he's even helper in moss

#

hes just a staff magnet

#

everywhere he goes

#

staff

river oracle
#

Discord mod

jagged monolith
sterile axle
#

Guess lots of people use jitpack

jagged monolith
#

I had to add it, Apparently one of the libraries I added required it

sterile axle
#

I checked their status page and they’ve been having trouble staying up seemingly. Many red days, some even in a row

river oracle
#

I use reposolite

remote swallow
#

damn

#

this is why we all hate jitpack

jagged monolith
sterile axle
#

Good luck soldier

sterile token
jagged monolith
sterile axle
#

Wait really

#

That used to be on central I thought

jagged monolith
sterile axle
#

That sucks

remote swallow
#

very

#

i just thought

#

why use jitpack when most of this is os

#

just build to maven local

#

boom

sterile axle
#

yeah that would be my temporary solution personally

jagged monolith
#

Apparently even pAPI is complaining about it

sterile axle
#

I wonder why they went down. I mean check their historical status page. It’s so red. Not sure why everyone is using a service that can’t seem to stay up

sullen marlin
#

Cause its free

sterile axle
#

I’m gonna post a tutorial on how to host your own repo with GH. I didn’t think that gist was so hard to understand

jagged monolith
#

It's annoying. I don't really want to not use the apis, but then again, it's stopping me from updating lol

sterile axle
#

Yea, that’s annoying for sure

jagged monolith
#

Ehh, i'm just going to switch to game development for a while then. Can't be bothered haha

remote swallow
#

if anyone here fucks with github packages would they by chance know the following

name: Publish package to GitHub Packages
on:
  push
jobs:
  publish:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-java@v3
        with:
          java-version: '16'
          distribution: 'adopt'
      - uses: SpraxDev/Action-SpigotMC@v4
        with:
          versions: 1.18.2, 1.17.1
      - name: Publish package
        run: gradlew publish
        env:
          GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}
``` with the correct stuff in my build.gradle would this just work or would i need more on my end
#

ok after a tad more researching the GIT_TOKEN wouldnt work so i need to figure out what that is

dim sandal
sterile axle
#

np

dim sandal
#

i mustve had some dubious if statements somewhere that i removed without knowing

sterile token
#

HI

#

I have been debugging a lot and i cannot cancel the second hand / off hand usage

#

Because i have debug and the messages are double all time, its making my head explode

jagged monolith
#

Add the getHand() to your debug message and see what it says

sterile token
#

okay

#

Im really stressed with this stupid thing, more than 3h 30m trying to solve this

jagged monolith
#

3.5 hours is nothing... Wait till you reach the x amount of days

sullen marlin
#

You never setCancelled.

jagged monolith
#

^ that as well, you commented it out

sterile token
#

yeah just for test reason, because my logic is next:

When you have the build on you shouldnt:

  1. Use off hand (being user and having mode active, if you have the permission you bypass it)
  2. Not able to interact
jagged monolith
#

uncomment the setCancelled.

sterile token
#

ok i will try the code cancelling it*

#

Also im stupid as fuck, because not canceling the event makes the next code of block being executed 🤡
In my case the else-if being executed, but why does it join into it, if im not using off hand?

#

That why i really mixed with that

sullen marlin
#

Its two separate events

sterile token
#

How md5, i cannot use the same event?

sullen marlin
#

Thats why you see both messages

#

It’s not merging the ifs lol

sterile token
#

yeah that why. its pretty weird that brokened my self

#

Now everything makes senses

#

It was being called both for block and off hand interaction , as far i didnt cancell it the next block of code was being executed

#

Thanks md5

#

Okay i realize something, when i right click it detect it as off hand too 🤡

#

That is causing all the problems

#

Because as right click is detected ass Off hand, then i cannot place nor breaks blocks inside the area

#

its finally brokened by brains idk how to do it

fathom hornet
#

how do i get the item which is being cooked in a FurnaceBurnEvent?

#

apparently Furnace used to have .getInventory but doesnt now, and i am lost

sterile axle
#

you use getBlock

#

That will be the block that is being ‘cooked’ in the furnace

#

Oh wait a minute

#

Nope ignore that.

#

getBlock will return the block that is the furnace itself. Then you should be able to cast it to a furnace block and get the inventory itself from that. FurnaceBurnEvent is usually used for detecting the fuel being burnt

#

I think you want FurnaceSmeltEvent instead.

fathom hornet
#

lmao

#

why are those different events

#

thank you so much

sterile axle
#

np

gleaming grove
#

Does anyone know how Lombok works under the hood? How In this example the Getters method are both included in class and I invisible in IDE? As far as I've read about annotation processor it's only triggered on Java code compilation

ivory sleet
#

Yep

sullen marlin
#

Correct

gleaming grove
#

But Lombok generates code dynamicaly or does IDE compile code every time I make change in code?

sullen marlin
#

The latter usually

quaint mantle
#

I want to get the title of my inventory but it says that i dont have the method ??

sullen marlin
#

Title is in view not inventory

gleaming grove
#

and how it is possible that getters are invisible

sullen marlin
#

They're in the compiled code not the source

quaint mantle
ivory sleet
#

Well, IDEs make it possible in the way that you get up code suggestions for getters, setters and other stuff that is gonna be generated by lombok

sullen marlin
#

?jd-s

undone axleBOT
gleaming grove
#

right then

wary kettle
#

is there any issues id run into with adding lores to almost every item

#

like would world folders be significantly bigger

sullen marlin
#

No

quaint mantle
#

why error

humble tulip
#

You can't listen to something that isn't an event

quaint mantle
#

im new to spigot

humble tulip
#

?events

#

?help

undone axleBOT
#
CafeBabe Help Menu
*Red V3*
**__Admin:__**

selfrole Add or remove a selfrole from yourself.

**__Cleanup:__**

cleanup Base command for deleting messages.

**__Core:__**

embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.

**__Downloader:__**

findcog Find which cog a command comes from.

**__Mod:__**

names Show previous names and nicknames of a member.
userinfo Show information about a member.

**__ModLog:__**

listcases List cases for the specified member.
reason Specify a reason for a modlog case.

**__Permissions:__**

permissions Command permission management tools.

humble tulip
gilded knot
#

Small bug on my plugin which utilises MySQL database connection

#

I assume it's because the connection needs to be closed?

drowsy helm
gilded knot
#

Right, cheers

humble tulip
gilded knot
#

Nope, The issue was that I don't close my connections after executing queries

humble tulip
#

Just query the db every 5 mins with SELECT 1;

#

Are you using hikari?

gilded knot
#

No

#

jbdc

humble tulip
#

Yes then query the db every 5 mins

#

Leave the connection open

gilded knot
humble tulip
#

Yes

#

So don't connect every time

gilded knot
#

I mean, is there an issue connecting every time?

humble tulip
#

Yes with higher player count

#

You'll have more joins

#

So more connections being opened constantly

#

Orr

gilded knot
#

right

humble tulip
#

Use 1 connection, don't close it

#

And check isConnected before using

#

If it's not, you need to reconnect

gilded knot
#

hm

humble tulip
#

Or use autoReconnect = true

summer agate
#

I disagree, having a single connection leads to queries waiting on each other

humble tulip
#

So you don't have to do that

summer agate
#

Because the connection can only use one thread

gilded knot
#

Bare in mind the plugin is meant for hubs

#

It's something I custom coded, a referral system

#

if a gamemode is shutting down

#

suddenly like 50 players will be sent to the hub

#

Lol

humble tulip
sterile axle
#

Do not hold a connection open by querying on interval for the love of god

#

Use a pool or close your connection and reopen it as needed

onyx fjord
#

is there priority higher than MONITOR 😂 ?

humble tulip
#

😂

onyx fjord
#

a plugin decided to use monitor and i need to be higher than that

humble tulip
#

Try to get your listener executed after it

onyx fjord
#

ye how tho

eternal oxide
#

runTask so your code runs 1 tick later

onyx fjord
#

ehh but that'll add some latency

#

yeah they def dont just log

eternal oxide
#

throw their plugin away then

#

Never modify on Monitor

onyx fjord
#

aha whats that for?

humble tulip
#

It contains all the listeners

#

You could lower the priority of their listener if you don't mind being hacky

onyx fjord
#

so what you mean is that i can change their priority?

humble tulip
#

Yep.. I think

onyx fjord
#

wait if listeners have the same priority

#

how do they run, in what order i mean

humble tulip
#

The order that the bake() method puts them into a list ig

onyx fjord
#

mhm so i can put myself later or earlier in order then right

onyx fjord
#

is there a tutorial to nms packets?

sterile axle
#

Wiki.vg I guess. But that’s just the protocol docs.

onyx fjord
#

yea not what i meant but i found it

#

i needed to know how injecting works

gleaming grove
#

How can I force YamlConfiguration to save my IP String like '1.111.111.111' instead of 1.111.111.111?

#

nvm It is unnecessary to use ' ' for strings in yaml

rotund ravine
#

You'd have to save "'1.111.111.111'" or smth

twilit roost
#

is this smart
or stupid?

gleaming grove
#

I would use Persistent annotation over classes then single fields, that would be more flexible

twilit roost
#

right
rn I'm running test() on start
but I don't get any souts in console

#

for some reason I only get STARTASDASD in the Console
any clues why?

#

maybe due to saving process being inside interface

gleaming grove
#

You are running it with Spigot or Unit tests?

twilit roost
#

spigot onEnable

#

like so

gleaming grove
#

try use getDeclaredFields instead of getFields

#

getFields only returns public fields

twilit roost
#

but why doesn't it even print out this line?

gleaming grove
#

spigot dont really like System.out.printLine, try Bukkit.getConsoleSender().sendMessage()

twilit roost
#

changed nothing but what u said
and got this

#

?paste

undone axleBOT
gleaming grove
#

oh that is the reason

#

so

twilit roost
gleaming grove
#

field.setAccessible(true);

#

that will do the job

twilit roost
#

ye forgot to accesible it
thx

#

right now I have struggle getting that Object
its poiting towards screenshot 2
I would guess I have to change f.get(f) to f.get(f.getName())?

gleaming grove
#

what is f

twilit roost
gleaming grove
#

field.get(object)

#

the object should be in your case instance of LanguageGeek

#

LanguageGeek geek... -> Object value = field.get(geek)

twilit roost
#

thx
works fine now

#

btw should I try using reflections to scan thru all classes in project and save them, if they contain @Persistent?

gleaming grove
#

Im doing that in my project to handle Yaml mapping to objects

twilit roost
#

I tried doing so via org.reflections.reflections
but it didn't work for me

gleaming grove
#

loading of all plugin classes is a littlebit tricky

#

for sec I give you code example

tardy delta
#

why do people do ifAnnotationPresent -> getDeclaredAnnotation

#

same thing like checking map#contains and then map#get

#

and reflections is already slow asf

gleaming grove
tardy delta
#

you can always say such things

gleaming grove
#

should I stop using Json because reflections are slow?

#

or spigot @EventHandler

tardy delta
#

json doesnt use reflections

gleaming grove
#

*gson, so how it map file to object

tardy delta
glossy venture
#

catch

tardy delta
#

could use an IdentityHashMap for classes as key

gleaming grove
#

good to know, I will read about it

tardy delta
#

it considers two keys as equals if k1 == k2

full holly
#

Does anyone know how to fix this error? java.lang.IllegalStateException: zip file closed

hazy parrot
#

To get that error

full holly
hazy parrot
#

Are you using JDA?

#

If not, put full stack trace pls

full holly
#

funny, I found the error now xD

#

Bukkit.getPluginManager().disablePlugin(this); caused it whyever

quaint mantle
#

anyone know how to remove the ai of an entity?

full holly
summer agate
full holly
#

xD

summer agate
#

Never knew this existed haha, the more you know

quaint mantle
full holly
#

Endermite endermite = .......;
endermite.setAI(false);

LivingEntity entity = .......;
entity.setAI(false);

twilit roost
#

how tf do I get interface from class?
reflection

summer agate
twilit roost
gleaming grove
#

you can not cast Class<?> object to interface

quaint mantle
summer agate
#

If you change Entity to LivingEntity you can call the AI method, alternatively you can change it to EnderMite

full holly
#

yes, this should work:
Entity entity = e.getPlayer().getWorld().spawnEntity(loc, EntityType.ENDERMITE); LivingEntity endermite = (LivingEntity)entity; endermite.setAI(false);

dry forum
#

section.getDouble() always return 0.0

quaint mantle
twilit roost
# gleaming grove

eeeh im new to reflections; therefore Im sorry for not being able to do such things alone 😄

But what should I pass there? I got rid of that Interface, therefore there isn't anything I can pass there

gleaming grove
#

so basically you gives as parameter Class<?> class metadata, but to make it working there should be provided List<Object> list of objects that need to be saved

#

then from each object you can get Class, object.getClass()

#

and use object inside that loop to get field value, f.get(object)

tender shard
#

does anyone know how I can access custom java objects from within velocity?

#

(VTL)

tender shard
#
Person mfnalex;
String nameOfMfnalex = (String) Person.class.getDeclaredField("name").get(mfnalex);
#

like this

twilit roost
#

ooh right

#

wondering how to get that Object tho
as JW said; im trying to loop thru all Objects in Class, but then I dont have Fields
and 🔄

full holly
#

yes that would be much easier 😆

gleaming grove
twilit roost
#

right
but I don't have slightest clue how to get those Objects

gleaming grove
#
         objectsToSave.add(new ExampleData());```
tender shard
#

I mean, you do have a class. And you need to get all the fields from a certain object of that class, right?

#
public class MyPlugin extends JavaPlugin {

    public class Person {
        String name = "name";
        int age = -1;
    }

    @Override
    public void onEnable() {
        Person mfnalex = new Person();
        for(Field field : mfnalex.getClass().getDeclaredFields()) {
            String fieldName = field.getName();
            Object value = field.get(mfnalex);
            System.out.println(fieldName + ": " + value);
        }
    }
}
twilit roost
gleaming grove
#

In some place of you plugin, propably OnEnable, you want to create instances of objects that has Persistent annotation
and store then inside of List. So instance can be created manually var geek = new LanguageGeek or with reflections var geek= LanguageGeek.getClass().newInstance()

tender shard
# twilit roost I have custom annotation `Persistent` and Im trying to save every `Field` inside...
    public static boolean isAnnotatedWithmyAnnotation(Field field) {
        return field.isAnnotationPresent(Persistent.class);
    }

    @Override
    public void onEnable() {
        Object yourObject;
        for(Field field : yourObject.getClass().getDeclaredFields()) {
            if(isAnnotatedWithmyAnnotation(field)) {
                String fieldName = field.getName();
                Object value = field.get(yourObject);
                System.out.println("I found a field called " + fieldName + ". It's annotated with my custom annotation. And here's its value: " + + value);
            }
        }
    }
#

if you do this often though, you should rather cache the fields. reflection is kinda slow

twilit roost
gleaming grove
#

you can make this trick ``` var plugin = JavaPlugin;
var plugin = JavaPlugin;
var scanner = new AssemblyScanner(plugin);
var classes = scanner.findByAnnotation(YamlFile.class);
var instances = new ArrayList<Object>(); //here are objects
for(var clazz : classes)
{
var constructors = clazz.getConstructors();
if(constructors.length == 0)
{
continue;
}

        var instance = constructors[0].newInstance();
        instances.add(instance);
    }```
#

IK newInstance() for demonstration purpose only

#

fair enoght, fixed

twilit roost
gleaming grove
#

I use to this code style from job

twilit roost
#

oh right

#

but it isn't beneficial in any way tho?

gleaming grove
#

code is in one line, and you type less

#

mainly it is beneficial when a class is called like VeryVeryVeryImportantUserService

elfin pilot
#

yo, can i interrupt this real quick to ask a question about blockdata

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!

elfin pilot
#

Lmao alright

#

I'm trying to set the state of a block but it won't change no matter what I do. I'm trying to set the growth value of some crops if a certain event is happening on my server

#

    @EventHandler
    public void crop(BlockGrowEvent event) {
        if(NightCycleWatcher.CURRENT_EVENT.equalsIgnoreCase(NightCycleWatcher.BOUNTIFUL_DAY)) {
            //The crop growing event is happening. Crops grow faster in this event
            Block block = event.getBlock();
            Material type=block.getType();
            
            switch(type) {
            case BEETROOTS,WHEAT,POTATOES,CARROTS,NETHER_WART,MELON_STEM,PUMPKIN_STEM,COCOA:
                int growthChance=ThreadLocalRandom.current().nextInt(0,3);
                if(growthChance==1) {
                    Ageable ageable=(Ageable)block.getBlockData().clone();
                    ageable.setAge(ageable.getMaximumAge());

                    Bukkit.broadcastMessage("Bonus growth! (" +ageable.getMaximumAge()+")");
                    
                    block.setBlockData(ageable);
                }
            
                break;
            default:
                break;
            }
        }
    }
#

Oh god the formatting

#

This is my code. Bukkit.broadcastMessage fires just fine and retrieves the correct maximum age of the block (7 for wheat) but .setBlockData seems to do nothing

#

Essentially it should set the crops to max growth

undone axleBOT
elfin pilot
tender shard
#

var plugin = JavaPlugin;

#

what's that o0

tender shard
#

oh wait

#

you are using blockdata, not blockstate

#

sorry mb

elfin pilot
#

Lol np, I searched the forums and came to the same result

tender shard
#

well actually not my bad, you said "state of a block" yourself 😛

elfin pilot
#

Heh

tender shard
#

does it print the "Bonus growth" message at all?

elfin pilot
#

yea

#

with the correct max age as well

gleaming grove
tender shard
#

try it without cloning the blockdata maybe

#

there's no need for a clone anyway

tender shard
#

I mean that's like saying

#
String name = String;
#

what the heck is that supposed to mean

sage dragon
#

If I make an ArmorStand ride a player, it will dismount if the player goes under water, right?

tender shard
#

I don't think so

tender shard
gleaming grove
twilit roost
#

yep found same answer 😄

gleaming grove
#
        for(var clazz : classes)
        {
            var constructors = clazz.getConstructors();
            if(constructors.length == 0)
            {
                continue;
            }

            var instance = constructors[0].newInstance();
            save(instance)
        }```
#

try this

elfin pilot
twilit roost
vale ember
#

Hi, i have a question. (Serialization via GSON)
I have a Map<Enchantment, Integer> and i want to serialize it so, that keys of the resulting objects are like minecraft:something, but when i actually do it, it is of form Enchantment[...], which i don't like. How can i fix this?

gleaming grove
#

propably will fail for some fields that has more complex types

tardy delta
#

register a typeadapter for a Enchantment

vale ember
#

i did

vale ember
# tardy delta register a typeadapter for a Enchantment
@JsonAdapterFor(Enchantment.class)
public class EnchantmentAdapter implements JsonDeserializer<Enchantment>, JsonSerializer<Enchantment> {
    @Override
    public Enchantment deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
        return Enchantment.getByKey(context.deserialize(json, NamespacedKey.class));
    }

    @Override
    public JsonElement serialize(Enchantment src, Type typeOfSrc, JsonSerializationContext context) {
        return context.serialize(src.getKey());
    }
}
twilit roost
tardy delta
#

wheres the annotation for

twilit roost
#

Target of Type

gleaming grove
#

maybe do @Ignore annotation to get rig of unwanted fields

vale ember
tardy delta
#

make them transient lol

#

not talking to you anyways

twilit roost
gleaming grove
#

or use transient keyword like Fourteen said

tardy delta
#

people be using stupid annotations

twilit roost
#

right right
but idk why it warns about ConfigurationKey, while the class doesn't have any
Maybe something during saving ?

sage dragon
#

Is it possible to somehow lower the nametag of an ArmorStand?

I made a small ArmorStand ride a player to preview text above the player, but it's a little high 😅

#

I could make it a Marker, but that would make it too low...

Using an Arrow + Marker Tag would be the perfect height, but always seeing an Arrow sounds annoying

vivid cave
#

Hi, how to send a packet to client that CHANGES the state / content / properties of an entity?
I have a bukkit Entity, an ItemFrame to be precise.
This ItemFrame has a content.
I want to make the client think that this ItemFrame holds another item (without changing it server side), so essentially I'd like to send a packet that makes the client update its content (purely visual) even though it doesn't happen for real

weak bear
#

Hey do you know why I have this error ?

vivid cave
#

@tender shard any clue?
Also could you link me again the website that gives all mojmaps and their associated CraftBukkit namespace and their obfuscated namespace?

opal juniper
opal juniper
vivid cave
#

ah thx

tardy delta
#

how can a 👡 scream

opal juniper
#

how can tokyo get destroyed

river oracle
#

nuke

weak bear
#

Where can I post my error ?

opal juniper
#

?paste

undone axleBOT
tardy delta
#

fuck

river oracle
#

fuck

opal juniper
#

not helpful

#

send the whole class

#

please just click control + a

#

i need the line numbers to line up

weak bear
twin elbow
#

How to setup NMS usage in intellij ? (the unobfuscated way)

weak bear
#

That's better?

opal juniper
#

yes

#

if(e.getClickedInventory().getName().startsWith("Report")){

#

by bet is on they didn't click on an inventory hence the inventory is null

weak bear
#

Ok so do you think that I dont need to use .startsWith ?

#

Maybe just .contains?

opal juniper
#

no you need to do a null check on thge inventory

#

but this is a horrible way of doing it

tardy delta
#

what meme is that class

opal juniper
#

^

tardy delta
#

380 lines of horror

weak bear
opal juniper
#

idk use inventory holders or a proper inventory GUI lib

tardy delta
#

man just look at it, youre doing the same thing for 20 times

#

not even a switch

weak bear
#

😅 yes I forgot that I can do that

#

Sorry I just start with java

tardy delta
#

and dont hardcode slot numbers

weak bear
#

okay

#

thx

tardy delta
#

bruh moment but how can i simplify this without breaking the logic

vivid cave
#

packet to change content of ItemFrame clientside

tacit night
#

can someone tell me why my blockbreakevent doesnt work. it has an eventhandler and is registered but the plugin dont call it

dry forum
#
                        ((Directional) data).setFacing(BlockFace.valueOf(section.getString("face")));
                        block.setBlockData(data);``` ``` java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_19_R1.block.data.CraftBlockData cannot be cast to class org.bukkit.block.data.Directional (org.bukkit.craftbukkit.v1_19_R1.block.data.CraftBlockData and org.bukkit.block.data.Directional are in unnamed module of loader java.net.URLClassLoader @5c29bfd)``` im trying to set the direction a block faces
limpid bloom
#

i am trying to place powered rails with a specific direction , or at least get a BlockData object that represents a powered rail with a certain direction , through the power of google and chatgpt i have no clue what to do, everything google says is a decapratied thingy and some of the few things that chatgpt says should work cause errors in console so i need some help

here are some examples of my code

        BlockData data = mat.createBlockData();
        Directional face = (Directional) data;
        face.setFacing(BlockFace.EAST);
        data = face;
        return data;```

```@EventHandler
    public void onHangPlace(HangingPlaceEvent event){
        if(event.getItemStack().isSimilar(ItemManager.getBob())){
           event.getBlock().setBlockData(BlockDataManager.east(Material.POWERED_RAIL));
           broadcastMessage(event.getBlock().getLocation().toString());
            
        }

    }```
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!

tacit night
#

its a question you just need to read it

#
@EventHandler(priority = EventPriority.MONITOR)
    public void onBlockBreak(BlockBreakEvent event) {
        Player player = event.getPlayer();
        World playerWorld = player.getWorld();

        Bukkit.getConsoleSender().sendMessage("BLOCK BREAK by " + player.getName() + " in " + playerWorld.getName());

        ConfigManager worldConfig = new ConfigManager(instance, "worlds/" + playerWorld.getName() + ".yml");

        player.sendMessage("Debug 1");
        if(event.isCancelled()) return;
        player.sendMessage("Debug 2");
        if(!worldConfig.getFile().exists()) return;
        player.sendMessage("Debug 3");
        if(!instance.buildModeIds.contains(player.getUniqueId())) return;
        player.sendMessage("Debug 4");
        if(worldConfig.getConfig().getBoolean("world.archived")) return;
        player.sendMessage("Debug 5");

        event.setCancelled(true);
    }

Its a normal breakEvent

remote swallow
#

?paste errors

undone axleBOT
remote swallow
#

that too

tacit night
#

i tryed it without the eent prio no response

#

yes

calm falcon
#

How do you register it?

tacit night
#

yeah its only the blockbreak event

quaint mantle
#

Hi

#

so

tacit night
#

its the marked line

quaint mantle
#

can i have help with this

 
[Penumbra] Enabling Penumbra v1.0-SNAPSHOT
[08:36:06 ERROR]: Error occurred while enabling Penumbra v1.0-SNAPSHOT (Is it up to date?)
java.lang.IllegalArgumentException: Plugin cannot be null
    at org.apache.commons.lang.Validate.notNull(Validate.java:192) ~[commons-lang-2.6.jar:2.6]
    at org.bukkit.craftbukkit.v1_19_R1.scheduler.CraftScheduler.validate(CraftScheduler.java:462) ~[craftbukkit-1.19.2-R0.1-SNAPSHOT.jar:3566-Bukkit-c379a6b]
    at org.bukkit.craftbukkit.v1_19_R1.scheduler.CraftScheduler.runTaskTimer(CraftScheduler.java:196) ~[craftbukkit-1.19.2-R0.1-SNAPSHOT.jar:3566-Bukkit-c379a6b]
    at org.bukkit.craftbukkit.v1_19_R1.scheduler.CraftScheduler.runTaskTimer(CraftScheduler.java:187) ~[craftbukkit-1.19.2-R0.1-SNAPSHOT.jar:3566-Bukkit-c379a6b]
    at org.bukkit.craftbukkit.v1_19_R1.scheduler.CraftScheduler.scheduleSyncRepeatingTask(CraftScheduler.java:182) ~[craftbukkit-1.19.2-R0.1-SNAPSHOT.jar:3566-Bukkit-c379a6b]
    at penumbra.penumbra.Penumbra.onEnable(Penumbra.java:22) ~[?:?]
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[bukkit-1.19.2-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:334) ~[bukkit-1.19.2-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:479) ~[bukkit-1.19.2-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugin(CraftServer.java:511) ~[craftbukkit-1.19.2-R0.1-SNAPSHOT.jar:3566-Bukkit-c379a6b]
    at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugins(CraftServer.java:437) ~[craftbukkit-1.19.2-R0.1-SNAPSHOT.jar:3566-Bukkit-c379a6b]
    at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:576) ~[craftbukkit-1.19.2-R0.1-SNAPSHOT.jar:3566-Bukkit-c379a6b]
    at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:395) ~[craftbukkit-1.19.2-R0.1-SNAPSHOT.jar:3566-Bukkit-c379a6b]
    at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:242) ~[craftbukkit-1.19.2-R0.1-SNAPSHOT.jar:3566-Bukkit-c379a6b]
    at net.minecraft.server.MinecraftServer.v(MinecraftServer.java:947) ~[craftbukkit-1.19.2-R0.1-SNAPSHOT.jar:3566-Bukkit-c379a6b]
    at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:285) ~[craftbukkit-1.19.2-R0.1-SNAPSHOT.jar:3566-Bukkit-c379a6b]
    at java.lang.Thread.run(Thread.java:833) [?:?]```
vocal cloud
#

?paste your errors please

undone axleBOT
quaint mantle
#

ok

#

i did

vocal cloud
#

Then send the link lol. Pastebin is so that you don't clog up the channel with extra long messages

quaint mantle
vocal cloud
#

What is on line 22 penumbra.penumbra.Penumbra.onEnable(Penumbra.java:22)

quaint mantle
#

it is

vocal cloud
#

Send the whole class in a pastebin

quaint mantle
#

wait so where do I do it sorry I just woke up

undone axleBOT
quaint mantle
#

ooooooo lol

tacit night
#

its loaded, i cant break blocks when plugin is loaded but i dont become a response

#

yeah but there is no plugin with a break event

hexed void
#

I would like to set an NBT tag on an item, but is is not working.
can someone please enlighten me?

vocal cloud
#

?pdc use pdc instead

hexed void
#

Thank you so much
it helped me a lot :)

tacit night
# dry forum bump
Directional directional = (Directional) block.getBlockData();
directional.setFacing(BlockFace.EAST);
block.setBlockData(directional);```
sage dragon
#

What's the smallest Entity that can be made invisible? 🤔

tacit night
#

i think its a pufferfish

hushed pawn
#

i didnt do any kb modifications, ans even so i take that much kb that i cant touch ground, it hapend randomly

#

did anyone know such bugs?

#

on 1.8.8 server

undone axleBOT
sage dragon
#

Is there a way to have an invisible AreaEffectCloud?

dry forum
sage dragon
#

Expected it to throw an exception, but seems to work, thanks

final hatch
#

Hi

#

I have a problem with a plugin

dry forum
#

im using a chest

#

and im getting that error

undone axleBOT
final hatch
#

Plugin NametagEdit v4.5.11 generated an exception while executing task 23259

dry forum
#

                            Directional directional = (Directional) block.getBlockData();
                            directional.setFacing(BlockFace.valueOf(section.getString("face")));
                            block.setBlockData(directional);
                        

                        block.setType(Material.valueOf(section.getString("material")));``` 

ignore the random indents idk what happened
final hatch
#

They dont have discord

dry forum
#

the block can be anything

#

then id need to do that for every material

#

the material can be anything

#

im getting the direction a block is facing and then setting it the same way it was facing

#

it can be any block not just a chest

keen basin
#

java.lang.Throwable: Warning: A plugin is creating a recipe using a Deprecated method. This will cause you to receive warnings stating 'Tried to load unrecognized recipe: bukkit:<ID>'. Please ask the author to give their recipe a static key using NamespacedKey.

WHY ?

dry forum
#

but im testing with a chest which ofc can be rotatable and im getting that error

#

so i dont understand

undone axleBOT
dry forum
onyx fjord
#

u can use enhanced instanceOf btw

#

both names are commonly used

warm light
#

is there anyway to access the /plugins/update folder?

#

how?

#

checked almost all spigot post

#

I mean is there any method like "getDataFolder()"

#

to access the update folder

#

so anyway to access the server root folder?

#

how? (by spigot)

narrow sphinx
#

Hello fellas
Updating the API used in my plugin from 1.16.2 to 1.19.2, successful buildtools build but when I switch the library in eclipse, nothing is recognized and none of the imports work, what may I be doing wrong?

hazy parrot
tardy delta
#

Bukkit.getWorldContainer()?

fathom carbon
#

Is there a way to somehow reset the last time a player slept to prevent phantoms from spawning even without the player going to sleep?
I know the NMS entity player class has some sleepTicks field but idk if thats what im looking for

ivory sleet
narrow sphinx
chrome beacon
#

Are you using the jar directly or something like maven/gradle

narrow sphinx
#

I imported the jar directly as an external library

chrome beacon
#

?bootstrap

undone axleBOT
#

Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.

Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163

fathom carbon
#

Basically what i want to do is to stop phantoms from spawning even when players havent slept for longer than 3 days

#

(i know theres some shitty gamerule for that but thats not a solution for me)

chrome beacon
#

Doesn't look like there's a good way to set that value

fathom carbon
#

As I said i know theres this sleepTicks field in entity player but idk if that the thing that the game uses to determine whether phantoms will spawn or not

#

or actually i dont know what the value of this field means in general

#

if it is like time in ticks since the last time the player went to sleep then it's fine i can work with that

#

but as i said im not sure what that sleepTicks thing represents?

chrome beacon
#

hm interessting I was looking at the NMS code and it appears to be using the time since rest statistic for phantoms

subtle folio
#

How tf do I use a BaseComponent ???

#

why is it so hard

chrome beacon
subtle folio
#

How do I return a BaseComponent and not a BaseComponent[]

fathom carbon
#

That wouldve been great

#

so i can just do like player.setStatistic(time since rest, 0) and thats it?

warm light
#

is there a way to know the name of my plugin file?
like if server owner changed it from original

hazy parrot
#

name of plugin is inside of plugin.yml, its not relevant to jar file

sage dragon
#

I'm currently playing around with ArmorStands as Nametags to display prefix and name with hex colors.

For some reason, as soon as the second player joins, the first player just sees a gigantic AreaAffectCloud and the ArmorStand doesn't seem to spawn.

It looks just fine for the second player itself though.

The first player is always fine, does anyone have an idea why this is happening?

Here's my current code:
https://paste.ofcode.org/hqJqqHgUyjBmTT8Q8bKgyk

warm light
hazy parrot
#

there is getCodeSource iirc

#

let me find real quick

#
 String jarPath = ClassName.class
          .getProtectionDomain()
          .getCodeSource()
          .getLocation()
          .toURI()
          .getPath();

It will return full path, just extract jar name after last /

warm light
#

thanks

glacial yew
#

What would I need to add in my if statement so that my custom item can generate a random item?

public class ItemHandler implements Listener {
    public void PlayerInteractEvent{
        Player player = event.getPlayer();
        if (event.getAction() == Action.RIGHT_CLICK_AIR) {
            
        }
    }
}
fathom carbon
charred blaze
#

How do I get item's material data correctly? I'm trying to use this below, but it pop-ups an error:
Material.REDSTONE_BLOCK.getData()
error:
java.lang.IllegalArgumentException: data should be class org.bukkit.material.MaterialData got class java.lang.Class

glacial yew
hazy parrot
ivory sleet
glacial yew
glacial yew
onyx fjord
#

i mean java 14 isnt that old @ivory sleet

ivory sleet
#

Its old enough kacper

glacial yew
#

I am new to using java

#

kinda

hazy parrot
glacial yew
weak kayak
# glacial yew I am trying to generate a random item by just right clicking with a custom item

i'd first go about making a list of Materials which are items
you can use Material#isItem to check if a material is obtainable
you could get all elements of the enum using Class#getEnumConstants by doing Material.getDeclaringClass().getEnumConstants() then loop through those, check if it's an item using #isItem(), add it to a list, and use that list to create a random itemstack

#

i'd do this in a static block

#

it might not be the best way to do it but it's a simple solution

quaint mantle
#

okay so basically I might be stupid but I can't figure this out lol

@Override
        public void onEnable() {
            HashMap<Integer, Integer> goldenAppleMap = new HashMap<>();
            AtomicInteger totalAppleCount = new AtomicInteger();
            Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, () -> {
                Bukkit.getServer().getOnlinePlayers().forEach(p -> {
                    Inventory inv = p.getInventory();
                    if(inv.contains(Material.GOLDEN_APPLE, 24)) {
                        for (int i = 0; i < inv.getSize() - 1; i++) {
                            ItemStack item = inv.getItem(i);
                            if (item != null && item.getType() == Material.GOLDEN_APPLE) {
                                if(item.getAmount() > 24) {
                                    item.setAmount(item.getAmount() - 24);
                                } else {
                                    goldenAppleMap.put(i, item.getAmount());
                                }
                                goldenAppleMap.forEach((slot, amount) -> {
                                    totalAppleCount.addAndGet(amount);
                                });
                                if(totalAppleCount.get() > 24) {
                                    goldenAppleMap.forEach((slot, amount) -> {
                                        while (totalAppleCount.get() > 24 && inv.getItem(slot) != null) {
                                            item.setAmount(item.getAmount() - 1);
                                        }
                                    });
                                }
                            }
                        }
                    }
                });
            }, 0L, 5L);
        }```
tardy delta
#

tf

quaint mantle
tardy delta
#

youre clearly really creative

quaint mantle
#

ooooo

weak kayak
#

i don't think you need to make it an atomic integer if it's a synced task but i'm unsure

tardy delta
#

what are you even doin

hazy parrot
weak kayak
#

ohhh yeah

#

i totally forgot about that

quaint mantle
#

I'm trying to make a plug-in where you can have a certain amount of one item in your inventory at once and if you have more than that set amount it will you cannot pick it up

hazy parrot
#

iirc there is api methode for it ?

quaint mantle
#

ooooo

weak kayak
#

i think there is an item pickup event

hazy parrot
#

something like Inventory#containsAtLeast ?

tardy delta
#

just listen for the item pickup event lol

quaint mantle
#

lol

weak kayak
#

i'll check docs for the exact name

#

you don't have to use the scheduler

#

PlayerPickupItemEvent

quaint mantle
#

ops

weak kayak
#

you should also probably listen to when they grab stuff from a chest too

dawn plover
#

i dont know why i cant click my messages?, does anyone know whats wrong?

weak kayak
#

or any other container but chests came to mind first

sage dragon
rough drift
#

Bukkit#getWorld loads if the world isn't loaded?

sterile token
#

Why the getHand() is Equipment.OFF_HAND, when you do right click and also when you interact with the slot itself? Doesnt make snse the first thing tho, im using PlayerInteractEvent and im just trying to block off hand usage, without cancelling placing nor breaking blocks

Really i have been such a long time debugging and i never could block the second hand usage tho

misty ingot
#
    public static CompletableFuture<Integer> getDeathbanAmount(OfflinePlayer target) {
        return CompletableFuture.supplyAsync(() -> {
            try {
                PreparedStatement statement = plugin.getConnection()
                        .prepareStatement("SELECT COUNT(*) FROM deathban_history WHERE UUID = ?");
                statement.setString(1, target.getUniqueId().toString());
                ResultSet resultSet = statement.executeQuery();
                if (resultSet.next()) {
                    return resultSet.getInt(1);
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
            return 0;
        });
    }

(used for PAPI placeholder) screenshot is what the placeholder returns

rough drift
sterile token
#

Mainly how processors cores works

rough drift
#

oh, world creator

sterile token
rough drift
#

yes

#

I need to load it, so yea

sterile token
#

okay, yes you need to use WorldCreator for loading words

ivory sleet
tardy delta
misty ingot
#
                case "deathbans":
                    return String.valueOf(DeathbanHelper.getDeathbanAmount(player));
ivory sleet
#

You’d have to append a callback to the future

#

And then print the result

tardy delta
#

nice placeholder lol

sterile token
#

Conclure i was going to suggest something like a callback

misty ingot
sterile token
#
@FunctionalInterface
public interface callback {

    callback(ResultSet results, boolean done);

}```
tardy delta
#

is the callback way even supported for papi? doesnt it just require a value immediately so you must join the future?

sterile token
tardy delta
#

like in the onPlaceholderRequest method or whatever

misty ingot
#

when I return Integer in the method instead of CompletableFuture and join the future it crashes the server (time out)

sterile token
tardy delta
#

how does that crash your server

sterile token
#

As the sever use 1 thread, the server is closed

tardy delta
#

\🤔

sterile token
#

CompletableFuture joins method, joins/stop the proccess from the current thread talking about if you havent pass an executor to CompletableFuture

#

That is what im making reference

ivory sleet
#

Oh

#

Its for papi

#

Well you might have to use some sort of polling desgn then

tardy delta
#

why not just cache those bans for each player? i hope a player isnt making a streak of it

sterile token
tardy delta
#

catch the database?

sterile token
misty ingot
dawn plover
#

hello, i have a weird question that i dont understand
i am trying to make my messages run commands
but for some reason the closest thing i can do is make it suggest commands
whats wrong and how would i fix it, i cant find anythong online

tardy delta
#

i always use the componentbuilder and it always worked

tardy delta
#

what yeah

sterile token
#

I think you must use the component builder but im not sure

tardy delta
#

would surprise me but whatever

sterile token
misty ingot
#

so um, how do I do my placeholder thing again?

sterile token
misty ingot
#

...

sterile token
#

Make a cache design, where you have your user data cached and you dont need to query at the time, so that will fix the issue

#

So it was what i have said?

misty ingot
#

so I put all their deathban amounts in some sort of list when they join and keep that list up-to-date (cuz the placeholders are really only for online players anyways)

sterile token
# misty ingot so I put all their deathban amounts in some sort of list when they join and keep...

I would make something like:

OnJoin -> Look for user cache, if doesnt exists load user data from db
OnQuit/OnKick -> Save user cache to db, if db doesnt contain it create it, if not just update their values

Also you have to save your data periodically, in case servers goes down that can be done by a runnable every x amount of time

When doing important changes must be directed updated to db

misty ingot
#

Ima just make a hashmap and keep it updated

#

and grab from it when needed

dawn plover
sterile token
#

bruh sorry man, now no one can said something wrong they all get mad 🤦‍♂️

#

Yeah yesterday a guy shitty me because i said smth wrong without realizing and now you being like that
What is happening to spigot comm it didnt use to be like that, i thought that was 10x better than paper comm

#

okay

#

So i want to improve my cache skills

#

So i just need to load from db into cache when i need right?

#

okay thanks man and sorry for what ive said i was mad with shity off hand issue

#

Elaborate a bit more

tardy delta
#

that cache may be unsynched

sterile token
#

When i need to use it sync in others server i prefer redis cache

#

Yeah thats what i done all time

tardy delta
#

fuck is unsynced with a h

sterile token
#

For single server db, plugin cache
For multi servers db, redis cache

#

Because you cannot always depends on an external database for just a single unsync plugin cache

burnt sand
#

I got this error

#

This is my code:

tardy delta
#

what error

burnt sand
tardy delta
#

what corresponds to line 83

#

dutch lmao

#

@burnt sand

burnt sand
#

Itemstack

tardy delta
#

what itemstack

burnt sand
#

Itemstack named Hamburger

#

Material Cooked Beef

tardy delta
#

bruh where is line 83

burnt sand
#

in the code from hastebin

#

from the class

tardy delta
#

are you kiddin me

burnt sand
#

no?

tardy delta
#

first guess is that your e.getInv().equals() throws that npe

burnt sand
#

i just used this

eternal oxide
#

Which actual line is 83?

tardy delta
#

line 83 ofc \🤡

sterile token
#

Could someone explain me, why the getHand() of the PlayerInteractEvent event is equal to Equipment.OFF_HAND, when you interact with the secondary hand or when you make right click. The second one is causing me problems, because when acting that way it cancels the events of placing and/or removing blocks

remote swallow
#

?interactevent

undone axleBOT
#

The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.

For example, only executing code if the main hand was used:

@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
        return; // do not progress past this point  |
    }
    // provide functionality
}
remote swallow
#

its called once per hand

#

so will be called for main hand and off hand pretty much

sterile token
#

Wait i wiill place my code? Because i need to cancel the second hand usage but also cancels placing/removing blocks

#

Its making me stress a lot because i cannot figure how to fix it

remote swallow
#

just cancel off hand events?

tardy delta
#

average programmer with a bunch of stress

sterile token
#

That is what im making reference and making my brain to burn

remote swallow
#

?paste your code

undone axleBOT
vivid cave
#

How to update an entity on someone's client, without updating it on the server? (Essentially, I just want to update 1 field / 1 setting of the entity and keep the rest intact)

Here is my progress so far:

  • I realise I have to use nms for such trickery.
  • I found that sending a ClientboundMapItemDataPacket to the client might do the trick. (previously called PacketPlayOutEntityMetadata)
  • But in order to construct such packet, a SynchedEntityData (previously called DataWatcher) is required (as 2nd argument).
    For those who don't know what it is, basically it holds the data of an entity AND ensures that its state is synchronized between client and server. But here is my whole issue. I do NOT want the server to be updated, i only want the client to be updated. Which means that if such object contains the data i wanna update on client's entity, necessarily, the entity toward which this object points to also has the update data (for real/on the server)
#

Please try to read me; i'm desperate. And since no one does NMS i find no help online

sterile token
#

I am using my code for a mini game, where I need that in a certain region they can place blocks/break, not use the secondary hand and at the same time they cannot interact with anything that have an inventory either blocks and/or entities.

tardy delta
#

event.getClickedBlock().isAir() \😉

sterile token
#

But can you explain me, why the heck is preventing for placing/removing blocks tho?

tardy delta
#

cuz clicked block != null?

sterile token
tardy delta
#

uhh what were you trying to do again?

sterile token
#

I put on black what i need

tardy delta
#

id just uncancel the blockbreak and place event

sterile token
#

But interaction is blocking them for some reason

tardy delta
#

because they cannot use their off hand but they may place and break blocks?

#

cuz that hand is involved in both those events?

sterile token
#

What i would have to do tho

#

Im already with 0.000001 brain working caused of that messing issue

#

😮‍💨

tardy delta
#

id just uncancel block break and block place

#

cant really assume that it was your plugin that cancelled it but whatever

sterile token
#

I dothat

#

But PlayerInteractEent is acting as super class, because it fck cancelling those events

#

Sorry fourten, i raged my bad man im really weird with this problem

tardy delta
#
void onInteract(PlayerinteractEvent event) {
  // blablabla
  if (event instanceof BlockBreakEvent blockBreak) {
    blockBreak.setCancelled(false);
  }
}```smth like this?
#

my head is alraedy full of other crap so cant help that much

sterile token
#

Hmn wait is burning brains, because PlayerInteractEvent and BlockPlaceEvent/Break are none related

tardy delta
#

isnt blockbreakevent a playerinteract event?

#

looks like it isnt

sterile token
#

That why i came here, because of this

#

So why the heck, cancelling interact event will not allow the second events (breaking and placing) !!

#

That the main reason of comming here

fluid river
#

what can be wrong here

tardy delta
#

cuz a blockbreak event fires an interact event too?

fluid river
limpid bloom
#

i keep on getting an error in console whenever i load my plugin, no clue why since it shows no errors in my IDE and it compiles fine, also i don't think i changed anything but it was working fine earlier
https://pastebin.com/ENVp6jKM

fluid river
#

it throws some random error

sterile token
tardy delta
#

russian segfault ig?

sterile token
fluid river
#

exception: violation of read access

#

idk

sterile token
fluid river
#

it's c++

tardy delta
#

jvm lol

fluid river
#

bruh

sterile token
tardy delta
#

good somehow becoming a nullptr?

fluid river
#

it's not even a resource

fluid river
sterile token
#

So let came back to my problem tho

fluid river
tardy delta
#

wouldnt make sense but c++ is tricky

fluid river
#

this is a kind of linked list

#

i'm just looping from head to the tail

sterile token
#

NukerFall, you remember you recommend me to use PlayerInteractEvent for cancelling the off hand usage?

fluid river
#

to find the childest child(chaddest chad)

west linden
#

what is the best way to convert a uuid in a string into a player. I have an uuid and i need to make in into player so i can use player.sendMessage("message");?

tardy delta
#

Bukkit.getPlayer(uuid)

#

and assure that player is online

fluid river
#

u can do offlinePlayer(uuid) afair

west linden
#

what is the best way to make sure that the player is online?

subtle folio
#

.isOnline() ?

tardy delta
#

Validate.isTrue(player.isOnline())

fluid river
#

Bukkit.getPlayer() != null

tardy delta
#

isnt always true

#

if player just went offline

fluid river
#

enough for me

sterile token
#

Lmao know no one know what happening i love this type of situations

fluid river
#

casting

#

guess what i'm doing here

subtle folio
#

if (player.isOnline()) {} Will work fine for you @west linden

sterile token
#

Could someone explain me, why the getHand() of the PlayerInteractEvent event is equal to Equipment.OFF_HAND, when you interact with the secondary hand as such or when you make right click. The second one is causing me problems, because when acting that way it cancels the events to place and/or remove blocks.

I ask because I need to do it in a mini game, where in a certain area you can only place/remove blocks (working), not interact with blocks and/or entities that have where to store things (worked perfectly, until I added the last condition) and not use the secondary hand (causing problems, with the first condition).

Lmao im being like a parrot tho, because no one understand my points

tardy delta
fluid river
#

casting from string to int

subtle folio
#

Why wouldn't it equal to OFF_HAND if you interacted with your offhand?

fluid river
#
atoi(myString.c_str());```
tardy delta
#

is c_str needed for that

fluid river
#

yeah

tardy delta
#

what does it return?

fluid river
#

it's atoi

tardy delta
#

c stuff too ig

fluid river
fluid river
#

yeah

river oracle
#

?paste

undone axleBOT
subtle folio
fluid river
#

char*

sterile token
fluid river
#

goes to c level from c++

tardy delta
#

whers the c++ equivalent

sterile token
subtle folio
#

Yes yes do that

fluid river
#

i guess i have some shitty build

river oracle