#help-development

1 messages · Page 778 of 1

candid galleon
#

oh

#

how tall it is

#

bruh

slate tinsel
#

yes

timid hedge
#

When i launch mcp (trying to open it in intellij) all the dependencies are at another location from another mcp, and i have just changed them all and when im opening intellij it sets them back again, is there a way to fix that?

wet breach
#

you would need to know resolution in order to calculate pixels. but blocks are 1meter tall and 1 meter wide, and 1 meter long

slate tinsel
worldly ingot
wet breach
#

well, knowing that a full block is what I said, it should be fairly easy to calculate all other blocks based on that

worldly ingot
#

Get the collision shape, getBoundingBoxes(), iterate over said bounding boxes and find the highest y value

#

There's your height :p

wet breach
#

the alternative, is to just make a list of all block sizes

worldly ingot
#

I mean yeah but have fun making that list lol

wet breach
#

lol

worldly ingot
#

I suppose if you're checking a very specific set of blocks then possibly better, at least it's O(1).

#

But otherwise you can just use the method I suggested

rotund ravine
#

I mean if he goes through all types of blocks onEnable or smth and saves their height, he’d be at O(1) in a HashMap still 👀

worldly ingot
#

Micro-optimizing. My method will work fine in a majority of situations lol

rotund ravine
#

@timid hedge

timid hedge
pseudo hazel
#

I saw it but you would be hardpressed to find someone who knows a lot about mcp i think

rotund ravine
#

No clue about mcp

timid hedge
#

Yeah proberly, but is there anything else that is good for a client / a launcher

And i cant find out if it is allowed or not to make your own

rotund ravine
#

Fabric

timid hedge
#

Its for 1.8.8/1.8.9

eternal night
rotund ravine
#

Apparently

#

Such a project exists

dry hazel
#

We currently support versions: 1.3 - 1.13.2

#

mfw

hushed spindle
#

do maven modules make the jar size significantly bigger? ever since i made my project multi-moduled the jar size has been about twice the size it used to be

#

not a huge deal, but i'd prefer to keep jar sizes small

rotund ravine
#

No

worldly ingot
#

Might just be shading an extra dependency you missed

hushed spindle
#

unpacking my project shows it only has the essentials plus some jeff media stuff which it had before anyway

#

or is that not the right way to check that

rotund ravine
#

That’s a fine way

worldly ingot
#

Yeah, .jar files are just an archive you can unpack :p

hushed spindle
#

then im not sure where the doubled file size came from lol

#

project before produced a jar of like 800kb and now thats 1800

rotund ravine
#

Maybe you weren’t shading properly before?

river oracle
worldly ingot
#

THE essentials lol

hushed spindle
#

no not literally "essentials"

river oracle
#

lol

hushed spindle
#

essentials 🤮

river oracle
#

how many modules do you have though

hushed spindle
#

i was using the jeff media plugin preset thing which seems to do its shading fine

#

didnt support multi modules though so i had to change it up

#

currently it only has core, dist, and one for nms which is currently just 1

rotund ravine
#

You changed smth

#

It got bigger

#

Boom

hushed spindle
#

yeah

rotund ravine
#

Issue solved

hushed spindle
#

but WHAT

rotund ravine
#

Whatever wasn’t there before

river oracle
#

+1 ^

rotund ravine
#

Does maven not have a minimize function for shading?

hushed spindle
#

it does and im using that

river oracle
rotund ravine
#

Guess ur using one extra class or smth that has a shit load of dependencies

river oracle
hushed spindle
#

mind you when i didnt use it the jar became like 8mb big lol xd

#

used to be 800kb now its 1800kb

rotund ravine
#

Not really that big

hushed spindle
#

for a plugin though

#

8mb you cant upload to spigot

rotund ravine
#

Not that big

river oracle
#

that's still fairly small, though that little stuff shouldn't be that big make sure you're not shading stuff multiple times etc. if you're not you're all good to go

rotund ravine
#

You can just do github releases and link to those

hushed spindle
#

fair

#

im not saying its big im just wondering where the extra size is coming from

#

and 8mb for a plugin is rather big considering thats just code

#

not any configs or presets or whatever

river oracle
#

that includes the size of the plugin I shade into as well

river oracle
#

well first how many classes do you have abouts

hushed spindle
#

is there a quick way i can see that lol

river oracle
#

if you have a couple hundred the size would be expected

hushed spindle
#

its probably roundabouts there

rotund ravine
#

Open the archive

#

And see how many individual files are in it

#

If u unzip it and hit properties it should show

hushed spindle
#

666 files right then

rotund ravine
#

Probably about right

river oracle
#

sounds about good for that size then

hushed spindle
#

but like it was half the size before?

#

how's that work

river oracle
#

erm you uhh configured something incorrectly

hushed spindle
#

YEAH

river oracle
#

paste all your poms and label them

#

?paste

undone axleBOT
hushed spindle
#

yeah ill do that lol

river oracle
#

For once the time I spent properly learning maven may pay off

rotund ravine
#

Bruh, even when people share their gradles i can only help sometimes ahaha. Like there is so much random shit u can do in so many diff ways

worldly ingot
#

Which makes it so frustrating :p

#

No one gradle file is the same

river oracle
#

especially if they use random custom scripts

river oracle
#

you don't need to depend on GSON

#

spigot provides it

hushed spindle
#

ill try removing that

