#dev-general

1 messages ยท Page 131 of 1

remote goblet
static zealot
#

but you should always ask for the source code especially when you paid for it

cerulean idol
#

What are generally people's solutions for constructing PreparedStatements and avoiding a bunch of try catches? I'm currently using a sort of builder to do it but was interested in alternatives. https://i.imgur.com/9PxMe2l.png

analog crater
#

You need 1 try catch

errant geyser
#

^

lavish notch
#

I'm trying to access settingsManager in the main class, from the OnChat class

errant geyser
#

@cerulean idol yours looks interesting, can I see the whole class/do you have a repo I can grab it from to test?

cerulean idol
#

1 try catch everytime I have to make a SQL statement

analog crater
#

Well yes. What did you expect?

cerulean idol
#

That was exactly what I was expecting, I was making a solution that removed the need of redundant code

analog crater
#

Mackensie, you main class has a local variable and a global variable with the same name

#

You need a getter method and an instance of your main class using dependancy injection

lavish notch
#

mind spoon feeding me?

analog crater
#

eh no but I can feed you psuedo

onyx loom
#

spoonfeed urself by learning java

lavish notch
#

How does it work with EventHandlers?

#

actually

#

nrm

#

I meant, my OnChat Class doesn't have a main.

errant geyser
#

@cerulean idol yours looks interesting, can I see the whole class/do you have a repo I can grab it from to test?

cerulean idol
#

oop didn't see the ping

analog crater
#

You need a final Main instance with null in your event class. You also need a constructor in it to assign the variable. When you call your OnChat you need to feed the construcotr

cerulean idol
#

yeah sure I can put it in a paste ril quick

#

some of it uses code from other SQL management classes I have but it's relatively straightforward

onyx loom
#

?java-dependency

compact perchBOT
#
FAQ Answer:

Dependency Injection
Dependency injection is when we pass a class through other class constructors to access that specific class in those other classes.

public class Main extends JavaPlugin {

    @Override
    public void onEnable() {
        Other other = new Other(this);
        other.method();
    }

    public void myMethod() {
        /* Some code goes in here */
    }
}

public class Other {
    private final Main main;

    public Other(final Main main) {
        this.main = main;
    }

    public void method() {
        main.myMethod();
    }
}```
onyx loom
#

is that what mackenzies tryna do idek

analog crater
#

?kotlin-dependency

compact perchBOT
#
FAQ Answer:

Dependency Injection
Dependency injection is when we pass a class through other class constructors to access that specific class in those other classes.

class Main : JavaPlugin() {
    
    override fun onEnable() {
      val other = Other(this)
      
      other.method()
    }
    
    fun myMethod() {
       /* Some code goes in here */
    }
}
class Other(private val main: Main) {

    fun method() {
      main.myMethod()
    }
}
analog crater
#

For the real pros

onyx loom
#

๐Ÿ˜Ž

lavish notch
#

That dependency injection isn't working for me...

#

as the class has an EventHandler

analog crater
#

Can you share your update code?

#

Updated

#

The eventhandler wouldnt change it

lavish notch
#

well idk lol

#

sending updated code...

analog crater
#

You need to add an instance of Main in the arguements of OnChat( );

cerulean idol
#

it could probably be improved but

lavish notch
#

umm... which lines am I removing?

analog crater
#

Nvm forget I said that

lavish notch
#

?

analog crater
#

When you register your event, you create a new OnChat object. In your arguement you need to give it an instance of main

#

new OnChat(this)

lavish notch
#

oops... fixed the capitalisation of "This"

errant geyser
#

@cerulean idol I actually quite like that, is it a library or just a collection of some classes in one of your projects for now?

cerulean idol
#

part of my core, currently working on overhauling the SQL part

errant geyser
#

Fair enough

analog crater
#

No, you dont need to create two instances of OnChat

lavish notch
#

Shall I remove the 2nd?

analog crater
#

The one in the register is the one you need

#

The latter is in correct

lavish notch
#

latter?

analog crater
#

The one with the capital This

lavish notch
#

oh yeah

#

I fixed that

#

but I since delete that whole line, since it was a double instance

analog crater
#

Correct

#

It should work now

lavish notch
#

How to I get settingsManager from the onChat class?

analog crater
#

Create a final settingsmanager of global scope in your main class

topaz bay
#

make the getter

lavish notch
#

@topaz bay A getter would be...

public void method() {
  //code
  return getter;
}```
right?
topaz bay
#

more or less

hot hull
#

Not void

lavish notch
#

static?

hot hull
#

Hell naw

#

The type should be what you're returning

topaz bay
#

It would be the type of what you want to get

lavish notch
#
SettingsManager settingsManager = SettingsManagerBuilder
            .withYamlFile(new File(getDataFolder(), "config.yml"))
            .configurationData(Config.class)
            .useDefaultMigrationService()
            .create();

That is what Im wanting to return

topaz bay
#
public SettingsManager getSettings() {
  return settingsManager;
}
#

And make sure that field is both private, and final

lavish notch
#

where would I put the code I send above?

topaz bay
#

Its already a field in your main class isn't it?

lavish notch
#

in the onEnable, or ?

#

My main class, doesn't have a main field currently.

#

it just has an onEnable

topaz bay
#

what...

lavish notch
analog crater
#

Holy fuck no

topaz bay
#

oh dear god in heaven

#

You had it as a field before

#

Whyd you change it

lavish notch
#

I didn't remove it???

#

or... I had a brain fuck at 3am idk

topaz bay
#

Thats a field

#

It is in your main class

#

Make it private and final

#

Then add the getter I gave you, to the bottom of your main class

lavish notch
topaz bay
#

Im gonna punch you in the neck

#

I swear it

#

Look at the recent quote I did of you

#

Do that

lavish notch
#

Done

topaz bay
#

Now add the method I gave you

lavish notch
#

k

topaz bay
#

Now send what you have

lavish notch
topaz bay
#

