#dev-general
1 messages Β· Page 172 of 1
I forgot that was even there lol
Indeed it is
his name is Brister Mitten (well, it was for about 99% of last year until he thought he was really cool and decided to start changing his nickname to something really obnoxious lol)
Oh I see
Oki
can i contribute
doxxed him for his github 
by deleting the clojure part of ur life π
okay, sign me up lol
chapter 1. Java good
chapter 2. Kotlin good
chapter 3. Clojure good
what an interesting story!
it's great
"chapter 4: finally realised that Scala is the true king and that I was full of shit this whole time" pending...
lol
I've never used it before
ya know what? just for that, I'm doing it right now lol
repl.it time
I've only used it for the jvm-plugins repo
the build tool kinda sucks
takes like 20 seconds to build 2 classes π
how do I define a setter for a var in the constructor of a kotlin class?
the short answer is you can't
properties declared in a primary constructor are assumed to be "pure" (no custom getter or setter)
ah
I think you'd need to do
class Test(value: String) {
var youThing = value
}
Is there a better way to do this:
abstract class LogWriter(var loggingPrefix: String,
var detailed: Boolean = false,
var padding: Int = 60,
logLevel: Level = Level.ALL) : Logging, Debugging {
var logLevel: Level = logLevel
set(value) {
field = value
logger.level = logLevel
}
protected val logger = Bukkit.getLogger().also { it.level = logLevel }
...
}
I don't really need the logLevel value in the class itself
but I would like to have a field where if you set the field, you set the logger's field
when you go on repl.it and go to make a new repl, and you find Scala at the bottom of the list of practical languages lol
π¦
and if you get the field, you actually get the logger's field
scala is practical
ooh objects are a thing in Scala
quite a lot of kotlin things are in scala
@empty flint any reason you can't do ```kotlin
val logLevel
get() = Bukkit.getLogger().level
set(value) { logger.level = value }
@jovial warren that is correct
it's not that bad
I think it's pretty clean actually
val player = sender.asInstanceOf[Player]
var*
@empty flint it's a val, the Kotlin equivalent of final
@prisma wave it doesn't have smart casting either?
No yeah that's what I was going for but I didn't know how to write it better than the way I did. Didn't know the warning about setting the field went away if you specify a custom getter
also why tf do methods look like this: ```scala
def main() = {
}
because it's not an assignment it's a declaration
wdym first class?
scala is a functional language
it has first class functions
i.e higher order functions
how so?
main.scala:1: error: expected class or object definition
def main(args: Array[String]) {
^
one error found
compiler exit status 1
what I mean by strict OOP is that everything has to be wrapped in a class, like Java
probably not the right definition but eh
also why does it take like 2-3 seconds to literally compile 5 lines lol
sbt bad
SBT?
the build tool
also I figured out what's up with that = {} thingy btw
you only need the = sign if you specify the return type explicitly
=>
wait does Scala have type inference to the level where you don't have to explicitly specify the return type of a function?
E
L
A
R
A

wait does Scala have type inference to the level where you don't have to explicitly specify the return type of a function?
because that's something I've wanted in Kotlin for pretty much ever
messy
You should edit your L, it looks like EIARA
Uf you sprcify the =
With = it woukd infer the return type
Fyck cabt tupe
Oof
Brb
the only way I can think to make Kotlin use proper type inference on functions (like it should have) is something like this: ```kotlin
fun myFunction() = run {}
Its 3;20
gross
Spare me
ok :)
which is even more annoying than specifying the return type
functions should specify return type
unless it's totally obvious from context
especially in FP
yeah but the main reason why I switched to Kotlin is so that I can write less code lol
gn
it's like liskov
but extreme
EXTREME liskov substitution
every function returns Any
yeah but the main reason why I switched to Kotlin is so that I can write less code lol
you sound like a person in need of clojure
no specifying return types there
you mean this? https://en.wikipedia.org/wiki/Liskov_substitution_principle
Substitutability is a principle in object-oriented programming stating that, in a computer program, if S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e. an object of type T may be substituted with any object of a subtype S) without alteri...
or parameter types
wait what?
parameter types have always been one of those things that feels like it just kinda sucks the life out of type inference
true
I was just about to say "and also constructor parameters" but I got half way through typing the word "parameter" and went "hold on a second, that's still a type of parameter" lol
no constructors in clojure
Kotlin = poised to revolutionise programming
Kotlin vs Clojure
Can't compare to GO though
wait why is Go more popular than Kotlin?
speed
speed?
Yeah GO is hella fast, idk why it's popular though, but people love it
funny how people like the shittest of languages lol
like which
iirc sx likes go
choose your words carefully
JavaScript, Python, Java, the list goes on lol
C++, PHP, C
Rust is quire low as well
top 20 for kotlin tho pog
C is dogshit, and C++ is even worse
Better than Pascal or whatever was popular at the time
c++ has its uses too
Rust better than Kotlin?
/uj can't compare the 2
Top 5
yeah they're widely used, but that doesn't stop them being shit and not deserving any credit for anything
JS is gonna fall from 1st pretty soon
have you even seen the syntax? lol
kekw java going down
Yeah
There isn't a single low level language that isn't at least a bit ugly
it's still powerful
C++'s power isn't the syntax
and somewhat nice
like wtf is ```c++
using namespace std;
int main() {
cout << "Hello World";
return 0;
}
mEmOrY MaNaGeMeNt
^ that too
You can hate it, but memory management is one of it's greatest features
apparently using namespaces like that is an anti-pattern
hating manual memory management is dumb
what kind of a useless ass keyword is reinterpret_cast, or const_cast, or dynamic_cast, or static_cast, or even friend, wtf is a friend
companion
friend
companion makes more sense, because it's the companion of the class it's in
and i'm pretty sure most of those aren't keywords
yes they are
C++'s power isn't the syntax
yeah ik
true
but they shouldn't all be keywords
like wchar_t should not be a fucking keyword
keywords aren't supposed to look like that, they're supposed to be easy, short, and understandable from just about no context
companion object makes sense, volatile is a little bit more complex but still makes sense, synchronized makes perfect sense, and crossinline I'll admit needs some context
all of them make sense
but require you to know the language and its capabilities
the same goes for wchar_t and whatever else
true
C++ is not meant to be a language that you look at it and you can see what it does without knowing it, it's complex but that's not a problem
yeah I guess
@ niall
but if you're working with low-level stuff anyway, why not just use C? it's probably faster, is structured a bit better, and is actually alright lol
You'll hate me for saying this but Clojure is pretty ugly as well xD
the truth has been spoken.
def something nil xD
it's not the most pretty of languages
but most of the ugly languages are the most elegant and powerful
rust, c++, clojure, haskell
"elegant" my ass
I don't want to see your clash solution
also teach me the Clojure ways
I wanna see this
wdym
tell me where I find learning resources
u dont wanna know π
(require '[clojure.repl :refer :all]) okay, nope lol
It's always fun to learn a new language just to do it
it would be my pleasure
@ocean quartz yeah
jokes aside, clojure is kinda ugly but once you actually realise why it's ugly, it starts to become really elegant
imo anyway
last time I tried learning a new language properly, it was C, and I got as far as the part where static was declaring local variables and I was like https://tenor.com/UWiC.gif
ok the decompiled clojure experience
If you don't learn C as your first language and you learn an OOP one first once you try you get a shock
yeah I learnt Java first, big mistake lol
procedural only π
C was my first one
https://img.bristermitten.me/idea64_Eeqt5DxxkP.png already looking pretty hideous
Is it possible to interpret a string as a string that should be interpolated?
decompiled clojure
ah okay
yea
If I had a class with a field "name" and I knew that field existed, could I pass a string to that class that it will try to interpolate with its own field names?
show me the source code
wait I gotta see some decompiled Kotlin code lol
π
decompiled kotlin is boring
main__var π’
don't you just show Kotlin bytecode and then decompile to show decompiled Java code?
Decompilers can be misleading because they assume the source was java
indeed
tbh, it's not that bad
also question for mr clojure expert
is this supposed to compile to use the Reflector class?
Wdym?
when decompiled Kotlin becomes the exact same as the Java code that you're basing your code off of lol
Is it type hinted?
Yeah it does
how would one perform type hinting?
^Player
ah
i'm not sure that's possible?
since it's reusing a variable of type CommandSender
It is possible
Just don't hint it in the parameter declaration
I recommend you put :global-vars {*warn-on-reflection* true} in your project.clj
it's in the main class, is that not enough?
I already kinda did that in the lein template but the plugin namespace gets evaluated too late
i copied your clojure-plugin template
Yeah
lol (the left is decompiled Kotlin code, the right is the original Java code that I'm modelling my Kotlin code from on GitHub)
It loads the command namespace before setting that var
I see
wait, if I remove the parameter type hinting then it will just use reflection for when it's not a Player, no?
I never knew when decompiled to if/else if/else
what else would it compile to lol
switch?
not versatile enough
I mean, that's basically what it is
switch has to be compile time constants
Switch is a rather odd construct
indeed
yea
It actually has an own instruction that uses a constant lookup table
you can only do literals, enums, etc in switch
oh yeah you're right
I actually forgot about that since it's been that long since I used Java lol
https://img.bristermitten.me/idea64_DObwuMvrK7.png
anyway johnny if I remove the type hinting for sender then wouldn't it use reflection for the sendMessage?
actually ya know what, time to switch it up and make a Java project for the first time in months because why not
wait, if I remove the parameter type hinting then it will just use reflection for when it's not a Player, no?
@prisma wave since clojure isn't statically typed, type hinting is really just hints. If you type hint a function parameter it's going to use the type as the parameter, but other than that it's decided for each indidividual call. But it does "remember" hints and its inference isn't so bad
@prisma wave can I pass a string format in the shape of an interpolated String as a parameter to a function?
Java does have switch statements with expressions allowrd i thnk
In java 12 or 13
Tho
c isn't OOP
@prisma wave https://tenor.com/wX9L.gif
I'm not sure about this case, I'd assume since there is only a single onCommand method it may be able to resolve and infer hints on its own
14 I think
No it doesn't allow for synamic stuff I'm p sure
π
That would be a big deal
also, is it just me or is it funny how you can use a Kotlin DSL build script with a Java project, just sounds like "Kotlin DSL" is something that's Kotlin-exclusive to me, idk
It does John
Nvm I don't think that's possible either way
Its kinda diff from normal swtch tho
Mind showing an example?
You use arrows
And it doesnt fall through
now we're on double reflection lol
I know switch expressions
But I am pretty sure they still aren't dynamic
Which is what this was all about
I've just thought that I'm working on a REST API for BardyBot, and I got implementations to write anyway (albeit literally no one's gonna use them, but eh, it's fun anyway, and you must get some credit for trying, right?)
@prisma wave you removed the parameter type hint?
also wtf does "No tests found for given includes" mean btw?
(trying to run unit tests)
no tests found that match the criteria
what criteria?
Β―_(γ)_/Β―
No I mean you should leave it I was just wondering if interop inference was strong enough
yeah I got that, but it doesn't make any sense
add gradle test { useJUnitPlatform() } if you're on junit 5
(.kickPlayer ^Player sender text)
ah right
@prisma wave I have that, but I'm using DSL
tasks.withType<Test> {
useJUnitPlatform()
}
```is what I have
@prisma wave were you talking to me?
Its still a constant
to johnny
run gradle test and see if it works
What i also like to do (you can see that in connect-four) is make some interop more idiomatic. memfn is useful for that
(def kick-player (memfn ^kickPlayer ^String message))
You can look at the source of memfn, it's just a macro that gives you a clojure function that uses interop
Ah I expected something like that
Enables you to use it as first class and stop worrying about types
@jovial warren you don't have Junit?
I have kotlin("test-junit5")
do I need the JUnit engine thingy as well?
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.6.2") this one
I believe so
well, I guess it's time for a bit a' the ol' https://tryitands.ee
@lunar cypress so you'd call it with (kick-player player "blah")?
np
Yeah
Looks cool
Yeah well. It's nothing special and you don't technically need it but I just don't like having too many . forms around
Interop isn't bad for the most part, but staying as much in clojure as possible is definitely the most convenient
yeah idiomatic is always better
Idk if you saw the discussion we had about type hinting arrays @ discljord
Now that actually sucks
private var paddingFormat = "%1$-${padding}s"
var padding = padding
set(value) {
field = value;
paddingFormat = "%1$-${value}s"
}
I don't like this implementation, is there a cleaner way to simulate setter variable type overloading? (padding is an integer!)
var paddingFormat = "%1$-${padding}s"
get() = field.removeSurrounding("%1$-", "s").toInt() }
set(value: Int) { "%1$-${value}s" }
doesn't compile of course
rofl
I am trying to create a string format based on a number
"%1$-${padding}s" would result in the format "%1$-60s" for the padding number 60
but I want to both access the number 60 and set the value using a number, not a string
normally you would write a method that returns that returns that private field in java
but I want to access it using a field accessor instead of a method
no, actually that's dumb
nvm
I'm having trouble with scratch file encodings for utf-8 characters.
var output = String.format("%s β %d", "joe", 35)
println(output)
results in
joe ? 35
Any ideas how to set that up properly?
the IDE is set to UTF-8 and the file does appear to be UTF-8
Holy shit i just spent way too long trying to get Javafx to work with Kotlin and intellij's plugin
Yeah it's what i'm using
ah
Pig
hi
Did you have any issues with using gradle with tornadofx
didnt seem to work for me last time I used it
iβve never used tornadofx
i donβt even use kotlin
Holy shit his fingers must be cramped up with that daily avg...
i donβt even use kotlin
@quiet depot im so proud of you