river oracle
#
       <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.24</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.jeff_media</groupId>
            <artifactId>MorePersistentDataTypes</artifactId>
            <version>2.3.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.jeff_media</groupId>
            <artifactId>CustomBlockData</artifactId>
            <version>2.1.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.github.MilkBowl</groupId>
            <artifactId>VaultAPI</artifactId>
            <version>1.7</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.sk89q.worldedit</groupId>
            <artifactId>worldedit-bukkit</artifactId>
            <version>7.3.0-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.sk89q.worldguard</groupId>
            <artifactId>worldguard-bukkit</artifactId>
            <version>7.1.0-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>me.clip</groupId>
            <artifactId>placeholderapi</artifactId>
            <version>2.11.2</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.11.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-transport</artifactId>
            <version>4.1.82.Final</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.bstats</groupId>
            <artifactId>bstats-bukkit</artifactId>
            <version>3.0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.10.1</version>
            <scope>provided</scope>
        </dependency>```
This is a lot of dependencies to have just sitting around in your parent project? do you really use them all in EVERY modules? that's the only reason you should ever really put something as a depend in your parent
hushed spindle
#

i could just shove em to core i guess yeah

river oracle
#

despite them being marked as provided I'd find it suspect that the shade plugin being literally everywhere as well as you not carefully choosing which dependencies to put where may be the issue

hushed spindle
#

also i put gson there because supposedly using 2.10.1 fixed a specific bug i was having, it didnt solve it but i forgot to remove it

river oracle
#

leads me to believe you may be shading and relocating multiple times

rotund ravine
#

Ew lombok

river oracle
remote swallow
#

i heard the word gradle

rotund ravine
remote swallow
#

sad

remote swallow
hushed spindle
#

so just remove the shade plugin part yeah?

#

and yeah im not even using lombok so im removing that too lol

zealous osprey
#

I'm back again with more bit funniness... Because I can't figure this out!
This code works fine, EXCEPT for negative numbers. Ik why, cause the twos-compliment causes the bits to always have all leading "1"s. So something like this for "-5": 11111111 11111111 11111111 11111011 and I want too insert the "-5" into a long at a specific place. But then all of my bits to the left get turned into "1"s when I shift it in.
So I made a mask, ie the 0x000000000000FFFFL too ensure that only the last 16 bits are put into the long... but that still breaks everything, why?

hushed spindle
#

thought it would make certain stuff easier and i ended up making a whole lot of not use out of it

zealous osprey
pure stag
#

hm

#

how to send image?

chrome beacon
#

?img

undone axleBOT
#

Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.

Here's some screenshot utilities that can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org

pure stag
#

how to fix anvil working?

#

enchanting book give

grand flint
#

so when there is a minecraft update

#

how do i decide if i need to update the plugin or not

rotund ravine
#

Do you use nms?

grand flint
#

i might

rotund ravine
#

Do you use any deprecated or staging bukkit/spigot api? @grand flint

gleaming yarrow
#

is it preferable that we create threads or do we just ask away like this

rotund ravine
gleaming yarrow
#

Thanks, I have a piece of code that I can't figure out why it's not working

grand flint
#

is always

#

the latest version and above

#

such as 1.20+

rotund ravine
#

Wasn’t asking that

grand flint
#

or 1.21+

rotund ravine
#

Well no matter about that either way.

#

If you use nms, you should probably go recompile for each version

undone axleBOT
grand flint
#

okk

#

what else

#

what about protocols?

rotund ravine
#

They’re changed often

#

There was even a change between 1.20.1 and 1.20.2

grand flint
#

ye

#

so id need to update

#

if i use protocols right?

#

so wait if i use protocol as my protocol library for all my plugins

#

id need to only update procollib right?

rotund ravine
#

Sometimes

gleaming yarrow
remote swallow
#

if theres nms changes between versions yeah, eg 1.20 and 1.20.1 is compatable so you just need it for 1.20.1 but 1.20.1 has different internals to 1.20.2 so you use 1.20.2 nms

rotund ravine
#

If there is a major protocol change you might need to change smth

gleaming yarrow
grand flint
#

like the config state

hushed spindle
#

the entire point of protocollib is that it allows you to manipulate packets without having to update nms each time a new update comes out

grand flint
#

oh so i can just use

#

protocols

#

instead of

#

nms

hushed spindle
#

you could i guess

rotund ravine
#

Mostly

gleaming yarrow
hushed spindle
#

you just gotta wait on protocollib to update

storm crystal
#

an aquaintance of mine who does some software work asked me this when I was telling him that im gonna do an API to make other plugins access same configs and he basically asked if its not possible to make that so that Plugin 2 could use Plugin 1's config, is that possible?

hushed spindle
#

like honestly updating nms isnt hard at all, takes probably a couple minutes maybe

#

if you dont use nms or packets or whatever the quickest way to figure out if your plugin needs to be updated or not is literally just to test it out lmao

#

fix the errors and continue on

#

usually

grand flint
#

what is nms

#

why cant i just use protocols if i can

hushed spindle
#

net minecraft server code

remote swallow
hushed spindle
#

you can

#

sometimes a version change is a little more sneaky though, like 1.19 to 1.20 they changed it so that SmithingRecipes no longer get registered to the server. You had to either use a SmithingTransformRecipe or a SmithingTrimRecipe. bit annoying because it didnt throw errors

grand flint
#

ye but u can read the update log for that stuff right?

chrome beacon
#

No

hushed spindle
#

yesn't

#

smithing recipes got changed is about the furthest it goes, so you might wanna check your smithing mechanics then

hushed spindle
#

configs are just files, why shouldnt you be able to access em

#

(from other plugins)

shadow night
#

I'd expect bukkit to have some shitty anti-malware system or something

rotund ravine
#

Huh

#

@vagrant stratus did he call you

grand flint
#

so if i have like just a simple chat plugin

rotund ravine
#

Hkjk

grand flint
#

that wont need to be updated most of the time right?

hushed spindle
#

probably not

rotund ravine
#

Most likely not

hushed spindle
#

the simpler the plugin the less likely it is it needs updating, obvio

gleaming yarrow
hushed spindle
#

but text based shit is even less likely

grand flint
#

okk

#

and where do i find hcanges between updates

#

for plugin development

#

to know if i need to update or not

gleaming yarrow
#

honestly I always forget so I always just update and see whats broken and then google the methods

hushed spindle
#

just test it

#

no need to check

#

i dont think anyone here really does

rotund ravine
#

If smth breaks it’s time to update

gleaming yarrow
#

real

hushed spindle
#

put some tape on it and its as good as new

rotund ravine
#

@drowsy lion are you codez14?

storm crystal
#

so generally id have to make separate plugin for config management (saving, reading, writing etc.) and make it a dependency for other plugins to use?

grand flint
#

no

#

?

#

i swear there is a library for that

rotund ravine
#

I got a plugin that supports 1.5 to 1.17+ never updating it again and crossing fingers

chrome beacon
#

You really shouldn't be saving and writing to another plugins config

grand flint
#

ye fr

#

just use the library in the plugin ur using

chrome beacon
#

If you want to read something that's fine

storm crystal
grand flint
#

why would u want that

#

if u want to read stuff

storm crystal
#

because I do?

grand flint
#

just make a global database

storm crystal
#

thats what im literally doing

grand flint
#

then why are u making

chrome beacon
grand flint
#

another plugin

hushed spindle
#

if their use case requires reading other plugin configs then honestly let em

grand flint
#

u can make a main api plugin

#

which has like quick methods

#

to save to ur database

chrome beacon
storm crystal
#

someone here told me to make database with configs

grand flint
#

ye write stuff from the actual plugin its elf

#

which idiot told u that

#

use like mysql or mongo

#

look here:

hushed spindle
#

or sqlite

grand flint
#

have an api plugin that manages ur database with quick methods

#

let other plugins manage their own configs, and if they need to save anything or get anything to the database

#

then u get it from the main plugin which manages that

#

nothing to do w configs

#

config isnt a player data saving place

#

its for plugin data

storm crystal
grand flint
#

no way

#

they wouldve told u that

#

u probs explained it or understood it wrong

chrome beacon
#

^^

storm crystal
#

not at all

#

I was asking questions about databases and they told me to use configs

hushed spindle
#

maybe use configs to read the database connection stuff?

rotund ravine
#

Well ur probably doing something that doesn’t require a database

chrome beacon
#

It entirely depends on what you're doing

storm crystal
#

literally

#

config

#

as

#

a database

slender elbow
#

skull emoji

hushed spindle
#

using configs for extensive data storage isnt great no, for storing a handful of small little things you want an admin to be able to edit is probably fine i guess

rotund ravine
#

What is in this database?

slender elbow
#

next, I'm going to use postgresql for my server config

chrome beacon
#

PostgreSQL ❤️

rotund ravine
#

Cross server config easymode

storm crystal
rotund ravine
#

N1 and n2 are fine

#

Even N3 to an extent

storm crystal
#

and I want them to be set, read, removed if necessary or changed

chrome beacon
#

player stats on the other hand should be stored in a database

storm crystal
#

not just store

#

edit as well

rotund ravine
#

Yep

storm crystal
#

and I want to read and edit from those configs in several plugins

#

to not make one plugin do all the work

chrome beacon
#

Don't write to the config from other plugins

#

Make an API

vagrant stratus
#

I have seen malware on Bukkit though so 🤷‍♂️

rotund ravine
storm crystal
# chrome beacon Make an API

and I got an answer to make plugin with configs and make it into api so that other plugins could use those configs

chrome beacon
rotund ravine
#

I see

chrome beacon
#

this isn't the first time

storm crystal
#

so I make the api and what do I do in it

#

then

chrome beacon
#

the api would be changing stuff in the config

#

Do not expose the config directly to other plugins

storm crystal
#

eh

#

so do I just

#

make same configs for all plugins

rotund ravine
#

Sigh

sterile token
#

Is it a good idea to compare command logic with config logic, because if i see them both have a root level and start going deep and deep. Each tree, having nodes and each node childs

pure stag
#

Why is it that when I place an item forcibly, I can't pick it up? It just doesn't even click

undone axleBOT
river oracle
sterile token
pure stag
sterile token
rotund ravine
sterile token
#

Also is he using paper?

#

Because spigot doesnt have a Item#lore() 🤔

chrome beacon
#

yeah that's Paper

pure stag
sterile token
#

what? Paper and Spigot are different if that what you mean

#

They 2 different "server software" calling it in a way

pure stag
#

paper

rotund ravine
#

@pure stag Just forcefully set the cursor when they click it in inventoryclickevent

#

Anvils are evil to customize

storm crystal
#

so what if I want lets say plugins to just read information and thats it, not edit it at all, can I make them read those from same config?

chrome beacon
#

You'd normally interact with the plugin api

#

not read the config of another plugin

storm crystal
sterile token
#

give me 5m

chrome beacon
#

then depend on that plugin and call the api methods

sterile token
#
OtherPluginMain otherPlugin = (OtherPluginMain) getServer().getPluginManager().getPlugin("OtherPlugin");

String smth = otherPlugin.getConfig().getString("something");

This is a simple example, how you get an instance from another plugin.And then access its own config

chrome beacon
#

That would be how you read the config of another plugin

#

You're not making an api there

scenic onyx
#

how i can adjust?

sterile token
rotund ravine
sterile token
scenic onyx
river oracle
hushed spindle
#

what?

scenic onyx
hushed spindle
#

well what is SetPosition for one

#

naming convention tells me its a class

hushed spindle
#

so you do new SetPosition() instead

river oracle
hushed spindle
#

yeah it does

rotund ravine
#

I mean

scenic onyx
chrome beacon
rotund ravine
#

Looking at his “Sender” assuming that would be wrong

sterile token
#

I would suggest first learning the lenguage where you are coding at it

chrome beacon
#

I've told you multiple times to take a basic Java course

#

?learnjava

undone axleBOT
rotund ravine
#

?learnjava!

undone axleBOT
sterile token
#

If you dont want to learn java, you cant expect us to help because

storm crystal
#

and it didnt say anything about apis or dependencies

river oracle
rotund ravine
#

Is he the guy who was here the first time with us Olivo?

river oracle
chrome beacon
river oracle
#

be less specific on your query

rotund ravine
#

Like the first time he arrived

#

I was present

#

Idk

sterile token
storm crystal
#

thats why im asking

chrome beacon
#

It's a Java thing

river oracle
chrome beacon
#

or just generally a programming thing

river oracle
#

^

storm crystal
#

so what do I include in this api if I want to make it have configs that other plugins could read

chrome beacon
#

You want to abstract away the config

river oracle
#

how to make an API si something you need to look up

#

its a concept you want to learn

chrome beacon
#

Don't let others touch your config

storm crystal
#

what

#

xd

rotund ravine
#

Well, it seems our friend here might want to consider a little rendezvous with the magical land of programming slang and knowledge. It's like his programming dictionary is stuck in the Stone Age! 😂

#

Slang to be hip

sterile token
#

Wait wait, so he wasnt asking how to access another plugin config from his own plugin? I fully understand that

rotund ravine
#

He was, but he was a few steps from that.

storm crystal
#

I was at one point yeah

#

didnt know its "illegal"

rotund ravine
#

ItMs not

sterile token
#

no, why its illegal?

rotund ravine
#

The way he wanted to do it is considered bad practice.

storm crystal
#

some metaphysical shit perhaps idrk

river oracle
#

terrible idea and practice

storm crystal
#

I was told to store things in configs so that would be a natural thing to ask about

rotund ravine
#

Expect us to always go for “best practice” if we know it and we’re here

chrome beacon
storm crystal
#

dont apis need like a site

chrome beacon
#

No

river oracle
#

no

storm crystal
#

I saw that you need to use some kind of link

river oracle
#

Application Programming Interface

#

has nothing to do with websites

river oracle
hushed spindle
#

in the simplest terms, it basically is just a means for different programs to communicate with eachother

#

if you want to make a plugin where other plugins can read and write to your own plugin configs, that just basically means getters and setters for your config properties

#

why you would want this i dont know

#

what are you wanting to make anyway

sterile token
#

This a common error Y2k dont get upset, i used to happen this issue with a backend developer. Because when i talk about him API, he always associate them as REST API's because he was a backend, the same concept change depending your area

storm crystal
#

i said a few times already

hushed spindle
#

yeah but im not paying attention

#

my bad

storm crystal
#

I want to store/read stuff so that a few plugins could use it

hushed spindle
#

for what purpose

storm crystal
#

because I want to and need it for later

hushed spindle
#

im asking because theres likely better ways to do what you want to do

#

are you being secretive because it sounds like you dont actually know what you want to do

storm crystal
#

lets just say it with an example

rotund ravine
storm crystal
#

I have a thing that stores data about custom weapons with their respective statistics, same for players and custom enemies and I dont want one plugin to handle all the work because apparently its not optimal, so I want one plugin to handle custom damage (where it'd need all 3 forementioned things), weapon upgrade (that'd need weapon information) and such

sterile token
river oracle
storm crystal
#

and I dont think doing all of those mechanics in one single plugin and store it in configs would be optimal

sterile token
#

okay

rotund ravine
#

Why not

sterile token
#

I understand you Dusk

#

But thats would be a mess havign 3 plugins to do a final product

river oracle
storm crystal
#

do I just make one plugin with 294239439 classes each for one operation?

#

doesnt that sound like bloating?

slender elbow
#

they are all related things, or at least it seems like they are

river oracle
#

I don't think the amount is an issue as long as you stay consistent to some form of theme

#

my second message won't send fuck discord

storm crystal
#

idk one of java courses was saying that it's best to make things do one particular thing to keep things clean

river oracle
storm crystal
#

so I wanted each plugin to do one particular task

river oracle
#

That's a terrible way to go about things

#

especially if those plugins share a lot of data about eachother its Actually less clean then doing it all in one project

sterile token
#

Dont care about amount, just care about quality ☝️

orchid gazelle
#

it's exactly what you wanna do

#

but heck just don't use configs to store the data

hushed spindle
#

then its suboptimal to be accessing your configs, you just want to communicate the weapon and enemy information or whatever

orchid gazelle
#

np

hushed spindle
#

and honestly yeah just use a single plugin

storm crystal
#

thats currently how the structure looks like

hushed spindle
#

dont make a mess by fragmenting your main features

#

sounds like you need to learn some design patterns

#

discord is taking a shit rn

#

holy shit discord FUNCTION

#

finally good lord

#

discord took a right shit

#

right anyway, you dont see games splitting up their stuff in individual applications right? why should plugins

storm crystal
#

I dont know man its my first ever programming project bigger than a single python file

hushed spindle
#

you're making a plugin with a goal in mind, you don't need to make a new plugin for each task. generally speaking you want each class to be responsible for one thing

rotund ravine
#

A properly structured plugin should be fine having those 3 features

#

Limbo

#

.

#

Discord dies on me

#

died

hushed spindle
#

seems to be coming back now

slender elbow
#

average daily discord occurrence

hushed spindle
#

the item, enemy, and stat features you were talking about

#

its fine to have them all in 1 plugin

#

i mean heck my plugin combines custom crafting management and loot tables and stats and shit just because my goal for the plugin requires those features to be there

storm crystal
#

should I save customconfigs on plugin disable if I want plugin only to read those?

hushed spindle
#

what do you mean

#

if your plugin is only reading configs then no you dont need to save them again

zenith gate
#
public enum Monster {
    WYAX {

        public void summonWyax(Location location, MonsterType monsterType, int playerLevel) {
            Vex vex = location.getWorld().spawn(location, Vex.class);
            vex.setCustomName(monsterType.getTypePrefix() + ChatColor.WHITE + " Wyax");
            vex.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(CalculateAttribute.health(monsterType, playerLevel));
            vex.setHealth(CalculateAttribute.health(monsterType, playerLevel));
            vex.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE).setBaseValue(CalculateAttribute.damage(monsterType, playerLevel));
            vex.setCustomNameVisible(false);
            vex.spawnAt(location);
        }
    },

    SLACK {

        public void summonSlack(Location location, MonsterType monsterType, int playerLevel) {
            Enderman enderman = location.getWorld().spawn(location, Enderman.class);
            enderman.setCustomName(monsterType.getTypePrefix() + ChatColor.WHITE + " Slack");
            enderman.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(CalculateAttribute.health(monsterType, playerLevel));
            enderman.setHealth(CalculateAttribute.health(monsterType, playerLevel));
            enderman.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE).setBaseValue(CalculateAttribute.damage(monsterType, playerLevel));
            enderman.setCustomNameVisible(false);
            enderman.spawnAt(location);
        }
    }

    ;

    public static void SummonMonster(Monster monster, Location location, MonsterType monsterType, Player player) {
        switch (monster) {
            case WYAX -> WYAX.summonWyax(location, monsterType, LevelManager.getLevel(player));
            case SLACK -> SLACK.summonSlack(location, monsterType, LevelManager.getLevel(player));
        }
    }


}

Could someone explain to me why this won't work? I did try abstracting it which would work, but it required me to add every implemention into every enum variable and well that's just dumb because they would be doing nothing.

glacial coral
#

Hello there! I am learning all the events and such, so I'm working on the PlayerDeathEvent right now. I am wondering what way I can get the item that was used to cause the killing blow. I have tried a few things like killer.getItemInUse() (where the killer is the event.getEntity().getKiller() Player object). I have tried to google it but answers are from ~2012 and are telling me to use a deprecated function getItemInHand(). Any suggestions?

rotund ravine
#

?paste

undone axleBOT
rotund ravine
#

@zenith gate

rotund ravine
glacial coral
#

That's a good start, thank you! Will try to figure it out! ❤️

storm crystal
#

so I got a question about my project structure

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!

storm crystal
#

I am literally in the middle of typing

storm crystal
#

im just used to many short messages

#

if I wanted to add custom abilities to weapons id essentially make a package to hold them and then class for each one of them?

river oracle
#

organization is up to you

rotund ravine
river oracle
#

I wouldn't use an enum here

zenith gate
# river oracle I wouldn't use an enum here

I should just put them in their standalone methods? I also want the monsters in a nice list for when I do commands, and I have that setup so I could just add a monster to the enum, and the command will see that and can now summon that monster. An enum just seemed to be the best option.

ember estuary
#

How can i disable fire charges shot via dispenser from setting fire?

#

whats the event that i need to cancel?

zenith gate
#

👍

storm crystal
#

how to do I make external classes do stuff like in main class?

#

is dependency injection enough?

sterile token
#

Where you will have a super a clase and then each sub class inhertitate from the super

storm crystal
#

I made this so far in this class, and idk if I should do anything else

hushed spindle
# glacial coral That's a good start, thank you! Will try to figure it out! ❤️

the given solution may not work if the killer used a bow, since a bow might be in either main hand of off hand (or neither, if the killer switched their hands inbetween shooting and killing). this also wont work for any entity, just players.

if you want it to work for any entity killer:
you can get the last damage cause
if the damage cause is an EntityDamageByEntityEvent get the damager from said event
if the damager is a projectile, check if its projectilesource is an entity
if not, the damager itself will be what might have killed them. then you can get the item in their hand

mind you, this will not account for entities that die from non-entity causes. if you hit an entity and they die from fire ticks for example the last damage cause will be of said fire ticks, so that might not work entirely. You can solve this by keeping track of specifically the last EntityDamageByEntityEvents an entity took, and also probably at which time that occurred so you can decide when such an event should no longer be responsible for somethings death

like the first solution, it also wont work entirely for getting the bow used to shoot the entity since entities and players can switch their bow slot away between shooting and hitting, so one way to resolve this would be to map the projectile UUID with the ItemStack bow (which you can do in a EntityShootBowEvent listener) and then you know what item was used to shoot which projectile

#

of course, remember to clear out the entries of these maps when you no longer need them

zenith gate
#

are you just trying to access your plugin instance from other classes?

#

@storm crystal

glacial coral
storm crystal
zenith gate
#

what exactly?

hushed spindle
#

discord be dyin again it seems

zenith gate
#

yeah it took me 15 minutes to just load in on my computer. servers are at capacity is what it screamed at me

storm crystal
#

like events

trim lake
#

I have this code, but runnable will only run one time correctly. After I add data to set, that set is empty in runnable any case why?
Other class where Im adding data to set:

        System.out.println("CRYPTO MENU LIST: " + cryptoManager.getCryptosGuiPlayers());
        cryptoManager.getCryptosGuiPlayers().add(guiPlayer.getUniqueId());
        System.out.println("crypto added: " +cryptoManager.cryptosGuiPlayers);
        System.out.println("CRYPTO MENU LIST AFTER ADD: " + cryptoManager.getCryptosGuiPlayers());

Class with runnable:

public class CryptoManager {
    public Set<UUID> cryptosGuiPlayers = new HashSet<>();

    public CryptoManager() {
        cryptos.put(PCCryptoType.BTC, new Bitcoin());
        cryptos.put(PCCryptoType.ETH, new Ethereum());
        cryptos.put(PCCryptoType.DODGE, new DogeCoin());
        this.saveStartValues();
        this.startRunnable();
    }

    private void startRunnable() {
        int interval = 10; //in seconds!
        new BukkitRunnable() {
            private final Set<UUID> a = cryptosGuiPlayers;

            @Override
            public void run() {
                final Random random = new Random();
                for (CryptoCoin coin : cryptos.values()) {
                    double epsilon = random.nextGaussian() * random.nextInt(0, 10);
                    double minusChance = random.nextGaussian();
                    if (minusChance < 0.52)
                        epsilon *= -1;
                    coin.setValue((float) (coin.getValue() - epsilon));
                    historyCryptoValues.computeIfAbsent(coin.getId(), k -> new ArrayList<>());
                    historyCryptoValues.get(coin.getId()).add(coin.getValue());
                    System.out.println("NEW VALUE " + coin.getId() + ": " + coin.getValue());
                }
                System.out.println("Test: " + this.a);
                System.out.println("Test: " + new HashSet<>(this.a));
                System.out.println(cryptosGuiPlayers);
                for (UUID playerUUID : new HashSet<>(cryptosGuiPlayers)){
                    System.out.println("remove : " + cryptosGuiPlayers.remove(playerUUID));
                    Player player = Bukkit.getPlayer(playerUUID);
                    if (player == null) continue;
                    if (!player.getOpenInventory().getOriginalTitle().equalsIgnoreCase("Cryptos")) continue;
                    new PCCryptoMenu(player).show(player);
                }
                System.out.println("---");
            }
        }.runTaskTimer(RPComputer3.instance, 20L, interval * 20L );
    }```