GOOD

#

Perfect in fact

#

Except do what I said to the field

#

Make it private and final

lavish notch
#

private final class SwearFilter extends JavaPlugin {}?

topaz bay
#

No

#

The field

#

You only have 1 field

lavish notch
#

kmn what am I making private? - SettingsManager?

topaz bay
#

Do you understand what a field is?

lavish notch
#

Not really...

topaz bay
#

So you know what a class is right?

lavish notch
#

oh yes

topaz bay
#

Ok

#

Classes can contain literally only 3 things

#

fields, methods, and other classes

#
class ThisIsAClass {
  private final Object thisIsAField;

  private void thisIsAMethod() {

  }

  private static class ThisIsAnotherClass {

  }
}
lavish notch
#

ahh

#

so SettingsManager private?

topaz bay
#

Fields are basically variables that are declared in a class

#

Yes

#

And final.

lavish notch
#

Done

topaz bay
#

Now send what you have

lavish notch
topaz bay
#

Beautiful.

#

Now inside your OnChat class, you have a field that holds your main class right?

lavish notch
#

I think so..

topaz bay
#

Well yes

#

Look at your class, and look at the example I gave you

#

What in your class matches what I said a field is?

lavish notch
#

private final SwearFilter main;

topaz bay
#

Exactly

#

Now to access the settings manager, you would call the method you defined in your main class

#

main.getSettings()

lavish notch
#

Ah... ok

topaz bay
#

Can you go to your Config class please?

#

Put your mouse on words

#

And hit SHIFT + F6

#

Which enables rename refactoring

#

Change it to WORDS

lavish notch
#

done

topaz bay
#

Can you send that class?

lavish notch
untold prairie
#

Can I become developer?

topaz bay
#

Nice

steel heart
#

@errant geyser so I havent written everything but the concept though

topaz bay
#

Now that particular mixture of modifiers public static final or private static final makes those fields special

#

Fields with those modifiers are known as "constants"

#

So while they are still technically fields, they will almost always be referred to as constants

lavish notch
#

Right.

errant geyser
#

@steel heart Thats fine, is it usable yet?

steel heart
#

yeah

#

Wait can you add so I can simply push?

#

Idk if my pull req was goingf through

#

nvm

#

I will make a new one

#

Oh wait I dont have permission @errant geyser

analog crater
#

Can I become developer?
@untold prairie do you know how to learn?

onyx loom
#

how do i learn?

remote goblet
#

can you learn to learn to learn?

onyx loom
#

depends

analog crater
#

Can you learn to learn how to learn to learn?

remote goblet
#

perhaps

#

On today's episode of "Guess the build time"

#

What build times do you guys think i'm going to have today EmiPopcorn

analog crater
#

4:20:69 M:S:MS

remote goblet
#

its getting close that honestly

onyx loom
#

13minutes

topaz bay
#

trash comp

remote goblet
#

Buy me a new one then bitch

topaz bay
#

Absolutely fucking not

remote goblet
#

then shut up

#

rat

onyx loom
#

rat

remote goblet
#

4m pogChamp

onyx loom
#

๐Ÿ€

topaz bay
#

I barely enjoy your existence why would I do that

remote goblet
analog crater
#

I just realised your pfp is not a dildo but actually a bit

#

Bottle

onyx loom
#

LMAO

topaz bay
#

....

onyx loom
#

dont be surprised if it was tho

topaz bay
#

A DILDO

#

BRUH

#

What is up with the over sexualization in this discord

remote goblet
#

whatโ€™s the difference?

onyx loom
#

horny people

analog crater
#

Im teen of this generation so that may be why

topaz bay
#

@remote goblet willpower

remote goblet
#

Anything can be a dildo if you try hard enough EmiPopcorn

analog crater
#

Paige no!

onyx loom
#

๐Ÿ˜ฌ

remote goblet
#

speaking of which, how's your cat gaby

errant geyser
#

@steel heart you can't make a PR or you don't have permission to push?

onyx loom
#

LMAO

remote goblet
#

I should never say that ever again

#

i hate myself

#

for even considering that to be funny

onyx loom
#

ori dont wanna bbq it, but use it for something else

#

๐Ÿ‘€

remote goblet
#

BTS_Sips you right

onyx loom
#

why do we think such negatively for such a beautiful cat

#

@distant sun im sorry. nice cat

remote goblet
#

when you use pdm but the kotlin error still exists because you forgot something

topaz bay
#

using extra bullshit to solve simple problems

#

gross

onyx loom
#

@prisma wave he called pdm extra bullshit

remote goblet
#

well you didnt spoonfeed me solutions

onyx loom
#

i would not stand for this

prisma wave
#

Wow

topaz bay
#

You created your problem for yourself

prisma wave
#

Rude

topaz bay
#

All you had to do was just do it the normal way

prisma wave
#

Where's the fun in that

remote goblet
topaz bay
#

The fun is that you dont create an environment where you dont know how literally anything works

remote goblet
#

who has the time for that

topaz bay
#

Everyone

remote goblet
#

i'd rather be confused about fucking everything than understand what im doing EmiPopcorn

topaz bay
#

Literally everyone

remote goblet
#

I could of easily put implementation and the issue would be fixed but i didnt like having a 1.64mb jar file mmSitStareMocha

onyx loom
#

fuck ur jar size

remote goblet
#

bold of sxtanna to assume anyone here has a brain

topaz bay
#

I am well aware of the lack of brain cells around me

#

It's fucking painful.

remote goblet
steel heart
#

@errant geyser no perm to both

#

invite me as a collab

onyx loom
#

just because we have 2 braincells and u have 3 ๐Ÿ˜”

remote goblet
topaz bay
#

You barely have half of one

#

You have like 1/8th of a brain cell

onyx loom
#

๐Ÿ˜•

topaz bay
#

And its struggling to keep going

remote goblet
onyx loom
#

please elucidate

remote goblet
#