If I had a penny for every time I heard that joke
If I had a pound for every time I heard that ^ joke
because java couldn't c# π
since when do you need to see someone to beat them in a race tho
How do I prevent this from leaking in an abstract class constructor? Is there some init {...} block equivalent for after initialisation where it's certain this has been fully initialised?
() -> Type
@empty flint pretty sure your only option is to ignore the warning (or move to a separate function perhaps)
vacuum noises
π³
π
Hm when is a Kotlin companion object initialised?
classloading
Can I specify it as the Main class for a plugin?
no
because bukkit has to initialize it with the PluginClassLoader
yeah
what would be the best way to implement it as a singleton Plugin object without using the companion?
how do you mean?
lol i'm not sure what you're asking
I just want my class that extends the JavaPlugin to be a singleton
?kotlin-dependency
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()
}
}
practically speaking it is
that actually works I guess
dependency injection
Dependency Injection
Dependency Injection is a method of passing our dependencies, into the classes that need them. In java, this is commonly done by passing an instance of the dependency via the constructor.
public final class CoolPlugin extends JavaPlugin {
@Override
public void onEnable() {
final Other other = new Other(this);
other.method();
}
public void myMethod() {
/* Some code goes in here */
}
}
public final class Other {
private final CoolPlugin main;
public Other(@NotNull final CoolPlugin main) {
this.main = main;
}
public void method() {
main.myMethod();
}
}```
thats it in java
And why is that better than static stuff?
Because Java (and Kotlin to a degree) are object oriented languages
The very idea of static is not object oriented
But also it creates a more explicit dependency graph making code more or less tightly coupled which makes it easier to extend in the future
lol that sentence kind of means nothing
read into SOLID principles if you wanna find how to write "clean" object oriented code
?solid
What is SOLID?
S - Single-responsiblity principle
O - Open-closed principle
L - Liskov substitution principle
I - Interface segregation principle
D - Dependency Inversion Principle
If you wish to read up more on it, you can check here:
https://scotch.io/bar-talk/s-o-l-i-d-the-first-five-principles-of-object-oriented-design
class BlockyDebugPlugin : DistributedBlockyPlugin() {
init {
instance = this
}
companion object {
lateinit var instance: BlockyDebugPlugin;
}
override fun onEnable() {
}
}
Can I somehow direct every invocation of the companion object to an invocation of the instance? Do I have to specify the same methods in both for that to work or is there a generic method?
static <
static >
@obtuse gale That's a little too little info for me, what do you mean?
class BlockyDebugPlugin : DistributedBlockyPlugin() {
init {
instance = this
}
companion object {
lateinit var instance: BlockyDebugPlugin;
fun callableFunction() = instance.callableFunction()
}
override fun onEnable() {
}
fun callableFunction() {
}
}
Like this?
callableFunction
you shouldnt use instance = this anyway
so say you need ur main class in like a listener
class Listener(private val main:CoolPlugin
0{
@EventHandler
fun onPlaceBlock(event:BlockBreakEvent){
println(main.getConfig().getString("test"))
}
}
class CoolPlugin: JavaPlugin(){
override fun onEnable(){
server.pluginManager.registerEvents(Listener(this), this)
}
}```
right?
that way you dont need static/companion object
but what's wrong with a static companion object? Or is this about the SOLID principles again?
Because why would they implement that functionality if that's such a bad thing to do?
I don't want to have to pass around the plugin to every class I create that needs it
solid
basically if you want to test some part of your plugin seperatley
or whatever
its not that static/companion object are always bad
but having val plugin: BlockyDebugPlugin in every single class just seems very boilerplate-y and really unnecessary to do when I can access the effectively singleton via the companion
tbh im pretty sure its better to not even pass ur main round, just pass the things you need round, but I mean I dont do that i always pass my main round
βοΈ
tbh im pretty sure its better to not even pass ur main round, just pass the things you need round, but I mean I dont do that i always pass my main round
@obtuse gale Sometimes you need the plugin object though
Yeah
true
And that annoys me alot
same
that's why I think my companion object solution is OO enough and clean enough for nobody to complain
I mean its not OO in anyway is it?
well it's an object so it's gotta be at least 50% of the OO
says so right in the name
That is amazing. Maybe I'm googling something completely wrong but I can't find any tutorial on how to use gradle to replace strings in the plugin.yml file with values from the gradle build file
is there a plugin for that?
ProcessResources
Any form of static state is not object oriented
That's not necessarily a bad thing, but you can't deny that
And I don't
But it doesn't have to be
conforming to standards when it clearly makes more sense from a logical and readability standpoint to break the standard makes no sense to me
that sentence is a mess
but I hope it's understandable enough
Welcome to OOP
Where everything is over engineered and more verbose than it needs to be
when I specify sourceSets in gradle, do I have to start from the src/ folder or the main/ folder?
for what?
hm no actually I don't need sourceSets, do I?
I still don't understand how gradle works exactly :S
processResources {
with copySpec {
...
}
}
what does the "with copySpec" mean?
What's copySpec in this case? an object? a function?
processResources {
from(sourceSets.main.resources.srcDirs) {
filter ReplaceTokens, tokens: [version: version]
}
}```
Probably a function
thats what ive got, it replaces @version@ in the plugin.yml with theversiion
but that's more a case of not knowing groovy than Gradle
import org.apache.tools.ant.filters.ReplaceTokens
processResources {
from(sourceSets.main.resources.srcDirs) {
filter ReplaceTokens, tokens: [version: version]
}
}
this is what I use
so yeah pretty similar to aj's
just with the import
why @version@? Does it have to be surrounded by @?
yus
Hm does that work with the kotlin source file as well?
public class ScrewYouSpigot implements Listener {
public ScrewYouSpigot(final SpawnerMechanics plugin) {
System.out.println("Registering Event");
plugin.getServer().getPluginManager().registerEvents(this, plugin);
System.out.println("Registered Event");
}
@EventHandler
public void onBlockExplode(final BlockExplodeEvent event) {
System.out.println("Fired @BlockExplodeEvent!");
}
}
Being initialized onEnable, yet it doesn't get fired, what the fuck is this shit
it'll only process in the resources directory
from(sourceSets.main.resources
@prisma wave sure but can't you then dofrom(sourceSets.main.kotlin...)?
spigot bad
@empty flint I believe so
although it'll probably slow down the build a fair bit since there's now a lot more to process
Can I specify a single file as well?
So it was actually EntityExplodeEvent which gets triggered which begs the question, does BlockExplodeEvent trigger for anything :kek:
Blocks exploding
But it doesn't Aj
What did you try it with?
tnt, and creepers
are end crystals considered blocks?
how about a bed in the nether
How do I specify source dirs in kts?
the internet isn't very helpful when it comes to examples
sourceSets {
main {
kotlin {
srcDirs("src/main/kotlin")
}
}
}
doesn't work
But how does sourceSets.main.resources.srcDirs this get populated then?
is that automatic?
wdym?
sourceSets.main.resources refers to a SourceSet that basically wraps src/main/resources
you using the kotlin dsl?
yeah
yeah that's groovy syntax
well
that explains it
Could you translate that to kotlin for me?
I have no idea what these constructs are in groovy
this is the right task, right?
yeah
tokens: [version: version]
``` I believe is equivalent to ```kotlin
tokens = mapOf("version", version)
how do I print something during the build process?
you can probably just extend one of the tasks
one of which tasks?
in groovy it would be like gradle jar { println "Hello" }
one of the tasks that gets run in the build process
I have exactly 0 tasks
gradle build is shorthand for assemble, compileJava, jar, etc
in any of my gradle files
there are premade tasks
in groovy it would be like
gradle jar { println "Hello" }
gradle buildis shorthand for assemble, compileJava, jar, etc
oh those are tasks?
ah
DI is better with Koin π
kids these days
all they know is framework this, framework that
i just wanna grill code!
lol
Koin is a good DI framework
and also, yes, frameworks good
I love both making and using them lol
wtf?
supposedly "more idiomatic"
it is
i'll tell you what's idiomatic
what does that word even mean
the good old fashioned way
because you write DI like this: ```kotlin
val myInjectableClass by inject<MyInjectableClass>
hideous
yeah thatβs disgusting
constructor injection or nothing
buzzword
because I totally know the meaning of that word
brug
So if I define my task using
tasks {
processResources {
}
}
how do I call that task?
bruh*
gradle processResources @empty flint
βbuzzwordβ is way more common than all the other words ur saying
although it already exists iirc
processResources is called when you call build though isn't it?
yes
so if it exists
and also that task already exists
I have to override it?
correct
processResources {
// do thingys
}
getting the hang of it
you probably have to do it inside the tasks closure in the DSL or something
idk
DSL bad
groovy good
nope
I β€οΈ the Kotlin DSL
groovy is much more flexible
but it's ugly and just not good imo
ugly?
itβs not ugly imo
and it doesn't have the kotlin() function xD
I just didn't feel like having to learn groovy and kotlin at the same time that's why I went with the kotlin dsl
compileKotlin {
kotlinOptions.jvmTarget = '1.8'
}
tasks {
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
}
don't tell me the first is ugly
you donβt need to know kotlin or groovy to use gradle
@empty flint groovy is easy
and it means that the way I write dependencies would look like this: groovy implementation group: '' artifact: '' version: '' , whereas in DSL they look like this: ```kotlin
implementation("","","")
wat
(writing dependencies in that way I find is easier to read and looks nicer, but that's just personal preference)
theyβre literally not comparable
what's not comparable?
using the group: artifact: syntax is ugly
in Groovy it is
the point of manually declaring group: and blah is to enjoy the benefits of named parameters
the dsl sample you provided, is not named
yeah you don't need to name them in DSL, and IJ just shows the names up in those boxes anyway
you don't need to in groovy either
the direct equivalent would be kotlin implementation(group = "", artifact = "", version = "")
yeah, that does look a bit worse I'll give ya that
groovy good dsl bad
I just prefer the way things in Kotlin DSL are laid out, like for example: ```kotlin
tasks.withType<KotlinCompile> {
}
makes more sense to me than groovy
kotlinCompile {
}