Output:
storm crystal
#

listeners

zenith gate
#

Okay well when you create your file and implement listener.

in your main class in the onEnable() you just register that event. getServer().getPluginManager().registerEvents(new FILENAME(), this) then that event will be registered.

#

your methods you can get easily by just FILENAME.METHODNAME() if they are in other files.

#

make sure you make them public if you want to access it outside the current class

glacial coral
rotund ravine
#

Yes

glacial coral
#

Oof does that mean I have to also take into account armor and not just health?

#

😐

hushed spindle
#

if you solely want to count entity killing blows then you wont need to do this, if you want to account for causational deaths (like burning to death after the fact or being thrown off a cliff) then this is handy

#

basically all you do inside that damage event listener is mapping it to an entity and recording the time at which that event was taken, nothing else

glacial coral
#

Ah okay that does seem a bit easier 😄

hushed spindle
#

then in the death event you check if that entity is recorded, and check if the time at which that damage event was taken is sufficiently recent enough to be considered

#

and then you got the accurate entity damage event which caused the entity to die

glacial coral
#

Shouldn't be harder than making a list record

#

of some sort

hushed spindle
#

two hashmaps should do it

glacial coral
#

Oof that's a variable type I haven't heard of

hushed spindle
#

or alternatively make a little record containing the damage event and time and then 1 map will do it