It's okay kaliber, You have 2/8th of a braincell EmiHeadpat

topaz bay
#

Elucidate...

#

Are you fucking serious

#

Is this 1784?

errant geyser
#

@steel heart whats ur GH?

remote goblet
#

Don't worry sx

#

the extra bullshit didnt even work

steel heart
#

Same as discord

remote goblet
#

guess we having a 1.64mb jar file

#

cause i cant be bothered with this anymore 4769_apudancer

topaz bay
#

I would imagine because your plugin is literally written in Kotlin

errant geyser
remote goblet
#

well yes it is

topaz bay
#

well DUH

#

Fucking 4head ass

steel heart
#

Yeah

#

That pfp is yummy

errant geyser
#

Invited

topaz bay
#

that chocolate looks stale

#

:)

#

Can chocolate be stale?

frail glade
#

Yes.

steel heart
#

pushed katsu

errant geyser
#

Cheers, so that's it then right?

steel heart
#

yeah

#

It should work hopefully

ocean quartz
steel heart
#

Well, Forge is Forge for a reason

ocean quartz
#

Actually I think that's in Minecraft not Forge

steel heart
#

oof

errant geyser
#

@hot hull Conclure rewrote it, it's on the GH repo, not tested yet so lmk if something goes wrong

languid ore
#

yoo anyone got an nice idea what plugin to code?

steel heart
#

Yeah

#

Code a core plugin

lavish notch
#

Code a server jar that utilizes more than 1 core

onyx loom
remote goblet
#

recode Minecraft in a plugin

steel heart
#

recode Java

#

recode quantym phsyics

onyx loom
#

๐Ÿ˜ฎ

heady birch
#

๐Ÿคจ

analog crater
#

MinecraftServer already utilises more than 1 thread

steel heart
#

who cares

floral basin
#

Rude

steel heart
#

nah

#

just convenient

remote goblet
#

recode this current simulation

steel heart
#

lol

#

recode that code the simulation is using

analog crater
#

Recode windows to be a linux distro

remote goblet
#

or just make a very nice ban plugin

lavish notch
#

Litebans

remote goblet
#

That's free

lavish notch
#

AdVaNcEdBaN

remote goblet
#

That doesnt have a dumb name

lavish notch
#

EpicBans**.sk**

onyx loom
#

๐Ÿคข

prisma wave
#

ProBansHD.kt ๐Ÿ˜Ž

steel heart
#

XxX_EpicMinecraftProExtremeDeluxeEnlightedGucciSupremeBans_XxX

onyx loom
#

[MUST HAVE โœ… ]

steel heart
#

Only reflection

oak raft
#

Wait wtf is wrong with advanced ban

steel heart
#

mi.setCommandExecutor("advancedban");
mi.setCommandExecutor("change-reason");
mi.setCommandExecutor("ban");
mi.setCommandExecutor("tempban");
mi.setCommandExecutor("ipban");
mi.setCommandExecutor("ban-ip");
mi.setCommandExecutor("banip");
mi.setCommandExecutor("tempipban");
mi.setCommandExecutor("tipban");
mi.setCommandExecutor("banip");
mi.setCommandExecutor("kick");
mi.setCommandExecutor("warn");
mi.setCommandExecutor("tempwarn");
mi.setCommandExecutor("mute");
mi.setCommandExecutor("tempmute");
mi.setCommandExecutor("unmute");
mi.setCommandExecutor("unwarn");
mi.setCommandExecutor("unban");
mi.setCommandExecutor("banlist");
mi.setCommandExecutor("history");
mi.setCommandExecutor("warns");
mi.setCommandExecutor("check");
mi.setCommandExecutor("systemprefs");
mi.setCommandExecutor("unpunish");

#

this maybe

analog crater
#

The fact its written in java or this plethora of shit?

steel heart
#

lol java is fine

ocean quartz
#

Jesus

oak raft
#

Tf is that

onyx loom
#

lol java is fine
@steel heart debatable ๐Ÿ™ƒ

steel heart
#

dont talk to me u bobo

onyx loom
#

but that is disgusting wtf

oak raft
#

Kaliber is a kotlin karen

onyx loom
#

k a r e n

steel heart
#

java isnt rly

oak raft
#

While conclure is a java jeff

eternal compass
#

Question: I am trying to create my first spigot plugin, should I go with 1.12.2, or 1.16.1?

oak raft
#

Ok sorry that was kinda rude calling you Karen lmao

steel heart
#

jeff

#

u bobo

oak raft
#

I say 1.12.2, most would say 1.16.1

steel heart
#

1.15.2

#

1.16.1 has some bugs still iirc

eternal compass
#

Yeah, I'm leaning towards 1.12.2

oak raft
#

Yeah Iโ€™m sorry Jeff was kinda weird too

onyx loom
#

has the gui thing been fixed yet?

steel heart
#

idk

onyx loom
#

the italic thing in 1.16

steel heart
#

but 1.15.2 is most stable rn

onyx loom
#

yea

eternal compass
#

Also, are there any good tutorials in 1.12.2 about detecting when someone places a block, and summon an entity there?

#

I want to place a block when someone places a specific head

onyx loom
#

i mean depending on what ur doing it might just work on all versions anyways

steel heart
#

BlockPlaceEvent

eternal compass
#

Armor Stands, so 1.12.2 won't overlap

#

because of names and such

remote goblet
frail glade
#

You could even just do slot ->

#

But isn't that getting the same item each time from the config?

ocean quartz
#

Or use it instead

onyx loom
steel heart
#

or use $

#

to get lowkey rich

#

or does kotlin accept $

distant sun
#

Or at least to look rich

onyx loom
#

$ is for string interpolation?

steel heart
#

outside is the only thing that matters

#

I use $ in lambdas though

distant sun
#

As 'it'?

onyx loom
#

example?

distant sun
#

Thats ugly though xd

steel heart
#
void method(Consumer<String> t) {

}

