#help-development

1 messages Β· Page 946 of 1

grim hound
#

can discord helpers ban here?

lilac dagger
#

we have a bot that handles these on my server

tall dragon
#

pretty sure they can yes

grim hound
#

@lost matrix

#

do yo thing

#

I always wondered whether those are people who's account have been hacked or just accounts created purely for this

lilac dagger
#

do people put their credit card info into these discord servers that they keep promoting it?

grim hound
#

and get hacked

lost matrix
#

Wait i wanted to join aPES_Bongo

grim hound
lilac dagger
#

i have quiet a few in my automod channel if you want to lol @lost matrix

lost matrix
#

Always wanted to get scammed and put my credit card infos out there

lilac dagger
#

i don't know exactly what we use

#

it's automod

grim hound
lilac dagger
#

ye

#

might wanna check if someone can turn it on for discord too

grim hound
#

there's a mistake here

#

how can I report it?

#

this is false

lilac dagger
#

there doesn't seem to be a contact me page

#

maybe look through help

grim hound
#

well whatever

lost matrix
#

Write a letter

tall dragon
#

send a carrier pigeon

agile hollow
#

how can i get the statistics of an offline player?

lost matrix
#

By calling .getStatistic(Statistic) on the OfflinePlayer...?

agile hollow
#

ye

    public static int getKills(OfflinePlayer p) {
        return p.getPlayer().getStatistic(Statistic.PLAYER_KILLS);
    }
lost matrix
#

Nope

#

getPlayer() returns null for players which arent online

#

Cant do that

agile hollow
#

and how can i do the getPlayer() on an offline one?

lost matrix
#

You dont

agile hollow
#

and how i can...

lost matrix
#

By calling .getStatistic(Statistic) on the OfflinePlayer

agile hollow
#

oh okay

near crypt
#

how can i check if a item is a block?

shadow night
#

I bet those questions (of this kind) can be solved with a simple google search

umbral ridge
#

anything can be solved by google search. it's just that people are lazy and need a quick solution. at the end of a day I still don't understand why this channel is for, if eeeeeeverythinggg can be resolved with a "simple google search". So the idea of it, is confusing, however, I prefer not to search much on Google, because people here almost always know what the problem is, how should it be resolved or what I have to change or whatever. but yeah I guess not always..

But you know, whenever you post your code, idiots will be idiots, most of the programmers can be egotistic fucks and immediately start judging your code as if it's a trophy for them to achieve or some toy or a ball they have to catch. It's important to respect newbies, not the ones that use AI and then copy&paste and spam the fuck out of everything, but everyone else, yea

shadow night
ivory sleet
#

I mean google can help, but google can just be as confusing

umbral ridge
#

yea I agree with that people can be confusing

ivory sleet
#

i think being a good googler is a valuable skill, however there is a lot of outdated solutions on the web, it may just be as hard to filter out what you need yk

minor junco
lost matrix
lilac dagger
#

i'm so ready for title exploits to popup again

rapid vigil
weak adder
#

ive made some custom recipes on my server but non operator players cant craft or pick up those items for some reason? i have not set any permission restrictions for those is there any default ones?

https://paste.md-5.net/kinobuqoda.java

lost matrix
lost matrix
#

Nope

#

They are mutualy exclusive

#

If you didnt craft an item, then you wont be able to pick it out of your crafting UI because there is nothing to pickup

weak adder
lost matrix
#

Then there is some plugin preventing this

#

Items arent restricted in any way on default.
How about other items. Did you try throwing them a stone block to see if they can pick it up?

#

Because im suspecting there is a plugin in play which prevents creative players from handing out goodies.

weak adder
#

I will remove each plugin one by one and check if that's the issue

quaint mantle
#

Hello, I have been trying to create a plugin with custom heads from Minecraft Heads in an Inventory, but the plugin throws me this error

java.net.MalformedURLException: no protocol: 3f6d3a28dd1d680fa7cc3bc4bd04cd0113bc720320a9caaa7b097e0046889645

I don't know what can i do. This is my code.

(I have created only one head, is for test the method createHead)

lost matrix
#

This doesnt look like an URL to me...

quaint mantle
#

im gonna send the code

#

i cant send files

lost matrix
#

?paste

undone axleBOT
quaint mantle
#

?paste

undone axleBOT
quaint mantle
#

if you want the full code tell me

lost matrix
# quaint mantle https://paste.md-5.net/hupubuvaza.cs
private static final String BASE_URL = "http://textures.minecraft.net/texture/";
  private static URL createTextureURL(String key) {
    String url = BASE_URL + key;
    try {
      return new URL(url);
    } catch (MalformedURLException e) {
      throw new RuntimeException(e);
    }
  }
URL textureUrl = createTextureURL("ad8e4187921f223878af435d4554c32473e7437f59236618c80a0cd773b9606d");
#

You literally need to create an URL to the texture on mojangs server.

quaint mantle
#

im gonna try

quaint mantle
#

head

lost matrix
#

Then you call the method more than once...?
I dont understand the question.

#

Each texture has its own unique URL on mojangs servers.
So if you want different heads, then you need to create different URLs.

quaint mantle
#

like that? (i modified the paste)

lost matrix
#

Send the modified paste

quaint mantle
lost matrix
quaint mantle
#

It was unintentional, Im gonna fix it

lost matrix
# quaint mantle It was unintentional, Im gonna fix it