#

a hashmap is basically just a key:value pairing

#

sometimes called a dictionary

glacial coral
#

Oh a dictionary

hushed spindle
#

hey so just to be clear, BlockDropItemEvent#getBlock() always returns an AIR block?

#

i coulda sworn that wasnt the case

rotund ravine
#

Does it run before or after

hushed spindle
#

oh darn yeah according to docs yeah

#

bruh

storm crystal
#

how do I access method from main class in another class

rotund ravine
#

?di

undone axleBOT
tall dragon
#

it runs after the block has been broken so

#

it would return air yea

storm crystal
#

did I do something wrong

hushed spindle
#

doesnt look like it to me

#

its just yellowlined like that because its a variable you're not yet using

storm crystal
#

cause it gives me this

hushed spindle
#

playerCustomDamage is not a method

tall dragon
#

huh

hushed spindle
#

its a double

#

you're supposed to do new BoneAbility(plugin, damage)

#

wait no

#

what are you doing

storm crystal
#

I got it in main class

#

I thought I should specify what type it gives back in here as well

hushed spindle
#

thats in your main class?

storm crystal
#

yes

hushed spindle
#

then you should be doing plugin.playerCustomDamage(..., ...)

#

assuming you're in BoneAbility rn

storm crystal
#

yes

hushed spindle
#