{
  method($ -> );
}``` does this work lol
ocean quartz
#

Basically { guiScreen.addItemStackAt(it, getItem("border-item")) }

onyx loom
#

ive never seen it being used in that way conclure

#

i thought its only use was string interpolation

distant sun
#

Conclure is a php boy

onyx loom
#

๐Ÿ˜ณ

steel heart
#

well idk if it's accepted as a single variable assignment but it can be used in a variable name

distant sun
#

Gson or guava have a class that contains $ in it's name, idk why though

steel heart
#

or like java String me$string = "test";

onyx loom
#

๐Ÿค”

steel heart
#

I mean I use it instead of the thisStyleType

#

to this$style$type

distant sun
#

Im waiting for you to say 'just kidding'

steel heart
#

u gotta stop meme me

distant sun
#

Or take you serious

steel heart
#

yes pls

distant sun
#
me.me

ฤŸลธโ€ย Find ฤŸลธหœโ€š Funny Memesรขลกยกรฏยธย instantly. Updated daily, millions of the funniest memes worldwide for ฤŸลธยŽโ€š Birthdays ฤŸลธลกล’ School ฤŸลธยยฑ Cats ฤŸลธยยธ Dank Memes รขยยครฏยธย Love Memes

steel heart
#

u bobo

errant geyser
heady birch
#

@topaz bay Brister mitten has introduced me to type inference 'var' in Java

#

pretty much kotlin

old wyvern
#

uh thats Java 10+

#

and it doesnt deal with mutability

heady birch
#

what

old wyvern
#

var keyword

heady birch
#

what about mutability

old wyvern
#

there is no explicit val or var to define mutability like kotlin

#

its more like c# with just inference

heady birch
#

Oh yeah

#

But you can still do final var

hot hull
#

val fingerguns_reversed

old wyvern
#

But you can still do final var
Exactly, i.e, not the same meaning as using var in kotlin

heady birch
#

spring security really trying to annoy me

prisma wave
#

but... Isn't var pretty much identical in both languages?

steel heart
#

@errant geyser yeah katsu that should be it. One thing I forgot was to implement a way to remove an action as I expect that might be handy

#

I can do that if you want

old wyvern
#

In terms of inference, yes. But due to syntax var correlates to a mutable field/reference in kotlin. While Java 10's var makes no such assurance by itself. Which is why I think its more relatable to languages like C#'s var keyword. To further show similarities: variable definitions in kotlin require var/val whether or not the Type is specified which is not the case in Java or C#, it serves the sole purpose of not having to specify the type in the LHS when its clear with just the RHS.

prisma wave
#

Yeah I mean var in Java is only for local variables

#

But they still do the same thing

old wyvern
#

Their purpose is different in a sense

topaz bay
#

They dont do the same thing

#

Kotlin always has type inference

errant geyser
#

@steel heart It should just be removing the action from the map right? I can probably do that

old wyvern
#

More of - you still need that keyword even when type inference is not required

steel heart
#

Rn itโ€™s a list

#

Make it a map ig but then youโ€™d need something like a string key or id for each item

#

Donโ€™t use PersistentDataHolders

#

Itโ€™s untrackable

errant geyser
#

Wait where's the list? ๐Ÿ˜…

steel heart
#

The AbstractListener contains a List

#

Of the Actions or the Consumers

#

There is also an #addAction

#

@errant geyser

#

Though you should use a multimap for it then

errant geyser
#

@steel heart What should the value be for the Multimap?

steel heart
#

Action<T>

#

Key should probably be the Item

#

Or perhaps an id

#

I can see what you changed and if something seems a bit lost I can make a pr

errant geyser
#

Fair enough. I'll just use a random UUID assigned to the item, but how would I like, get that?

#

Ignore that photo

#

I'm an idiot

#

Happy now Barry?

steel heart
#

Multimap<UUID, Action<T>> actions = HashMultimap.create();

#

You need to give each item a uuid field now

#

Which is initialized at ItemActionManager#newItem

#

Then when adding actions you might have to change some stuff

errant geyser
#

Yeah

steel heart
#

General case here would be when we call a method like Item#removeAction

#

It would remove all actions corresponding to the uuid for that type

errant geyser
#

Ok

#

So whats a Multimap? Is it like a HashMap<UUID, Set<Action<T>>>?

steel heart
#

Why Set<Action<T>>

#

Just Action<T>

errant geyser
#

Oh, I assumed it was like a key: list of values thing

steel heart
#

Multimap<UUID, Action<T>> actions = HashMultimap.create()

#

Multimap != HashMap

errant geyser
#

So what exactly is it?

steel heart
#

It can store more values against a single key inform of a collection

#

It handles the creation and management of the collection itself

#

So get will give you a collection of actions

#

And put will not override anything

#

But you should go with removeall iirc

#

So #removeAll(uuid)

errant geyser
#

Thats cool

steel heart
#

As we want to clear all actions for that Item

errant geyser
#

And its from Guava right?

steel heart
#

Yeah

errant geyser
#

noice

steel heart
#

If anything is struggling lmk

errant geyser
#

I've just pushed it, see what you think. I'm fairly sure I didn't mess anything up.

steel heart
#

Hmm almost

#

Though I have a method through the manager which makes me now which ActionType to modify

#

You can look how I implemented the addAction

#

Also

#

Make removeAction take an Item instead

#

And then in removeAction call #getUuid

#

Or make both

#

Probably best

errant geyser
#

Is there a way to clear only actions of one ActionType?

steel heart
#

Yeah

#

Look how I implemented addAction

#

Do the same but with remove function

errant geyser
#

Yeah I see that

#

But the map stores a UUID and an Action<T>, so how would I tell which ones to remove by type?

quiet depot
#

type as in T?

errant geyser
#

As in ActionType<T>

steel heart
#

T extends ListenableEvent

#

katsu

#

Through the manager

#

The manager has a map with each type as key and storing values of AbstractListener

#

Pretty sure you might have to cast

#

Well ik generics is messed up

errant geyser
#

Don't buuuly, but how do I do this? Also is this right? No errors but doesn't seem like it. ```java
public void clearActions(Item item) {actions.removeAll(item.getId());}

