Log for #spongedev on EsperNet - 2018/12/11

Topic -- Topic: Docs: https://docs.spongepowered.org | GitHub: https://github.com/SpongePowered | Rules: https://docs.spongepowered.org/en/about/rules.html | Code Style: https://git.io/spongecodestyle | Gradle help in #ForgeGradle | Javadocs: https://jd.spongepowered.org | SOS XVI: TBA
Topic -- Topic set on February 10, 2018 06:05:07 am by Owen
00:40:43 Spongie <D​a​r​k​F​a​c​t​o​r​> So... Any ideas about the recipes?
01:17:28 <-- Gustavo6046 (Gustavo6046!~Gustavo60@ has quit (Ping timeout: 200 seconds)
01:21:07 --> Gustavo6046 (Gustavo6046!~Gustavo60@ joined the channel
02:02:34 --> xcube (xcube!~xcube@ joined the channel
02:05:57 <-- xcube (xcube!~xcube@ has quit (Client Quit)
02:06:14 --> xcube (xcube!~xcube@ joined the channel
02:32:13 Spongie <A​e​r​o​c​e​t​> @π_flavor were you the one explaining how to properly set up the shadow plugin?
02:32:39 Spongie <A​e​r​o​c​e​t​> you said to have it inherit from compile or something
03:47:47 <-- Gustavo6046 (Gustavo6046!~Gustavo60@ has quit (Ping timeout: 180 seconds)
03:49:06 Spongie <A​e​r​o​c​e​t​> https://paste.md-5.net/lowitukeno.m does anyone have the slightest goddamn clue what the fuck I am doing lol
03:49:12 Spongie <A​e​r​o​c​e​t​> I have zero clue
03:56:14 Spongie <d​o​o​t​> well what's the problem?
03:56:41 Spongie <k​i​l​l​j​o​y​> First of all, reobf{} does not belong in the shadowjar tasks
03:57:02 Spongie <A​e​r​o​c​e​t​> it can't find the kotlin library anymore if I uncomment those lines
03:57:06 Spongie <A​e​r​o​c​e​t​> but yeah that too
03:57:14 Spongie <k​i​l​l​j​o​y​> is this build.gradle.kts?
03:57:26 Spongie <A​e​r​o​c​e​t​> Duplicate method name "getExt" with signature "(Lorg.gradle.api.NamedDomainObjectContainer;)Lorg.gradle.api.plugins.ExtraPropertiesExtension;"
03:57:27 Spongie <A​e​r​o​c​e​t​> yeah
03:57:29 Spongie <A​e​r​o​c​e​t​> honestly this is crazy
03:59:10 Spongie <A​e​r​o​c​e​t​> i have no clue how to fix these bizarre errors
03:59:53 Spongie <A​e​r​o​c​e​t​> KotlinCompile completely vanished
04:00:01 Spongie <d​o​o​t​> I just don't use the kotlin dsl tbh
04:00:19 Spongie <d​o​o​t​> It's caused me issues as well
04:00:38 Spongie <d​o​o​t​> Gradle just needs to port it to kotlin, not just have a facade
04:00:56 Spongie <A​e​r​o​c​e​t​> is it possible to translate it directly
04:00:59 Spongie <A​e​r​o​c​e​t​> is there a thing
04:02:11 Spongie <A​e​r​o​c​e​t​> it's bizarre that KotlinCompile can't be found when it was found by default before I removed it lol
04:03:43 <-- kashike (kashike!kashike@is.sleeping.in.the.kingdom.of.kandarin.xyz) has quit (Ping timeout: 202 seconds)
04:04:00 Spongie <d​o​o​t​> there isnt
04:05:05 Spongie <A​e​r​o​c​e​t​> tasks.withType<KotlinCompile> { kotlinOptions.jvmTarget = "1.8" } this was pregenerated
04:05:10 Spongie <A​e​r​o​c​e​t​> I uncommented the lines
04:05:12 Spongie <A​e​r​o​c​e​t​> and it vanished lol
04:05:16 Spongie <d​o​o​t​> :blobfasthrmm:
04:06:04 Spongie <A​e​r​o​c​e​t​> oddly enough there are errors in lines where there is no red stuff
04:06:09 Spongie <A​e​r​o​c​e​t​> there's zero red in fact
04:09:08 Spongie <A​e​r​o​c​e​t​> the most nondescript errors I've seen in my life
04:09:19 Spongie <A​e​r​o​c​e​t​> I cannot glean a single thing
04:10:35 --> kashike (kashike!kashike@is.sleeping.in.the.kingdom.of.kandarin.xyz) joined the channel
04:10:35 -- Borg sets mode +o kashike
04:12:42 Spongie <A​e​r​o​c​e​t​> i'll just start over
04:21:01 <-- Brokkoli (Brokkoli!~Brokkoli@p5B23CC21.dip0.t-ipconnect.de) has quit (Remote host closed the connection)
04:30:10 Spongie <A​e​r​o​c​e​t​> apparently gradle dependencies { classpath("https://files.minecraftforge.net/maven") } is wrong
04:30:13 Spongie <A​e​r​o​c​e​t​> in the buildscript
04:30:42 Spongie <d​o​o​t​> you should add it as a repository not dependency
04:31:56 Spongie <A​e​r​o​c​e​t​> I was just copying what I had in the groovy setup
04:31:59 Spongie <A​e​r​o​c​e​t​> it's on the docs
04:32:09 Spongie <A​e​r​o​c​e​t​> gradle buildscript { repositories { maven { name = 'forge' url = 'https://files.minecraftforge.net/maven' } } dependencies { classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT' } }
04:32:16 Spongie <A​e​r​o​c​e​t​> ^ this is recommended apparently
04:32:33 Spongie <A​e​r​o​c​e​t​> oh
04:32:34 Spongie <A​e​r​o​c​e​t​> whoops
04:32:46 Spongie <A​e​r​o​c​e​t​> I fixed that part
04:34:49 Spongie <d​o​o​t​> :blobeyeshrmm:
04:35:44 Spongie <A​e​r​o​c​e​t​> literally
04:36:22 Spongie <A​e​r​o​c​e​t​> oh my IDEA build was outdated
04:36:23 Spongie <A​e​r​o​c​e​t​> whoops
04:36:30 Spongie <A​e​r​o​c​e​t​> lemme fix that and then try
04:37:24 Spongie <A​e​r​o​c​e​t​> nope
04:39:04 Spongie <d​o​o​t​> I wonder how well Kobalt works
04:39:47 Spongie <A​e​r​o​c​e​t​> ohj
04:39:51 Spongie <A​e​r​o​c​e​t​> kotlin is gone
04:39:53 Spongie <A​e​r​o​c​e​t​> from my IDE
04:39:54 Spongie <A​e​r​o​c​e​t​> completely
04:40:03 Spongie <A​e​r​o​c​e​t​> has left the building
04:40:08 Spongie <A​e​r​o​c​e​t​> good update
04:40:11 Spongie <c​o​r​e​> @gabizou Is this page down?
04:40:32 Spongie <d​o​o​t​> @Aerocet what intellij version
04:40:35 Spongie <A​e​r​o​c​e​t​> 2018.3
04:40:39 Spongie <A​e​r​o​c​e​t​> do i reinstall
04:40:47 Spongie <d​o​o​t​> check your plugins settings
04:41:03 Spongie <d​o​o​t​> @core yes
04:41:31 Spongie <A​e​r​o​c​e​t​> it says installed
04:41:39 Spongie <c​o​r​e​> :mc17:
04:41:42 Spongie <A​e​r​o​c​e​t​> oh my god
04:42:03 Spongie <A​e​r​o​c​e​t​> @doot
04:42:17 Spongie <A​e​r​o​c​e​t​> excuse me what in the fuck please
04:42:20 Spongie <A​e​r​o​c​e​t​> how even
04:42:36 Spongie <d​o​o​t​> community or ultimate?
04:42:45 Spongie <A​e​r​o​c​e​t​> community ofc
04:42:49 Spongie <A​e​r​o​c​e​t​> do i look like the bucks
04:42:52 Spongie <d​o​o​t​> oh I'm on ultimate
04:42:57 Spongie <d​o​o​t​> just reinstall
04:43:02 Spongie <c​o​r​e​> this page is also down :https://docs.spongepowered.org/stable/en/plugin/event/causes.html Can some one ,can someone fix it ?@gabizou
04:43:17 Spongie <d​o​o​t​> Please don't tag gabizou
04:43:22 Spongie <d​o​o​t​> He doesn't handle that stuff
04:43:29 Spongie <c​o​r​e​> sorry
04:43:41 Spongie <A​e​r​o​c​e​t​> did you pirate it
04:43:43 Spongie <d​o​o​t​> I've passed it onto the right people already
04:43:48 Spongie <d​o​o​t​> no I have a student license
04:43:52 Spongie <A​e​r​o​c​e​t​> oh kotlin is back
04:43:55 Spongie <A​e​r​o​c​e​t​> ok
04:44:10 Spongie <c​o​r​e​> thank you !
04:44:22 Spongie <d​o​o​t​> :meowthumbsup:
04:45:35 Spongie <A​e​r​o​c​e​t​> okay I have to reinstall
04:45:36 Spongie <A​e​r​o​c​e​t​> it's corrupted
04:46:10 Spongie <d​o​o​t​> rip
04:50:05 Spongie <A​e​r​o​c​e​t​> is the education license permanent?
04:50:21 Spongie <k​i​l​l​j​o​y​> I think most licenses are yearly
04:50:46 Spongie <A​e​r​o​c​e​t​> so you get it for a year?
04:51:29 Spongie <d​o​o​t​> You have to renew it yearly
04:51:48 <-- kashike (kashike!kashike@is.sleeping.in.the.kingdom.of.kandarin.xyz) has quit (Ping timeout: 190 seconds)
04:51:57 Spongie <d​o​o​t​> but you can have it as long as you have a school email
04:52:13 Spongie <A​e​r​o​c​e​t​> uhhh
04:52:20 Spongie <A​e​r​o​c​e​t​> I have my school email permanently
04:52:26 Spongie <d​o​o​t​> gottem
04:52:29 Spongie <A​e​r​o​c​e​t​> I just got an activation key; i graduated in 2017 lol
04:52:54 Spongie <d​o​o​t​> though keep in mind the student license is for non-commercial only
04:53:05 Spongie <A​e​r​o​c​e​t​> my kotlin experiments are highly not commercial
04:53:46 Spongie <A​e​r​o​c​e​t​> oof very gottem
04:54:05 Spongie <A​e​r​o​c​e​t​> wow look at all these new buttons
04:57:58 --> kashike (kashike!kashike@is.sleeping.in.the.kingdom.of.kandarin.xyz) joined the channel
04:57:58 -- Borg sets mode +o kashike
05:04:55 Spongie <A​e​r​o​c​e​t​> wtf it's working now
05:04:58 Spongie <A​e​r​o​c​e​t​> that I updated my IDE
05:05:08 Spongie <A​e​r​o​c​e​t​> how even
05:05:59 Spongie <A​e​r​o​c​e​t​> this is so bizarre
05:08:57 Spongie <d​o​o​t​> Is there a relatively easy way w/ Sponge to transfer a player to a different world without the loading screen
05:09:12 Spongie <A​e​r​o​c​e​t​> is it possible at all?
05:09:14 Spongie <d​o​o​t​> Yea
05:09:18 Spongie <A​e​r​o​c​e​t​> wut
05:09:47 Spongie <d​o​o​t​> you just send chunk updates to the player but not the world change packet im prettysure
05:11:01 Spongie <A​e​r​o​c​e​t​> not familiar with the technique. sounds interesting though
05:11:01 Spongie <d​o​o​t​> I want to seamlessly transfer a player to a different world when they enter a region
05:11:20 Spongie <A​e​r​o​c​e​t​> 1.14 is bringing some insanely seamless teleportation apparently; I saw people featuring it
05:11:27 Spongie <A​e​r​o​c​e​t​> making antichamber-type stuff
05:11:36 Spongie <A​e​r​o​c​e​t​> if you want to totally disguise the teleport
05:11:52 Spongie <A​e​r​o​c​e​t​> but yeah I am interested in learning how to do that though
05:12:14 Spongie <d​o​o​t​> I want to do a Ukanda style thing if you get what I mean
05:12:16 Spongie <A​e​r​o​c​e​t​> holy tit my kotlin build script is working and the class files are normal again
05:12:24 Spongie <A​e​r​o​c​e​t​> ukanda? no idea
05:12:27 Spongie <A​e​r​o​c​e​t​> GET IT IDEA
05:12:37 Spongie <d​o​o​t​> oops fixed name
05:12:39 Spongie <A​e​r​o​c​e​t​> do the cat
05:12:43 Spongie <A​e​r​o​c​e​t​> with the smile
05:12:49 Spongie <d​o​o​t​> :meownou:
05:13:58 Spongie <A​e​r​o​c​e​t​> oh my
05:22:01 Spongie <D​a​r​k​F​a​c​t​o​r​> @doot sorry to bother you, is there any way I can register recipes at any point? [06:18:01 ERROR] [Sponge]: Could not pass GameStartedServerEvent$Impl to Plugin{id=minuhc, name=MinUHC, version=1.0, source=mods\MinUHC-1.0.jar} java.lang.IllegalStateException: Cannot register additional Recipes at this time! Recipes can only be registered before Initialization! I'm doing this right now:
05:22:01 Spongie Sponge.getRegistry().getCraftingRecipeRegistry().register(...);
05:23:22 Spongie <d​o​o​t​> I think you are to register during GameRegistryEvent.Register<CraftingRecipe>
05:23:47 Spongie <A​e​r​o​c​e​t​> authors = arrayOf("Aerocet"), dependencies = arrayOf(Dependency(id = "packetgate")) is this how it is supposed to be in Kotlin?
05:23:53 Spongie <A​e​r​o​c​e​t​> it converted it to arrayOf
05:24:10 Spongie <d​o​o​t​> you can also do ["Aerocet"], a shorthand for only annotations
05:24:22 Spongie <A​e​r​o​c​e​t​> ooh okay cool
05:24:28 Spongie <A​e​r​o​c​e​t​> gosh so many things to learn
05:24:33 Spongie <d​o​o​t​> Kotlin is a real beauty
05:25:23 Spongie <D​a​r​k​F​a​c​t​o​r​> Yep, if the server I work for wasn't using Java by convention I'd love using it
05:25:35 Spongie <d​o​o​t​> Kotlin has seamless java interop
05:25:35 Spongie <A​e​r​o​c​e​t​> java @Listener fun onGameInit(event: GameInitializationEvent) { } am I doing this right
05:25:37 Spongie <D​a​r​k​F​a​c​t​o​r​> Had to learn it a few months ago XD
05:25:39 Spongie <d​o​o​t​> yea
05:26:04 Spongie <D​a​r​k​F​a​c​t​o​r​> @doot yeah, but most devs in the server use Java and they don't want to learn Kotlin :P <@77393884925132800>
05:26:07 Spongie <A​e​r​o​c​e​t​> ooh there's a kotlin colorizer
05:26:28 Spongie <d​o​o​t​> Kotlin == Java 2.0
05:26:48 Spongie <A​e​r​o​c​e​t​> so... why are those text functions nexessary?
05:26:57 Spongie <d​o​o​t​> "hello green text".green()
05:26:57 Spongie <A​e​r​o​c​e​t​> TextColors.whatever doesn't work?
05:27:04 Spongie <d​o​o​t​> they are extension functions
05:27:08 Spongie <A​e​r​o​c​e​t​> ohhh
05:27:09 Spongie <A​e​r​o​c​e​t​> right
05:27:19 Spongie <A​e​r​o​c​e​t​> so
05:27:24 Spongie <A​e​r​o​c​e​t​> how do I utilize those
05:27:33 Spongie <A​e​r​o​c​e​t​> I saw the video on extending functions
05:27:36 Spongie <d​o​o​t​> Like I put
05:27:47 Spongie <d​o​o​t​> Do you mean how to write them or how to use them?
05:27:51 Spongie <A​e​r​o​c​e​t​> where the dude was like BigDecimal(100)? no. 100.bd
05:28:19 Spongie <A​e​r​o​c​e​t​> yeah just how do you use those? is it a dependency?
05:28:23 Spongie <A​e​r​o​c​e​t​> or do I need it in my plugin
05:28:32 Spongie <d​o​o​t​> you put it in your plugin
05:28:50 Spongie <A​e​r​o​c​e​t​> so if I copy that class over, is it available everywhere?
05:28:54 Spongie <d​o​o​t​> yea
05:29:01 Spongie <d​o​o​t​> and IntelliJ should discover all of the extension functions on a class when you autocomplete
05:29:24 Spongie <A​e​r​o​c​e​t​> so I guess I'll put it in a util packag
05:29:46 Spongie <d​o​o​t​> I have a ton of extensions so I put mine in a sub module
05:30:06 Spongie <A​e​r​o​c​e​t​> how you do dat
05:30:22 Spongie <d​o​o​t​> gradle and intellij modules
05:30:48 Spongie <A​e​r​o​c​e​t​> haven't used them before 😛
05:30:58 Spongie <d​o​o​t​> These are also nice extensions to have: kotlin fun <T> Optional<T>.unwrap(): T? = this.orElse(null) fun <T : Any> T?.wrap(): Optional<T> = Optional.ofNullable(this)
05:31:16 Spongie <A​e​r​o​c​e​t​> uhhhh
05:31:26 Spongie <D​a​r​k​F​a​c​t​o​r​> In DLang there's also something like that
05:31:37 Spongie <D​a​r​k​F​a​c​t​o​r​> @doot take a look at DLang, you may like it :P
05:31:43 Spongie <d​o​o​t​> I've looked at it before
05:31:48 Spongie <d​o​o​t​> Don't really have a need for it
05:31:56 Spongie <A​e​r​o​c​e​t​> so that returns the object in the optional if T is not null... or else what
05:32:15 Spongie <d​o​o​t​> if I need to do any native stuff I'd use either kotlin native or nim
05:32:37 Spongie <d​o​o​t​> unwrap converts an optional to a nullable object
05:33:01 Spongie <d​o​o​t​> Kotlin idioms recommend you use nullable types instead of optionals
05:33:37 Spongie <A​e​r​o​c​e​t​> interesting
05:33:53 Spongie <A​e​r​o​c​e​t​> how do I use a submodule?
05:34:24 Spongie <d​o​o​t​> File > New > Module
05:34:29 Spongie <A​e​r​o​c​e​t​> oh
05:34:35 Spongie <A​e​r​o​c​e​t​> I think I can do it in project structure too
05:35:11 Spongie <A​e​r​o​c​e​t​> what should the groupid and artifactid be :thinkcorn:
05:35:18 Spongie <d​o​o​t​> Any code you write in intellij is in a module
05:35:26 Spongie <A​e​r​o​c​e​t​> yeah i'm familiar with main and test
05:35:30 Spongie <d​o​o​t​> a project contains modules
05:35:31 Spongie <A​e​r​o​c​e​t​> but obviously i ignore that and just use main
05:35:56 Spongie <A​e​r​o​c​e​t​> submodules get combined with everything else on compilation?
05:36:03 Spongie <d​o​o​t​> groupid should be the same, artifactid usually <basemodule>-<something>
05:36:10 Spongie <d​o​o​t​> Only if you tell gradle to do that
05:36:20 Spongie <A​e​r​o​c​e​t​> well if I want these colors to work properly
05:36:27 Spongie <A​e​r​o​c​e​t​> they have to be in there, no?
05:36:37 Spongie <d​o​o​t​> Just follow that
05:37:54 Spongie <D​a​r​k​F​a​c​t​o​r​> hmm... got this: java @Listener public void registerRecipe(final GameRegistryEvent.Register<CraftingRecipe> event) { event.register(getArrowShape(0)); event.register(getArrowShape(1)); event.register(getArrowShape(2)); } private CraftingRecipe getArrowShape(final int skip) { return ShapedCraftingRecipe.builder().rows(). row(skip,
05:37:54 Spongie Ingredient.of(ItemTypes.FLINT)). row(skip, Ingredient.of(ItemTypes.STICK)). row(skip, Ingredient.of(ItemTypes.FEATHER)). result(ItemStack.of(ItemTypes.ARROW, 8)).group("eight-arrows").build("shape-" + skip, MinUHC.getInstance()); } What am I missing? XD
05:37:59 Spongie <A​e​r​o​c​e​t​> do I want the cookbook color module to be put in the jar or not?
05:38:17 Spongie <D​a​r​k​F​a​c​t​o​r​> If you use it yep, I guess
05:38:17 Spongie <d​o​o​t​> you do
05:38:33 Spongie <A​e​r​o​c​e​t​> I'll come back to this, I want to write a class lol
05:39:18 Spongie <d​o​o​t​> people actually play UHC?
05:39:20 Spongie <d​o​o​t​> hmh
05:39:37 Spongie <D​a​r​k​F​a​c​t​o​r​> @doot yep, in the Spanish community +4000 people
05:40:21 Spongie <D​a​r​k​F​a​c​t​o​r​> It is weird at the beginning but in Kotlin unless you want some heritance, it's better to avoid classes in my experience @Aerocet
05:40:35 Spongie <d​o​o​t​> what
05:40:53 Spongie <d​o​o​t​> What would you replace classes with then
05:41:10 Spongie <d​o​o​t​> classes aren't just for inheritance; also encapsulation
05:41:51 Spongie <A​e​r​o​c​e​t​> my main class is going to be a class
05:41:57 Spongie <A​e​r​o​c​e​t​> my DAO is going to be an object
05:42:20 Spongie <A​e​r​o​c​e​t​> main classes are singletons anyway
05:42:21 Spongie <D​a​r​k​F​a​c​t​o​r​> hmmm... Well, I'd say a strong feature of kt is the usage of non-encapsulated methods
05:42:36 Spongie <D​a​r​k​F​a​c​t​o​r​> In case of Sponge maybe it's better to use classes
05:42:47 Spongie <A​e​r​o​c​e​t​> when would you ever use a non-encapsulated class
05:42:54 Spongie <A​e​r​o​c​e​t​> i would just put them in an object
05:43:26 Spongie <D​a​r​k​F​a​c​t​o​r​> In this case for example
05:43:28 Spongie <D​a​r​k​F​a​c​t​o​r​> https://cdn.discordapp.com/attachments/142425521391665153/521924963213508610/unknown.png
05:43:49 Spongie <D​a​r​k​F​a​c​t​o​r​> non-encapsulated methods, not classes I mean
05:44:03 Spongie <d​o​o​t​> You mean package level methods
05:44:06 Spongie <A​e​r​o​c​e​t​> i would convert static methods to methods within a singleton
05:44:23 Spongie <A​e​r​o​c​e​t​> aka an object
05:44:37 Spongie <D​a​r​k​F​a​c​t​o​r​> Hmmm... No, just methods for the global project
05:44:51 Spongie <A​e​r​o​c​e​t​> Like Util.isInAABB()
05:44:55 Spongie <A​e​r​o​c​e​t​> object method
05:44:59 Spongie <D​a​r​k​F​a​c​t​o​r​> I've got this as an example: java /** * Returns {@link ItemStack} with the specified data value (or damage) as an {@link ItemStack} * <b>Warning: beware of non-existing data/damage values!</b> * * @param stack {@link ItemStack} The item stack to be modified * @param dataValue {@link Integer} Data or damage value to be applied * @return {@link ItemStack} Modified item
05:44:59 Spongie stack */ public static ItemStack setDataValue(final ItemStack stack, final int dataValue) { return ItemStack.builder().fromContainer(stack.toContainer().set(DataQuery.of("UnsafeDamage"), dataValue)).build(); }
05:45:12 Spongie <d​o​o​t​> ^ That would be better as an extension method
05:46:15 Spongie <D​a​r​k​F​a​c​t​o​r​> In Kotlin you can just do kotlin fun setDataValue(stack: ItemStack, dataValue: Int): ItemStack = ItemStack.builder().fromContainer(...).build()
05:46:36 Spongie <D​a​r​k​F​a​c​t​o​r​> And you can use it wherever you want with just: setDataValue(...)
05:46:40 Spongie <d​o​o​t​> fun ItemStack.setDataValue(dataValue: Int): ItemStack = ItemStack.builder().fromContainer(...).build()
05:46:49 Spongie <D​a​r​k​F​a​c​t​o​r​> Ohh right
05:46:53 Spongie <D​a​r​k​F​a​c​t​o​r​> You can also do that
05:47:02 Spongie <d​o​o​t​> That is the idiomatic way
05:47:40 Spongie <D​a​r​k​F​a​c​t​o​r​> Yeah, sorry... I don't know terminology for development features XD (e.g. identifying functional programming)
05:48:01 Spongie <A​e​r​o​c​e​t​> why is one way better than the other lol
05:48:09 Spongie <A​e​r​o​c​e​t​> ItemStack isn't your objecty
05:48:19 Spongie <d​o​o​t​> But it the receiver you are operating on
05:48:33 Spongie <d​o​o​t​> That's the idea behind extension functions
05:49:09 Spongie <D​a​r​k​F​a​c​t​o​r​> java @Listener public void registerRecipe(final GameRegistryEvent.Register<CraftingRecipe> event) { event.register(getArrowShape(0)); event.register(getArrowShape(1)); event.register(getArrowShape(2)); } private CraftingRecipe getArrowShape(final int skip) { return ShapedCraftingRecipe.builder().rows(). row(skip,
05:49:10 Spongie Ingredient.of(ItemTypes.FLINT)). row(skip, Ingredient.of(ItemTypes.STICK)). row(skip, Ingredient.of(ItemTypes.FEATHER)). result(ItemStack.of(ItemTypes.ARROW, 8)).group("eight-arrows").build("shape-" + skip, MinUHC.getInstance()); } So @doot , do you know what I'm missing?
05:49:18 Spongie <A​e​r​o​c​e​t​> yeah the kotlin is missing
05:49:28 Spongie <D​a​r​k​F​a​c​t​o​r​> XDD
05:49:32 Spongie <d​o​o​t​> I have no idea because literally all you are posting is a code block
05:49:54 Spongie <D​a​r​k​F​a​c​t​o​r​> Okay, lemme write it better
05:52:00 Spongie <D​a​r​k​F​a​c​t​o​r​> Goal: changing the result of the recipe for arrows (I want 8 arrows instead of 4) What I'm getting: I still get 4 arrows Any log?: No, no errors are being logged Code: the above one + it registration java Sponge.getEventManager().registerListeners(this, new EightArrowsMode());
05:52:25 Spongie <d​o​o​t​> Honestly no idea because I haven't worked with recipes before
05:53:37 Spongie <D​a​r​k​F​a​c​t​o​r​> Do you know someone who might be able to help me? I've been dealing with this and googling stuff for a while :P
05:54:43 Spongie <A​e​r​o​c​e​t​> init {} gets run when the class is instantiated?
05:54:48 Spongie <d​o​o​t​> yea
05:56:41 Spongie <A​e​r​o​c​e​t​> java private void setupPool() { try { if (dataSource == null) { SqlService sql = Sponge.getServiceManager().provide(SqlService.class).get(); dataSource = sql.getDataSource(sql.getConnectionUrlFromAlias("dootsmells").get()); } } catch (SQLException e) { e.printStackTrace(); } } so here's a piece of shit code from java. how would you do this in Kotlin?
05:56:42 Spongie (there's a private DataSource dataSource; variable)
05:56:58 Spongie <D​a​r​k​F​a​c​t​o​r​> Do you use IDEA?
05:57:01 Spongie <A​e​r​o​c​e​t​> yeah
05:57:03 Spongie <d​o​o​t​> great alias
05:57:07 Spongie <A​e​r​o​c​e​t​> oh does it translate it automatically
05:57:08 Spongie <D​a​r​k​F​a​c​t​o​r​> Copy paste it
05:57:10 Spongie <D​a​r​k​F​a​c​t​o​r​> Yep
05:57:11 Spongie <A​e​r​o​c​e​t​> ugh that sounds awful
05:57:21 Spongie <D​a​r​k​F​a​c​t​o​r​> Nah, then change what may be changed
05:57:34 Spongie <d​o​o​t​> need more than just setupPool()
05:57:37 Spongie <A​e​r​o​c​e​t​> it changed nothing
05:58:20 Spongie <A​e​r​o​c​e​t​> so the variable would be val dataSource: DataSource
05:58:21 Spongie <D​a​r​k​F​a​c​t​o​r​> Btw, check this for that null https://kotlinlang.org/docs/reference/null-safety.html
05:58:28 Spongie <D​a​r​k​F​a​c​t​o​r​> Yep
05:59:17 Spongie <d​o​o​t​> yea no idea not enough information
05:59:24 Spongie <A​e​r​o​c​e​t​> property must be initialized or be abstract
05:59:35 Spongie <d​o​o​t​> lateinit var dataSource: DataSource
05:59:43 Spongie <A​e​r​o​c​e​t​> var instead of val
05:59:57 Spongie <A​e​r​o​c​e​t​> oh it has to be
06:00:04 Spongie <d​o​o​t​> lateinit var dataSource: DataSource = DataSource dataSource;
06:00:16 Spongie <A​e​r​o​c​e​t​> and... it technically can be null but it won't ever be so do I care
06:00:33 Spongie <d​o​o​t​> if it won't ever be then use lateinit
06:00:43 Spongie <A​e​r​o​c​e​t​> what's the alternative
06:00:52 Spongie <A​e​r​o​c​e​t​> if Sponge for some reason decides to close the SQL shop
06:00:53 Spongie <d​o​o​t​> var dataSource: DataSource? = null
06:01:06 Spongie <d​o​o​t​> but then you have to deal with nullable types
06:01:11 Spongie <d​o​o​t​> which can be annoying sometimes
06:01:30 Spongie <A​e​r​o​c​e​t​> so... if I use lateinit
06:01:38 Spongie <A​e​r​o​c​e​t​> it's saying that this is not null
06:01:44 Spongie <A​e​r​o​c​e​t​> but... what if I don't define it
06:01:57 Spongie <d​o​o​t​> then when you try to access it, it throws an exception
06:02:30 Spongie <A​e​r​o​c​e​t​> try/catch is the same?
06:02:37 Spongie <d​o​o​t​> yea
06:02:56 Spongie <A​e​r​o​c​e​t​> those annotations are just examples right
06:03:05 Spongie <A​e​r​o​c​e​t​> or do those do something
06:03:10 Spongie <d​o​o​t​> from a unit testing framework
06:03:31 Spongie <A​e​r​o​c​e​t​> alright so I'll say that it could possibly be null because Sponge suggests it
06:03:53 Spongie <d​o​o​t​> whatever you think; I don't have enough information to properly help
06:04:24 Spongie <A​e​r​o​c​e​t​> it's just the SqlService setup
06:04:28 Spongie <A​e​r​o​c​e​t​> literally copy/pasted from the docs
06:04:32 Spongie <A​e​r​o​c​e​t​> SqlService::class.java is interesting
06:04:58 Spongie <A​e​r​o​c​e​t​> so instead of .get(), I would use .unwrap() with the extension
06:05:14 Spongie <d​o​o​t​> Those do 2 different things
06:05:29 Spongie <A​e​r​o​c​e​t​> oh
06:05:37 Spongie <d​o​o​t​> get() retrieves it or throws an exception
06:05:44 Spongie <d​o​o​t​> unwrap() retrieves it or returns null
06:05:54 Spongie <A​e​r​o​c​e​t​> got it
06:07:23 Spongie <A​e​r​o​c​e​t​> so because my class is an object (Pool, for example) and I have a function (getConnection), I can just do Pool.getConnection() anywhere
06:09:22 Spongie <A​e​r​o​c​e​t​> Apparently Kotlin is flying in the face of Java's Connection#getConnection method
06:09:33 Spongie <A​e​r​o​c​e​t​> use property syntax
06:09:47 Spongie <d​o​o​t​> Pool.connection
06:10:00 Spongie <A​e​r​o​c​e​t​> wait what
06:12:05 Spongie <A​e​r​o​c​e​t​> so because the object I'm returning is a field within DataSource, I can use the kotlin magic to get it instead
06:12:21 Spongie <A​e​r​o​c​e​t​> and not use Java's getter
06:12:25 Spongie <A​e​r​o​c​e​t​> cute
06:20:33 Spongie <A​e​r​o​c​e​t​> kotlin val connection: Connection get() { return dataSource!!.connection }
06:20:36 Spongie <A​e​r​o​c​e​t​> uhh
06:21:10 Spongie <d​o​o​t​> val connection: Connection get() = dataSource!!.connectionsimplified
06:21:19 Spongie <A​e​r​o​c​e​t​> oh right
06:22:08 Spongie <A​e​r​o​c​e​t​> wait so... how do I get to that value from another class
06:22:54 Spongie <d​o​o​t​> Pool.connection
06:22:59 Spongie <A​e​r​o​c​e​t​> oh 😮
06:23:02 Spongie <A​e​r​o​c​e​t​> right
06:23:06 Spongie <d​o​o​t​> like a field
06:23:36 Spongie <A​e​r​o​c​e​t​> yeah but I would've had a private field and a public getter
06:23:52 Spongie <A​e​r​o​c​e​t​> intredasting
06:24:29 Spongie <A​e​r​o​c​e​t​> wait..
06:24:59 Spongie <A​e​r​o​c​e​t​> uh
06:25:07 Spongie <A​e​r​o​c​e​t​> this seems bizarre
06:25:25 Spongie <A​e​r​o​c​e​t​> the Connection#getConnection method and what I did are the same?
06:25:50 Spongie <A​e​r​o​c​e​t​> java public interface DataSource extends CommonDataSource, Wrapper { /** * <p>Attempts to establish a connection with the data source that * this {@code DataSource} object represents. * * @return a connection to the data source * @exception SQLException if a database access error occurs * @throws java.sql.SQLTimeoutException when the driver has determined that the * timeout value specified
06:25:50 Spongie by the {@code setLoginTimeout} method * has been exceeded and has at least tried to cancel the * current database connection attempt */ Connection getConnection() throws SQLException;
06:26:12 Spongie <A​e​r​o​c​e​t​> is the same as val connection: Connection get() = dataSource!!.connection?
06:26:33 Spongie <A​e​r​o​c​e​t​> (X) Doubt
06:26:49 Spongie <d​o​o​t​> mhm
06:27:20 Spongie <A​e​r​o​c​e​t​> wow
06:27:22 Spongie <A​e​r​o​c​e​t​> okay then
06:28:12 Spongie <A​e​r​o​c​e​t​> @doot have you used Exposed
06:28:15 Spongie <A​e​r​o​c​e​t​> the library
06:28:17 Spongie <d​o​o​t​> mhm
06:28:22 Spongie <d​o​o​t​> I am currently using it
06:29:00 Spongie <A​e​r​o​c​e​t​> what does that handle? do I need to worry about closing the connection, the prepared statement, and the result set every time?
06:29:21 Spongie <d​o​o​t​> Just pass it the datasource
06:29:25 Spongie <d​o​o​t​> instead of connection
06:29:29 Spongie <A​e​r​o​c​e​t​> oh okay
06:29:36 Spongie <d​o​o​t​> it should close everything for you
06:30:06 Spongie <A​e​r​o​c​e​t​> and you use guice w/ kotlin right
06:30:16 Spongie <d​o​o​t​> mhm
06:31:00 Spongie <A​e​r​o​c​e​t​> i have about 25 kotlin-related tabs open
06:31:17 Spongie <A​e​r​o​c​e​t​> oh another question 😄 how do you handle async db queries?
06:31:25 Spongie <A​e​r​o​c​e​t​> I was using consumers
06:31:39 Spongie <d​o​o​t​> I've just been doing sync for now
06:31:46 Spongie <A​e​r​o​c​e​t​> oh there's no impact?
06:32:01 Spongie <d​o​o​t​> Barely any when using h2
06:32:05 Spongie <A​e​r​o​c​e​t​> ahh okay
06:32:14 Spongie <A​e​r​o​c​e​t​> I'll use consumers just in case
06:32:39 Spongie <d​o​o​t​> or coroutinea
06:33:08 Spongie <A​e​r​o​c​e​t​> is that part of 1.3 or a separate library
06:33:34 Spongie <d​o​o​t​> I adapted coroutines to use Tasks
06:33:42 Spongie <A​e​r​o​c​e​t​> why o-o
06:35:10 Spongie <d​o​o​t​> kotlin task(plugin) { switchContext(SyncContext.ASYNC) // Do Async stuff switchContext(SyncContext.SYNC) // Do sync stuff }
06:35:26 Spongie <d​o​o​t​> I love coroutines
06:35:35 Spongie <A​e​r​o​c​e​t​> i don't understand that lol
06:35:56 Spongie <d​o​o​t​> // Do async stuff runs that block of code in an async sponge task
06:36:01 Spongie <d​o​o​t​> sync for a sync sponge task
06:36:20 Spongie <A​e​r​o​c​e​t​> interesting
06:36:43 Spongie <A​e​r​o​c​e​t​> is that part of kotlin 1.3?
06:36:47 Spongie <A​e​r​o​c​e​t​> coroutines
06:37:04 Spongie <d​o​o​t​> coroutines are but not the sponge task integration
06:37:18 Spongie <A​e​r​o​c​e​t​> I knew that 😛 I'm tired
06:37:36 Spongie <A​e​r​o​c​e​t​> ok so compile("org.jetbrains.exposed", "exposed", "0.11.2") isn't letting me use it
06:37:40 Spongie <A​e​r​o​c​e​t​> under dependeicies
06:37:42 Spongie <d​o​o​t​> you need the repo
06:37:48 Spongie <A​e​r​o​c​e​t​> ohh okay
06:37:52 Spongie <d​o​o​t​> jcenter()
06:38:13 Spongie <d​o​o​t​> I wish exposed had builtin async support
06:38:31 Spongie <d​o​o​t​> ohhh thats why i was using cassandra before
06:38:40 Spongie <d​o​o​t​> welp looks like im gonna switch back
06:38:40 Spongie <A​e​r​o​c​e​t​> it's working
06:38:48 Spongie <A​e​r​o​c​e​t​> to cassandra? from exposed?
06:38:54 Spongie <d​o​o​t​> yea
06:39:19 Spongie <A​e​r​o​c​e​t​> so my dataSource variable needs to not be private lol
06:39:58 Spongie <d​o​o​t​> I've been switching between so many databases
06:40:06 Spongie <d​o​o​t​> I think I'm just gonna pick cassandra and stick with it
06:40:07 Spongie <A​e​r​o​c​e​t​> kotlin object dooty { init { Database.connect(Pool.dataSource!!) } }
06:40:12 Spongie <A​e​r​o​c​e​t​> and then do things
06:40:20 Spongie <d​o​o​t​> yea yell it
06:40:23 Spongie <d​o​o​t​> data source !!!!!!!
06:40:27 Spongie <A​e​r​o​c​e​t​> LOL
06:40:29 Spongie <A​e​r​o​c​e​t​> i have no fuckin choice
06:40:33 Spongie <A​e​r​o​c​e​t​> it's nullable
06:40:35 Spongie <d​o​o​t​> yea
06:41:07 Spongie <A​e​r​o​c​e​t​> I love !=== too
06:41:21 Spongie <A​e​r​o​c​e​t​> like "don't fuckin touch me whatever is on the other side of this equal shaft`
06:41:31 Spongie <d​o​o​t​> "equal shaft"
06:41:38 Spongie <A​e​r​o​c​e​t​> it's long as hell
06:41:52 Spongie <d​o​o​t​> they should make it =!=
06:43:43 Spongie <A​e​r​o​c​e​t​> so checking if an initially null object is null in the init {} of a singleton is pointless
06:43:49 Spongie <A​e​r​o​c​e​t​> because it'll always be null on init
06:44:37 Spongie <d​o​o​t​> I love kotlin kotlin override fun execute(src: CommandSource, args: CommandContext): CommandResult { src.mustBePlayer() // "src" is now the type Player ... }
06:45:03 Spongie <A​e​r​o​c​e​t​> wait is that an extension you made
06:45:19 Spongie <d​o​o​t​> kotlin @UseExperimental(ExperimentalContracts::class) fun CommandSource.mustBePlayer(): Player { contract { returns() implies (this@mustBePlayer is Player) } if (this !is Player) { throw CommandException("You must be a player to use that command.".text) } return this }
06:45:28 Spongie <A​e​r​o​c​e​t​> @UseExperimental(ExperimentalContracts::class)
06:45:36 Spongie <A​e​r​o​c​e​t​> <a:6662_PepeHowdy:515290673814044706>
06:45:53 Spongie <d​o​o​t​> contract helps the compiler understand what a type is after the function is called
06:46:06 Spongie <A​e​r​o​c​e​t​> oh that's the subject to change thing I saw
06:46:19 Spongie <d​o​o​t​> aka experimental
06:46:33 Spongie <A​e​r​o​c​e​t​> so you put this in a class in a submodule
06:46:41 Spongie <d​o​o​t​> yup
06:46:50 Spongie <A​e​r​o​c​e​t​> that's hot af
06:46:52 Spongie <A​e​r​o​c​e​t​> holy shit
06:47:10 Spongie <A​e​r​o​c​e​t​> this is going to make my command executors like 10x smaller
06:47:18 Spongie <d​o​o​t​> I organize all my extensions into files named after the receiver
06:47:40 Spongie <A​e​r​o​c​e​t​> that is cool
06:47:49 Spongie <A​e​r​o​c​e​t​> how do you configure it to compile the module in
06:48:20 Spongie <d​o​o​t​> in your root settings.gradle you add include 'submodule'
06:48:50 Spongie <d​o​o​t​> and in your root build.gradle gradle dependencies { compile(':submodule') }
06:49:11 Spongie <d​o​o​t​> The colon is required
06:49:14 Spongie <A​e​r​o​c​e​t​> okay cool
06:49:19 Spongie <A​e​r​o​c​e​t​> i'll try it
06:49:25 Spongie <A​e​r​o​c​e​t​> what should I call the submodule
06:49:28 Spongie <A​e​r​o​c​e​t​> Extensions
06:49:41 Spongie <d​o​o​t​> I call mine mainproject-ext
06:49:47 Spongie <A​e​r​o​c​e​t​> oh okay
06:49:55 Spongie <A​e​r​o​c​e​t​> well the main module is main
06:50:02 Spongie <A​e​r​o​c​e​t​> main-ext lol
06:50:05 Spongie <d​o​o​t​> no
06:50:12 Spongie <A​e​r​o​c​e​t​> i know i'm just being picky
06:50:37 Spongie <A​e​r​o​c​e​t​> ARVEN
06:50:42 Spongie <A​e​r​o​c​e​t​> yeah I see
06:50:44 Spongie <d​o​o​t​> shortname for a longer
06:50:49 Spongie <A​e​r​o​c​e​t​> so you renamed your main module
06:50:52 Spongie <A​e​r​o​c​e​t​> to arven-core
06:50:57 Spongie <d​o​o​t​> the root module
06:51:07 Spongie <d​o​o​t​> and I didn't rename it
06:51:08 Spongie <A​e​r​o​c​e​t​> ohhhhh
06:51:12 Spongie <d​o​o​t​> I named it when I created the project
06:51:15 Spongie <A​e​r​o​c​e​t​> it's a module in a module whoops
06:51:18 Spongie <d​o​o​t​> mhm
06:51:36 Spongie <d​o​o​t​> I don't do
06:51:59 Spongie <d​o​o​t​> when creating a project
06:52:04 Spongie <d​o​o​t​> I do the Gradle option
06:54:41 Spongie <A​e​r​o​c​e​t​> i totally just messed something up
06:54:50 Spongie <A​e​r​o​c​e​t​> the module appeared in the root and everything vanished 😄
06:55:01 Spongie <d​o​o​t​> :blobfasthrmm:
06:56:10 Spongie <A​e​r​o​c​e​t​> not the slightest clue
06:56:21 Spongie <A​e​r​o​c​e​t​> alright deleting project, starting again tomorrow lol
06:56:34 Spongie <A​e​r​o​c​e​t​> good learning was done
06:56:39 Spongie <d​o​o​t​> <a:ablobcatsleep:397082489484607490>
07:03:43 Spongie <A​e​r​o​c​e​t​> oh and i’m 100% for using the experimental stuff, but you could’ve just done isPlayer() and returned a boolean src instanceof Player
07:03:51 Spongie <A​e​r​o​c​e​t​> lol
07:04:08 Spongie <A​e​r​o​c​e​t​> or just processed it all in the extension
07:04:11 Spongie <A​e​r​o​c​e​t​> without the contract
07:04:22 Spongie <d​o​o​t​> nope not the same thing
07:04:37 Spongie <d​o​o​t​> with contracts, it smart casts it
07:05:21 Spongie <A​e​r​o​c​e​t​> oh
07:05:23 Spongie <d​o​o​t​> else without contracts I would have to copy and paste the entire method body into every command executor
07:05:23 Spongie <A​e​r​o​c​e​t​> eh
07:05:45 Spongie <A​e​r​o​c​e​t​> oh really
07:06:06 Spongie <A​e​r​o​c​e​t​> throwing an exception in the extension wouldn’t murder the command?
07:06:11 Spongie <A​e​r​o​c​e​t​> eh
07:06:25 Spongie <A​e​r​o​c​e​t​> you might be right, but that’s very kotlinny
07:06:43 Spongie <d​o​o​t​> kotlin if (src !is Player) { throw CommandException("You must be a player to use that command.".text) } vs kotlin src.mustBePlayer()
07:06:56 Spongie <A​e​r​o​c​e​t​> yeah i’m saying put that in an extension
07:07:16 Spongie <d​o​o​t​> thats literally what im doing
07:07:29 Spongie <A​e​r​o​c​e​t​> but the contract doesn’t seem necessary
07:07:35 Spongie <d​o​o​t​> yes it is
07:07:41 Spongie <d​o​o​t​> else I have to assign it to a new variable
07:07:49 Spongie <d​o​o​t​> or use it right away
07:07:59 Spongie <A​e​r​o​c​e​t​> hrmmmm
07:08:02 Spongie <A​e​r​o​c​e​t​> i’ll year tomorrow
07:08:13 Spongie <d​o​o​t​> Once I call src.mustBePlayer(), src is now a Player
07:09:45 Spongie <A​e​r​o​c​e​t​> KotlinConf Spinner by JetBrains https://itunes.apple.com/us/app/kotlinconf-spinner/id1291282375?mt=8
07:09:49 Spongie <A​e​r​o​c​e​t​> what the kotlin
07:10:17 <-- xcube (xcube!~xcube@ has quit (Ping timeout: 180 seconds)
07:12:13 Spongie <A​e​r​o​c​e​t​> do decompiled plugins put through a java decompiler make them look like java :ThonkAngery:
07:12:22 Spongie <A​e​r​o​c​e​t​> they would right
07:12:26 Spongie <A​e​r​o​c​e​t​> dumb question
07:14:35 <-- TheHiggsBozo (TheHiggsBozo!~thehiggsb@CPEa84e3fc982b3-CMa84e3fc982b0.cpe.net.cable.rogers.com) has quit (Ping timeout: 183 seconds)
07:15:08 Spongie <A​e​r​o​c​e​t​> wow it completely convolutes
07:15:43 Spongie <A​e​r​o​c​e​t​> kotlin bytecode is filthy lmao
07:18:58 --> TheHiggsBozo (TheHiggsBozo!~thehiggsb@CPEa84e3fc982b3-CMa84e3fc982b0.cpe.net.cable.rogers.com) joined the channel
07:20:00 Spongie <d​o​o​t​> because java is lackluster
07:23:17 Spongie <A​e​r​o​c​e​t​> true. i love seeing whacky weird flailing inflatable arm tube bytecode
07:23:45 Spongie <d​o​o​t​> otherwise known as mixin
07:23:57 Spongie <A​e​r​o​c​e​t​> it converts letters of strings into their uh.. \u00a+whatever form
07:24:02 Spongie <A​e​r​o​c​e​t​> because why not
07:24:26 Spongie <A​e​r​o​c​e​t​> hadn’t seen that before
07:28:53 <-- TheHiggsBozo (TheHiggsBozo!~thehiggsb@CPEa84e3fc982b3-CMa84e3fc982b0.cpe.net.cable.rogers.com) has quit (Ping timeout: 190 seconds)
07:32:27 --> TheHiggsBozo (TheHiggsBozo!~thehiggsb@CPEa84e3fc982b3-CMa84e3fc982b0.cpe.net.cable.rogers.com) joined the channel
08:07:02 <-- progwml6 (progwml6!~progwml6@ has quit (Ping timeout: 200 seconds)
08:09:46 --> progwml6 (progwml6!~progwml6@ joined the channel
08:09:46 -- Borg sets mode +o progwml6
09:05:02 <-- Cow_Fu (Cow_Fu!~CowFu@v-74-91-113-40.unman-vds.premium-chicago.nfoservers.com) has quit (Quit: ZNC 1.6.5 - http://znc.in)
09:05:02 <-- Dark_Arc (Dark_Arc!~DarkArc@v-74-91-113-40.unman-vds.premium-chicago.nfoservers.com) has quit (Quit: ZNC 1.6.5 - http://znc.in)
09:07:19 --> Cow_Fu (Cow_Fu!~CowFu@v-74-91-113-40.unman-vds.premium-chicago.nfoservers.com) joined the channel
09:07:49 --> Dark_Arc (Dark_Arc!~DarkArc@v-74-91-113-40.unman-vds.premium-chicago.nfoservers.com) joined the channel
09:07:54 -- Borg sets mode +v Dark_Arc