playerCustomDamage you've made a behavior of your main class. it probably shouldn't be there, but good practice comes later. but because you've made this method a behavior of your main class you need an instance of your main class to act out that behavior

storm crystal
#

wasnt doing instance of main class bad

hushed spindle
#

why would that be

#

you already have an instance of your main class

chrome beacon
#

Creating a new instance of it would be bad

hushed spindle
#

yes

tribal cypress
#

Why is this doing this?

hushed spindle
#

but you'll find that out if you try it anyway, because itll throw an error saying you cant make another instance of your plugin main class

rotund ravine
#

No code block

chrome beacon
tribal cypress
#

Ain't the plugin set when I'm creating the class?

chrome beacon
#

Fields get initizalized first then the constructor runs

#

so then getConfig is called plugin isn't initialized

tribal cypress
chrome beacon
#

move that get config to the constructor

tribal cypress
#

Alr, thanks

rotund ravine
storm crystal
#

like this?

rotund ravine
#

Main and Javaplugin are the same thing

hushed spindle
#

yeah you dont need to literally make a main class

#

your main just refers to your application's starting point

#

for plugins thats your JavaPlugin class

storm crystal
#

doesnt work like that tho

hushed spindle
#

have you removed your playerCustomDamage() method from your JavaPlugin class?

storm crystal
#

whats javaplugin class

zenith gate
#

    [15:01:55 ERROR]: Error occurred while enabling Toastart v1.0.4 (Is it up to date?)
java.lang.IllegalStateException: Unable to find a resolver for parameter type class org.bukkit.Location
    at revxrsal.commands.core.CommandParser.getParameters(CommandParser.java:436) ~[Toastart-1.0.4.jar:?]
    at revxrsal.commands.core.CommandParser.lambda$parse$4(CommandParser.java:197) ~[Toastart-1.0.4.jar:?]
    at java.util.ArrayList.forEach(ArrayList.java:1511) ~[?:?]
    at revxrsal.commands.core.CommandParser.parse(CommandParser.java:168) ~[Toastart-1.0.4.jar:?]
    at revxrsal.commands.core.CommandParser.parse(CommandParser.java:121) ~[Toastart-1.0.4.jar:?]
    at revxrsal.commands.core.BaseCommandHandler.register(BaseCommandHandler.java:188) ~[Toastart-1.0.4.jar:?]
    at revxrsal.commands.bukkit.core.BukkitHandler.register(BukkitHandler.java:148) ~[Toastart-1.0.4.jar:?]
    at pine.toast.toastart.Toastart.onEnable(Toastart.java:31) ~[Toastart-1.0.4.jar:?]
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:281) ~[paper-api-1.20.2-R0.1-SNAPSHOT.jar:?]
    at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.enablePlugin(PaperPluginInstanceManager.java:189) ~[paper-1.20.2.jar:git-Paper-234]
    at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.enablePlugin(PaperPluginManagerImpl.java:104) ~[paper-1.20.2.jar:git-Paper-234]
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:507) ~[paper-api-1.20.2-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.craftbukkit.v1_20_R2.CraftServer.enablePlugin(CraftServer.java:644) ~[paper-1.20.2.jar:git-Paper-234]
    at org.bukkit.craftbukkit.v1_20_R2.CraftServer.enablePlugins(CraftServer.java:555) ~[paper-1.20.2.jar:git-Paper-234]
    at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:627) ~[paper-1.20.2.jar:git-Paper-234]
    at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:424) ~[paper-1.20.2.jar:git-Paper-234]
    at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:308) ~[paper-1.20.2.jar:git-Paper-234]
    at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1086) ~[paper-1.20.2.jar:git-Paper-234]
    at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315) ~[paper-1.20.2.jar:git-Paper-234]
    at java.lang.Thread.run(Thread.java:833) ~[?:?]

theres an error but no class name or line count for my plugin?

storm crystal
#

like my main class

#

?

hushed spindle
#

yes your main class but not literally your "Main" class

storm crystal
#

no its still here

hushed spindle
#