public void removeActions(ActionType<T> type, Item item) {actions.entries().removeIf(uuidActionEntry -> uuidActionEntry.getValue().getClass().isInstance(type));}```
hot hull
#

Where are finals damn

steel heart
#

Frosty u bobo

errant geyser
#

PR or shut

#

I'll add them anyway later

hot hull
#

Not home

#

Can't

steel heart
#

Okay katsu I will write the methods for ya

#

On mobile so will be a pain but yh

errant geyser
#

OoF

steel heart
#

So the item has a getter of a uuid

#

Right ?

errant geyser
#

Yeah

#

U want me to push my aids

steel heart
#

Hahah idm

#

Okay do this

obtuse gale
#
class Main{
    public static void main(String[] args) {
        Test<Integer> testOne = new Test<>(5);
        testOne.doStuff();
    }
}

class Test<T>{
    private final T generic;
    public Test(T gen) {
        this.generic = gen;
    }

    public void doStuff(){
        System.out.println(generic.getClass().getName());
    }
}``` So, im tryna learn how generics work, this is where im at rn, I just dont get where this would be useful lol, I get that if I extend something for `T`, then I can only give it subclasses of that, but I dont get where that would be useful ๐Ÿค”
steel heart
#

AbstractContext

#

Okay so katsu

#

In AbstractListener make a method same as the one removeActions

#

But it takes an item

#

And then it gets the uuid of the item in that function and removes it

#

Can be handy

errant geyser
steel heart
#

Oh my bad

#

Btw

#

Make it nice formatted

errant geyser
#

fine

old wyvern
#

So, im tryna learn how generics work, this is where im at rn, I just dont get where this would be useful lol, I get that if I extend something for T, then I can only give it subclasses of that, but I dont get where that would be useful
@obtuse gale
You already use generics a lot probably. Collections all use Generics to work with all object type.
You use it when you need that specific class to work with a specific set of Types

steel heart
#

Yeah why not

prisma wave
#

@obtuse gale a great example is List - you only want to allow certain types to be added and removed

steel heart
#

now make a new method

obtuse gale
#

Is there anything I could try and make that uses this? Thats how I learn best lol

old wyvern
#

ofc after compilation its just an Object being used and being casted everywhere as implied

steel heart
#

In ItemActionManager

prisma wave
#

Make your own LinkedList or something

steel heart
#

This will be our removeAction

old wyvern
#

mhm

steel heart
#

Make it package private

obtuse gale
#

I dont even know what a normal linked list is thonking

steel heart
#

@errant geyser and declare the generic type parameter T extends ListenableEvent

errant geyser
#

Yep

old wyvern
#

Linked List is a data structure where each Node in the list stores the current item and the next node*

steel heart
#

So you see how I casted in addAction

#

Do the same

onyx loom
#

Not home
@hot hull whered u go on holiday anyway

errant geyser
#

Yep, done

steel heart
#

Then call the remove

errant geyser
#

OH

#

No

#

Mb

steel heart
#

Thatโ€™s good

#

Make one with uuid aswell

#