All you need to do is replace

    public static ItemStack createHead(String toBeUrl){
        URL url = null;
        try {
            url = new URL(toBeUrl);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }

with

    public static ItemStack createHead(String toBeUrl){
        URL url = createTextureURL(toBeUrl);
rapid vigil
#

sTaTic AbUsE

quaint mantle
#

done

buoyant jasper
#

hi i need thelp with connecting plugin to database its connected but does not show player stats

valid burrow
#

no clue why people dont like spamming static lol

buoyant jasper
#

yes

grave vale
valid burrow
#

okay what language?

quaint mantle
valid burrow
#

(Mysql, Mongo)

buoyant jasper
#

mysql

valid burrow
#

alright

#

i can help with that

#

is there an error in the console?

buoyant jasper
#

no

#

can i send you the file

valid burrow
#

mhm okay show me the code that seems to be causing the problem and the methods used by kt

#

sure

#

?paste

undone axleBOT
valid burrow
#

put it in here

buoyant jasper
#

but its large project

valid burrow
#

make 1 paste link peer class

#

i dont need all classes

rapid vigil
buoyant jasper
#

ok

grave vale
valid burrow
#

99% of time

#

theres nothing wrong with static

buoyant jasper
#

how do i send the other classes

rapid vigil
valid burrow
#

then copy the link

#

and open ?paste again

grave vale
#

I used to extremely abuse static (even in my main class) until I learned it wasn't the right way to do it
I was told it's the only basic thing I hadn't learned somehow

buoyant jasper
#

?paste

undone axleBOT
grave vale
#

now I think I over-instantiate stuff lmao

buoyant jasper
#

can you see the first code

valid burrow
#

click save

buoyant jasper
#

i did

valid burrow
#

and copy the link

buoyant jasper
valid burrow
#

your main looks good

buoyant jasper
#

can i send you file of the project

valid burrow
#

show me db class

#

im on phone

#

so

buoyant jasper
#

ok

valid burrow
#

i cant really open that xd

chrome ferry
#

does boundingbox#contains not include the actual border of the box?

buoyant jasper
#

?paste

undone axleBOT
buoyant jasper
#

it doesnt let me save

valid burrow
#

wdum it doesnt let you save lol

#

that sounds new

#

never heard of an issue like that

surreal wind
#

Guys im having trouble, my plugin listens when a player clicks a barrel, if he clicks it it gives it a key if he clicks it again it does not have that key anymore, why is that?

buoyant jasper
#

?paste

undone axleBOT
lilac dagger
#

i know him, he copy pasted two plugins into one and i think he didn't unify the javaplugin classes

quaint mantle
buoyant jasper
#

i fixed part of it

quaint mantle
#

but the inventory doesnt open

buoyant jasper
#

now just the database part is not working

valid burrow
#

alr show me

#

just show me

buoyant jasper
#

if it would let me save

valid burrow
#

what methods of the db are being used

#

uhh

#

if you want

#

send me screenshots in dΓΆs

#

dms

near crypt
#

when i cancel the inventory click event if a certain item is clicked, it just duplicates the item in creative mode. How can i fix this?

grave vale
#

what are you trying to do?

grave vale
surreal wind
#

how

grave vale
#

I'm not sure though, let me look at my hopper plugin to check how I saved persistent data onto a block

surreal wind
#

ok

grave vale
#

it's simple, you're already doing it right but missing one thing

surreal wind
#

what am i missing?

grave vale
#

after you've set your value in your PDC, simply call state.update()

#

that'll actually write the value you've edited in the block's metadata

surreal wind
#

so after the last line i should put state.update()

grave vale
#

correct

surreal wind
#

tysm i have been trying everything i could think of in the last 30 minutes

grave vale
#

can you show us how you're doing it?

grave vale
#

?paste

undone axleBOT
grave vale
#

just checking, are you counting the slots from 1 to 10 (example) or from 0 to 9?

#

alright

#

you aren't updating curtitle

#

you're getting it once and it gives you the name of the first menu, but when you change menus it doesn't update with it, you have to explicitly set it again

near crypt
#

How can i get all online players in a class that not extends JavaPlugin?

grave vale
#

I have the idea in my head but I'm bad at explaining 😭

#

your second if statement is nested in another if statement

#

so it's never reached

#

oh sorry I can't read... lmao

brazen aurora
#

nvm my english isn't good
and also i found what is wrong. thanks πŸ™‚
vanilla items don't have itemmeta

grave vale
#

yeah

#

also you're checking twice if the item is AIR/null

#

item == null is the same as item.getType() == Material.AIR

grave vale
#

Judging others for trying is a bad thing

brazen aurora
#

cool

#

do you know how can i get vanilla item's display name?

#

it can't be getting with using itemmeta

worthy star
#
    public static Object getValue(Map<?, ?> map, Object key) {
        for(Map.Entry<?, ?> entry : map.entrySet()) {
            if(entry.getKey().equals(key)) {
                return entry.getValue();
            }
        }
        return null;
    }``` is this a good code to get a value from its key? :)
grave vale
ivory sleet
worthy star
#

oh what?

#

i tried map.getValue(key) but not a thing xD

ivory sleet
#

i mean like

#

Just map.get(key)

#

:)

worthy star
#

and it will return the value?

#

dam nice

ivory sleet
#

Yea

#

well null if the key is mapped to null or its entry is absent

granite owl
#

does ```java
Bukkit.unloadWorld("world_nether", true);

#

or only put it in like standby mode

#

that simulation is stopped

young knoll
#

It unloads it

granite owl
#

so?

#

because unloading worlds is not a vanilla concept

#

what does that mean in terms of memory management

#

i want to have n worlds, with only m worlds active at any time to prevent OOM errors

#

but i want to change which worlds are active at runtime

young knoll
#

It removes the world from the server's world list

#

Whether that actually frees the memory depends on what else is holding refrence to the world

granite owl
worldly ingot
#

If you're having OOM errors, I feel like unloading worlds probably isn't going to be the solution you should be exploring

#

Maybe investigate what's allocating so much memory and reduce its memory footprint. Search for memory leaks

granite owl
pseudo hazel
lost matrix
quaint mantle
#

hello, i created a head in a inventory with custom textures from minecraft heads, but the head doesnt have textures

#

why?

lost matrix
#

Show your code

#

First prediction: Didnt apply ItemMeta

quaint mantle
#

that is, if I put meta item but in a different way

quaint mantle
#

now says profile name must not be null

#
Caused by: java.lang.NullPointerException: Profile name must not be null
young knoll
#

What version of minecraft

slender elbow
#

mfw setting the profile reflectively instead of using API

#

sad

river oracle
#

Paper

umbral ridge
# lost matrix "Ok guys, today i will teach you how to make guis in minecraft" ```java @Event...

for a person that's new in this, that's perfect. it's not like everyone should write code exactly as you would prefer. it doesn't matter if there's a space missing, or any of the visual characters that don't really affect the performance of the code. it doesn't matter if they use switch or the shittiest code possible. if they know what it does, and didn't just copy and paste it from somewhere, then that's fine. As long as they understand it. They'll get better, maybe better than you, me or the whole server. Also most of the people get judged for x problem when they were asking about y. It's like coming to a restaurant ordering a steak but receiving a beer.

worthy star
river oracle
worthy star
#

no i mean

#

isn't adventure for both paper and spigot?

river oracle
#

No

#

Only paper

worthy star
#

oh mb

slender elbow
#

adventure-platform: exists
spigot:

granite owl
#

does some AST parser library exist for java to parse mathematical terms?

young knoll
#

adventure bukkit sucks tho

slender elbow
#

ok? it still exists and you can send messages

young knoll
#

And that's about it

#

:c

lost matrix
slender elbow
#

tablist header/footer, bossbar, title, book

slender elbow
#

crubch

river oracle
slender elbow
#

what's that

river oracle
#

My mini message clone that I built cuz I wanted to learn parsing

#

Was a worth while project I learned parsing πŸ‘

slender elbow
#

good

granite owl
river oracle
slender elbow
#

pinneapple

river oracle
#

I'll call it Y2KisTheBest

granite owl
#

lets fork the fork of the fork

young knoll
#

I thought it was CabinetMC

river oracle
#

He's gone now tho so idrc anymore

#

I might do something this summer tho who knows

surreal wind
#

guys i have the player's item in hand how can i destroy it?

vast ledge
#

Itemstack.setType air

#

Or smth

surreal wind
#

oh ty

vast ledge
#

Maybe material

young knoll
#

Set held item to null

river oracle
#

Null mfw

#

😭

#

I hate null in inventories smh

vast ledge
#

Yea, why can't they just return air, it's basically null, but doesn't throw 50 Exceptions

surreal wind
#

yep this works

young knoll
#

You can just use null

river oracle
remote swallow
#

L

young knoll
#

Hush this isn't kotlin

lilac dagger
#

this would've been so nice

#

no wildcards sadly

lost matrix
#

Or if its a specific user set

public interface UserSet<T extends User> extends Iterable<T>
slender elbow
#

true

restive mango
#

Anyone know how to get a persistentdatacontainer from different plugin?

#

πŸ™‚

lilac dagger
#

i think it makes sense, it breaks the contract sort of, but i wanted the classes that implements it to give more information than just this

lost matrix
#

Sometimes they have them laying around somewhere and can be grabbed.

median trench
#

Hey when using the Respawn packet I get the "loading terrain..." message for a long time, am I using it wrong?

val respawnPacket = ClientboundRespawnPacket(
            CommonPlayerSpawnInfo(
                nmsPlayer.level().dimensionTypeId(),
                nmsPlayer.level().dimension(),
                nmsPlayer.serverLevel().seed,
                nmsPlayer.gameMode.gameModeForPlayer,
                nmsPlayer.gameMode.gameModeForPlayer,
                false,
                false,
                Optional.empty(),
                0
            ),
            0,
        )

According to wiki.vg I should avoid setting it to the same dimension, but I've read many other resources that don't care about that. (Edit: Even when using two dimensions it gets stuck)

slender elbow
#

why are you using a packet?

median trench
#

it is changing but it gets stuck there for about 10-15 seconds

ocean hollow
#

how can I make a gradient for text? So that the user enters into the config (example: '<#AA0000>Admin</#cc0c0c>'), and I can create a gradient using kyori Component?

inner mulch
ocean hollow
#

yes

#

I use paper

inner mulch
#

do you know what minimessages are?

ocean hollow
#

yes

inner mulch
#

okay

#

this would be a gradient

#

for minimessage

ocean hollow
#

so i should deserialize String?

inner mulch
#

just call </gradient> to stop the gradient

inner mulch
#

make it a component

worthy star
#

if i want to get message sender with JDA, should i use #getAuthor() or #getMember()

kind hatch
#

Typically you'd want to use #getMember() as it has more methods available to you.

worthy star
#

ok thx

hazy parrot
#

depends on what u want to do tbh

#

Member is a user in a specific server

#

and User is user in general

shell geyser
#

Hey, i got a question, how can i use arguments in Java?

hazy parrot
#

cli arguments ?

#

when u have public static void main(String[] args), "args" are cli arguments passed after your jar name

grave vale
#

hey, does anyone have an idea why I'm losing some items when serializing a player's items in a config?

#

actual inv:

#

what I'm getting

eternal night
#

I mean, how are you serialising HMM

#

?paste

undone axleBOT
grave vale
#

the same way I was told to by spigot LOL

#

it looks like the problem is the break;

#

ok yeah, for some reason I always believed break; only skipped the curent iteration but turns out that continue; does that

#

nevermind I solved my own problem

wide coyote
#

lol

light saffron
#

i have my code and i want to turn it into .class files just btw maven isnt working and idk how to link my pom.xml file to my .java files

lost matrix
#

The pom is just a config for maven to run off

light saffron
#

but i dont have maven it doesn't work for me idk why

lost matrix
#

In that case your pom is useless

light saffron
#

o

lost matrix
#

Lets fix maven

#

What doesnt work?

light saffron
#

in cmd prompt

#

when i type mvn

lost matrix
#

Continue

light saffron
#

BRO WTF IT JUST WORKED πŸ’€

#

ive been trying for 2 days

#

and all the sudded boom it works i hate this bor

#

[WARNING] The POM for org.spigotmc:spigot-api:jar;1.20.1-R0.1-SNAPSHOT is missing, no dependency information available

#

what do i do about this

icy beacon
#

If it compiles, it compiles

lost matrix
#

You forgot to add the spigot repository

light saffron
#

shit did i?

#

πŸ’€

lost matrix
#

Wait i thought this was an exception, not a warning

icy beacon
#

Yep it's a warning so i'd assume it's fine

light saffron
#

it said build failure

icy beacon
#

Is that the cause of your build failure?

#

Or are there other errors?

light saffron
#

here ill send the entire thing

#

[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< your.group.id:SpeedKillPlugin >--------------------
[INFO] Building SpeedKillPlugin 1.0.0
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for org.spigotmc:spigot-apiπŸ«™1.20.1-R0.1-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.320 s
[INFO] Finished at: 2024-03-30T09:16:55-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project SpeedKillPlugin: Could not resolve dependencies for project your.group.id:SpeedKillPluginπŸ«™1.0.0: The following artifacts could not be resolved: org.spigotmc:spigot-apiπŸ«™1.20.1-R0.1-SNAPSHOT (absent): Could not find artifact org.spigotmc:spigot-apiπŸ«™1.20.1-R0.1-SNAPSHOT -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

icy beacon
#

Yeah you seem to not have the repo

#

Show yourpom

#

?paste

undone axleBOT
light saffron
#

ok

#

<!-- suppress MavenModelInspection -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>your.group.id</groupId>
<artifactId>SpeedKillPlugin</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

#

thats my pom

icy beacon
#

Please use ?paste for large code blocks in the future

#

And yes you do not have the repository

light saffron
#

o ok

#

so how do i get that?

icy beacon
#

?codeblock

undone axleBOT
#

You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {

}

}```
Becomes:

public class MyPlugin extends JavaPlugin {
    @Override
    public void onEnable() {

    }
}```
icy beacon
icy beacon
light saffron
#

ok

icy beacon
light saffron
#

do i paste that in my pom

icy beacon
#

You add the <repositories> block yes

light saffron
#

ok

kind hatch
#

Does anyone know when Server#getVersion() gets initilized in the startup process?

#

Or through what means?

kind hatch
#

Ty

light saffron
#

my pom is working but now when i do "mvn clean install" in cmd prompt it gives me a jar file with my pom.xml manifest.mf and pom.properties but there's no trace of the actual plugin javascript

icy beacon
#

Javascript??

light saffron
#

uhh

#

like the thingy

icy beacon
#

Also you build your plugin with package, not install

icy beacon
light saffron
#

o

light saffron
icy beacon
#

What class

light saffron
#

liek bytecode

icy beacon
#

Your plugin gets packaged into a .jar file

#

From java files

light saffron
#

yes

icy beacon
#

There is no javascript

light saffron
#

mbmb

icy beacon
#

They are 2 completely different languages

light saffron
#

im dumb

icy beacon
#

?learnjava

undone axleBOT
#

For Beginners:

Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/

For Intermediate to Advanced Learners:

Oracle Java Tutorials: The official guides by Oracle for Java programmingβ€”great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/

Practice and Hands-on Learning:

Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/

Free Resources and Documentation:

Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/

Community and Support:

Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/

Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! πŸŽ‰

light saffron
#

but it doesnt put the java file in the jar?

icy beacon
#

If you don't know Java you will struggle a lot while making plugins. It's like reading a book in Chinese except you don't know Chinese and you look up every word in the dictionary

umbral ridge
#

along with compiled .class

light saffron
#

alr

umbral ridge
#

if you choose it

light saffron
#

bet

#

dms?

next plume
# undone axle ### For Beginners: Codecademy - Learn Java: Interactive Java programming course ...

Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions.
"Creating computer software is always a demanding and painstaking process -- an exercise in logic, clear expression, and almost fanatical attention to detail. It requires intelligence, dedication, and an enormous amount of hard work. But, a certain amount of unpredictable and often unrepeatable inspiration is what usually makes the difference between adequacy and excellence."

light saffron
#

W Quote

next plume
#

I have another one:
"Computer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter." - Eric S. Raymond

light saffron
#

where is bro getting these

next plume
#

The Intertubes

light saffron
#

nice

#

wait so how do i turn .java to .class?

fallen lily
#

the javac command

#

Or you can use an IDE

#

Like IntelliJ IDEA

light saffron
#

ik but i have errors because my pom file isnt there

fallen lily
#

Which does it for you

hazy parrot
#

Or with proper build tool that does that under the hood

light saffron
#

just lmk

lilac dagger
#

download intellij community from their website

#

set up a maven project and then import the java class

light saffron
#

i already have that

#

ok

lilac dagger
#

by importing it's a simple copy paste

#

make sure you match the package

light saffron
#

wdym package

lilac dagger
#

package as in path

light saffron
#

ok

#

so then do i click build?

lilac dagger
#

if you set up maven you'll have to click install from the maven's lifecycle

light saffron
#

how would i go to that page?

solemn meteor
#

is there any documentation regarding sending messages to console

lilac dagger
#

click m

light saffron
#

ok

solemn meteor
#

like is there a better and/or different way from sysout?

lilac dagger
light saffron
lilac dagger
#

or if you want to color your prints there's Bukkit.getConsoleSender()

solemn meteor
lilac dagger
#

you can use the color code here

lilac dagger
#

yes

light saffron
#

ok

lilac dagger
#

it's archetype

light saffron
#

gotcha

solemn meteor
lilac dagger
#

it's plainly

#

this is how it looks

#

it's colored but not here

solemn meteor
#

I see, so I have to add the [PluginName] manually

lilac dagger
solemn meteor
#

thanks

lilac dagger
#

do try to get the logger working

solemn meteor
light saffron
#

btw Fr33styler in the lifcycle what is the thing i click is it package?

hazy parrot
#

y

light saffron
#

bc

lilac dagger
#

it should be like this

#

click install

hazy parrot
#

why install if he wants just to compile

lilac dagger
#

i assume he wants to have a jar?

light saffron
#

yes

lilac dagger
#

i dunno what you do with a class

light saffron
#

wait wtf

light saffron
lilac dagger
#

well, clicking install makes the jar for you

hazy parrot
#

install will also put it into your local repo

light saffron
#

oh

lilac dagger
#

nothing wrong with that in most cases

hazy parrot
#

sure there is nothing wrong, but no reason to

ocean hollow
#

why i can't use it

hazy parrot
ocean hollow
worthy star
#

how can i remove a configuration node ? like

linking:
  uuid: id```,  i want to remove the **id** and the **uuid**
#

if i use set(uuid, null) it will just become empty (uuid: )

hazy parrot
lilac dagger
#

deleteconfigurationsection or remove

worthy star
lilac dagger
#

oh it's createSection("linking")

#

this will wipe everything under linking itself included

#

make sure to save the file

worthy star
#

oh dang

#

can't i just delete the node?

#

not possible at all?

lost matrix
#

Setting it to null will remove it

worthy star
#

wait wha?

#

let me test again

lilac dagger
#

pretty sure set null was buggy for someone but i haven't checked myself to confirm

flint warren
#
new ShapedRecipe(new NamespacedKey(plugin, "emerald"), new ItemStack(Material.EMERALD))
                .shape(" D ","DDD"," D ")
                .setIngredient('D',  new RecipeChoice.ExactChoice(
                        RegisterAllItems.registeredItems.get("emerald_fragment").getAsItem()
                        // ^^ this returns an item with custom tags (a tag for the id being "emerald_fragment" and others like a custom uuid to not stack with other items of the same kind)
                ))

any idea if there is any way for that to work?
if there was any way to get what item im placing in that slot it would be fixed but maybe there is a better way

solemn meteor
#

Does .saveDefaultConfig(); make the config.yml file? A lot of resources say yes but my server says no. The embedded resource 'config.yml' cannot be found

quaint mantle
hazy parrot
#

its not

solemn meteor
#

saveDefaultConfig() will write the config.yml file from your plugin's jar file to the plugin's data folder. (If that folder doesn't exist it will be created) It will not overwrite an existing config file.

quaint mantle
#

its not wrong

solemn meteor
hazy parrot
#

everything inside resources folder will be packed inside of your final jar

#

so if you want to get config, it have to be inside of your resources folder

quaint mantle
#

you have just to create a config.yml file inside your plugin resources folder

quaint mantle
#

there resources and put it directly inside of it

solemn meteor
hazy parrot
#

that is standard project structure

solemn meteor
#

I did not know about the existence of resources folder 🀦

quaint mantle
#

Oh

#

Hahah, it exists

#

Its most likely always there when you create a new java project

solemn meteor
#

I know it exists, I didn't know that the function of it was that

quaint mantle
#

Now you know πŸ₯°

solemn meteor
#

what do I put in there, if I make a config.yml file? the default values?

hazy parrot
#

y

quaint mantle
#

yea just write config.yml and leave it empty after starting your plugin it should be within the plugin folder of your plugin

solemn meteor
#

man

quaint mantle
#

because you put it within your resource folder, after calling the method the plugin will take the file from the resource folder and put it into your plugin folder

#

there should be a documentation for it as well if you click on the method saveDefaultConfig() just download the source

solemn meteor
#

oh my fucking god it worked

#

how did I not know of this before

#

thanks a lot btw

quaint mantle
#

you're welcome lol

quaint mantle
solemn meteor
#

it makes a lot of sense now

echo basalt
#

or just have a little method that copies over every file :3

sleek estuary
#

event.setcursor is executed but i continue with the item

#

why

echo basalt
#

add more debug lines

quaint mantle
#

It should clear the cursor entirely of the player

#

if that does not work the Item is probably not similar to the other item

worthy star
eternal oxide
#

no

inner mulch
#

can i disallow or somehow discourage the anonymous use of a certain class?

worthy star
#

why whenever i add something to a custom yml file it sends

#

if i remove it it builds, but i need it

#

help pls :)

lilac dagger
#

it shouldn't

remote swallow
#

spigot doesnt class that as a config section

worthy star
#

it happens sometimes, and sometimes not

lilac dagger
#

are we talking about this?

worthy star
#

yea

#

i had to add it manullay because uhh #createSection(string) method didn't work

remote swallow
#

your trying to create it then by loading it delete it

eternal oxide
#

creating an empty section does nothing

worthy star
#

oh

#

so should i create the section then save the file?

kind hatch
#

Hmmm, adding this update checking seems to be harder than I thought. lol
Need a way to get the server version string at early startup, but it's not generated until after the main server has already started. 😦

worthy star
sleek estuary
#

the code in block is executed

#

because event.setcurrentitem is being executed

worthy star
#

um why this always returns false

    public boolean isLinked(UUID uuid) {
        return config.getConfigurationSection("linking").getKeys(false).contains(uuid);
    }```
#

even if it contains the uuid

lilac dagger
#

UUID and the keys are string

eternal oxide
#

did you puist a String in and expect it to match a UUID?

lilac dagger
#

use uuid.toString()

worthy star
#

oh thx :)

lilac dagger
#

it should be yellow too

worthy star
#

yea it is

#

but it didn't give a fix adding .toString()

lilac dagger
#

it's impossible for the ide to infer this

#

it assumes you just put some random object

solemn meteor
#

question regarding config.yml in resource folder

#

is it better to add the defaults by writing it directly onto the config.yml or is it better to do it code-wise

lilac dagger
#

depends on how you're feeling

kind hatch
solemn meteor
lilac dagger
#

yeah

#

up to you

solemn meteor
#

alright nice

inner mulch
#

how do i create annotations that underline the code yellow when something is wrogn?

#

like @Nullable

deft heath
#

Any idea why this shouldn't work?
Event is registered; Same thing happens without the runnable

@EventHandler
public void onSpawnerSpawnEvent(SpawnerSpawnEvent event) {
    CreatureSpawner spawner = event.getSpawner();
    Bukkit.getScheduler().scheduleSyncDelayedTask(ClaimUpgrades.getInstance(), () -> {
        spawner.setMinSpawnDelay(15);
        spawner.setMaxSpawnDelay(25);
        spawner.setDelay(20);
        spawner.getBlock().getState().update(true);
    }, 5L);
}
kind hatch
#

Damn it, I think I have to make a patch directly in MinecraftServer.
I don't know how to do that shiz. 😫

remote swallow
#

step 1 is fork spigot or craftbukkit and modify the class in src/main/net/minecraft

kind hatch
deft heath
eternal oxide
#

don't getstate.update

worthy star
remote swallow
#

and run patches

kind hatch
#

Ngl, haven't done this type of spigot development yet.

#

How do I build spigot itself?

#

With BuildTools? or one of the scripts included in cb?

remote swallow
#

uhhhh, do you know how buildtools works internally

#

basically doing buildtools manually

#

@river oracle can explain better than i can

lost matrix
deft heath
worthy star
lost matrix
worthy star
#

i want to store linked players' uuids with discord id's

#

but when i add linking: section it sends that error

kind hatch
#

What's your config structure supposed to look like?

worthy star
#

i tried using #createSection() but it deletes the old section when it loads

kind hatch
kind hatch
#

And how are you currently creating those sections?

lost matrix
#

Just throw a Map<UUID, String> in there. Dont bother with sections.

worthy star
#

for the linking: i create on load of the file, the uuid and id i create it when linking

worthy star
kind hatch
#

If you're creating it on load, then you're likely overwriting any existing data. You should check to see if the section already exists.

lilac dagger
#

just create a new file over

worthy star
#

i just added this

        if(!config.contains("linking"))
            config.createSection("linking");
        ```
river oracle
worthy star
#

that fixed it!

kind hatch
#

How to create cb patches?

river oracle
kind hatch
#

I guess modifying one in this case.

#

No guranatees it even works though.

#

lol

river oracle
#

alr just run ./applyPathces /path/too/buildtools/work/decompile-latest

#

its a script in craftbukkit

kind hatch
#

Do I just need to make my changes directly in the net.minecraft classes or do I need to modify the patch files directly?

river oracle
#

have you run applyPatches already and modified the .java file?

kind hatch
#

I've modified the .java file.

river oracle
#

okay mb run ./makePatches /path/too/buildtools/work/decompile-latest

remote swallow
#

does make patches need the bt path?

river oracle
#

no lol

#

that'd be idiotic design

kind hatch
#

Alright, patches made.

river oracle
#

yes it does I thought you meant it moved the patches to BT

remote swallow
#

smh

kind hatch
#

I see it updated the patch file in the project dir.

#

So now what?

river oracle
#

the two scripts do everything for you

remote swallow
#

(for testing either run package and test with cb or install and do the spigot stuff

cobalt flame
#

Hey so i got a 1.20.4 server and i've found something. Unlike 1.16 my mobs get counted as dead if the chunks unload. Like if i go to the nether the mob.isDead() gets triggered. But once i return the mob is there. My problem is that i run some stuff that cancel on mob death. Don't have that issue in 1.16 but for some reason it pops up in 1.20. Is there anything that can be done?

kind hatch
river oracle
#

doingw hat BT does yourself is annoying

surreal wind
#

guys how can i wait 1 second?

rough ibex
#

20 ticks

surreal wind
#

what method should i use?

rough ibex
#

?showcode

#

?nocode

undone axleBOT
#

It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.

rough ibex
#

what are you trying to do

surreal wind
#

a timer

#

like 5 seconds wait

kind hatch
#

Ok, just for funsies, how would I go about creating a new patch file?

surreal wind
#

i currently have this but it just stalls the game

rough ibex
#

yes, don't thread sleep

#

use the scheduler

torn shuttle
#

one day the threads will unionize and get a 1 day a week thread sleep

river oracle
#

find the java file you want to patch and move it into the right folder in CB

surreal wind
river oracle
#

if the folder doesn't exist create it

kind hatch
#

Under nms-patches?

#

Or wait.

river oracle
#

no under src/net/minecraft

#

you're only working with java files here

kind hatch
#

Are we still in the BT decompile folder or in the cb project?

#

Let's say I want to mess with decopile-latest/net/minecraft/recipebook/AutoRecipe.java

#

At least for me, that file only exists in the bt work dir.
It doesn't exist in the cb project.

remote swallow
#

drag it to the correct path in the same place that you edited that other java class

#

i dont remember the exact package

kind hatch
#

I am doing this correctly right?

#

That was copied over from the decompiled work directory.

river oracle
#

yeah

kind hatch
#

Now it's more or less just running makePatches again?

#

Or is there another step?

river oracle
#

yeah

#

no just makePatches

kind hatch
#

Interesting

river oracle
#

all make patches does is compare t he two java files

kind hatch
river oracle
#

and patch the dif

kind hatch
#

Ahhh

buoyant jasper
#

something in my plugin code dont work

kind hatch
#

Does it also handle the auto numbering or is that something that spigot does when it compiles?

sleek estuary
#

Bukkit.getScheduler().runTaskAsynchronously(YourPlugin.getInstance(), () -> {
for (Player player : Bukkit.getOnlinePlayers()) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "/" + args[0].replace(".", " ").replace("%player%", player.getName()));
}
});

i can use asynchronously to add item to a inventory player?

river oracle
ivory sleet
#

Why do you wanna do it async?

sleek estuary
river oracle
#

kekw

kind hatch
#

Can I remove a patch?

river oracle
ivory sleet
kind hatch
#

Oh, lol.

river oracle
#

you might have to delete the file in CB as well

sleek estuary
#

async work to add item to player inv?

river oracle
#

its not even worth it unless you have thousands of players

#

on the same server

#

plus Inventories don't even support Async operations afaik. You'd need some work distribution

kind hatch
sleek estuary
kind hatch
#

Time to start testing if things actually work now. lol

river oracle
shadow night
stoic cosmos
#

Is getTitle a thing for inventories because i followed a tutorial and seemingly the code is 1 to 1 i have an error with getTitle they dont and the ide doesnt say anything about imports

vital storm
#

Does anyone know how to enable both premium and cracked players, who may possess identical usernames, to join the server simultaneously.

For example: the user Intexor can join with cracked and premium at the same time.

if anyone knows a solution for this issue please let me know.
My discord is Intexor

river oracle
#

don't use getTitle to determine inventories anyways

#

?gui

stoic cosmos
#

thanks

sleek estuary
shadow night
vital storm
tall dragon
river oracle
vital storm
#

Are you sure that is gonna work?

shadow night
wintry lynx
#

This is a properly stored Material map in YML correct?

sleek estuary
remote swallow
#

that is delaying it by 1 tick

shadow night
vital storm
#

Do you have any idea of how to accomplish that?

#

I mean I can obviously set a prefix but idk the rest

shadow night
#

No, I have never made a plugin of that kind

vital storm
#

Alright thanks for trying to help

river oracle
#

the fact you're running this async is giving my brain damage

#

I can't help

remote swallow
river oracle
#

kek they want it async tho

#

why do you wanna run a command every tick

#

wtf

buoyant jasper
#

i have problem in my plugin clickevent not working also Vault not updating player balance

tall dragon
#

?nocode

undone axleBOT
#

It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.

buoyant jasper
#

how to show you code

tall dragon
#

?codeblock

undone axleBOT
#

You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {

}

}```
Becomes:

public class MyPlugin extends JavaPlugin {
    @Override
    public void onEnable() {

    }
}```
tall dragon
#

?paste

undone axleBOT
tall dragon
#

if its alot

buoyant jasper
#

the openBuyMenu menthod is the problem

#

when clicked on green wool it doesnt do anything

tall dragon
#

any exceptions?

#

ah wait nvm

#

that completely doesnt work this way

ivory sleet
#

and especially not always possible w spigot api

tall dragon
#

this wwhole part has to go inside an inventory click event

#

but i would advize you to setup an actual proper menu framework

#

it would make all this alot easier

buoyant jasper
#

so do i need to create new class for this

tall dragon
#

?gui

tall dragon
#

i would read this

cobalt flame
#

Hey so i got a 1.20.4 server and i've found something. Unlike 1.16 my mobs get counted as dead if the chunks unload. Like if i go to the nether the mob.isDead() gets triggered. But once i return the mob is there. My problem is that i run some stuff that cancel on mob death. Don't have that issue in 1.16 but for some reason it pops up in 1.20. Is there anything that can be done? Also it seems that EntityDeathEvent gets called aswell.

#

i do run mob.removeWhenFarAway(false)

wintry lynx
#

How does one write a material to a YML file?

river oracle
#

a material is just a string

#

so just write the material name

wintry lynx
#

or do i need quotes

river oracle
#

no quotes required

#

because YAML is sucky

#

and weird

wintry lynx
#

Im trying to debug a thing that is giving me an anurism

#

xD

#

And for some reason it returned null unless i add the define.

#

And it is under "replace_interact"

river oracle
tall dragon
#

why not

#

we always have a choice!

wintry lynx
#

Plugins I didnt make :D

#

Im just using the same config to keep all item interactions within the same item file

glad prawn
wintry lynx
stoic cosmos
# river oracle no

is holder the same as handler because handler doesnt exist as in InventoryHolder

wintry lynx
#

i think i had a stroke

river oracle
stoic cosmos
#

then how do i use inventory handler

river oracle
#

read the tutorial

stoic cosmos
#

oh

#

I understand

#

thank you

summer scroll
#

Can you determine min and max location from list of locations to create a region for example?

sullen marlin
#

yes? what's your actual question

summer scroll
#

Sorry, I'm trying to do that basically.

#

So right now I have a system that can paste a schematic in front of you and I want to show hollow cubes as a indicator where the schematic will be placed.

tardy delta
#

bet you've heard of a loop

summer scroll
#

I know but I want to create a hollow cubes instead.

tardy delta
#

find two opposite corners and create a cube from them?

echo basalt
#

Now you have your two points

sour bluff
#

i'm trying to register a listener but its not working, not sure why

#

lack of image perms womp womp

echo basalt
#

A cube has 8 vertices -
sX sY sZ
bX sY sZ
sX bY sZ
sX sY bZ
bX sY bZ
bX bY sZ
sX bY bZ
bX bY bZ

#

s = small (min)
b = big (max)

#

Just interpolate between then and you have your hollow cube

undone axleBOT
echo basalt
#

?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 you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org

tardy delta
#

only need 2 locations

echo basalt
summer scroll
sour bluff
echo basalt
#

If you want a wireframe you just go over each point and render a line to every other point

#

If you want to skip the full wireframe then you only interpolate to the nearest neighbour

sour bluff
#

!verify

undone axleBOT
#

Usage: !verify <forums username>

sour bluff
#

womp womp

#

do i just make an account on spigotmc forumns

echo basalt
#

Yes

sour bluff
#

!verify ChoaticPoly

undone axleBOT
sour bluff
#

???

echo basalt
#

did you spell it right

summer scroll
sour bluff
sullen marlin
#

"ChoaticPoly"

echo basalt
#

chaotic and choatic are two different things

sour bluff
#

womp wopm

echo basalt
sour bluff
#

rate limited 😭

summer scroll
echo basalt
#

You're skipping to conclusions too fast

sour bluff
#

fire

tardy delta
#

see if any x, y or z is smaller then or equals your stored one and at some point youll get the min loc

sour bluff
#

not sure why its red

summer scroll
#

Okay, to get the smallest of them all I'll compare them one by one

echo basalt
#

Great

#

Same process to get the biggest one right

#

Now, you need 6 values

#

minX, minY, minZ

#

maxX, maxY, maxZ

remote swallow
sour bluff
#

i'm new to java so no idea what it means

remote swallow
#

you arent implementing listener

echo basalt
#

Your listener class does not implement listener

remote swallow
#

?events

#

?event-api

undone axleBOT
echo basalt
#

noob

summer scroll
#

Alright, that explains everything then. I think I understand, thank you.

sour bluff
echo basalt
sour bluff
#

what

#

so i just slap implements listener fire

#

πŸ—£οΈ πŸ”₯

echo basalt
#

❀️‍πŸ”₯

sour bluff
#

also what do I use in place of getItemInHand, i found getItemInMainHand but it won't automatically import it for me and idk which . i stop at

echo basalt
#

getItemInMainHand is part of the PlayerInventory not the player

sour bluff
#

oh so i do like event.getPlayerInventory instead then?

echo basalt
#

getItemInHand exists and routes to the main hand exclusively for plugins made 8 years ago

echo basalt
sour bluff
#

πŸ”₯ I have a mild idea on what that means πŸ—£οΈ

echo basalt
#

?learnjava time

undone axleBOT
#

For Beginners:

Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/

For Intermediate to Advanced Learners:

Oracle Java Tutorials: The official guides by Oracle for Java programmingβ€”great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/

Practice and Hands-on Learning:

Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/

Free Resources and Documentation:

Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/

Community and Support:

Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/

Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! πŸŽ‰

sour bluff
#

ohhh so i put player.getInventory.getIteminmainhand fire

#

why would I learn java ⁉️

#

i'll figure it our πŸ”₯

echo basalt
#

Because puke

#

It'll save you ⏲️

sour bluff
#

oop was an oops πŸ—£οΈ

echo basalt
#

On the long run πŸƒβ€β™‚οΈ

sour bluff
#

is there a way to reload plugins without restarting the server, i know /reload exists but i heard I shouldn't run it

#

idk why though πŸ€”

echo basalt
#

There's a reason why you shouldn't run it

#

The concept of reloading plugins is ass

tardy delta
#

you shouldnt run if if you didnt implement it properly

sour bluff
#

FIRE IT WORKS

#

thank's

echo basalt
#

What if we made a JavaPlugin#reload api method that by default just throws an error

#

And a /reload MyPlugin command

#

πŸ€”

tardy delta
#

πŸ’€

echo basalt
#

So plugins that want to support reloading just override and do their own custom logic

sullen marlin
#

I mean reload is reliable

#

but only for plugins that use the API

sour bluff
#

i'm sure this is hella funny but idk what this means πŸ”₯

sullen marlin
#

the whole reload is bad is a myth from shitty plugins

#

the actual concept of reload is fine

vocal cloud
#

reload bad. Blowing up server good.

echo basalt
#

Sometimes we can't bother going over every existing player and loading their data knowing damn well that only should happen when a player joins

sour bluff
#

okay so i'm coming from skript so is there like a temporary variable equivalent in java or do i just make one and delete it later

echo basalt
#

There's no "delete a variable"

sour bluff
#

whar

echo basalt
#

There are just different visibility scopes

#

You have local variables, which are defined and only accessible within a code block

tardy delta
#

java isnt javascript

echo basalt
#
public void doWhatever() {
  int value = 123;
  // This only exists within this code block
}
#

And then there are fields

#

Which belong to the object

sour bluff
#

how do you make the shiny like that

echo basalt
#
public class MyObject {

  private final int money = -1;

}
#

This is a field

#

Then there's static

#

Which "belongs to the type instead of the object"

remote swallow
undone axleBOT
#

You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {

}

}```
Becomes:

public class MyPlugin extends JavaPlugin {
    @Override
    public void onEnable() {

    }
}```
sour bluff
#

ah

echo basalt
#

Poor explanation but basically these are accessible everywhere

public static final int money = 123;
#

And have very specific use-case scenarios and are often abused

#

They're also kept in memory forever because you never know when someone might reference to it

sour bluff
#

oh but local variables aren't

echo basalt
#

Compared to objects which if held no references to, are garbage collected

sour bluff
#

mee

echo basalt
#

Whether it's a constructor, method or initializing block

sour bluff
#

alright, so use static when i need to reference it across everywhere, and local when i'm only using it for one thing

rough ibex
#

eh

sour bluff
#

wopm womp

echo basalt
#

Anything that's static should be immutable

#

As in never changing and never being able to change

#

It's final, constant

#

And constants ARE_NAMED_LIKE_THIS

sour bluff
#

makes sense

#

the static thing is static 🀯

echo basalt
#
public class MyWhatever {
  
  private static final int MONEY = 123;

}
#

Any field that's static should in best practice be final

summer scroll
echo basalt
#

Sweet!

rough ibex
#

nice

sour bluff
#

fire

echo basalt
#

Now, given it's static it's always present

#

But also it's only initialized once - When the class is loaded

#

And a class is loaded when it is referenced for the first time

#

Or if someone writes a funky classloader but that's advanced

sour bluff
#

humble begginings πŸ”₯

#

then what are fields used for

echo basalt
#

Fields belong to the object

#

So if you have two objects

#

Each object's fields can point to different things

#

Think of this

public class Person {

  private final String name;
  private int money;

  public Person(String name, int money) { // Constructor
    this.name = name;
    this.money = money;
  }
 } 
#

You have a Person class and that class has 2 fields

#

One's named name of the type String

#

And the other's named money of the type int

#

You can create multiple objects:

Person illusion = new Person("Illusion", -1);
Person chaotic = new Person("ChaoticPoly", Integer.MAX_VALUE);
#

And now you have two objects but with different values assigned to each field

sour bluff
#

so its object specific variables, as opposed to static which is immutable and global?

echo basalt
#

Yeah

#

A field is just a "variable" that's not local

#

Static values are still fields

#

They're static fields

sour bluff
#

🀯

#

wait so what happens to local varaibles when the code block ends, it just gets garbage collected?

echo basalt
#

uH

#

It's weird

sour bluff
#

"what happens when a person variable dies"

echo basalt
#

An object gets garbage-collected when it no longer has any reference pointing to it

#

When it's held in a static field it's always referenced

#

So if you create an object inside a method and pass it around or store it in a list, it still holds a reference to it

#

Until it gets removed from the list or the methods you passed it to finish executing and don't store it anywhere else

#

Then, and just then, it's queued for garbage collection

#

There are phases to garbage collection and it's a complex topic but just assume it's "gone for good"

sour bluff
#

alright

echo basalt
#

Also a "memory leak" happens when an object's reference is kept beyond the object's expected lifetime

sour bluff
#

expected?

echo basalt
#

Think of storing an object in a list and not removing it when the object should be declared "dead" (as in storing a player and not removing it after they disconnect)

sour bluff
#

so then it cloggs up space

echo basalt
#

Forever

sour bluff
#

my hardrive 😭

echo basalt
#

ram

sour bluff
#

my gpu 😭

#

rip gtx 745 you will be replaced πŸ”₯

echo basalt
#

I got a 610 waiting for you

#

soaked in pepsi

sour bluff
#

bro was doing chemistry in his computer

#

who needs little alchemy πŸ—£οΈ

echo basalt
#

I had a big pepsi bottle in my backpack

#

same pocket as the gpu

sour bluff
#

πŸ’€

echo basalt
#

some pins put a hole in it

sour bluff
#

weak ass plastic what

ocean hollow
river oracle
#

is this how kids talk now

#

[insert some words]πŸ—£οΈ or [insert some more words] πŸ”₯

echo basalt
#

no just special kids