whichever one of your classes says extends JavaPlugin

storm crystal
#

yeah Main.java is that one

hushed spindle
#

wuh?

#

oh i see

#

no you literally passed JavaPlugin to your constructor

#

JavaPlugin doesn't have the playerCustomDamage() method

river oracle
tribal cypress
river oracle
#

?main

hushed spindle
#

you need to specify which JavaPlugin you're wanting to use

#

in this case, Main

river oracle
#

?jd-s

undone axleBOT
hushed spindle
#

so use main.playerCustomDamage() and just remove the JavaPlugin part of your constructor

river oracle
#

you can't have an if statement outside of a method

tribal cypress
#

Just forgot.. I'm learning this way, duh.

hushed spindle
#

how come so many beginners jump to putting developer and all sorts of languages in their bio when they literally just started lol

storm crystal
#

wait

hushed spindle
#

you're not a developer bro you barely started touching java

storm crystal
#

I got fucking lost

#

I renamed my Main.java with JavaPlugin extension to Rpg now to make it less confusing

river oracle
#

mb forgot rust

hushed spindle
#

im a c++ developer fellas i touched it like once when i was 13

#

and i got scared

#

am an assembly developer too because i read an article about it one time

river oracle
storm crystal
#

how come you've worked in C# and didnt know if statements cant be outside of method

river oracle
#

I've touched assembly for those processor architectures

hushed spindle
#

mindfuck developer too

#

it hurts

#

or was it brainfuck i forgor

storm crystal
#

anyway what do I do now to access customPlayerDamage from Rpg class again

river oracle
hushed spindle
#

dont put JavaPlugin in your constructor

#

put Rpg

tribal cypress
#

Brothers, why be mad bout it? I just didn't program in Java for a long time, I tend to do more Lua these days - just returned to Java for some plugins for Minecraft and y'all be trash talking me just cause I touched objects after a long while

hushed spindle
#

we're just poking fun lol

tribal cypress
#

ah, alr, seemed like y'all were hatin on me :(

storm crystal
#

if thats poking fun then I must have become a swiss cheese by now lol

#

wait so when do I want to pass JavaPlugin and when I want to pass main class instance

hushed spindle
#

like, think of it like this. Rpg is your implementation of the JavaPlugin class, JavaPlugin doesn't know about your customPlayerDamage() method, Rpg does. If you put JavaPlugin in your constructor you can pass Rpg into it because Rpg extends JavaPlugin, but unless you then cast that JavaPlugin to Rpg you cant use the behaviors that Rpg has

#

because it doesnt know JavaPlugin is an Rpg yet

#

like, JavaPlugin is a Fruit but Rpg is an Apple. All apples are fruits but not all fruits are apples. Apples know how to roll() but Fruits might not

#

thats my baby way of explaining that lol

tribal cypress
#

That's a nice way of explaining tho, good work

hushed spindle
#

which btw that allows me to explain the difference between static and non-static. static variables you can see as the properties that belong to that class in general, static methods are behaviors that apply to the class in general. non-static variables are properties that belong to only the instance of that class and likewise non-static methods are behaviors only that instance has. take for example

Apple {
  static boolean hasRotten = false;

  public static void setRotten() { hasRotten = true; }
}
#

when you call Apple.setRotten() suddenly all apples are rotten, might not be what you want

#

but

Apple {
  boolean hasRotten = false;

  public void setRotten() { hasRotten = true; }
}
#

now you cant call Apple.setRotten() because its not static, instead you do
Apple apple = new Apple();
apple.setRotten();
and now only that apple is rotten, you're still free to make new apples which wont be rotten

quiet ice
#

Does anyone know whether Jitpack still works if I have my own publishing logic - if so, what are the constraints?

chrome beacon
#

Save yourself the trouble and use github actions with github packages

#

500MB free limit but 🤷‍♂️

quiet ice
#

Well if it'd be that easy I'd publish straight to mavenCentral :P

#

But alas, I'm PR-ing build logic changes to a repo that is deployed using Jitpack - don't think I can change that anytime soon as the Anti-Jitpack movement is rather limited in the relevant community

#

Though, isn't github package the absolute of the absolute dogshit given that it requires a GH account and extensive manual configuration?

chrome beacon
#

not sure

storm crystal
#

why does it do action twice?

river oracle
#

you need to filter for one hand specifically

shadow night
#

Wasn't there like ?interactevent

river oracle
#

?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
}
river oracle
#
/**
 * A Node that links a structure together
 */