More feature rich (:

errant geyser
#

Thats in the ItemActionManager tho, didn't you want it to be in the AbstractListener?

steel heart
#

No

#

We have one in there as well

errant geyser
#

ok

steel heart
#

The manager manages everything through the listeners and the items

#

Now in item

errant geyser
#

So how would the one with just the UUID work then?

heady birch
#

There is no context โ˜ ๏ธ

steel heart
#

Make a public remove function

#

well thatโ€™s the original one

#

The item is the one where you call the original one and just get the uuid of the item

#

However in the Item class

#

Make a single remove function only taking an ActionType

#

Since we already know the uuid of that item

#

And that should be it

obtuse gale
#

Are generics used in spigot plugins much or is it mainly outside just in general java?

errant geyser
old wyvern
#

It can be applied anywhere, just depends on what you are trying to do

obtuse gale
#

I dont see any cases in which id use this lol

#

Like actually making my own class, not talking about lists and stuff

errant geyser
#

Still though, how would I do this? Since it doesn't take a type. Its in the ItemActionManager

steel heart
#

Yeah

#

Add a parameter

#

For the type?

old wyvern
#

You would use it when a specific class you create should work with diff types. Lists was the just the easiest example

steel heart
#

Aj

#

SimpleServicesManager for instance

obtuse gale
#

Ive just never been in the situation where im like, damn I wish this class worked with different types

prisma wave
#

it's not necessarily for a class

#

in the case of kotlin you could use a reified type parameter to make a simple event listener

obtuse gale
#

reified

prisma wave
#

eg kotlin listen<PlayerJoinEvent> { message = "Welcome" }

obtuse gale
#

:what:

prisma wave
#

it's a keyword

steel heart
#

I mean Aj you gotta love functional interfaces though

prisma wave
#
inline fun <reified T : PlayerEvent> listen(body: T.() -> Unit) { blah }
old wyvern
#

Thats inlined right?

#

yup

prisma wave
#

yeah

#

there's nothing spigot specific about it, they are often used in library design

steel heart
#

It can be more flexible to use generics

prisma wave
#

indeed

#

while maintaining type safety

steel heart
#

Yh

#

Though I wish x instanceof T would have worked

prisma wave
#

type erasure

obtuse gale
#

riight

errant geyser
#

@steel heart But I wanna be able to clear all actions for an Item, so surely I shouldn't pass that a type?

steel heart
#

I mean maybe just for a specific type

obtuse gale
#

I still have never wanted/needed to do that but I guess maybe one day I will lol

steel heart
#

But you can make one that clears all actions as well

#

Would be through looping all AbstractListener

errant geyser
#

Oh, so like this? java void clearActions(Item item) { manager.forEach((actionType, abstractListener) -> abstractListener.clearActions(item)); }

steel heart
#

Yeah

#

Something like that

#

But make one that only clears for specific ActionType

#

Will be handy I promise

errant geyser
steel heart
#

Make a shortcut one

errant geyser
#

I don't think we have one to remove a specific action but idk how we'd even do that

steel heart
#

In the Item class

old wyvern
#

Though I wish x instanceof T would have worked
@steel heart
I mean you could ...

inline fun <reified T> isType(obj: Any): Boolean {
    return obj is T;
}```
errant geyser
steel heart
#

Good

#

Push it so I can see ๐Ÿ˜‡

errant geyser
#

ok

steel heart
#

Yugi Iโ€™m not kotliner

#

But I usually go with Class#isInstance

prisma wave
#

That's basically the same thing

#

Just compiler generated

steel heart
#

(:

errant geyser
#

Pushed

steel heart
#

@errant geyser you donโ€™t need the ActionType parameter in AbstractListener

errant geyser
#

Where?

#

Oh the removeActions?

steel heart
#

Yeah

#

You already know the type

#

Also clearActions in Item doesnโ€™t need any params

twilit ledge
#

Sleep

steel heart
#

Just use this

#

Also make those methods in Item.java visible

errant geyser
#

Oh true

twilit ledge
#

Canโ€™t you use test.replaceall(โ€œtestโ€, โ€œ2โ€)

errant geyser
#

Conclure how does it know the type tho?

steel heart
#

The manager should handle that part

errant geyser
#

Ok but

#
public void removeActions(Item item) {actions.entries().removeIf(uuidActionEntry -> uuidActionEntry.getValue().getClass().isInstance(type));}``` I need the type here tho
steel heart
#

Where is that

errant geyser
#

AsbtractListener

#

Where you wanted me to remove the ActionType

steel heart
#

Abstract listene

#

You only need clearactions

#

Though you should have a method that takes a uuid instead of an item

#

In AbstractListener

robust shuttle
#

When i reloaded the plugin it says "An internal error occurred while attempting to perform this command", done anyone know how to fix it?

obtuse gale
#

whats the error

steel heart
#

Send stacktrace

hot hull
#

Ah yes we read minds here

onyx loom
#

which plugin

versed ridge
#

The plugin

foggy pond
#

What does the GoDead guy want to do?

errant geyser
#

THE plugin

onyx loom
#

ah i see now

foggy pond
#

I saw everyone going insane in the chat and I am curious

obtuse gale
#

tried turning it on and off?

onyx loom
#

fork spigot

#

for 1 like method

obtuse gale
#

make sure to unplug it at the wall plug

#

leave her off for 30 seconds

#

bam fix

foggy pond
#

But why what

#

Why would he wanna fork for a join method even

#

I am so confusd

onyx loom
#

๐Ÿ™‚

steel heart
#

@errant geyser I will make a pr if I see anything is booboo later

heady birch
#

wrapper classes are used alot

#

easy as

#

MyUser user = myUserManager.get(player)

user.someCoolMethod()

errant geyser
#

@steel heart updated, and alright

steel heart
#

(:

regal gale
#

@prisma wave there's your fAvoRitE val

prisma wave
#

ty

#

although you don't need to specify the type there

#

:)

regal gale
#

Nah, i purposely do that just not to let people confuse kotlin with smth else thonking

prisma wave
#

๐Ÿค”

#

not many languages use val

#

also

#

kteval

regal gale
#

I do have jseval too, ya know

errant geyser
#

What's that keybind in IJ that copies the line your cursor is on to the one below it

prisma wave
#

Win + Shift + Down?

analog crater
#

Crtl D copies line

errant geyser
#

Thats it, thanks Jolly

regal gale
#

@prisma wave wanna play a small game? :)

prisma wave
#

maybe

regal gale
errant geyser
#

For me MB that just pulls IJ out of full screen

regal gale
#

Js or Kt

errant geyser
#

JS

#

Otherwise you code is gai

regal gale
#

Lol

prisma wave
#

hm

quiet depot
#

brister

prisma wave
#

yeah?

quiet depot
#

where's your final at bruh

prisma wave
#

soz

#

i was gonna final everything

regal gale
#

Also yeah it's js ._.

prisma wave
#

but got bored

quiet depot
#

final MalformedURLException

prisma wave
#

@regal gale i'm 99% sure that would work with kotlin too though

regal gale
#

Yep

#

Next guess

#

I think this one's too easy actually

#

Js or Kt

prisma wave
#

js

#

kotlin would infer it as Int

#

so wouldn't print it out as a float

#

i think

onyx loom
#

why does that return 30.0 thonking

regal gale
#

Told ya it's too easy...

prisma wave
#

ยฏ_(ใƒ„)_/ยฏ

hot hull
#

I mean you can see the j in there

prisma wave
#

true lol

regal gale
#

Breh

#

I will need to cross out w. next time, thanks for reminding

#

:)

#

Last one

#

Js or Kt

prisma wave
#

Hmm

#

Kt?

hot hull
#

js

errant geyser
#

JS

prisma wave
#

It could be either

hot hull
#

Get gud BM

regal gale
#

Yeah it's kt

hot hull
#

Fuck

prisma wave
#

HA

#

EZ

errant geyser
#

DAMN

#

I thought the red was too small to write w.kteval

regal gale
prisma wave
#

Get gud Frosty

onyx loom
#

Get gud BM
this aged well

prisma wave
#

Certainly

regal gale
prisma wave
#

Kotlin doesn't have the ternary operator

regal gale
#

Yeah..

hot hull
#

Damn, sad

errant geyser
#

Thats the only thing from Java I kinda miss

prisma wave
#

I mean

#

you rarely need it

#

if is an expression

errant geyser
#

But it was cool and I did use it sometimes

onyx loom
#

using if looks nicer

steel heart
#

