#development

1 messages · Page 16 of 1

lyric gyro
#

If the difference is < 15 seconds, then they still have their lightning strike active, so you strike the entity they hit

#

If it’s over 15 seconds, then the time ran out and you should remove the player from the map

#

That should be a pretty good base to work with, so gl

proud pebble
#

in the horn sound event

UUID playerUUID = e.getPlayer.getUniqueId();
if (!isActive(playerUUID)) { //add the buff only if the player doesnt have it
    addBuff(e.getPlayer.getUniqueId(),15000); //15000 = 15s
}

in the onhit event

UUID playerUUID = e.getPlayer.getUniqueId();
if (isActive(playerUUID)) { // only activate if they have the buff active
    strikelightning; //whatever method is used for striking lightning on a entity cus idk waht it is on the top of my head
}
lyric gyro
#

don’t give him the code

#

@lyric gyro doesnt even work, gives me two errors dont worry

#

Well yeah ofc it won’t work

icy shadow
#

That's not entirely true, uuid vs player uses the same amount of memory in a hashmap. The reason to use uuid is to prevent memory leaks so the player object can be fully unloaded when they disconnect (also possibly prevents weird behaviour with old player objects)

proud pebble
lyric gyro
#

getplayer doesnt exist and cant resolve method isActive

#

oh

proud pebble
#

i forgot the brackets

lyric gyro
#

the isActive one was because of captalization

turbid jewel
#

Does anyone know if it's possible to set the fadeIn, stay and fadeOut of a actionbar through protocol packets?

#

For example, Title has more fields, but for some reason actionbar doesn't

dense drift
#

I dont think action bar has any of these

#

hence why you need to constantly send it

merry knoll
#

you resend it to set its time approximately but its minimum amount of time is limited

turbid jewel
#

So to make a constant actionbar, I just have to send it multiple times a second basically?

dense drift
#

not really a second

merry knoll
#

not sure how long exactly it lasts but yes

turbid jewel
#

Ah okay, I get the idea

dense drift
#

but depends how often you need to update the data

merry knoll
#

check how long it is and resend

turbid jewel
#

Thanks!

lyric gyro
#

Do I get help from the general-plugins-2 channel, or this one

whole yacht
lyric gyro
lyric gyro
#

💀

#

if
if
if
if

#

yandere dev of minecraft

#

cant say im much better but damn bro

merry knoll
#

its just an arrow

lyric gyro
# lyric gyro if if if if

Its not super bad. Personally I'd just invert the conditions and do early returns instead to keep it neat

#

And split the common code into methods instead

#

wait I just saw the screenshots frsleeper

#

gah damn

icy shadow
#

that looks like copilot

merry knoll
#

goddamn

dense drift
#

Does anyone know a replacement to spigot's conversation api?

lyric gyro
#

what's wrong with it?

#

besides it being totally abandoned

hoary scarab
#

@somber gale did you figure it out with the code I sent?

somber gale
#

Didn't test it and honestly won't test it

icy shadow
#

lol

dense drift
# lyric gyro what's wrong with it?

One thing I REALLY dislike is that it requires a message for each prompt and I can't pass null or an empty string to make it skip the message

#

And id like a more up to date version xD

lyric gyro
#

Cannot resolve method 'isActive' in 'LightningListener'

dense drift
#

is probably a part of another class?

lyric gyro
#

but i cant make it work it in other class

#

because im stupid and probably forgot how

tired olive
#

is it a static or instance method?

hoary scarab
lyric gyro
tired olive
lyric gyro
#

but

#

i cant make it static

tired olive
#

i didn't say to make it static

lyric gyro
#

i know

#

nah nvm

#

im just stupid

#

and slow

#

java beginners are something else

tired olive
#

💀

lyric gyro
#

why isnt it strucking a lightning on the entity i hit?

#

w8

tight junco
#

if i had to guess

#

final damage is less than 0

icy shadow
#

if i had to guess you're missing @EventHandler

tight junco
#

the adBuffObj is not active

#

or the world is null

#

or that

#

maybe its all of the above

icy shadow
#

either is likely

#

could well be

tight junco
#

maybe you should just quit

lyric gyro
tight junco
#

what

lyric gyro
#

quit what

tight junco
#

idk im vibing

lyric gyro
#

ill need someone to help me review this whole code

tight junco
#

i dont recommend literally anyone here unless you want ego shattered ASevilFast

lyric gyro
dusky harness
#

💀

tight junco
#

this person clearly hasn't had a code review from the members of helpchat before

dark garnet
#