public record StructureNode(StructureNode north, StructureNode south, StructureNode east, StructureNode west, StructureNode up,
                            StructureNode down, UUID world, int blockX, int blockY, int blockZ) {

}``` can't wait to write a traversal for this one
storm crystal
#

anyone have tutorial on cooldowns? I forgot their name

#

the ones that can make something be done every few secs and such

inner mulch
#

its fairly easy, do you want me to show it to you?

storm crystal
#

I essentially want to spawn armor stand on action and after a few secs make it disappear

chrome beacon
#

?scheduling

undone axleBOT
river oracle
#

oh scheduling is perf for that then

#

see link above

storm crystal
#

okay, also you got a link for spawning armorstands and changing their position item in hand etc.?

river oracle
#

I got this fs

#

?jd-s

undone axleBOT
river oracle
#

Bukkit#spawnEntity and then cast to ArmorSTand

chrome beacon
#

^ don't do that

river oracle
#

you sure

#

pretty sure that works

chrome beacon
#

Use the spawn method that accepts a consumer if you plan on modifying the entity

#

modifying entity and then spawning it
vs
spawning entity and modifying it

river oracle
#

ahhh I didn't see the consumer method

#

also another correction its World#spawn(Location, Class, Consumer)

storm crystal
#

I dont think I am implementing it correctly lol

river oracle
#

re not in a method

chrome beacon
#

Keep in mind the order of execution

river oracle
#

oh I just realized the runnable is just out of order as far as conventions not a scope error

chrome beacon
#

That code will work fine if you fix the variable type and the plugin variable

#

though I wouldn't recommend starting a runnable on object creation

storm crystal
#

but I initialized plugin

#

I dont get it

chrome beacon
storm crystal
#

initializing plugin is literally above it

chrome beacon
#

runTaskLater is called before the constructor

storm crystal
#

how

river oracle
# storm crystal how

unlike languages like python the order in which you place the code doesn't really matter in the global scope

#

e.g.

storm crystal
#

okay so how do I make it later than constructor

river oracle
#

why do you even need the runnable

storm crystal
#

to make spawned armorstands disappear after like 4 secs

quiet ice
chrome beacon
storm crystal
#

there was one method with lambda (idk what it is) so I picked that one

quiet ice
#

Well I only saw "init plugin" and "after constructor"

chrome beacon
#

yeah plugin is their variable

storm crystal
#

I passed it from main class

quiet ice
#

Well once you have the actual plugin var you can just use the scheduler to init stuff on the first tick

quiet ice
#

It's fucking horrendous but it works ™️ (but - don't use this to init Vault or similar)

storm crystal
#

not to be douche but did you actually read what I want to do

chrome beacon
quiet ice
#

I fail to see what the problem is

chrome beacon
#

Missing basic Java knowledge is the problem

quiet ice
#

You initialize a variable that you defo shouldn't have

storm crystal
river oracle
chrome beacon
quiet ice
#

BukkitRunnable is ALWAYS a huge red flag. Period and there is no exception

#

Same goes with new Runnable()

storm crystal
#

idk man its literally my first time working with that kind of shit

chrome beacon
river oracle
quiet ice
hushed spindle
#

is there any event called when Block#breakBlock() is called?

#

cant be BreakBlockEvent because no player is involved

storm crystal
#

why is it even a thing, being initialized before constructor does anything

river oracle
#

fields are initialized before a constructor runs

#

no matter where in the code your classes field is

storm crystal
#

is there a way without doing all of it

quiet ice
#

You can init your field in the ctor

#

However, I don't think you actually want that anyways

chrome beacon
#

^^

storm crystal
#

no I mean doing something after X time elapsed

chrome beacon
quiet ice
storm crystal
#

havent worked with them yet

quiet ice
#

Uh, like how do you want to tell bukkit that you want to kill this amourstand and not the other one

storm crystal
#

idk yet why is that even important

hushed spindle
#

basically everything you see in minecraft is an instance of something

quiet ice
#

Honestly, you probably want to have this be a task that runs periodically in the background, purging all amourstands that are too old

chrome beacon
#

Well it's an object oriented language so a lot of things are instances

quiet ice
#

Otherwise you may run into issues with server restarts and other funsies

storm crystal
#

but fuck those armorstands for now thats totally out of the point

remote swallow
#

Kek this asking for helping is just looping back around to the basics of java can answer most of ur questions

storm crystal
#

I wont even think about them if I cant make delay at all

quiet ice
storm crystal
#

still boils down to setting a plugin field or whatever it is separately despite the fact that constructor exists and I literally have the plugin initialized in scope

#

so intellij just throws an error

quiet ice
#

Uh, and what prevents you from initializing the field in your constructor?

storm crystal
#

well, its already here

river oracle
#

I'm going to write something very useful out whether or not you pay any attention to it is whatever I don't care anymore this is a continued sensless discussion

quiet ice
#

Right now the assignment happens outside the constructor

inner mulch
#

I got a static hashmap in my plugin1, once i use the plugin1 as a depedency in another plugin2, the hashmap is null, even though its being set on the start of the plugin1 with the hashmap. Why is it null once i use it in another plugin2?

remote swallow
#

Are you accidentally shading it

quiet ice
#

So basically something like (warning: pseudocode, I have no programmed with bukkit/spigot for well over a year now)

Bukkit.getScheduler().runTaskTimer(JavaPlugin.getPlugin(MyPlugin.class), () -> {
  for (World world : Bukkit.getWorlds()) {
    for (AmourStand e : world.getEntitiesByClass(AmourStand.class)) {
       PersistentDataContainer pdc = e.getPersistentDataContainer();
       Long time = pdc.getOrDefault(expiryTimestampKey, PersistentDataType.LONG, Long.MAX_VALUE);
       if (time < System.currentTimeMillis()) {
          e.kill();
       }
     }
  }
}, 10L, 10L);
inner mulch
remote swallow
#

Ye

inner mulch
#

i dont think so, i will look into this

#

what does it need to be, is it supposed to be shaded ?

remote swallow
#

Check the scope is provided for maven or compileOnly for gradle

inner mulch
#

scope is provided

river oracle
# storm crystal well, its already here

Java loads a class in order

  1. Static Fields
  2. Static Initializing Blocks
  3. Fields
  4. Constructor

While I missed some nuanced examples this is basic enough for now.

public class ExmpleError {
  private final MyPlugin myPlugin;
  public ExampleError(MyPlugin myPlugin) {
    this.myPlugin = myPlugin; // myPlugin is initialized in the constructor not a field
  }
  private BukkitRunnable runnable = Bukkit.getScheduler().runTask(() -> thing, myPlugin) // this will cause an ERROR because fields are intiailized BEFORE the constructor so myPlugin is null
}

as you see in the example no matter the order FIELDS are initialized before the constructor. The runnable can't use myPlugin because it is still null.
even though you set it to myPlugin in the constructor java couldn't give 2 fucks seeing as it only intializes the fields first and as far as java is conerned at this point your class looks like below

public class ExampleError {
  private final MyPlugin myPlugin;
  private BukkitRunnable runnable = Bukkit.getScheduler().runTask(() -> thing, myPlugin) // this will cause an ERROR because fields are intiailized BEFORE the constructor so myPlugin is null
}

Java doesn't even care about your constructor only once the constructor is run does java begin to factor in the value you assigned myPlugin to. As you see within the field MyPlugin myPlugin it has yet to be assigned a value

remote swallow
opal carbon
chrome beacon
river oracle
#

The main difference is I'm uncertain if you can compile when using an unitialized field like that

chrome beacon
#

You can't

inner mulch
glacial coral
#

@hushed spindle Big thank you mate! I managed to make it work!
https://i.imgur.com/avwTzlO.png I now have a log of things that happened 20 seconds ago and can find what the last player did to the dying person!

river oracle
storm crystal
hushed spindle
#

epiiic nice job

river oracle
chrome beacon
#

Copy paste is easier so they went that route

quiet ice
storm crystal
river oracle
river oracle
quiet ice
#

I only asserted that assigning fields outside the constructor (or other methods) isn't great

river oracle
#

https://www.w3schools.com/java/java_constructors.asp constructors are used for intialization

#

please learn about constructors above ^

quiet ice
chrome beacon
#

I'd say that's worse than BukkitRunnable

river oracle
quiet ice
#

Though uh, I don't use it when it is performance-sensitive but generally you only need the plugin instance for one-off things so whatever

quiet ice
#

But whatever

quaint mantle
#

if I have an interface

river oracle
#

unless you're diehard DI

storm crystal
quaint mantle
#

and a data class impl an interface, do I name it like DataImpl?

storm crystal
#

without all the unnecessary hassle

quiet ice
#

I think I did multiple times

chrome beacon
#

^^

quiet ice
chrome beacon
#

but you seem to not want that

river oracle
quaint mantle
#

okay

#

MyData

#

boom

#

short and easy

river oracle
#

give me an example of what your impling

#

cuz sometimes their is something more specific you can use too

wet breach
#

?conventions

quaint mantle
#
public interface CustomCharacter {

    @NotNull CustomCharacterInformation getInformation();

    @NotNull ArmorEquipment<@NotNull CustomItem> getArmor();

    @NotNull List<@NotNull CustomItem> getItems();

}
public class CustomCharacterImpl implements CustomCharacter
chrome beacon
#

That's fine

#

Just stay consistent

quaint mantle
#

@wet breach

#

so does that mean records are against convention

chrome beacon
#

no?

river oracle
quaint mantle
#

alr

river oracle
#

or whatever

quaint mantle
#

oh is that the conventions for java 9

wet breach
#

its just a convention that most people follow for Java, whether you choose to use it or not is up to you. But if you don't follow it, just be prepared for all kinds of people to not like it 😉

river oracle
storm crystal
#

is there a way to make scheduler conditional?

quaint mantle
chrome beacon
#

?scheduling

undone axleBOT
river oracle
storm crystal
chrome beacon
#

Yeah

quiet ice
#

Yeah, runnables don't run when the server isn't yet ticking

quaint mantle
#

idk if its just me but do the bukkit runnables violate srp

quiet ice
#

Wha? Could you peeps stop inventing funny bullshit acronyms for "sane code"

chrome beacon
#

Single Responsibility Principle

storm crystal
#

or will it always run regardless

quaint mantle
chrome beacon
#

You're just wasting your own and our time

storm crystal
#

they will totally teach about bukkit runnables

chrome beacon
#

They don't need to

#

because if you understand the fundamentals you'd also understand how methods are called and what the scheduler actually does

storm crystal
#

yeah but getting stuck in front of black console trying to get desired input is kinda blunt and boring

chrome beacon
#

almost every problem I've seen you have is because you lack an understanding of Java fundamentals

storm crystal
#

yeah am learning simultaneously

#

more or less

quaint mantle
#

do yk what a lambda is dusk

chrome beacon
storm crystal
#

wavelength

chrome beacon
#

and instead you only want the answer

storm crystal
wet breach
#

and yes java courses will teach you about runnables

chrome beacon
#

Like we told you multiple times how to solve the problem

wet breach
#

it is weird they are having this much problems with Java considering they supposedly know another language

storm crystal
#

since when know equals to know everything

wet breach
#

do you know what an API is?

storm crystal
#

and its python bruv

#

I use it for uni assignments 💀

wet breach
#

you should if you know another programming language, the concept of an API isn't different because of the language

storm crystal
#

I think we are only past if and loops

wet breach
#

if you know how to read an API for one language, it shouldn't be super difficult to read an API of another language

storm crystal
wet breach
#

well you do need it

#

but whatever

storm crystal
#

okay so when I want to access something from constructor that's like this.something = something; id just say something.whatever_I_need

#

but what about bukkitrunnable

wet breach
#

python is more about functional programming, good news is that Java supports such things too

#

so it shouldn't be super hard to transition over 🙂

storm crystal
#

yeah but I cant just do this.BukkitRunnable

wet breach
#

anytime you use this, it means you want to reference a variable that was declared in the class and not the variable in the method

#

variables in classes can come from a parent class too, which happens if you extend something

quiet ice
#

||Let's not introduce them to OuterClass.this though||

wet breach
#

lol

storm crystal
#

I mean okay I got this and how do I access this outside in some method, like I know of scheduler.runTask but idk what to type in field of BukkitRunnable

#

like it doesnt really have a special name or anything like that

quiet ice
#

RTFM

If you have:

public class OuterClass {
    private final JavaPlugin plugin;
    private final BukkitRunnable runnable;

    public OuterClass(JavaPlugin plugin) {
        this.plugin = plugin;
        this.runnable = new BukkitRunnable() {
           @Override
           public void run() {
              // Do stuff here
           }
        };
        this.runnable.runTask(this.plugin); // In order to start the task on the **next** tick
    }
}
wet breach
#

depends what you need really

quiet ice
#

Of course, in this circumstance you might eventually see the need for ||OuterClass.this|| but I believe it's best to hide the existence of that feature until absolutely necessary as I think I'd be confused as heck if one were to introduce me to this feature 4 years ago

#

Yeah, it's best to have it be it's own class

wet breach
#

lol

quiet ice
#

Of course you could also use Local classes but that is another thing done rarely

tall dragon
quiet ice
#

It makes sense, but only once you know that the constructor of anonymous classes isn't what it says they are

storm crystal
#

okay I get it

#

okay i dont get it

#

XD

quiet ice
#

You need to invoke the method runTaskLater on the BukkitRunnable, not on the Scheduler

storm crystal
#

wa god damn it

#

it works now

quiet ice
#

So instead of Bukkit.getScheduler().rtl(plugin, runnable, delay) you have runnable.rtl(plugin, delay)

storm crystal
#

like that?

quiet ice
#

Yeah

#

Although, uh honestly given in the context of folia I don't think that makes much sense but whatever - Folia is a large rewrite regardless of this

wet breach
quiet ice
#

Huh`