Its nice as it can be used almost anywhere

prisma wave
#

Yeah

hot hull
#

Not really, when you have short returns, ternany is butiful

prisma wave
#

It would be useful but if they added it they should change the syntax

steel heart
#

But I mean and if else thing doesnt take long to write

prisma wave
#

Exactly

#
return if (blah) something else otherThing```
steel heart
#

^

onyx loom
#

return if ๐Ÿ˜Ž

steel heart
#

Its useful but not that useful

prisma wave
#

return try/catch is what all the cool kids use

steel heart
#

Aye wish that was me

onyx loom
#

and me ๐Ÿ˜ฆ

prisma wave
#
return require(someCondition) { 
  something
} catch (e: IllegalArgumentException) {
  somethingElse
}```
#

ez readability

regal gale
#

Idk if my kt eval can even run a try-catch lol

prisma wave
#

I don't see why not

steel heart
#

Thats lit

#

Although I could easy make a help function of that

regal gale
#

๐Ÿ‘

steel heart
#

With callbacks

#

(:::

regal gale
#

Probably not with this...

prisma wave
#

for isn't an expression

regal gale
#

Is foreach count?

heady birch
#

can you use until in kotlin?

prisma wave
#

forEach returns Unit

#

yes

heady birch
#

oh nice

#

always used 0..2

prisma wave
#

that's exclusive range iirc

#

until is inclusive

#

or possibly the other way around

topaz bay
#

you should use repeat

#

until is exclusive

regal gale
#

Nope..

topaz bay
#

What are you expecting to happen?

regal gale
#

Loop 5 times the word "Hi" in evaluation, isn't that already obvious thonking

topaz bay
#

Youre showing the returned value though...

#

forEach returns nothing

#

And you just have a string in it

heady birch
#

lol

prisma wave
#

"Hi".repeat(5)

topaz bay
#

If youre catching console output, change it to forEach(::println)

#

that would print numbers

prisma wave
#

It's probably just the returned value

topaz bay
#

If youre using the script engine, it definitely is

#

Speaking of script engine

#

Spigot is so fucking trash

prisma wave
#

how so?

topaz bay
#

All their classloader bullshit completely breaks engine service resolution

prisma wave
#

Ah yes

#

I remember the pain

heady birch
#

what the heck is an engine service resolution

#

getScriptEngine ?

topaz bay
#

script engines are resolved from the classpath

regal gale
topaz bay
#

kinda like how jdbc drivers are resolved

prisma wave
#

the short answer is that you can't @regal gale

#

Because the script engine only returns the last returned value

regal gale
#

Welp

topaz bay
#

I had to directly access odin, because it would not resolve the engine from the classpath

prisma wave
#

You could return a List, and then have some custom functionality for that

topaz bay
#

But resolution works perfectly fine outside of spigot

#

do this @regal gale (0..5).map { "Hi" }.joinToString("\n")

#

Or like "Hi\n".repeat(5)

#

lol...

regal gale
#

I am so amazed and furious of the amount of ways to iterate in kotlin...

distant sun
#
$ git push -u origin master
remote: HTTP Basic: Access denied
fatal: Authentication failed for 'https://gitlab.com/org/repo.git'```
Pls halp ๐Ÿ˜ฆ
topaz bay
#

Theres... literally 3?

distant sun
#

fucking gitlab

topaz bay
#

Unless youre counting iterator itself, in which case 4

regal gale
#

Doesn't foreach count?

topaz bay
#

just like Java

regal gale
#

@distant sun why are you even using gitlab

distant sun
#

cuz my client wants to

#

smh

onyx loom
#

artifactId should be -jdk8 i believe

#

idk if . works

hot hull
#

@distant sun Tell the client to fuck off fingerguns_reversed

onyx loom
#

OMG i cant even add reactions here

#

this is bullshit

#

DONT FLEX frosty

#

๐Ÿ˜  ๐Ÿ˜  ๐Ÿ˜ 

obtuse gale
#

bullshit indeed

hot hull
#

Get gud

distant sun
#

))

onyx loom
#

gonna apply for staff just for reaction perms

#

and upload perms

#

fc doesnt wanna give the perms to tier 6 ๐Ÿ˜ญ

distant sun
#

To anybody*

onyx loom
#

๐Ÿ˜ 

#

how selfish of him

distant sun
#

Ye

hot hull
#

Rip my vc perms :((

prisma wave
#

@onyx loom ah oops

#

Better fix that

onyx loom
#

๐Ÿ™‚

prisma wave
#

Or you could make a fat PR

onyx loom
#

๐Ÿค”

#

u know what

#

i will make a PR

#

and ill add a kotlin example ๐Ÿ˜Ž

prisma wave
#

yay

onyx loom
#

and add loadAllDependencies to the readme

#

altho i wasnt able to get the Dependency thing to work for me

prisma wave
#

hm

onyx loom
#

addDependency method or whatever

prisma wave
#

what went wrong?

onyx loom
#

just saying unknown reference

#

loadall dependencies seems to be fine tho

prisma wave
#

weird

#

oh actually

onyx loom
#

when i get back on pc ill show u what i put but idk

prisma wave
#

I know why

#

that example is really outdated

#

I removed the Dependency class

onyx loom
#

ok so im not stoopid ๐Ÿ™‚

prisma wave
#

nah dw

#

I'll update the docs

onyx loom
#

๐Ÿ‘

#

u gonna add the kotlin example urself?

prisma wave
#

you can if you want

onyx loom
#

alr sure

digital patrol
#

Hi can someone bug fix a plugin for me please

#

i have the source code

quiet depot
digital patrol
#

thank

analog crater
hot hull
#

@analog crater No ;(

obtuse gale
#

๐Ÿ˜ฆ

onyx loom
#

no one is generous ๐Ÿ™‚

remote goblet
onyx loom
analog crater
#

A (probally simple) edit vs a full core plugin with other modules

hot hull
#

Noone is going to make that

analog crater
#

The edit or the core

onyx loom
#

both

hot hull
#

Both

errant geyser
#

guis, for IAL do I go with only supporting Paper servers (PlayerJumpEvent), or do I somehow have to make my own for spigot?

onyx loom
#

imagine not using paper

errant geyser
#

I wanna but I also want people to be able to use my lib for whatever

prisma wave
#

Don't tell me you're supporting 1.8

errant geyser
#

No

#

Its written on 1.15.2 but eh

#
prisma wave
#

You have to cast to Damageable afaik

errant geyser
#

Well thats retar d e d idiotic

#

Which do I cast?

#

Neither of them implement or extend it

prisma wave
#

i'm pretty sure it's the meta

#

the implementation probably implements Damagable

#

or not

#

based on if the item can actually be damaged

errant geyser
#

So, what do I do for the PlayerJumpEvent?

#

Do I just support paper and anyone who moans I can tell to fuck off or PR me a PlayerJumpEvent?

prisma wave
#

That seems fair

#

Alternatively make your own but with a bit of reflection to only use it if on spigot

steel heart
#

Maybe fork paper spigot and see how they implemented the jump event?

errant geyser
#

I already saw how they did it

#

The best I can probably do in Spigot is listen for the statistic

#

And then call my own event

#

Kinda dumb they haven't added this yet tho

#

ยฏ_(ใƒ„)_/ยฏ

prisma wave
#

gross

steel heart
#

Oof

onyx loom
#

@prisma wave the fuck does this mean https://paste.helpch.at/ugiyeworam.bash
MF downloads and is put into the PluginLibraries folder, but still NoClassDefFoundError. kotlin stdlib doesnt dl โ˜น๏ธ

#

weird, i restart server and now kotlin is downloaded, but still NCDFE with matts framework

prisma wave
#

interesting

#

does the jar download correctly?

onyx loom
#

its in the PluginLibraries folder

#

how large is MF jar?

prisma wave
#

ยฏ_(ใƒ„)_/ยฏ

hot hull
#

sm0l

onyx loom
#

34KB seems right to me but yea idk

prisma wave
#

hmm

#

what's new error?

onyx loom
hot hull
#

Isn't it like 70kb or something like that?

onyx loom
#

o

#

cc: @ocean quartz any ideas?

#

how bigs MF

hot hull
#

Wait

#

U using both or just commands?

onyx loom
#

cmds

hot hull
#

I feel like that should be the right size then

prisma wave
#

can you check that the class is actually present in the jar?

#

if it is, then something's broke with the classloading

onyx loom
#

yea sure

prisma wave
#

send your onEnable btw

ocean quartz
#

@onyx loom MF is 32kb

onyx loom
#

o da fuq

ocean quartz
#

Or 34 i guess

#

Since the latest versions added a bit more

#

Yeah 34KB

onyx loom
prisma wave
#

ah yeah

#

that's not gonna work

#

loadAllDependencies returns a CompletableFuture<Void>

#

because downloading and loading is async

onyx loom
#

o

prisma wave
#

you need to either block, or use thenRun to register stuff in a callback

onyx loom
#

โ˜น๏ธ

#

ok so how would ido that ๐Ÿ˜…

prisma wave
#

which one?

#

you have 2 options

onyx loom
#

which ever is easier

prisma wave
#

blocking is easier

#

just add join()

hot hull
#

Which ever is more efficient fingerguns_reversed

prisma wave
#

blocking the main thread is pretty efficient

hot hull
#

In kangarko's eyes, indeed

prisma wave
#

our lord and saviour

trim hare
#

To be loved in kangarkoโ€™s eyes?

hot hull
#

A true honour

prisma wave
#

the man who teaches good coding

trim hare
#

โ€œImagine you have the power to code anything you desireโ€ฆโ€ cues the steamy, suggestive music

prisma wave
#

"are you imagining? good, now give me all your money"

onyx loom
#

i kinda just fired in the dark here

#

and no idea if what i did was right, but it removed the error from MF but now i get a noclassdeffounderror in kotlin ๐Ÿ˜†

#
            val dependencyManager = PluginDependencyManager(this)
            dependencyManager.loadAllDependencies()
        }
        request.join()```
@prisma wave ive no idea if this is correct at all
prisma wave
#

why run?

onyx loom
#

ยฏ_(ใƒ„)_/ยฏ

hot hull
prisma wave
#

They get stranger every time

onyx loom
#

frosty u just know that its something gonna be harder than $50

#

and more like $1k kappa

hot hull
#

Most likely yea

onyx loom
#

so bm, what do u recommend instead?

prisma wave
#

just do it normally?

trim hare
#

I think thatโ€™s just someone whoโ€™s lonely enough to pay $50 to someone just so they can interact with a real human being

prisma wave
#

although that's not the problem

#

send your full code now

#

it might be the problem

hot hull
#

@trim hare GWempOof

onyx loom
#

ignore the empty onDisable method kek, will do it later

prisma wave
#

try without the run

#

I think I know what's going on here

hot hull
#

Sorcery

onyx loom
#

wdym without the run?

prisma wave
#

take those 2 lines

#

out of the run

#

idk why you even put them in there

onyx loom
#

pls no booly

#

i cant remember what i was doing before but the join() wasnt working idk, got it to build now

#

oh shit it works

#

yay

#

no more 1.6mb jar fingerguns

prisma wave
#

nice

onyx loom
#

thanks bm โ™ฅ๏ธ

prisma wave
#

np

#

my hunch was right

#

run probably generates some stuff behind the scenes that uses the Intrinsics class, and since kotlin wasn't loaded then it threw an error

steel heart
#

Pdm is nice

prisma wave
#

ty

onyx loom
#

ok but now let me try get rid of the pluginlibrary and install the jar fresh

steel heart
#

You should put it on spigot wiki or smtng

#

And make it known to the people

prisma wave
#

i could do

#

might do that actually