#dev-general
1 messages ยท Page 154 of 1
Oh yes
Lmfao #738969308746612766

fingergun to you too
@heady birch thank you for vouch! The plugin will segfault if there are more than 3 players. I can't fix it. Have a nice day!
How does this look so far? https://github.com/ipsk/mf-msg/blob/master/src/main/java/me/mattstudios/mfmsg/base/Message.java
it's not kotlin so...
Well it's a lib so, i gotta suffer through Java
๐
๐
Gradient works noice
completely breaks the formatting though
the classic

matt is this just a fun project ur doing? im not sure why ur making it ๐
its very cool tho
It's going to be a lib, making it so i can use on my plugins but also for anyone else who wants to use
Would be a cool chat plugin
if clip wants he can use it
I really like the idea of having a convenient markdown-style language for mc chat. Let us know when it's public, I'll definitely use it
Yeah it seems very handy
Will definitely do!
Gonna have to change it a bit if i want to do gradient
Also a bit worried about performance, doesn't seem awful right now, but needs more tests
ok @chilly jungle after some thinking a found the issue in DM.. the /dm list is returning the wrong names...
for ex..
the real name is advanced_menu
KOTLIN
The blade can only be as sharp as your mind.
anyways i got a couple weirdass quotes that im gonna rant about in #off-topic
@obtuse gale needs to be banned
spam pinging everyone
@distant sun @chilly zenith
please hel p
@obtuse gale Wrong channel
๐ค
same
Does anyone know uses the leaderhead plugin?
Many people probably do
you ever just looking over your code and you remember a monstrosity of a method that you wrote not too long ago
https://prnt.sc/txjxqf
what have I done it just got worse https://prnt.sc/txjyjj
ended up renaming it to getPossibleStackableBlockMaterials() so I wouldn't keep making it worse
it was fun while it lasted
If you keep extending the name, there's a point it's more readable to just inline the stream method instead of wrapping it in another method
yeah I know, it's only ever used in one spot, I mostly just did it for organization but then it quickly grew into a joke
@prisma wave will it work 3.5 players we never reach 4
no
Any luck with mcdev?
whats the error again lol? Imma just ask it in the mc dev server
oof ok, the issue is with me tryna run the IDE in IJ i remember
fair enough
private void traverse(Criteria criteria) {
if (criteria instanceof CriteriaGroup) {
CriteriaGroup group = (CriteriaGroup) criteria;
for (Criteria subCriteria : group) {
traverse(criteria);
}
} else {
System.out.println(criteria);
}
}```
```java
Vs:
private void traverse(Criteria criteria) {
System.out.println(crtieria);
for (Criteria child : criteria.getChildren()) {
traverse(child);
}
}
NiallToday at 10:14 AM
Take into account here the api design, which is the best?
Because most criteria never have children
Only a few will
API is the criteria class
Two snippets are to show how the criteria is structured
Fellas, using Monitor and not actually modifying the state of the event just sending a message if a condition is met should be fine right? (To ensure nothing else modifies it afterwards)
fine
Any Kotlin Missionaries here? I could use some help
I have a little knowledge
kotlin good java bad
Can I use default values in the constructor parameters that take up values from previous parameters?
I dont know about that one
Say something like:
Person(var name: String, var birthName: String = name) {}
huh
Eclipse isn't throwing anything shady at me with this syntax so I guess it's fine:
class Context(val id: String, val type: ContextType, val priority: Int = type.priority) {}
Why you using eclipse with kotlin tho
thats like
one of the sins, kinda like maven with kotlin
Shush. I'm on vacation and my internet is too shitty to download IntelliJ ๐
thanks
Polymorphism fortunately isn't an OOP concept ๐ค
Ayy, IJ is cucked 
Using that material them again I bet
Remove the theme
material theme more like malicious theme
Darcula is literally fine
The theme has nothing to do with it
liberals owned
Spending more time using that theme than writing
material good
Delete the theme save time
Yeah but it doesnt use 4GB of ram
bet
800GB, ah yes ofc
That's 809MB, that's not that much
Material theme
Holy god of packages...... w......
Piggy, it phisically can't use more
593mb
phisically
Kill me
pls
good design
because the author clearly has no regard for other developers
:)
Yugi, have you seen GriefPrevention lmao?
Btw finally done with my rocket
nothing beats slimefun
Also, I just realized the one thing america doesnt have a diff unit for than the other countries.... data
What do you recommend me for flame particles?
Yugi, have you seen GriefPrevention lmao?
Not yet xD im scared now
Go check
oh god
I wanted to cry
Wish me luck, diving in gp
And sorry for the sound but yeah it does that when my mic is muted
I PRed a fix yesterday, didn't include my package sorting cause it would probably break something, which I can't be bothered fixing
Yeah it is in the theme of vehicles
That is damn cool
It's a commission
Oh you have a galacticraft plugin damn
@hot hull had a look, My eyes are bleeding now. ๐ฉธ ๐
Ah okay
take a look at the vid on the readme, make sure it's what u want
Unfortunately I had to use armorstands for the model
My mind went ahhh
I spent my whole yesterday on this plugin
My laser tag was better Piggy 
pf
my plugin has great potential
the concept of modded in vanilla in general has great potential imo
Mars dimension
my plugin had the moon
Imagine if mc didn't have a 256 block height limit
or there was a way to bypass it in vanilla
Can I not send images too here?
=imgur
Please use imgur to share screenshots and other images.
โข Imgur
500+ lines of goddamn model lmao
ah yeah feelsbadman
Yeah I know it could be optimized I will do it later
I'm confused, like it legit doesn't show shit after this line
why couldn't you use an rp?
resource pack
resource pack
Oh because it had to be in the theme of vehicles
pure blocks is cool
I had a great project idea the other day
Not telling, it's got to do with either armor stands, or actual structures with entities
Vehicles is a plugin that uses armorstands too for mutliple vehicles
ah that narrows it down
Told the guy I've been doing plugins for, and let's see if he comes up with any ideas for it 
Also dan you can possibly reduce all that repeating part into a function
Yeah yeah as I said I can optimize the code but I wasn't looking at it while doing the model
It's just one day of work
hi frosty under the 2000 freedom of information act, for the sake of "vital to the functioning of a democratic society" you are required to tell me your idea
I am gonna finish it today
Niall, switch to material dark theme, and I'll think about it
lol
Lol
Get r3kt nerd
"He will never use material dark theme"
atom one dark at least
I found the issue, turns out IJ wasn't broken completelly, just acted weird when not casting an Object to a String
Wasn't there a way with intellij to make the repeating code into a function?
IJ ultimate duplicate checking can sometimes do that
We'll see what the guy decides it can be used for, and I'll perhaps show sneak peaks if I do work on it 
i was joking i dont really wanna know
Okay 
is 1.16.2 nms update?
๐ฎ
I think so, because of the Brute mob
Sad
@quiet depot what was the particle name for the flame ones you used?
wdym?
I am having a problem starting my server, its keeps giving the message:
FAILED TO BIND PORT
The exceptopm was: jave.net.BindException: Cannot assign requested adress: bind perhaps a server is already running on the port?
I get that message every time i try to start it :/
Go to code style and turn on the opacity or what'
theres already something running on that port
Yeah
also not really the right channel
@obtuse gale https://github.com/PiggyPiglet/GalactiBukkit/blob/master/src/main/java/me/piggypiglet/galacticraft/rocket/launch/lift/FireComponent.java lava
Yh found it already thanks anyway
Any cleaner ways I could approach this?
final ItemStack item = getItem(value);
switch (key) {
case "HELMET":
entityEquipment.setHelmet(item);
break;
case "CHESTPLATE":
entityEquipment.setChestplate(item);
break;
case "LEGGINGS":
entityEquipment.setLeggings(item);
break;
case "BOOTS":
entityEquipment.setBoots(item);
break;
case "HAND":
entityEquipment.setItemInHand(item);
}
its pretty nice
Map<String, EntityEquipmentApplier>
interface EntityEquipmentApplier {
apply(final EntityEquipment equipment, Item item);
}
map.put("HELMET", .........
sucks that people are actually recommending MineAcademy to these beginners who want to learn Java.
is it bad
@hot hull Save EquipmentSlot as the key, instead of a String
Then when you loop through the map you do entityEquipment.setItem(equipmentSlot, item)
Smart 
But String test is like barely highlighted
How can I make the String test look like the other one
https://github.com/Oribuin/Skyblock/blob/8cd3eda087c6dace46f0524f69c6de81db7425d6/src/main/java/xyz/oribuin/skyblock/commands/ExampleCommand.kt i will always love this
DeathRealms, have you played around with the codestyle?
I've looked at, don't really see anything related to that though
Maybe because of the color your line is, since the line is much darker than the rest it'd be harder to see the color so IJ changes it? Idk xD
Just set your background as darker if you want to enhance the text brightness
@remote goblet kill it
appreciate it
Or use Atom One Dark, since it's the superior theme
Material Oceanic best
That's ugly
Frosty ;p
Matt, you were working on a pets plugin right?
Yeah
How's it coming along?
great
Sheesh
I'll get back to working on it soon though, just gotta finish the messages lib, then update mf-gui, then work on mf, very little things
Then work on aliases 
When you fork a plugin, and then you clone it and everything is red (not due to a missing sdk, but actual errors)
When the plugin isnt in rust
@lunar cypress Hello reckon you could advise me on this
track_list is an Arc<RwLock<HashMap<i32, Track>>>
You need to use Arc::clone or whatever it's called and move that to the other thread
How do I declare the default getter as private and override it with a custom public one in Kotlin?
You don't, as far as I'm aware
When the member attribute is declared in the primary constructor
You don't, as far as I' aware
@lunar cypress Kotlin bad then...
When the member attribute is declared in the primary constructor
not possible
there is a workaround
although i'm not sure why you need this
class SomeClass(blah: Type) {
val blah = blah
get() = blah.something
}
``` ?
Well subclasses don't have access to private
@lunar cypress It has nothing to do with subclasses
You talked about overriding
overriding its own default getter
I basically don't want a getter for an attribute of a class
and a separate method to get and set the value
wait what
whatever, I think what Clojure did might work
write what you want to do in java
You don't want a getter but a method to get the value
I think the terminology you're using is a little misleading
Maybe I'm going at this all wrong
So I have a mutable map in a class
I don't want any outside class to be able to just change the values in the map directly
I want them to use methods to do it
so I want the map to be private
no not possible
and a getter and setter used to make changes within the map
nothing works
nothing works
@heady birch shut up ๐
but that's not a getter and setter?
Any reason why you don't want people to directly change the map?
but that's not a getter and setter?
@prisma wave No, it's not
error after error after error after error after error after error after error after error after error after error after error after error after error after error after error after error after error after error after error after error after error after error after error after error after error after error after error after error after error after error after error after error after with rust
I told you that's rust for you
๐
Btw you shouldn't modify the type of track list, just where it's used
Meh
@empty flint kotlin class ClassName(private val map: MutableMap<Blah, Blah>) { fun put(key: Blah, value: Blah) { map[key] = value } } ?
Playin around with those little life time thins
Any reason why you don't want people to directly change the map?
@hot hull Because I require a specific format for the map contents and if anybody can just input anything that's bad
restricting mutability good
@empty flint
kotlin class ClassName(private val map: MutableMap<Blah, Blah>) { fun put(key: Blah, value: Blah) { map[key] = value } }?
@prisma wave Yes, that's what I was thinking of. Ty. Didn't know you could set the private modifier in the parameters of the constructor
yeah lol
Need opinions, is this a good format?
modules?
Yeah, so for example if you don't want italic, you can disable it
hm
i would do a blacklist rather than a whitelist, because I can't think why you'd want that apart from in a few specific circumstances
or like
yeah, have it takes excluded rather than included modules
or both
static factory 
How's pdm going?
let first_ref = Arc::new(RwLock::new(HashMap::new()))
let second_ref = first_ref.clone() // move this to the other thread``` @heady birch
Is 0.0.2 out?
apart from the lack of relocation it's going pretty well
more than 0,.0.2 now
I had to skip 0.0.2 lol
were on 0.0.12 
I published to gradle and it failed and wouldn't let me try again
so I had to skip to 0.0.8 lmao
Can I get a TLDR of the changes from 0.0.1?
Was thinking about both yeah, just gotta think of a good way to do it
i would like that too
What's pdm?
downloads dependencies at runtime
Message.withModules(whitelist);
Message.withoutModules(blacklist);
This sounds pretty dumb right? xD
mostly bugfixes
the gradle plugin is a lot more reliable now (doesn't need kotlin plugin etc),
a few refactors (you use PDMBuilder instead of making a PluginDependencyManager now)
Johnny added some method that means you can do dependency loading before the plugin actually gets loaded
it supports parsing <parent> tags so things like Jackson should work
Matt, I'd have them all enabled, and then if they don't want certain bits, have a way to unregister the modules
and might be a little bit faster too
So can I just put this onLoad and let it do its thing now?
Yeah, but it doesn't make a difference unless you use code from dependencies on class load
Which is what I needed
Before any dependency is used
That's the most important part
Would make sense in onLoad rather than onEnable of course
normally you probably want onEnable just so you can callback any initialization
I would've thought 1.4 Kotlin be out by now.
๐ฆ
I know it's in RC
yeah it's close
Did you look at the stuff I sent you?
How he was downloading from json and just relocating when it's loaded it?
No callbacks needed if you just slap a join there ๐
Loaded in*
oh yeah, I'll probably end up doing something similar
Waiting on the day relocation works (:
although i'm gonna try and look into classpath isolation, which might be better than relocation
iirc lucko does something like that but only for a few dependencies
Never heard of that
I really hope that's possible bc it's probably a lot easier than relocation lol
So does that just mean you don't relocate in the shadowJar?
yeah I think it would mean that each plugin has its own classpath and can't interact with classes from other plugins
making relocation redundant
not sure how possible it is though
Might be more of a headache
Like this?
Yeah I ended up fixing the jar size by simply removing runtime from everything and then runtime Kotlin. That alone made the jar small enough ๐
that'll do it lol
What if you have compileOnly dependencies like apis from other plugins
Okay so July 27th was Kotlin 1.4RC
How do compile-time unknown generics work in Kotlin?
List<?> does not seem to be a thing
List<*> I think
ty
track_list is expected to remain throughout the program executiion
So I would make that <'static> right
No
You don't change its content
I found the perfect summary of discussions in this chat
Lol
Also Im kind of worried
I will be locking/unlocking this thousands of times a second
@lunar cypress and how would I get something from that Arc now?
For some reason my ide is playing up and thinks the type is my hashmap when its actually a RwLockReadGuard<TrackList>
my bad I actually need to write to it
well not to the hashmap
but the object in the hashmap
I dont want to deref it surely
๐คธโโ๏ธ
๐ฆฝ ๐๏ธโโ๏ธ
YES
don't really know where to put this, since it doesn't feel like a thing for #738969312051593249 ,
anyways,
i'm looking for someone to just chill with and code together, maybe show each other what were working on, or work on something together, just all around coding buddies, you know?
(im pretty new at this minecraft plugin dev thing, just fyi)
anyways, dm me
Someone send help!
eeeeeeeeeeee
Why is everything green yugi
You can change it sheesh, that's too much green
I have to finish this for server to open today and its fucking impossible to find where what happens
Thought you were doing the parser
obligatory /s, do whatever you want
what triggers me the most is the fact theres no space between the if
Yugi, have you checked out Grief Prevention?
Yes I am
Have to finish this
its just a simple ignore N deaths
But this shit is wired so badly god knows what happens when
Im just going to drop it in the beginning of EntityDeath listener and just hope it works ๐
@heady birch you should just be able to call functions on the arc directly
@lunar cypress https://github.com/knightzmc/pdm/blob/master/CHANGELOG.MD
And use read()/write() respectively
@prisma wave wrong date mate
Which is more appropriate, considering:
- lots of threads writing very quickly
- 1-2 reading every now and again
Well mutex works too but will be a lot less efficient
Ok yeah it may actually be more appropriate
Most recent comes first @prisma wave
I think
oh
Damn rust is neat
But gj bm
In most of my new projects I do that now too simply because leiningen auto generates such a changelog
Would be cool if GitKraken worked on 32bit
kite board OS
would be cool if frosty got a 64 bit system
Indeed it would :((
Hello who wants to help me on a design decision
frosty ur the reason why we still have 2 different installers for programs
I had my former computer science teacher install it on the school machines
Which were all still 32 bit
Must've missed an old versions tab then Johnny
Which is why I had the original GroupCriteria interface
because it seemed silly giving the pure Criteria interface children when most implementations wont have any
************ bump ************
Is there a kotlin way to do this better?
contextualValues.toSortedMap().values.first()
If contextualValues is an empty map it will result in a "NoSuchElementException". In java I'd check this with an inline-if
contextualValues.empty() ? null : contextualValues.toSortedMap().values.first()
Is there a kotlin expression that does something similar?
I want to avoid checking for emptiness in an if block if this is possible with a oneliner
Nvm
...firstOrNull()
is a thing
why isn't it a sorted map to begin with
Also, if is an expression if you didn't know
@prisma wave How do you mean?
oh interesting. so it's different from java there
cool
thanks
why isn't it a sorted map to begin with
@lunar cypress Right you are. Kotlin good. Blocky bad
Hm what's the best way to create a new empty map like a sorted map?
sortedMapOf<...>() ??
Or is there something like new SortedMap() ?
or SortedMap::new
or whatever
You can do something like val map = sortedMapOf(Pair("c", 3), Pair("b", 2), Pair("d", 1))
Copypasted it from the documentation xD
Ooh didnt know I could make pairs like that
๐
Is there a datastructure that is an order list equivalent where each element occurs only once in the list and every element of another collection or an enum or whatever has to occur in it?
that is incredibly specific
LinkedHashSet will preserve ordering and doesn't allow duplicates
Not sure about the final thing
How would it work if the original collection changed?
you're basically describing sets
if all elements of a set are contained within another set, you have a super/subset relation
you enforce that with checks, not by baking it into some data structure
I guess this isn't too bad, for constantly spamming the command
Very bad
Maybe I'm being stupid again but can somebody explain what the <init> in the kotlin doc actually means?
<init>(elements: Collection<E>)
How do I actually initialize this pos class? https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-linked-hash-set/-init-.html
there dpesn't seem to be a linkedHashSetOf(...) function
Is there a key in IJ to import everything in a class?
This is harder than I thought
Johnny
println!("{:06x} {:04x} {:08} {}",
track.address,
track.squawk.unwrap_or(-1),
track.call_sign.as_ref().unwrap_or(&"--".to_string()),
track.emergency_status.as_ref().unwrap_or(&EmergencyStatus::None).get_name());
Anyway to make squawk, call_sign and emergency status to give empty string
when they dont exist
Or should I just concatanate as usual
there dpesn't seem to be a linkedHashSetOf(...) function
Because that's what mutableSetOf is
@empty flint
or just setOf afaik
you sure?
Positive
Last I checked setOf and mutableSetOf used LinkedHashSet
Returns a new read-only set with the given elements. Elements of the set are iterated in the order they were specified. The returned set is serializable (JVM).
?
Idk maybe I'm confused by learning a new language rn
I might be mistaken but doesn't setOf... return a HashSet?
no
The function itself returns a Set
But I am confident that the implementation is LinkedHashSet
is there anyway to revert pvp to like 1.8 style for newer versions? Ive seen some attempts but nothing looks updated/well made
fair enough, know any that have given it a good attempt?
Forge can probably do it super well :^)
Hm how do I format this xD
liskov
please
newContextPriorities.size == ContextType.values().size pretty sure this check is unnecessary
lol
L
Nope, won't work
newContextPriorities.size == ContextType.values().sizepretty sure this check is unnecessary
@prisma wave You're right, because it's a HashSet...
So just the setter this time:
set(newContextPriorities: LinkedHashSet<ContextType>) {
if(newContextPriorities.containsAll(ContextType.values().asList())) {
contextPriorities = newContextPriorities
} else {
throw IllegalArgumentException("New context priorities failed to meet criteria. The new set has to contain each context type exactly once.")
}
}
Declaring as LinkedHashSet is kinda ew
Yes
is ContextType an enum?
Yes
hmm
I'm not sure how else to do it
I could give the enums some values that indicate the order
but then they would be fixed
and couldn't be changed anymore
So nothing cleaner then? That setter definition is fugly af
it's not great
I mean I guess I could do away with the else, negate the if and put the throw inside and the assignment outside
set(newContextPriorities: LinkedHashSet<ContextType>) {
if(!newContextPriorities.containsAll(ContextType.values().asList())) {
throw IllegalArgumentException("New context priorities failed to meet criteria. The new set has to contain each context type exactly once.")
}
contextPriorities = newContextPriorities
}
pretty sure you should use
field = newContextPriorities
@prisma wave I am
contextPriorities = newContextPriorities ?
ye
that's different
then I didn't understand what you mean
pretty sure you should use
field = newContextPriorities
@prisma wave What is that?
How do you make the primary constructor private?
private constructor(blah)
I ASK 3 times
ONE person reply
NO open source KITEBOARD
NO E-CLIUD
Default Description
I have no idea what you're on about, just gonna let you wear yourself out
you are mad
Cheese
Lmao
MOON!
Not cheese
Please remove my previous messages I have come to my senses
Told ya he'd recover shortly
private constructor(blah)
@prisma wave If I do not specify a constructor?
class Context(val id: String, val type: ContextType) : Comparable<Context> {
how do I make this constructor private?
class Context private constructor(val id: String, val type: ContextType)
better than java
Yes, every time.
Welcome to the circlejerk
Am I missing something?
String name = Bukkit.getOfflinePlayer(f.getKey()).getName() || "Unkown";
why have you got the or operator there?
I'm wanting "Unknown" to be returned if Bukkit.getOfflinePlayer(f.getKey()).getName() is null
buuuurrrr
val name = Bukkit.getOfflinePlayer(f.key).name ?: "Unknown"``` in kotlin, come over to us Molloy
You can do
Bukkit.getOfflinePlayer(f.getKey()).getName() != null ? Bukkit.getOfflinePlayer(f.getKey()).getName() : "Unknown"
or save Bukkit.getOfflinePlayer(f.getKey()).getName() in a variable and do the above thing with the variable
uh no you can't
Or switch to Kotlin. I'm slowly starting to believe
@prisma wave If you teach me - sure ๐
uh no you can't
@prisma wave Sure you can
Teach me the fundamentals, and get my kick started.
@empty flint you edited it, that's cheating
@lavish notch val a = 3 = final int a = 3;
that's all you need to start
a lot is similar to Java
the kotlin docs are really good
any questions ask me and I'll write a paragraph or something
Bossman loves his free xp
i do
@empty flint you edited it, that's cheating
@prisma wave It's called delayed compilation
@lavish notch I watched https://www.youtube.com/watch?v=SXLmr4Qp4OM and got the basics down. It's hands-on learning after that
Whenever i see this message I always think it sounds weird to have "return void" lmao
What's the most efficient way to create a leaderboard?
ConfigurationSection cf = main.getplayerData();
cf.getValues(false)
.entrySet()
.stream()
.sorted((a1, a2) -> {
int points1 = (int) a1.getValue();
int points2 = (int) a2.getValue();
return points2 - points1;
})
.limit(3) // Limit the number of 'results'
.forEach(f -> {
int points = (int) f.getValue();
System.out.println(f.getKey() + " " + points);
String name = Bukkit.getOfflinePlayer(f.getKey()).getName() != null ? Bukkit.getOfflinePlayer(f.getKey()).getName() : "Unknown";
p.sendMessage(name + " " + points);
});
I have that - but it lags the server
it won't do much for performance but I'm fairly sure you can prettify the sort lambda to ((a1, a2) -> a1.getValue().compareTo(a2.getValue())) or something of the sorts. It's definitely a one-liner.
In the forEach lambda, try to remove the second bukkit offline player call like so:
.forEach(f -> {
int points = (int) f.getValue();
System.out.println(f.getKey() + " " + points);
String name = Bukkit.getOfflinePlayer(f.getKey()).getName();
p.sendMessage((name != null ? name : "Unknown") + " " + points);
}
Getting Player or OfflinePlayer by name is deprecated. You're supposed to get them via UUID
The thing is you can't really get the UUID if the player is offline ๐
There is a trick tho
another good spigot api design
You could get the UUID from name via a Mojang API call, but thats prolly slower than just getting by name in the first place
Anyone else have that frustration when a plugin is like .3 over the discord upload limit
Nope
You could get the UUID from name via a Mojang API call, but thats prolly slower than just getting by name in the first place
that's what getOfflinePlayer does behind the scenes iirc
just with caching
nitro 
You could get the UUID from name via a Mojang API call, but thats prolly slower than just getting by name in the first place
@errant geyser I think that's exactly what I was doing
Anyone else have that frustration when a plugin is like .3 over the discord upload limit
@hot hull Why would you upload a plugin to Discord?
to send it to whichever kiddo wants it
Why would you upload it to GH or some shit when it's gonna be used by a single person?
Hm should I go with the == nullcheck or with ===?
if(worldUuid != null && network == null && rank == null) or if(worldUuid !== null && network === null && rank === null) ?
==
@empty flint so can I fetch a username faster with getOfflinePlayers with a uuid?
or does it not return UUIDs?
returns this currently
OfflinePlayer[] players = Bukkit.getOfflinePlayers();
p.sendMessage(String.valueOf(players));
String.join(", ", players)
wat
@lavish notch here's my piece of code:
https://hastebin.com/usuyefoyoq.cs
replace String.valueOf(players) with that
Cannot resolve method 'join(java.lang.String, org.bukkit.OfflinePlayer[])'
What string are you importing?
OfflinePlayer[] players = Bukkit.getOfflinePlayers();
Some wack thing
You can also do players.stream().collect(Collectors.joining(", "))
ew streams
So what exactly does getOfflinePlayers return?
final List<OfflinePlayer> playerList = Arrays.asList(Bukkit.getServer().getOfflinePlayers());
String result;
for (int i = 0; i < playerList.length; i++) {
if (i == playerList.length -1) {
result = result + player.getName() + ".";
continue;
}
result = result + player.getName() + ", ";
}
boom
It returns an array Mackenzie
final List<OfflinePlayer> playerList = Arrays.asList(Bukkit.getServer().getOfflinePlayers());
String result;
for (int i = 0; i < playerList.length; i++) {
if (i == playerList.length -1) {
result = result + player.getName() + ".";
continue;
}
result = result + player.getName() + ", ";
}
@hot hull I just vomited a little in my mouth
That was the point
There isn't a more simpler and, less taxing way?
Not really taxing
fucking hell
It's not gonna affect performance at all
to make it simpler just make it a method and never look at it again
Or use kotlin, <insert code here @prisma wave>
kotlin?!?!!?
kotlin good 
@lavish notch I really think that String.join(...) is the simplest thing ^^ https://www.geeksforgeeks.org/java-string-join-examples/
1.8 is very fun to develop on
is that sarcastic
nahhh, not at all
1.8 is very fun to develop on
@versed ridge Why would you even...?
making a plugin for someone that's on 1.8
implement fuck-1.8 :)
ah yes, good idea
Not gonna lie, it's almost impossible finding a commission which isn't 1.8 these days
very sad
Just need to know where to look.
Nah Glare, for you it might be easy since people throw them at you, and wouldn't consider having it public otherwise
Ah you're doing commissions. Got it. I was just about to say I would not develop on 1.8 for free ๐
Not like I'm complaining, I've had constant commissions for the past 2-3 months so 
Wouldn't consider having it public otherwise
Wdym?
ie. request-paid, most are 1.8 ones, I've had some people dm me asking for a non 1.8 commission, which they didn't consider putting in there, as an example
Ohhh, I get what you mean.
You famous 
I often do try to pass on commissions to other people that I don't have time for. If I know someone is looking, I will consider them to pass it on to.
https://discordapp.com/channels/164280494874165248/695431668944732270/742855509715189788
Bukkit.getServer().getOfflinePlayers().stream()
.map(OfflinePlayer::getName)
.filter(Objects::isNotNull)
.collection(Collectors.joining(", "));```
js
^
https://discordapp.com/channels/164280494874165248/695431668944732270/742855509715189788
Bukkit.getServer().getOfflinePlayers().stream().map(OfflinePlayer::getName).filter(Objects::isNotNull).collection(Collectors.joining(", "));
@distant sun If that piece of code was a hotdog and you were a vendor, I would buy that hotdog
or well frosty it can
it can, but it will never be
Unless you're doing some jank shit and modifying it yourself
Avoid NPE, don't cause them.
Bukkit.getOfflinePlayers()
.filterNotNull()
.map { it.name }
.joinToString()
``` ๐
Well pretty sure getOfflinePlayers wouldn't give you any OfflinePlayer with a nullable name
still better than what you had initially ๐
streams is meh
Yall wanna see some ugly ass piece of code?
sure
๐คท
whats that
Frcsty
how do people use abstract classes for their plugin api?
is that a rhetorical question?
no
how do u use api gaby ๐ฎ
uh
if(rank != null) {
if(network != null) {
if(worldUuid != null) {
return ContextType.RANK_IN_NETWORK_ON_WORLD
}
return ContextType.RANK_IN_NETWORK
}
return ContextType.RANK
} else if(network != null) {
if(worldUuid != null) {
return ContextType.NETWORK_ON_WORLD
}
return ContextType.NETWORK
}
return ContextType.GLOBAL
smh
I remember seeing this api who had no return of any methods but they worked
abstract / interface class
you return upon preconditions
umm this is flattened already
its good to think that you should make your api based on interfaces
and well interfaces is mostly aimed to determine behaviour
Imagine using else, ew
well I've seen worse
I mean, in this case I can't avoid it I don't think
there is one else in there
everything else is a guard clause
@steel heart ok but I still dont know how it works xd
I would love if there was some sort of switch or when for conditions with multiple conditionals and their combinations
Like write down all the permutations and just list all the results
do you do something like public interface API, public class APIImplementation implement API and API api = new APIImplementation();?
fuck off with that if if if else else else shit already
I assume this way you can have a public api for premium plugins?
by providing only the interfaces
yeah ignore that then ig
@steel heart It's necessary sometimes...
actually
I have an idea
I mean a generally case is to not expose anything in the api itself as it should only define behaviour. Gaby but I mean you don't always have to follow it just like I don't follow solid.
I mean there's a lot of explanation out there but its most likely because for instance the end user who uses the api shouldn't really know how things are done and they don't really have to care anyways. They only need to make things for themselves. Trying to modify it such as implementing it could break the behaviour.
I assume I can make them package private
which one?
Trying to modify it such as implementing it could break the behaviour.
Like the API interface
or it doesn't work for implement but only for creating an instance?
I mean implement or extend it generally. Because your application that implements them should handle that part and for instance if the end user would extend the interface Shoe, that wouldn't necessarily break anything although it can cause weird behaviour.
There's also a lot of apis which has some implementing classes that might be handling security and algorithms which the end user most likely shouldn't be able to access.
fun main() {
val a = 42
val b = 69
val c = 420
val permutations = conditionPermutations((a < b), (b > c), (c == a))
when(permutations) {
"TFT" -> println("a is smaller than b, b is smaller than c and c is equal to a")
"TTF" -> println("a is smaller than b, b is larger than c and c is not equal to a")
"TFF" -> println("a is smaller than b, b is smaller than c and c is not equal to a")
"else" -> println("leave me alone!")
}
}
fun conditionPermutations(vararg conditions: Boolean): String {
var ret = StringBuilder()
for(condition in conditions) {
ret.append(if(condition) "T" else "F")
}
return ret.toString()
}
I made a thing...
rofl
lol
what the
condition permutations
I'm gonna use it...
I just wish there was a cleaner way to indicate the result of the condition instead of as a string with T and F. Maybe numbers with 1 and 0 but that's not clear enough
Kotlin is fun dude
I wish I knew about it sooner
idk if Predicate<T> is useful
@steel heart in this case? I don't think it makes sense in this case
is that a class?
there is a BitSet in Kotlin tho
@steel heart it's not
its a thing u do with raw bytes
@silk jewel Oh no I know what a bitmask usually is, I just thought you meant more by it
Idk how to compare a BitSet in the when body though
What do I compare it to?
@empty flint any reason you can't just use a boolean?
@empty flint any reason you can't just use a boolean?
@prisma wave Yes. There's 3 of them.
So one would be 2 too little
so 3 potential states?
and all their permutations, yes
oh and you want that expressed in a single class
HexaPredicate
that's 2^3 potential states.
I just want
if(rank != null) { if(network != null) { if(worldUuid != null) { return ContextType.RANK_IN_NETWORK_ON_WORLD } return ContextType.RANK_IN_NETWORK } return ContextType.RANK } else if(network != null) { if(worldUuid != null) { return ContextType.NETWORK_ON_WORLD } return ContextType.NETWORK } return ContextType.GLOBAL
@empty flint this to be not so fugly to look at and maintain
I have basically 3 variables that can be null or not
and depending on their combination I want different things to happen
also kotlin fun conditionPermutations(vararg conditions: Boolean): String { return conditions.joinToString(separator = "") { if(it) "T" else "F" } }
use when perhaps?
also
kotlin fun conditionPermutations(vararg conditions: Boolean): String { return conditions.joinToString(separator = "") { if(it) "T" else "F" } }
@prisma wave I'd kiss you on the cheek rn if the 'Rona wasn't around
<3
That is beautiful
I love Kotlin
use
whenperhaps?
@prisma wave Can you use a when with mutliple variables?!
declarative programming > imperative programming
when doesn't need a variable
when {
conditionA && conditionB -> blah
}```
declarative programming > imperative programming
@prisma wave I wouldn't know the difference or their signatures but sure, whatever you say chief
might be better
when {
conditionA && conditionB -> blah
}```
@prisma wave Oooooooooooh
That changes EVERYTHING!
๐
@prisma wave I wouldn't know the difference or their signatures but sure, whatever you say chief
@empty flint declarative is telling the computer what to do (eglistOf(1, 2, 3).map { it + 1 }.sum()), imperative is telling the program how to do it (eg a for loop creating a new list manually
when doesn't need a variable
@prisma wave Hm does when hit on the first condition that is met?
yes
val list = listOf(1, 2, 3)
val other = ArrayList()
for (element in list) {
other.add(element + 1)
}
var sum = 0
for (element in other) {
sum += element
}
return sum
this would be declarative
and yes
the first condition, then it stops
when good
why is it even called switch case ๐คฃ
@prisma wave Is there a shorthand notation for == null and != null?
when {
rank != null && network != null && worldUuid != null -> return ContextType.RANK_IN_NETWORK_ON_WORLD
rank != null && network != null && worldUuid == null -> return ContextType.RANK_IN_NETWORK
rank != null && network == null && worldUuid == null -> return ContextType.RANK_IN_NETWORK
}
np
Wth when in kotlin is actually cool
you thought it wasn't?
Oh well didnโt really know
Lmao
Wait does it allow -> ?
Idk if youโd call it a lambda in that scenario but iirc java 14 or smtng has that right?
Um*
oh
Yeah I think so
With switch
yeah Java 14 switch is pretty much she.
when*
Mobile bad
The actual cool thing with kotlin is that we can have java 14 features in java 8 with kotlin
well
Or I mean kotlin is cool not only because of that