echo basalt
#

I don't think 30*20 is 1500

quiet ice
#

30*20 is 600, no?

wet breach
#

which is like 75 seconds

wet breach
#

its 600

quiet ice
#

Which is like half a minute

echo basalt
#

it's literally 30 seconds

storm crystal
#

fyi I may not be the smartest

echo basalt
#

no clue what you're on

storm crystal
#

but I know my maths

quaint mantle
echo basalt
#

bro went from the army to re-learning his abc's

wet breach
#

for some reason I saw it as a 5 and not a 2 XD

echo basalt
#

isn't the cos of 45deg like 0.767

storm crystal
#

like a champ

quaint mantle
quiet ice
quaint mantle
#

I thought it was like 0.707

quiet ice
#

So it probably is closer to 0.71

quaint mantle
echo basalt
#

fuck

#

my memory is off

quaint mantle
#

idk I only remember this stuff was cause I was tryna understand spherical vectors

#

I remember I was in 8th grade wondering if there was a formula for the sin function I didnt know it was an algorithm 💀

echo basalt
#

I was looking for trigonometry back like on 6th grade

#

I was like

#

"if I had an angle and a vector length couldn't I calculate the 2d positions"

#

turns out

#

it's called cos and sin

quaint mantle
#

U were not thinking about that in 6th grade

echo basalt
#

I was

quiet ice
echo basalt
#

my man I've been making plugins for like 7 years now

young knoll
#

You were in 6th grade 7 years ago

#

Smh I’m old

echo basalt
#

yes, coll, I'm 18

storm crystal
#

bro if I knew it was so fucking easy 😭

echo basalt
#

now make a cooldown for the cooldown message so it isn't spammy

storm crystal
#

if someone clicks like a chimpanzee they deserve whatever happens to them

#

:]

young knoll
#

Does that cooldown also get a cooldown

river oracle
young knoll
#

I started making plugins 10 years ago

#

I was in 9th grade

river oracle
#

Wtf

echo basalt
#

still amateur

river oracle
#

Damn you're old

storm crystal
#

fossil

river oracle
#

Still not as good as me

#

I'll stop now and give you 10 years to catch up coll

quiet ice
#

I am ahead of all of you: I already quit making plugins

river oracle
#

Damn he's a pro

chrome beacon
#

It's been a while since I made a plugin

echo basalt
#

it's been a while since I genuinely had fun in this industry

young knoll
#

Oof

gleaming yarrow
#

is it possible to add a keybind component to a line of lore

young knoll
#

Not with the api

#

Yet

gleaming yarrow
#

but presumably it can be done via nms

young knoll
#

Yes

gleaming yarrow
#

thank god

echo basalt
#

bros avoiding adventure

chrome beacon
#

Paper

quiet ice
#

The only good reason to use paper

young knoll
#

Adventures Bukkit adapter sucks

#

So yeah

quiet ice
#

Yeah the adapter is pretty useless, I wonder why it exists at all

river oracle
#

hook bukkit developers on the components so they switch to paper

quiet ice
#

Even for that it isn't great

gleaming yarrow
#

😳

wet breach
river oracle
wet breach
#

at that point I will have no choice but to take over CB

grand flint
#

when creating a new plugin on intellij

#

should i just use the minecraft plugin creator plugin

river oracle
grand flint
#

or a plain gradle project?

river oracle
tall dragon
echo basalt
#

it's fun

#

just buy more ram

grand flint
#

@tall dragon idk u so i dont trust u

grand flint
#

💋

tall dragon
#

ok

wet breach
#

lol

tall dragon
#

guys how can i register a command?

wet breach
#

o.O

eternal night
#

idk u so I don't trust you so I cannot answer

tall dragon
#

sorry i dont know you, so it must be a virus.