how can i get the non-decimal digits in a double without any rounding? (im trying to teleport a player to the center of the block they're standing on)

tight junco
#

uh usually id do Player#getBlockLocation() + 0.5

viral moth
#

double newNum = ((int) oldValue) + 0.5

hopefully thats what you were asking for

dusky harness
#

use floor

#

or else you'll run into issues with negative coordinates

dusky harness
dark garnet
dusky harness
#

casting it to an int is different from floor

#

they do different things

#

I'd recommend using the spigot's built-in method

#

and then +0.5 on that

dark garnet
#

yea ill do that

#

is player.getLocation().getBlock().getLocation() correct?

#

cause Player#getBlockLocation() doesnt exist

dusky harness
#

player.getBlockLocation

#

oh

#

then Location#toBlockLocation

#

or something like that

#

unless theres just getBlockX

tight junco
#

d;spigot getBlockLocation()

uneven lanternBOT
#
public class EntityDamageByBlockEvent
extends EntityDamageEvent```
EntityDamageByBlockEvent has 1 extensions, 1 all implementations, and  2 methods.
Description:

Called when an entity is damaged by a block

tight junco
#

hmmmmmm

dusky harness
tight junco
#

wack

#

d;spigot Player#getBlockLocation()

uneven lanternBOT
tight junco
#

i could be psycho and my kotlin brain go brrr

dusky harness
#

extension function?

#

🥲

tight junco
#

yes sir

#

okay then just new Location(world, Location#getBlockX() + 0.5, Location#getBlockY(), Location#getBlockZ() + 0.5)

#

its either my kotlin brain or paper spigot brain

dusky harness
#

d;paper Player#getBlockLocation()

uneven lanternBOT
#
@NotNull
@NotNull Block getTargetBlock(@Nullable @Nullable Set transparent, int maxDistance)```
Description:

Gets the block that the living entity has targeted.

This method considers all blocks as 1x1x1 in size. To take exact block collision shapes into account, see getTargetBlockExact(int, FluidCollisionMode).

Returns:

block that the living entity has targeted

Parameters:

transparent - Set containing all transparent block Materials (set to null for only air)
maxDistance - this is the maximum distance to scan (may be limited by server by at least 100 blocks, no less)

dusky harness
#

nope

dark garnet
#

why wouldnt this work?
player.getLocation().getBlock().getLocation().add(0.5, 0, 0.5)

tight junco
#

that too

dusky harness
#

yes but that would load the block each time

tight junco
#

it just looks kinda wank YesYes

dusky harness
#

i mean it doesn't really matter i guess since it's always going to be loaded so unless you're doing it a lot of times it doesn't matter much

dark garnet
#

im only using it once

#

player.teleport(player.getLocation().getBlock().getLocation().add(0.5, 0, 0.5));

dusky harness
#

👍

lyric gyro
#

oh my

tight junco
#

oh zooeymama

pulsar ferry
#

Don't forget to clone, cuz stupid mutability

tight junco
proud pebble
#

and check if damager instance of player, cast as player and then get uniqueid

lyric gyro
#

ok

proud pebble
#

check if active then strike lightning on damagee

lyric gyro
#

does the ide know that poorsoul is the one that was hit?

proud pebble
#

looking at the docs, yes e.getentity is the damagee

lyric gyro
proud pebble
#

you would use that in the playerinteractevent

merry knoll
lyric gyro
#

cause it gives me an error if i try to use bukkit player

merry knoll
#

what is this "error"

lyric gyro
#

let me see

lyric gyro
lyric gyro
#

god idk what to do

#

why do I forget how to do simple things

tight junco
#

that's coding literally summed up

#

i unironically forgot how to do for loops sometimes

lyric gyro
#

i dont feel so bad now

tight junco
#

when you start learning other languages your brain ends up just merging shit together into one clusterfuck of a language

lyric gyro
#

yeah

#

i think i should just take the weekends as a break

#

i spend the whole week coding

tight junco
#

i do the gigachad move of code a months work of work in a day

#

then don't code again for the next 3 months

lyric gyro
#

and on weekends my brain is busy not being smart

proud pebble
lyric gyro
#

dont spoon feed me just say what i got to do

#

im not good at problem solving

#

btw

proud pebble
lyric gyro
#

its not a custom item

#

and its just for the yearn goat horn

#

everything about the horn is basically set up already

#

i just need to add code to the class

lyric gyro
#

when you sound the yearn goat horn

#

it would struck a lightning at every entity you hit for 15 seconds

proud pebble
lyric gyro
proud pebble
#

in the playerinteractevent, check if the item is a goat horn, check that the goat horn sound is yearn, and then make a new instance of yearngoathorn and passthrough the player to the action method

lyric gyro
#

ig ill do that tomorrow

#

¯_(ツ)_/¯

proud pebble
#

tho i dont think you would have to implement horn

whole yacht
#

My friend create

lyric gyro
whole yacht
#

What

#

Ok

whole yacht
thin spear
#
                Object result = getPrivateField(Bukkit.getServer().getPluginManager(), "commandMap");
                SimpleCommandMap commandMap = (SimpleCommandMap) result;
                Object map = getPrivateField(commandMap, "knownCommands");
                @SuppressWarnings("unchecked")
                HashMap<String, Command> knownCommands = (HashMap<String, Command>) map;
                Set<String> commandsRemoved = new HashSet<>();
                for (String command : knownCommands.keySet()) {
                    if (command.contains(":")) {
                        commandsRemoved.add(command);
                    }
                }
                Bukkit.getLogger().info("[NoCommandPrefixes] Removing Command Prefixes...");
                knownCommands.entrySet().removeAll(commandsRemoved);
#

Why wont that work?

#

Im trying to unregister a command

#

but it just wont unregister it

#

its giving no error

wintry grove
#

so I have some sort of cache system which uses a hashmap to store the things, I'm currently trying to add things to it and try to log them, so I can look for any problems, but this is where I found one kekwhyper
As far as I can guess, it is due to the way the methods are coded, but I do not know what is the exact problem.
this is the class: https://paste.helpch.at/geladusupa.cs

#

the design I ended up doing was meant to do this:
when the addEntry method is called, it will call an update method, which checks if the key that is to be added already exists, if so, it is completely removed to allow a new value to be added

#

what I think is happening is that it is sorta removing itself

#

because when I log everything, only one thing is logged

#

which is the exact message which was sent

#

not every single message that was logged

#

and I have checked and it should log certain messages

torpid raft
#

you are only saving the most recent message

#

assuming all messages are being sent by the same sender

#

also this is so incredibly janky

public Map.Entry<UUID, String> getEntry(UUID key) {
        this.updateKeys(key);
        //check if the key exists
        if(this.checkIfKeyExists(key)) {
            //Loop every entry in the map and check if it is the desired one, then return that key entry
            for(Map.Entry<UUID, String> entry : this.getMessageCache().entrySet()) {
                if(entry.getKey().equals(key)) {
                    return entry;
                }
            }
        }
        return null;
    }
#

and also you don't really need to ever explicitly remove an entry if it's a cache

// useless ->
private void updateKeys(UUID key) {
        //check if a UUID already has a messages related to it
        if(this.checkIfKeyExists(key)) {
            this.removeEntry(key);
        }

    }
#

for your usecase you can just overwrite the entry whenever you get a more recent one (at least going off what you said + current code)

deep cradle
torpid raft
#

looking at this i just realized getEntry() will delete the key it is looking for every time

#

so it will never find the key you want

#

at this point just

public String getEntry(UUID key) {
    return null;
}
deep cradle
torpid raft
#

do you see this line
this.updateKeys(key);

deep cradle
#

what is you goal ?

torpid raft
lyric gyro
#

null?

#

what?

#

how come its null

brittle thunder
#

wdym?

#

The member received from the event is just null

proud pebble
lyric gyro
#

GuildRemoveEvent

#

something like that

#

GuildMemberRemoveEvent

#

when a member leaves a server

lyric gyro
#

since the member left the server

#

the code cant get the member

#

cause there is no member to get

#

so its null

#

but idk

proud pebble
#

then do a null check

lyric gyro
#

whai

#

wait

#

why

#

i know its null

#

no need to check if its null

proud pebble
merry knoll
#

jda uses futures as well

#

so could be that he is checking before it arrived

lyric gyro
#

ill do an arraylist with all the members that join

#

to use it when they leave

wintry grove
#

but that would mean to make the updateKeys method have a key and value param

#

which I do not really want to do

wintry grove
#

it checks if the key already exists

#

which I dont know why it deletes it

#

because its just when its ran when that happens

lyric gyro
#

oh nvm

wintry grove
#

to allow it to change the value

#

it cant change it if it doesnt have the value and key lmao

torpid raft
#

right but why do you need to delete the old value

wintry grove
#

that was my approach to it I guess

#

it is so only one message is stored per UUID

torpid raft
torpid raft
#

there is no way to store more than one message for the same person if you are using a Map<UUID, String>

#

deleting the entry might make sense IF you had a map of UUID to Lists of strings which you were sometimes appending to and sometimes deleting

torpid raft
#

you dont need to delete the old value

#

storing only one message is the default behavior

#

and the only behavior

wintry grove
#

so what I should do instead is to make that method be an update value method?

torpid raft
#

just delete the method

#

you dont need it, it is redundant

wintry grove
#

alright

torpid raft
#

whenever you put a new entry into your map you will override any old entries of the same key

#

so if i do

map.put("bob", "i like apples")
map.put("bob", "i like oranges")
#

the "i like apples" entry will be overriden and erased

#

i didnt have to call any extra code for that to happen

#
map.get("bob") -> "i like oranges"
wintry grove
#

that

#

makes sense

#

for the get entry method this should do it right?

torpid raft
#

seems fine

wintry grove
#

now for the logAllEntries method

#

it should now ig right?

torpid raft
#

probably

#

also your for loops are all weird

#

like i guess entry sets might be a bit faster

#

but you like them a lil too much i think lol

#

for example

 public void removeAll() {
        for(Map.Entry<UUID, String> set : messageCacheList.entrySet()) {
            this.getMessageCache().remove(set.getKey(), set.getValue());
        }
    }
#

im pretty sure Map has a clear() method you can call

wintry grove
#

yeah

#

I'm pretty much not going to be like in the commit message:
"fly me to the moon, let me be an idiot"

#

thanks man

#

made my week

#

now time to see if it works

torpid raft
#

👍

wintry grove
#

should log more things

torpid raft
#

what did you expect the output to be

wintry grove
#

all of the entries that have been added

#

there is nothing that is removing the entries

torpid raft
#

but like

#

what are all of the entries that were added

#

and did more than one of them get sent by the same player

wintry grove
#

every single message sent

torpid raft
#

thats why

wintry grove
#

but there were more unique senders that repeated one

#

no mather the what it should have been more messages

torpid raft
#

can you post code again

wintry grove
#

a sec

#

fuck

#

did not mean to do that

torpid raft
#

when are you calling logAllEntries

#

and also when are you adding entries

wintry grove
#

I add the entries and then after that I call logAllEntries

torpid raft
#

show code

wintry grove
#

this method is called after another method which is called by a mixin

torpid raft
#

how come you are logging all entries every time an entry is added

#

just to help debug?

wintry grove
#

yeah

#

that method itself is just for debug

#

wont be in the final build

#

or after that

torpid raft
#

i cant really tell whats goin wrong tbh

#

but i suspect it's not happening in the cache code

#

or at least not only* in the cache code

wintry grove
wintry grove
torpid raft
#

like the issue might be somwhere else

#

but it might be because you made a nad assumption back then about how your cache code runs

#

idk tho

proud pebble
lyric gyro
#

i figured it out by myself

#

dont worry

lyric gyro
#

how do I do a toggle command in jda?

lyric gyro
#

can someone explain to me how the fuck i keep forgetting how to use objects from other classes in fucking java

#

and can someone also explain how you do it

#

i cant make the object i want to acess public or static

winged pebble
#

These are kind of the basic principles of oop/java

lyric gyro
#

you cant blame someone for forgetting

winged pebble
#

There is no one clean cut answer as it depends on the context

lyric gyro
#

doesnt mean im bad

#

just because i sometimes forget how to do a simple equation doesnt mean i need to be sent back to eight grade...

winged pebble
#

I never said anything like that

lyric gyro
#

sorry

#

im just getting really defensive when people say "oh but thats the basics"

#

i know the basics

#

i just forget

#

but anyways

#

heres what im trying to do

#

basically channelOpt is getting the option of a command I made for a bot im developing

#

its a text channel

#

the option

#

and I wanted to use it where the red square is

#

(which is the id of a discord server channel)

winged pebble
#

Sounds to me like you need a shared instance of an object that tracks that detail

lyric gyro
#

shard instance?

#

shared

winged pebble
#

Yeah, as in you create an instance of a class, and then pass it to both classes that handle those two things

#

Or if they are both in the same class, then a field

lyric gyro
winged pebble
#

okay?

#

What do you mean?

lyric gyro
#

it means that most of the time idk what to do

#

when i see it

#

yo what the fuck did i just do

winged pebble
#

It just means you give it as a parameter to a function (in this case a constructor most likely)

lyric gyro
#

I just create a new instance

#

of the class

#

which i already did

#

dont spoon feed btw if u doing that

winged pebble
#

I'll just show you an example```java
public class Details {
private String someDetail;

// constructor
public Details(String detail) {
this.someDetail = detail;
}

// getter/setter
}

lyric gyro
#

oh

#

so basically just use a getter?

winged pebble
#
public class SomeClass {
  private Details details;

  public SomeClass(Details details) {
    this.details = details;
  }
}
``````java
public class OtherClass {
  private Details details;

  public OtherClass(Details details) {
    this.details = details;
  }

}

#
Details details = new Details("Something");
SomeClass someClass = new SomeClass(details);
OtherClass otherClass = new OtherClass(details);
#

Then the instance of someClass and otherClass will share the same instance of Details

#

So they will both look at the same info

lyric gyro
#

ok

winged pebble
#

So if one of the objects change something in the details class, then it will still be the same for both

lyric gyro
#

heres the thing im trying to get

#

can I just

#

move it to outside this method

#

i dont think i can

winged pebble
#

Does the same class handle those two events?

lyric gyro
#

no

winged pebble
#

Then no not really

lyric gyro
#

if im declaring the object here

#

inside the method

winged pebble
#

The constructor is just to get the instance of the class to inside of the class

#

After that you can interact with it

#

So at that point in time, you can use the methods on the object to pass in information

#

so like

In SomeClass

public void setDetail(String detail) {
  this.details.setSomeDetail(detail)
}

In OtherClass

public void onSomeEvent(SomeEvent event) {
  String detail = this.details.getSomeDetail();
  
  if (detail.equals("Whatever") {
    event.whatever()
  }
   
}
#

So the Details object in this example is the one responsible for holding the shared data

lyric gyro
#

You know what

#

ill see this tomorrow

#

its pretty confusing

neat pierBOT
haughty gazelle
dense drift
#

org.bukkit.plugin.IllegalPluginAccessException: Unable to find handler list for event me.glaremasters.guilds.api.events.challenges.GuildWarEndEvent. Static getHandlerList method required!

haughty gazelle
#

what could be the problem?

dusky harness
#

Ooof 💀

dense drift
#

np

lyric gyro
#

how do I make the value of a variable persistent

#

like lets say I have a boolean that initially equals to false

#

I run a method to make it equal true

#

then I stop the program

#

and check if this boolean equals true or false

#

how do I make it store the value?

#

and read it

#

for later uses

proud pebble
#

im sure there are guides on storing data

lyric gyro
#

which is what i need to store

stuck hearth
#

Config?

stuck hearth
lyric gyro
#

i tried saving it into a string

#

and then parsing it into a boolean

#

cant really tell if thats parsing

#

but i tried

stuck hearth
#

Do you plan on having other values like this?

lyric gyro
#

not for this specific command im making

#

this one toggles a function that welcomes members

#

and says bye to them when they leave the server

#

fixed it

#

string cant have else lol

#

this whole class is a mess

#

can barely understand it

stuck hearth
#

So I would read into setting up a proper configuration file

icy shadow
#

recepRead returns a single integer byte

#

the FileReader is still a FileReader, so equals will never be true

lyric gyro
#

then how do I store a boolean

lyric gyro
#

and check if its true or false

lyric gyro
icy shadow
#

The simplest way to read a whole string from a file is with nio, Files.readString

#

The reader stuff is usually outdated and bad

lyric gyro
#

whats nio

stuck hearth
# lyric gyro idk what is a config file tbh

The standard format for spigot/bukkit is yaml or .yml
There are many formats available
Json, hocon, etc..

I don't know the standard setup for bukkit, I usually use configurate and let the object mapper handle it.

lyric gyro
#

im developing for discord with jda

icy shadow
# lyric gyro whats nio

"new io", a package. Google the specifics but that readString method and the Files class is really all you need

stuck hearth
#

Oh,then I'd reccomend configurate then as a lib, but there's others floating around.
Unless you're wanting to parse it yourself.

icy shadow
#

Or gson is easy for json

stuck hearth
#

True

icy shadow
#

And the corresponding code to write a string

#

But that's certainly the easiest way

lyric gyro
#

cool. sounds doable

icy shadow
#

I'm sure you can guess what the method to write is called

lyric gyro
#

@icy shadow how do I specify the path I want a file to be written in?

#

or better

icy shadow
#

File#toPath or Paths.get

lyric gyro
#

how do I get the path of my file so I can use read string?

lyric gyro
lyric gyro
#

is this how you do it

hoary scarab
#

Any method similar to ChatColor.getLastColors(String)? Don't think it works with hex.

high edge
#

Could make your own implementation of it

dense drift
#

Component#color 🙂

stuck hearth
#

That doesn't deserialize does it?

#

Oh nvm

light jungle
light jungle
#

Thank you so much 🙂

By the way It would be great if you could add "Shield" sign to my expansion.

broken elbow
#

That sign just means it's verified. So whenever I verify it, the sign will be added

broken elbow
#

Was the problem that you can't update it? I might've misunderstood you

light jungle
#

I can't because I need re-verification?

#

"To combat spam uploads, all expansion updates currently require to go through re-verification, please ask a staff member in the Discord for assistance."

broken elbow
#

oh no.

#

that's unrelated.

#

you can upload expansions just fine. But to get the blue shield (verified) then we need to verify it

light jungle
#

I updated it 🙂

broken elbow
#

alright. will verify it later then

light jungle
#

Thanks!

gusty bay
#

Hello, could ask how would I be able to create a placeholder with the code run Async? The data I get for the placeholder are from a MySQL database, so I don't want the server to lag. Thanks! (Please ping me)

high edge
#

Cache

proud pebble
#

and afaik gson is built into spigot so you dont have to include it in your plugin as a library

#

you also have FileConfiguration which handles yml files

#

and jdbc for using something like mysql or sqlite

hoary scarab
# dense drift Component#color 🙂

Not seeing that... What version and import?
I see ComponentBuilder but doesn't have a .color method. Also nothing to get the strings last color.

proud pebble
stuck hearth
proud pebble
stuck hearth
#

Oh makes sense

broken elbow
#

@light jungle, talked with the admins and given the recent (few months old) problems we've had with scripting expansions, we've decided to not verify it. People can still manually download the expansion but they won't be able to download it from ingame using the /papi ecloud download command.

stuck hearth
#

Cry react

surreal lynx
dense drift
#

looks like the command would be git clone https://<access token>@github.com/org/repo.git

lyric gyro
#

how do I create a yaml file

#

to simply store a boolean value in it

merry knoll
lyric gyro
#

jda

merry knoll
#

then, you gotta either use a library

#

or implement it yourself

#

(go with a library)

lyric gyro
#

im using boosedyaml

#

I just need to know how you do it

#

i got everything set up

merry knoll
#

what is that even

#

just use snakeyaml

lyric gyro
#

no

#

why the fuck is it so hard

#

to store a boolean in this goddamn programming language

#

why dont they have a way to do it without having to use a library

merry knoll
#

why would they?

lyric gyro
#

that is so ridiculous and its really starting to get on my nerves

merry knoll
#

why would a language support a file format by default

lyric gyro
#

except booleans

merry knoll
#

no?

#

you can write to files

lyric gyro
#

im not talking about yaml

merry knoll
#

yes but thats not "storing"

#

yaml is a format

merry knoll
#

its a text file format basically

icy shadow
#

the only mechanism java (and most languages) have for file IO is strings and bytes

lyric gyro
#

ugh ok

icy shadow
#

however a boolean is just a string

#

if you think about it

merry knoll
#

^

#

you can use "true" "false"

#

or even better

#

just 1 - 0

#

or, stop crying and use a proper yaml library

lyric gyro
#

it would be cool if i could just write true or false into a file and just parse it into a boolean

merry knoll
#

like snakeyaml

icy shadow
#

if that's really all you want

lyric gyro
icy shadow
#
String s = read file;
boolean asBool = Boolean.valueOf(s);
#

easy

lyric gyro
#

I LITERALLY

#

SHOWED THIS to someone

#

and they said you cant use value of with reader or whatever

merry knoll
lyric gyro
#

thats all I wanetd to do from the start

icy shadow
icy shadow
lyric gyro
#

thats what I wanted to do from the start and no one understood

#

I just want to store a single boolean

icy shadow
#

i understood fine

#

but you were doing it wrong

#

lol

lyric gyro
merry knoll
#

also you really need to learn how to read documentation

lyric gyro
#

change from false to true

lyric gyro
icy shadow
lyric gyro
#

how the hell am I supposed to understand this

#

if they dont even explain what is going on

icy shadow
#

they kinda do

#

but you dont need snakeyaml

merry knoll
#

yeah, my comment was in general

#

all big libraries have great documentation usually

icy shadow
#

i would actually say that documentation is pretty clear if you have a decent understanding of java

lyric gyro
#

do I look like i have a decent understanding of java

icy shadow
#

evidently not

lyric gyro
#

exactly

icy shadow
#

but anyway

icy shadow
lyric gyro
#

ill try to do what you said

icy shadow
#

it was pseudocode obviously lol

#

but if you know how to read a file the rest should be easy

lyric gyro
#

I need to create a file reader right?

icy shadow
#

i would recommend the Files api rather than reader stuff

#

readers will still work, but theyre outdated and so Files is recommended instead

lyric gyro
#

just tell me

#

do I need a file reader

icy shadow
#

im pretty sure i already answered that question

#

readers will still work, but theyre outdated and so Files is recommended instead

lyric gyro
#

too many words

lyric gyro
#

i like it too

#

yeah yeah

icy shadow
#

i dont

lyric gyro
#

just say it

ebon whale
#

Me neither

lyric gyro
icy shadow
#

it's not that deep bro

lyric gyro
#

you can use whatever you want

#

BM is giving suggestions

icy shadow
#

exactly

lyric gyro
#

i dont know how to use them

#

thats why

icy shadow
#

and?

lyric gyro
#

well thats why im here ig

icy shadow
#

you dont know how to use either, so it doesnt matter

lyric gyro
#

to ask for help

#

if you know how to use a FileReader then use a FileReader

#

no one is stopping you from using a FileReader

#

i dont even know the difference

icy shadow
#

thank goodness i already said

lyric gyro
#

i know

#

but what is outdated

icy shadow
#

the reader class

lyric gyro
#

is it important?

icy shadow
#

what?

#

you dont know what outdated means?

lyric gyro
#

god

icy shadow
#

?

lyric gyro
#

just tell me what I got to do

#

God is not available at this time

icy shadow
#

both of us have

icy shadow
#

my personal recommendation is to use the Files api instead

#

it's really not that deep lmao

dusky harness
#

I think ur confusing him what he should use

icy shadow
#

there is nothing confusing about what we're saying dkim

lyric gyro
#

i just dont know how to use the files api

icy shadow
#

so google it lol

lyric gyro
#

then don't use it

#

oh my god

icy shadow
#

or ask questions

#

or dont use it

#

whatever

lyric gyro
icy shadow
#

ok

dusky harness
#

OK

icy shadow
#

problem solved

lyric gyro
#

ez

icy shadow
#

that really didnt need a 7 minute discussion

ebon whale
#

Just what is this chat

lyric gyro
#

its cause i still need brister's help

icy shadow
#

then just say that rather than arguing about what api to use lmao

lyric gyro
#

lmao

dusky harness
#

👍

#
  • brister
#

Ofc

icy shadow
#

yeah my tutorial is coming 2024

#

It extends the InputSreamReader class

lyric gyro
#

so here... (in the string) I use my reader class?

dusky harness
#

Um

icy shadow
#

no you should make a method to read from the file

lyric gyro
#

well that

dusky harness
#

Properties file is also ez

lyric gyro
#

that actually makes sense

lyric gyro
dusky harness
#

No thx

#

I'm on phone

lyric gyro
#

thats what I thought

dusky harness
#

Google can do it tho
Useful if u want to store more than a boolean in the futute

#

Future

icy shadow
dusky harness
#

Sorry

icy shadow
#

yeah

dusky harness
lyric gyro
#

shocking innit

#

i know how to make methods

dusky harness
#

Leaks

#

💀

lyric gyro
#

what

dusky harness
#
  • 3 intellij warnings
#

Nice

#

But besides that

#

Good job

icy shadow
#

well

#

ur only reading a single character so far

#

but

dusky harness
#

Oh

#

Lol

lyric gyro
dusky harness
#

Sorry Ive never used file reader vefore

dusky harness
#

That's not something to brag about

icy shadow
dusky harness
#

Oh like scanners read

#

I remember

#

From coc

lyric gyro
#

clash of clans?!

dusky harness
#

Ez

#

Yes

#

I code in coc

#

💯

lyric gyro
#

sus

#

carrying on

icy shadow
dusky harness
#

Oh

icy shadow
#

lol

dusky harness
#

Huh

#

Sorry I use readln

icy shadow
#

that is also more than 1 byte at a time

dusky harness
#

Yes

icy shadow
#

@lyric gyro would it be easier if i just gave an example

lyric gyro
#

will that method work brister mitten soldier team fortress 2

dusky harness
#

Tf2

lyric gyro
#

team for trees

icy shadow
lyric gyro
#

oracle did a great job on overcomplicating this

icy shadow
#

well

#

funny you should mention that

dusky harness
#

Didn't even look at my link

#

:(

icy shadow
#

the Files api is actually a lot simpler which is part of the reason why i was recommending it

dusky harness
#

also avoids leaks

icy shadow
#

because you're correct, the old api is too low-level for practical use

lyric gyro
#

if only I knew how to use it

lyric gyro
dusky harness
#

Well

lyric gyro
#

just tell me what i got to do in the method

icy shadow
#

if only you knew how to google

dusky harness
#

OK I gtg

#

Bye

lyric gyro
#

bye

#

so I can fix ita

#

and be done with this

lyric gyro
#

Mister @fast yokeWarnings("all")

#

L

icy shadow
#

@SuppressWarnings("all")

#

L

dusky harness
#

U mean

#

Suppress

#

For kotlin

#

Ofc

icy shadow
#

🤓

lyric gyro
#

i like how two different servers have the exact same emoji

#

kotlin is universally hated

icy shadow
#

3 servers

lyric gyro
#

nice

#

got anything to say dkim?

#

i do

#

@icy shadow how do I make that method do what I want it to do

icy shadow
#

mr kotlin = best

icy shadow
lyric gyro
#

i would wrap it in a tortilla and eat it

pulsar ferry
lyric gyro
lyric gyro
#

if I knew how to do it

#

how do you wrap

#

like that

lyric gyro
#

after years

dusky harness
#

WAIT WHAT

#

Still Java 8 smh

lyric gyro
#

Well yeah

#

It doesn't make sense to distribute a JRE for 9+

dusky harness
#

How come?

lyric gyro
#

The entire point around the module system is to distribute self-contained applications, fully executable from the start without depending on an installed runtime; picture this, I develop an application for Java 8 update 41, but update 56, the one you have installed, introduces some change my application relied on and is now broken, my application stops working on your system because you have a different runtime version than my targeted version

dusky harness
#

Isn't that what graalvm is for

lyric gyro
#

jlink/jpackage are for that, to package the runtime of your choice with all your dependencies into a single application

#

no, it is not a native image

dusky harness
#

Oh

dusky harness
#

Oh is it so that u don't include the entire jdk

lyric gyro
#

the point of the module system was to modularise the jdk itself into smaller pieces with well-defined dependencies between them, as opposed to having a single rt.jar that is almost 70 MB alone without your application
That way you choose with what modules you want your application to ship with with as little as ~15 MB

dusky harness
#

I see

#

Interesting

#

Now I know the purpose of this module system

#

Wait so does jlink and jpackage package the jdk? And if so, does it look in the module info files?

lyric gyro
#

Basically yes, they traverse the module dependency tree to know what modules to include and which ones to exclude

dusky harness
#

Oooh

#

Wow

#

And if there's no file

#

It includes the entire jdk?

#

Jre I mean

lyric gyro
#

You can also manually add or remove modules, case for service loader bindings
non-modularised applications cannot be used by jlink/jpackage

dusky harness
#

Oh what

#

Oh

lyric gyro
#

because there is no information about module dependencies they can read

#

jmod command which can be used for many things can create, or help with creating, a module-info.java for a specific jar that isn't modularised

dusky harness
#

So no matter what

#

It needs module

#

U can't package the entire jre?

lyric gyro
#

I mean you can do that but then what if some library you're using depends on some other jar that isn't in your modulepath during jlink? it'll fail at runtime far into it when it tries to use it, another reason of the module system is that all dependencies are known at compile time and runtime, and if a module isn't present the runtime will fail to load, it ensures every module to be is there

dusky harness
#

Is there a plugin for gradle or smth to automate it? Never written one myself but I remember seeing some long ones

#

Automates making module info file

lyric gyro
#

i mean it takes no effort to write it

dusky harness
#

Oh

lyric gyro
#

granted you're using IntelliJ it'll suggest dependency module name completions, and module descriptors are a bit more than just dependencies between modules

lyric gyro
lyric gyro
#

how do I use this

lyric gyro
#

how do I get these two objects

unreal wigeon
#

Hey guys i need some help

#

anyone online?

#

SO I basically want to usee this "ROUND" thing to round to 2 decimal places like 10.25%

This is what they say it is: Returns an integer that follows rounding rules. If the value of the passed parameter is greater than or equal to x.5, the returned value is x+1; otherwise the returned value is x. ROUND(number)
The ROUND operation accepts a second parameter for rounding the number to the nearest multiple of this second parameter. ROUND(X,Y)

sterile hinge
#

Are your talking about SQL?

#

Also, are you talking about monetary values?

dusky harness
#

Although if ur going to Google the javadocs, Google it with "v5" or else Google will show you v4

lyric gyro
#

not really related to jda, much more of a general java question

dusky harness
#

Ah I misunderstood
Well you would have to make it a field since a method one would be recreated each time the method was called

lyric gyro
#

and what is it useful for

merry knoll
lyric gyro
merry knoll
#

we gotta somehow teach you how to work with objects

#

okay first you need to understand a concept, otherwise you will keep running into this issue

#

when you assign a variable, instead of thinking that variable becomes what you assign it

#

think of it as it tells you where to look (aka a pointer) and the value is at the end of where its pointing

#

an example:
Apple apple1 = new Apple();
Apple apple2 = apple1;

#

^ what do you think this does?

#

is there 2 apples or just 1?

lyric gyro
#

you are just using terms that i dont know

merry knoll
#

good luck then shrug

grim oasis
#

you were using terms you didn't know

lyric gyro
grim oasis
#

If you don't know how to work with objects, OOP language is not ideal

lyric gyro
#

explain to me how do you pass the reference or whatever

lyric gyro
#

not really

merry knoll
#

you need to understand how OOP works

grim oasis
#

we will be writing your program

merry knoll
grim oasis
#

I'd say take the free lesson if Aki is gonna teach you somethin fingerguns

lyric gyro
#

which is what im asking you to teach me

merry knoll
#

you just pass it as you pass everything else

#

either though a method or a constructor

merry knoll
vivid flower
#

wait

#

now im unsure

#

hold on

#

ty btw

#

2 apples

merry knoll
#

its 1

vivid flower
#

what

#

the second apple tells you to look at the first one

merry knoll
#

= operator assigns a ference

#

reference*

#

first one is also "looking" at the apple

#

it being the first one to look does not change how the operator works

#

"new" is the one creating it

vivid flower
#

oh right

#

one equals is to assign a value

#

so the 2nd apple is the first apple

#

there is no 2nd apple

merry knoll
#

they are just the same object

vivid flower
#

heres how i see it in my head rn

#

A = something
B = A

#

there is no B because its just A

merry knoll
#

well, the issue is

lyric gyro
#

thats the problem

merry knoll
#

how these work is this:
extremely rough and simplified explanation but it should make it easier to understand

when you create an object using the new keyword it gets placed on memory (aka loaded) at a certain zone
and that certain zone has an address.

#

by saying A = x,y,z

grim oasis
#

this they are both pointing to the address that the new Apple() was saved in (let's say 00005 just for example)

merry knoll
#

= basically assigns the address

#

to the variable on the left

vivid flower
#

yes

merry knoll
#

therefore pointer

icy shadow
merry knoll
#

it points to the objects address

vivid flower
#

oh my god it points

grim oasis
#

then B is no longer A

#

so, yes, mostly correct

vivid flower
#

?

icy shadow
#

because java is pass by value

vivid flower
#

A = something
B = A

A = something else
B = A (still)

grim oasis
#
Apple A = new Apple()
Apple B = A
A = new Apple()

now there are 2 different apples

merry knoll
#

this is what i was trying to explain,

grim oasis
merry knoll
#

pointer does not point to the variable

#

it directly goes to the address

#

when you do B=A

grim oasis
#

I believe what you wanted to type was this

A = something
B = A

A = something else
B == A //?
#

which is false this

merry knoll
#

nah, they meant B is still A

vivid flower
#

yeah

grim oasis
#

ya I know, but it's hard to show with B = A if you're going between code and not code

merry knoll
#

which is vague a bit

#

since you mean the value

vivid flower
#

even if i change A, B will still be A

merry knoll
#

here is the messy part though

#

lets say apples can have colors

#

class Apple {
Color color;
}

#

basically

#

what happens when i do

#

A = new Apple()
B = A

#

then i change the color of A

vivid flower
#

let me ponder this one

merry knoll
#

learning OOP is quite binary honestly

#

you either get it or you dont

#

once you do get it though its hella easy

vivid flower
#

im afraid im on the dont side but hold on

#

if you change the color of A then B will change to that color as well

#

?

merry knoll
#

yes

#

but why is that?

icy shadow
# icy shadow because java is pass by value

ergo ```java
Apple A = new Apple()
Apple B = A // copy the pointer of A. so B holds a different pointer that points to the same location
A = new Apple() // changes the pointer of A, but B is a different pointer so it still points to the old object

grim oasis
#
Apple A = new Apple() //A points to address 00005 - where the new apple is stored
Apple B = A //B points to address 00005
A = new Apple() //A now points to address 00006 - where the new apple is stored
//B still points to address 00005 where the first apple was made
vivid flower
#

because B has the same value as A

#

1 equals is assigning value

#

2 equals is checking/comparing value

icy shadow
#

lmao

merry knoll
#

think of variables as addresses

#

rather than values

merry knoll
#

both still point to the same apple, by changing a property of the apple that they point to

#

you change it on both of them

vivid flower
#

wait

#

i think im understanding it

merry knoll
#

if the addresses are the same for A and B any change done to the object under the address

#

will be reflected on both

grim oasis
#

Nik rn ⬇️

vivid flower
#

lol

#

yeah really

merry knoll
#

OOP legit feels that way though, once it clicks its done

#

on a fundamental level

round sail
icy shadow
#

everything is by value

vivid flower
#

i must be right because my color just turned green

#

thats how it works

merry knoll
#

new is the keyword here (ignoring primitives)

vivid flower
#

and when you change something about the apple/address but not changing the address itself, then both variables will have that change done to them since they are both still pointing at the same apple/address

merry knoll
#

not the address

#

yes to apple

vivid flower
#

yes my bad

#

youre not modifying the address

grim oasis
#

addresses are in the backend, hidden away. correct this

merry knoll
#

editing the properties of apple just edits whats stored at the address

vivid flower
#

i feel like i just unlocked the third hemisphere of my brain

#

thank you so much

#

❤️

merry knoll
#

now you can join rest of us at getting annoyed with how spaghetti OOP languages can get once the projects grow a bit

#

then you dive into patterns etc gl

high edge
#

Better terminology (well in this case more accurate) would be apple is your object

icy shadow
#

TRUE

vivid flower
#

i love how i came here to get help with implementing soundcloud and direct mp3 file links and instead ive learned the basics of oop

#

cant complain

#

lol

merry knoll
#

i mean you gotta use oop for it anyway

vivid flower
#

even better

brittle thunder
icy shadow
#

😌 😌 😌 😌 😌

merry knoll
#

there are some libraries made for soundcloud api btw

#

might want to google around and check those out to make your life easier

#

not sure if there is one in java though

dense drift
brittle thunder
#

also since when did helpchat have simon emoji xD

vivid flower
#

would you look at that

#

feels too easy

#

i retract that statement

merry knoll
#

yeah its down

icy shadow
#

lol

merry knoll
#

from reading the actual api docs