idk, it's really personal preference
I love the DSL personally, because it's made from Kotlin (meaning it kinda just feels like writing normal code), and it's laid out like it's programming, and it's very idiomatic for Kotlin
ofc it's personal preference but I don't get how you could prefer kotlin configure<JavaPluginConvention> { sourceCompatibility = JavaVersion.VERSION_1_8 }
to gradle sourceCompatibility = JavaVersion.VERSION_1_8
erm
what are you on about BM
bardy ur example before
that bottom one works in both
well
once again those arenβt equivalent
Β―_(γ)_/Β―
the only benefit of the DSL is having kotlin features
and groovy pretty much has most of them
@quiet depot yeah I think you're right, wouldn't the equivalent in DSL be something like: ```kotlin
val kotlinCompile by tasks.getting(KotlinCompile::class) {
}
grooooooovyyy
or am I still wrong lol
ah okay
yeah I don't know how the DSL works all that much either, I've just seen examples of it and kinda just google it when I get stuck
one thing that is objectively better in DSL though is the maven-publish plugin's publications layout
even though this is very specific, hear me out
iβve never published shit through gradle
i just use mvn cli, usually via a bash script
in Groovy, you configure the maven-publish plugin a little something like this: groovy publishing { publications { publicationName(MavenPublication) { // configure your publication in here } } } whereas, in DSL, you do it like this: ```kotlin
publishing {
publications {
create<MavenPublication>("publicationName") {
// configure your publication in here
}
}
}
and as I said, that's a very specific example, but it still counts
Lets say I have a few objects (50-100) all using the same value for one of their String fields, is it worth using a small cache (not intern())
"a few objects" lol
Lol
I recommend you cache any data that you want to be able to use/be used frequently that comes from an external source
I just need help with the ReplaceTokens() class for Kotlin dsl, please:
from("src/main/resources/plugin.yml") {
filter(ReplaceTokens(), mapOf("" to ""))
}
How does that syntax work that you wrote in groovy?
tasks.withType<ProcessResources> {
filter(ReplaceTokens, mapOf("" to ""))
}
```I think?
lemme see
Classifier 'ReplaceTokens' does not have a companion object, and thus must be initialized here
tasks.withType<ProcessResources> {
from("src/main/resources") {
include("plugin.yml")
val tokens = mapOf(
"" to "",
"" to ""
)
filter<ReplaceTokens>("tokens" to tokens)
}
}
that's pretty much what I have
I forgot that filter is a reified function in DSL lol
yw
what does reified mean?
it's not something I can really explain, @prisma wave this one's your turn lol
Also, why does it say "tokens" to tokens? doesn't that replace the literal token "@tokens@" with the map.toString() string?
Means you can access the type parameter as if it was a class
^^ there ya go
@empty flint because it's replacing all tokens with the map of tokens
Means you can access the type parameter as if it was a class
@prisma wave Is that like static access?
not quite
he means exactly what he says
you can access the reified type parameter as if it was a class
mmmmh
e.g. imagine doing this in Java: java public <T> T myFunction(Class<T>) { return something; } with reified type params you could do this: ```kotlin
inline fun <reified T> myFunction() = something
basically, you don't need to provide a class as a parameter, you can just provide it as a type parameter
ooooh
bruh
so it's a typed inline function similar to a typed class? (idk the correct terminology here)
The common pattern is a function that takes a Class/KClass with a reified helper function
a... generic class...
A generic class
right
anyway back to the filter function
@empty flint because it's replacing all tokens with the map of tokens
@jovial warren I don't really understand what the literal "tokens" is there for.
basically, it's using the class ReplaceTokens to replace tokens, is all you need to know in this context
what does "tokens" refer to?
"tokens" refers to the fact that you want to replace tokens
Lets say I have a few objects (50-100) all using the same value for one of their String fields, is it worth using a small cache (not intern())
@heady birch no
or I believe so
"tokens" refers to the fact that you want to replace tokens
@jovial warren what else would you replace other than tokens?
filter can replace other things
like..?
no idea
it's just basically putting the contents of the files through a filter
there are other things that you'd want to replace
I just don't really know what they are
alright I guess that's not something I need to know now anyhow
ty for the reified thingy again
oh, also, @hot hull I owe you a coffee because I was stupid yesterday
how do I send you some?
=pl frozen join
You click buy me a coffee 
send me the link
What an unprepared nerd :kek:
Go to paypal.me/mcknightz and type in the amount. Since itβs PayPal, it's easy and secure. Donβt have a PayPal account? No worries.
Lol
Using a boxed primitive for an optional value e.g:
Integer fieldName;
vs
int fieldName;
boolean has(FieldName);
what
bruh @empty flint Thanks for the 3 coffee β€οΈ
bruh...
@heady birch so it would be boolean hasFieldName()?
oh shit ty @empty flint
@prisma wave I have no idea if you actually got the cup of coffee or if paypal took all of it.
vs using an Integer
PayPal took like 1/5 of it
@heady birch might as well use an Integer
Rather than adding a degree of complexity
Blocky, that site is nice, just sad no spigot kids actually donate :c
Or an Optional
OptionalInt
^
I was actually joking lol
@prisma wave I wanted to show my gratitude for all your help :)
bruh @empty flint Thanks for the 3 coffee β€οΈ
@hot hull β€οΈ
niall you can't react to optionals with a puke emoji. i thought you were doing rust
Yeah but rust is different
Blocky, that site is nice, just sad no spigot kids actually donate :c
@hot hull Gotta force them donations with premium plugins. make those kids yeet their parents' credit cards at their screens
new File(lawsuit)
Blocky, ain't got any premium worthy shit :p
Yeah but rust is different
@heady birch how so?
I don't think I've published enough plugins for premium xD
You need 3
It just is
I got 2
π
xD
Its an enum π
you're an enum
Maybe if Java could do
I had 5, but deleted 4 (well some still need to be deleted)
Optional.SOME(10)
disgusting
I could probably just publish my debugging plugin and tell people not to download it as I won't be updating it
meh
oh yes I need some expertises here
the only thing you get from that is pattern matching and java can't do that
other than that its functions are very similar
Hm when you unlock a premium plugin, can you delete the free plugins and still publish premium ones?
lmao are you just shitposting yourself to premium perks?
lmao are you just shitposting yourself to premium perks?
@lunar cypress I could, yeah
Legit just upload some shitty projects
Or smaller ones, it doesn't matter, just the count matters
I am designing a system that needs to look up details via multiple methods "LookupProvider"s. There may be more than 1 lookup provider. Some lookup provider that connect to internet may want to batch stuff (e.g make 1 single HTTP request with 10 lookups instead of 10 separate HTTP requests). This is fine and all but such thing as a "LookupPipeline" exists so that multiple pipelines may be combined if required. Not really sure the best way to design this will callbacks or something? the system I used had a blocking pipeline so Provider 1 would do its lookup and take like half a second on a Map<K, V> (the batch) and Provider 2 would lookup after Provider 1 is done. I guess that actually works fine to be honest but there might be some room for improvement.
for (provider in pipeline) {
provider.lookup(batch);
}
//all processed fine.
I am designing a system that needs to look up details via multiple methods "LookupProvider"s. There may be more than 1 lookup provider. Some lookup provider that connect to internet may want to batch stuff (e.g make 1 single HTTP request with 10 lookups instead of 10 separate HTTP requests). This is fine and all but such thing as a "LookupPipeline" exists so that multiple pipelines may be combined if required. Not really sure the best way to design this will callbacks or something? the system I used had a blocking pipeline so Provider 1 would do its lookup and take like half a second on a Map<K, V> (the batch) and Provider 2 would lookup after Provider 1 is done. I guess that actually works fine to be honest but there might be some room for improvement.
for (provider in pipeline) {
provider.lookup(batch);
}//all processed fine.
@heady birch yes
free xp
Classic
class Boop : JavaPlugin() {
override fun onEnable() {
System.out.println("maximum boopage activated.")
}
}
My contribution to unlocking premium perks. The system totally works.
Lol 2mb for a plugin that does nothing
I am designing a system that needs to look up details via multiple methods "LookupProvider"s. There may be more than 1 lookup provider. Some lookup provider that connect to internet may want to batch stuff (e.g make 1 single HTTP request with 10 lookups instead of 10 separate HTTP requests). This is fine and all but such thing as a "LookupPipeline" exists so that multiple pipelines may be combined if required. Not really sure the best way to design this will callbacks or something? the system I used had a blocking pipeline so Provider 1 would do its lookup and take like half a second on a Map<K, V> (the batch) and Provider 2 would lookup after Provider 1 is done. I guess that actually works fine to be honest but there might be some room for improvement.
for (provider in pipeline) {
provider.lookup(batch);
}//all processed fine.
@heady birch Cool
I am designing a system that needs to look up details via multiple methods "LookupProvider"s. There may be more than 1 lookup provider. Some lookup provider that connect to internet may want to batch stuff (e.g make 1 single HTTP request with 10 lookups instead of 10 separate HTTP requests). This is fine and all but such thing as a "LookupPipeline" exists so that multiple pipelines may be combined if required. Not really sure the best way to design this will callbacks or something? the system I used had a blocking pipeline so Provider 1 would do its lookup and take like half a second on a Map<K, V> (the batch) and Provider 2 would lookup after Provider 1 is done. I guess that actually works fine to be honest but there might be some room for improvement.
for (provider in pipeline) {
provider.lookup(batch);
}//all processed fine.
@heady birch yes
The system is currently great. One of the greatest that exist. There is room for improvement. Not much though. Maybe a bit. It is already a great system. Great. If anyone... anyone. has any improvements I am happy to take these up. In fact I will be more than happy. Really happy. Thank you for taking the time to read my issue and I hope it find you well
how does one do multiple lookups with a single request?
Lol 2mb for a plugin that does nothing
@prisma wave it activates maximum boopage, wdym?
I would suggest you write in clojure to boost the size up to 5mb
The system is currently great. One of the greatest that exist. There is room for improvement. Not much though. Maybe a bit. It is already a great system. Great. If anyone... anyone. has any improvements I am happy to take these up. In fact I will be more than happy. Really happy. Thank you for taking the time to read my issue and I hope it find you well
@heady birch Are you a spigot dev or wdym by "take it up"?
:clojuremoon:
π₯΄
guess what I've just managed to do
nope, get an NPE from Kotlin code
Jotlin
Clotlin
Sounds like a you problem
probably is tbh
Multiple lookups with a single request: The service I'm connecting to do a multiple lookup accepts some form data. It is a dated service but Nice. One of the nicest systems to work with. Such request parameter might look like values=000000+000001+000002. There may be a lot of this values. Not loads but a lot. A decent amount, You could say anywhere between 1-100. Although its likely to be 1-5 the majority of the time. So not many. It would only reach higher numbers as the program startups. So the api service will return json data with each of the corresponding values sent in the form data, that is the the form data I have mentioned above. The response may be large. But not really large. Not large enough for any compression but still relatively large. Again that depends on the data being requested.
this has transcended irony
What is the irony? Too many people making accusations without backing up their claims these days. If there is irony prove it. Or you could answer my question... I put a lot of effort into detailing the issue and outlining several important points of which you have requested, just to respond with "this has transcended irony" I am unhappy. Not angry just disappointed. But I can assure you I will not let this effect my general view on you or my perspective of the world. Thank you
Trump
@prisma wave since when could a non-null value in Kotlin become null and throw an NPE?
platform types? what are those?
also it's literally passed through the constructor
like String!
it's passed through the constructor as Lavalink<*>
https://bin.bardy.me/4CrTltbw.cs getNode(selectIfAbsent: Boolean) is causing it
at node = lavalink.loadBalancer.determineBestSocket(guildId)
yikes
lavalink is null apparently, according to debugging
and I did some debugging before that point and there's literally 0 reason at all why lavalink should ever be null
I literally debugged where that's created, which is at override fun buildNewLink(guildId: String) = JDALink(this, guildId), and I evaluated this, and it told me that it was fine
