#help-development

1 messages · Page 904 of 1

young knoll
#

Holder is just a holder

#

I believe conflicts are handled by a method

wraith apex
#

Aye but what would it be checking against? or is there just a massive switch statement lol

young knoll
#

Each enchantment has their own class

wraith apex
#

That doesn't seem to be the case with all of them

young knoll
#

Well, any that need to override anything presumably

#

Yeah all those basically work the same

#

You really should use Mojang mappings

wraith apex
#

aye but prot will conflict with fire prot and the others

young knoll
#

Yes

wraith apex
#

so I'm looking for that logic

young knoll
#

Im pretty sure it just checks if otherEnchantment instanceof ProtectionEnchantment

wraith apex
#

oh... that's uh.. kinda smart but also very annoying...

#

I'll test that theory

young knoll
#

I would just grab the key of the enchantment and then test against that

wraith apex
#

I could do it manually but the idea was I was hoping to find some logic method that I could override to have minecraft to the conflict checking for me

young knoll
#

Well yeah you just override the conflict method

#

And then add the checks you want

wraith apex
young knoll
#

I think it’s conflictsWith

#

Or checkConflicts or something

wraith apex
#

Also, yes it seems you're correct. An enchantment determins conflict by if they have the same class...
Given that, I think I found it

#

Thank you very much!

young knoll
#

Again

#

Use Mojang mappings smh my head

wraith apex
#

No idea how to use them lel

young knoll
#

?nms

wraith apex
#

I just rummage through obfuscated code, this is life for me :p

#

if I remember correctly, you can't use mappings in your actual plugin? They're only used to find the correct methods ye?

quaint mantle
#

u like unmap them when it compiles

wraith apex
#

How do you incorperate an unmapped then? I use a custom build script

young knoll
#

You can use them during development

quaint mantle
#

@wraith apexalex has a great blog on it

#

let me find it

young knoll
#

I just posted it silly

wraith apex
#

Ye thanks for that 👍

quaint mantle
wraith apex
#

what if ye don't use maven or gradle?

young knoll
#

Then you should reconsider

quaint mantle
#

wtf

#

that's wild

#

lol

wraith apex
#

I don't do enough NMS stuff to consider converting to maven, my build pipeline is already quite streamlined. I just press 1 physical button atm

drowsy helm
#

are you using artifacts?

#

should be using maven or gradle anyway, it's 100x better

wraith apex
#

Don't think I've heard of that no

drowsy helm
#

how are yo compiling

wraith apex
#

I built my own build pipeline

#

just a auto-generated bash script

drowsy helm
#

so just running javac

wraith apex
#

aye

#

simple

young knoll
#

Why would you reinvent a worse version of maven/gradle

drowsy helm
#

maven does all of that for you

#

with version control

#

and automatic repository downloading

#

you don't have to manually download all your imports

wraith apex
#

my internet is ass

#

not gonna be able to compile if my internet goes out :/

young knoll
#

It caches everything

drowsy helm
#

it caches it

#

you dont need internet

wraith apex
#

so it does download everything...

drowsy helm
#

it downloads the necessary imports for yoru project

#

and caches it

young knoll
#

Which is the same thing you do

#

But manually

wraith apex
#

I've been too lazy to learn gradle or maven, it also looks hella complicated

drowsy helm
#

it's not

#

maven takes 10 mins to learn

#

I guarantee you 99% of java developers and 100% of any company using java uses either maven or gradle

#

and for good reason

next plume
#

It is a pain updating the Maven plugins.

drowsy helm
#

you just change version in pom

next plume
#

Yes, it's a pain to go look up the versions and change them. Why can't it just use the released version itself?

drowsy helm
#

just put latest as version

#

and it will auto update

#

..?

next plume
#

Last time I tried latest, it didn't work, but that was probably with jitpack

hazy parrot
#

but that is generally not really good practice

wraith apex
#

I just see maven as another tool that can break easily if not configured properly

#

call me a dinosaur

drowsy helm
#

it's not

#

it is easy

wraith apex
#

it's only easy for someone who already knows how to use it

#

lol

drowsy helm
#

I see so many new devs refusing to use maven, but once they do they never go back

#

I've met many people like you, with the same thoughts.

#

Trust me, maven is just better in all aspects

wraith apex
#

adding custom libs that are not in the central repo?

drowsy helm
#

We're more than happy to teach you how to use it

wraith apex
#

conflicting libs?

drowsy helm
#

you can still have local libs

#

and you can chose priority

young knoll
#

I wonder what Mojang uses

#

Dun dun dun

wraith apex
#

lmao

drowsy helm
#

they use gradle

wraith apex
#

💀

young knoll
#

Source?

drowsy helm
#

idk for the minecraft src

drowsy helm
#

but thats what they use on their github

slender elbow
#

in the time you've spent here complaining about this crap you could've set up nms with maven like 10 times over lmao

young knoll
#

Fair

wraith apex
slender elbow
#

the guide is pretty straight-forward

rough ibex
#

I'm 99% sure Mojang uses Git.

wraith apex
#

lmao

rough ibex
#

yeah well it should be known they use git

drowsy helm
#

this is news to no one

young knoll
#

Inb4 it’s gitlab

rough ibex
#

gitlab is nice

slender elbow
next plume
wraith apex
#

Adding a lib to eclipse or itelliji directly is far easier than using an over complicated build tool

next plume
#

Linus Torvalds wrote git in a weekend.

drowsy helm
#

give this guy a medal

rough ibex
#

use maven

#

yes i know context

#

just use maven

#

instead of trying to argue why you shouldn't try

slender elbow
#

no you don't get it

#

i HAVE to argue on the internet

rough ibex
#

I love arguing too

next plume
#

This was one of Linus' goals:

Take the Concurrent Versions System (CVS) as an example of what not to do; if in doubt, make the exact opposite decision.

rough ibex
#

damn

slender elbow
#

what's that captain disillusion talk about arguing with strangers on the internet again

tender shard
#

Just let them enjoy their javac bash script and wait until they actually wanna do sth a bit more complicated like shading sth lol

young knoll
#

How you gonna argue that a() b() c() are better than actual method names

tender shard
#

Its shorter! Less to type

wraith apex
drowsy helm
#

when using non mapped nms i roll a set of dice and hope its the right function

wraith apex
#

have you ever wanted a random dependancy to magically update one day causing your build to break and you don't know why? Try Maven today!

young knoll
#

a() b() c() easy as 123 simple as do ray me

slender elbow
#

dependencies don't update if you don't update dependencies

#

you update dependencies when you want to update dependencies

rough ibex
#

also, specify a version?

#

1.2.3 gets 1.2.3 not 1.2.4

young knoll
#

Yeah man gradle keeps updating my project to the latest spigot and breaking everything

#

Smh

slender elbow
#

this is why you use maven instead

#

clearly

young knoll
#

I guess technically that’s true since spigot always uses v0.1-snapshot

drowsy helm
#

also not to mention if you ever collaborate with anyone, if they hear you're using artifacts intead of maven or gradle, they will most likely leave lmao

slender elbow
#

why is my alter-ego typing

drowsy helm
#

L'emily

wet breach
drowsy helm
#

inverse Emily

young knoll
#

French Emily

next plume
young knoll
#

🥖

waxen ledge
#

xd

slender elbow
#

this is why i don't use dependabot lmao

young knoll
#

Tbf I tend to not update dependencies or plugins until something breaks

next plume
#

I saw PlotSquared(?) had to revert a dependabot change.

wraith apex
#

I don't need maven to contact skynet to pull libs and complain about a syntax error in pom.xml

drowsy helm
slender elbow
#

gross

#

fr*nch

drowsy helm
young knoll
#

Pfft my build tool copies the jar for me

#

Checkmate

rough ibex
#

also learn to write xml

#

its not hard

young knoll
#

They’ll run the bash script obviously

slender elbow
#

my guess is that they don't plan on collaborating with anyone ever basically

wet breach
rough ibex
#

they are preemptively preventing themselves from every having a contributor

young knoll
#

Tbf you’ll probably live longer that way

slender elbow
#

less chances of getting stabbed ....

rough ibex
#

would you rather cure cancer and live to be 20 or live to be 100 and do nothing

#

cure cancer
use maven

wraith apex
young knoll
#

But I’m already past 20

rough ibex
#

your coworkers must hate you

wraith apex
#

the amount of time we spend on fixing git merges and build tools

rough ibex
#

then your team needs to learn git

wraith apex
#

a lot of time wasted lol

rough ibex
#

and learn BT

slender elbow
#

are your teammates 14?

rough ibex
#

this is a deficiency on your part

wraith apex
wet breach
young knoll
#

Back in my day we had to trudge through 7 miles of swamp to merge changes

#

Uphill both ways

wraith apex
#

get rid of people

wet breach
wraith apex
rough ibex
#

you must be such a welcoming and warm person to work alongside

young knoll
#

At first I thought you meant cvs pharmacy

wraith apex
rough ibex
#

that's the entire point

wraith apex
wet breach
young knoll
#

We don’t have cvs here so I wouldn’t know

#

All I know is they are known for long recipes

wraith apex
#

Well, have a good one o/
this was fun kek

slender elbow
#

no u

wraith apex
#

❤️

unreal quartz
#

how romantic

young knoll
#

Enjoy your obfuscation

#

Don’t let the h() hit you on the way out

wraith apex
rough ibex
#

vlogcreations is great

rare rover
#

Mojang mappings >>

#

Fr

deep herald
#

anyone know why this is erroring?

young knoll
#

Smh using NMS instead of pdc

#

Anyway

#

What’s the error

deep herald
#

the methods dont exist

young knoll
#

What version

deep herald
#

1.20.2

young knoll
#

You can check for the correct names with

#

?mappings

undone axleBOT
young knoll
#

Although if you are on 1.20.2 just use pdc

deep herald
#
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.20.2-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>```thats my import
deep herald
young knoll
#

?pdc

young knoll
#

It’s an api for attaching arbitrary data to items

#

(And entities, chunks, worlds, block entities, etc)

deep herald
#

my brain hurts so bad rn

junior anvil
#

im struggling with adding the worldedit api in my pom

echo basalt
#

ah good ol' wedit

junior anvil
#

the dependency section is red

#

:D

echo basalt
#

added the repo?

junior anvil
#

well nevermind

#

it fixed itself

young knoll
#

🦆

junior anvil
#

🦆 💨

mortal hare
#

is this is a bug?

#

i use Integer to prevent autoboxing

#

since i use Integer for multiple generic functions anyways

#

so what's the deal?

river oracle
#

its really begging you to use int

mortal hare
#

but its for a purpose

#

i use call two functions with Integer

river oracle
#

yeah but intellij doesn't have that context (though tbh doing this to prevent autoboxing probably saves at most a few nanoseconds)

young knoll
#

Muh cpu cycles

drowsy helm
#

autoboxing is a non issue

#

and that is an over optimisation that will effectively do nothing

mortal hare
#

ofc its non issue

#

its just that i'm using Integer for a reason and it shouldnt throw this error

drowsy helm
#

youll have to just disable it in ide settings

mortal hare
#

but i guess it doesnt analyze called function, where multiple functions with Integer args are being called

drowsy helm
#

not much else you can do

young knoll
#

You’d never survive working on

#

Idk

#

An Atari 2500

river oracle
#

just a warning

#

this code will compile and run

#

I wouldn't be surprised if your compiler just optmizes Integer into an int though

young knoll
#

Ooh is it bytecode time

mortal hare
#

but wait

#

maybe it's right

#

it would autobox the integer

#

for the called argument

#

since i specify Integer inside called function args

#

so it doesnt really matter

#

it just that it would increment the primitive and then autobox it

#

but due to how Integer is immutable it really doesnt make any difference

#

?print

#

!print

remote swallow
#

?paste

undone axleBOT
mortal hare
#

thanks

drowsy helm
#

Sounds like you’re over complicating it

river oracle
#

the easy solution here is to cope with the fact you just lost like 5 cpu cycles to autoboxing

#

if you can't cope with that code in assembly and leave java behind

mortal hare
#

no that's not why im optimizing it

#

i need to complicate things rn

#

since im participating in a java course enrollment

river oracle
#

???

mortal hare
#

and i need to fancify my code

rough ibex
#

No

#

That is how you get rejected

young knoll
#

minecadamy

river oracle
#

looks like you want to get rejcected lol

rough ibex
#

for complicated, unreadable, stupid code

mortal hare
#

that's literally what they asked lol

rough ibex
#

verbatim?

#

or did they ask to be as concise

#

specific and clear

mortal hare
#

they asked for me to implement fizzbuzz algorithm that could be maintainable without "if statement hell" in the future

rough ibex
#

okay

mortal hare
#

i did smth like this with lambdas

#

im not sure if this is "fancy" enough lol

rough ibex
#

what the hell

#

"maintainable"

mortal hare
#

i mean the only thing you need to add is lambda to a list

#

that's it

rough ibex
#

if you put this code into a merge request and asked me to review it

#

I would reject it immediately

#

and look at all of your other merge requests and likely reject those by adjacency

mortal hare
#

Consider that in the near future more conditions will be added, so code should be extendable without much effort.

rough ibex
#

okay

mortal hare
#

ofc i would've done if statements

rough ibex
#

I have no idea how to do that here

mortal hare
#

but if you add like 100 cases

#

its gonna be hell

#

so i've used lambdas

rough ibex
#

You are not understanding

mortal hare
#

what im not understanding

#

explain

rough ibex
#

You are overcomplicating it

young knoll
#

You could also make a record

rough ibex
#

to the point where it is impossible to maintain

#

you are making enterprise java

#

stop it

#

KISS

#

keep it simple, stupid

river oracle
#

@mortal hare are you trying to make enterprise fizzbuzz

young knoll
#

Record that holds an integer and then the string that should be added if the number is divisible by said integer

river oracle
mortal hare
rough ibex
#

no it's a pejorative

river oracle
#

that's horrible enterprise code is fucking shit

rough ibex
#

'enterprize java' means its horrible

#

and incredibly abuses Java's paradigms

remote swallow
#

why was i told about KISS 2 days ago and ive now seen it like 3 times here after

young knoll
#

I swear I’ve said it to you before

river oracle
#

this is my universe you're juist living in it

junior anvil
#

uhh

river oracle
remote swallow
mortal hare
#

because that's what they're not asking to do

#

this is an example

rough ibex
#

what/

river oracle
young knoll
#

Actually you don’t even need a record

river oracle
#

its not worth your time

young knoll
#

You could just do Map int -> string

river oracle
#

genuinely if they make you do enterprise java for a simple problem its not worth your time

mortal hare
#

actually

rough ibex
#

you are overdecomposing the problem

mortal hare
#

and i got 8 page test

rough ibex
#

you are actively corpsing it

young knoll
#

Idk you never know when you might need uhh

#

More fizz in your buzz

mortal hare
#

i would never write this, but they want me to write smth like this just to prove that i know something about java

rough ibex
#

this shows me you know nothing about java

river oracle
#

then show them you know best by KISS

rough ibex
#

and you just know how to stuff as much shit as you can into a program

river oracle
rough ibex
#

if I cannot read your code or understand how to use it, it's bad.

mortal hare
rough ibex
#

why are you even trying to do pure functional

river oracle
#

in an OOP language none the less

mortal hare
#

because if statements would be cancer according to them

rough ibex
#

what oh

mortal hare
#

i already stated

mortal hare
river oracle
mortal hare
#

although this is the best

rough ibex
#

I feel like youre misinterpreting

mortal hare
#

lol

junior anvil
#

anyways i want to do a sort of "mana" system with mana regeneration every tick and here's my idea
onPlayerJoin i insert the values inside a persistent data container, if the persistent data container does not have those values
for every tick i update the "mana" value for every player but i dont know how to do it in an efficient way cause my first idea was just use the scheduler on plugin enable, which i dont like cause it feels like an inefficient idea
any suggestions?

mortal hare
#

no its not even my code

#

its their code

rough ibex
#

'modular code'

mortal hare
#

they're asking to do something better than if statements that could be expandable in the future

rough ibex
#

you want modular code? put your entire AST in a JSON document /s

mortal hare
#

so i used functions to make it expandable 😄

wet breach
rough ibex
mortal hare
#

ik

rough ibex
#

you actively made it harder

mortal hare
#

that's what they asked it

rough ibex
#

no

#

again, I strongly feel you are taking what they are asking for and using it to spite your face because of your nose

junior anvil
wet breach
junior anvil
#

alright, thank you

mortal hare
rough ibex
#

then whoever is running this test is an idiot.

#

and is not a good reflection of skills

#

it's a reflection that you can cram concepts together where they don't belong

mortal hare
#

they know that its wrong to not use if cases for such a simple problem, its not as if you're putting 100 cases in fizz buzz problem 😄

rough ibex
#

okay

mortal hare
#

4 if statements vs 6 functional inteface implementations ofc is worse

rough ibex
#

so why did you do it like this

#

also you violate the do one thing and do it well principle

mortal hare
#

because they've asked for something that could be expandable, so i've made almost everything in fizzbuzz modular, so that way you can do whatever you fuck you want

#

with functions

rough ibex
#

Application#fizzbuzz does not do fizzbuzz

#

yeah you did it wrong

#

this is not modular

#

this is enterprise

#

what the fuck is this


    private static <T> void execute(Integer number, Consumer<T> executor, List<Function<Integer, T>> functions, Function<Integer, T> fallback) {
        for (Function<Integer, T> function : functions) {
            T object = function.apply(number);
            if (object != null) {
                executor.accept(object);
                return;
            }
        }
        executor.accept(fallback.apply(number));
    }
#

I don't know what this does by looking at it

junior anvil
#

why are you guys arguing about fizzbuzz

mortal hare
#

it executes function if returned value is not null

rough ibex
#

because someone must be taught the correct way today

mortal hare
#

otherwise fallback consumer will kick in

#

which is set to integer.ToString() in the args

#

so it prints integer if the divisor in fizzbuzz was not found

rough ibex
#

...

#

why are you involving functions

#

at all

#

you are repeating your logic

mortal hare
#

with functions i can combine multiple fizz, buzz, bazz, jazz words in to multiple cases

#

so that way i can print FizzJazz, FizzBuzz

#

without rewriting the logic for each case

#

if Fizz function returns null it means FizzJazz wouldnt get printed

#

neither Fizz also

#

that's why u see CombinedStringFunction class

#

so i can combine multiple function output into one

rough ibex
#

... use... +?

#

"combine output"

#

why do you need to make it so generic and functional

mortal hare
#

modular

rough ibex
#

how is this modular

mortal hare
#

you can plug whatever words, output storing functions in the call

rough ibex
#

why can't you make it simple

mortal hare
#

fizzBuzz(105, (string) -> builder.append(string).append(' '), functions, Objects::toString);

#

again

#

they dont like simple

#

😂

#

its dumb

#

ik

rough ibex
#

then stop entertaining it?

#

any possible accreditation from this place is worthless.

#

I might even actively exclude people based off of it

#

because of how awful they teach, it seems.

#

or you're misrepresenting the requirements

#

and trying to justify making it the worst it can be

candid inlet
mortal hare
#

that's not even premature optimization

#

how functions are premature optimization

#

they're worse to performance

slender elbow
#

optimisation is not all about performance

#

you could optimise for development, future proofing

#

this is pristine

#

the best code you will ever see in your life

#

it can do all the fizzes and buzzes

#

and more

mortal hare
#

its not for my project, im sorry that this angered you guys so much 😂 its for my upcoming test its a bonus task

rough ibex
#

how about you provide a list of divisors and they're associated with some string

mortal hare
#

if do this the way they want i get extra points

#

that's it

#

its not about performance

#

its about knowledge of various java syntax features

rough ibex
#

'it's not about performance'
you clearly care about it here

mortal hare
#

its not as if this is going into production or something

#

relax

rough ibex
#

no, but you are a CS student I assume

mortal hare
#

yes

rough ibex
#

and eventually you will be writing production code

mortal hare
#

That's not what i would write normally

#

just stop

#

misinterpreting

#

its getting ridiculous now

river oracle
#

Whoever runs this course needs to find a real job lol

rough ibex
#

I feel like the requirements were just "Write an extensible fizzbuzz solver program"

river oracle
rough ibex
#

immediate graduation

mortal hare
#

ok if lets say i would not send this code

#

how would you write it

#

with a map?

#

two arrays to associate divisor indexes with strings

rough ibex
#

One moment...

mortal hare
#

all of those are just as dumb

#

as mine

#

its not as if if statements would not beat the other data structures

river oracle
#

I wanna try writing hello world enterprise

rough ibex
#

object FizzbuzzProgram {
  fun fizzBuzz(fizzes: Map<Int, String>, number: Int): String {
    val sb = StringBuilder()
    for ((fizz, name) in fizzes.entries) {
      if (number % fizz == 0) sb.append(name)
    }
    if (sb.length() == 0) sb.append(number) // If not divisible by any, put the number plainly.
    return sb.toString()
  }
}

// test
FuzzbuzzProgram.fizzbuzz(hashMapOf(3 to "Fizz", 5 to "Buzz", 7 to "Bazz"), 105)
#

something like this

#

you pass in a map of applicable divisors and their fizz names

mortal hare
#

oh yeah a hashmap is trully better than if statements

rough ibex
#

actually any Map but

mortal hare
#

its just as dumb as mine

rough ibex
#

I doubt that.

mortal hare
#

the whole concept of extensible "fizzbuzz" is dumb

river oracle
#

What is your guys favorite
jne, jeq, jlt, jle , jgt, jge

mortal hare
#

jz

river oracle
#

Personally I love jeq

rough ibex
#

jne is deprecated use jneq

#

lol

river oracle
rough ibex
#

Oh I thought you were just joking

drowsy helm
river oracle
#

my mind is mush

#

and assembly

rough ibex
#

to be fair I did say 'something like that'

wet breach
#

But if you can replace 100 if statements with a hashmap then hashmap is going to be the way to go

young knoll
#

You could change the Integer to a predicate<Integer> if you want more than just divisibility

#

Ig

rough ibex
#

you could but that's outside the scope of fizzbuzz

young knoll
#

FizzBuzz scope creep

rough ibex
#

such a thoughtful and productive discussion here about enterprise fizzbuzz

young knoll
#

Now we are doing enterprise development

rough ibex
#

scrum agile sprint

river oracle
young knoll
#

Right int gets a special one

slender elbow
#

just how mama used to say

young knoll
#

You know who doesn’t get to be special

#

BooleanConsumer

mortal hare
#

do you guys hate spring boot also

#

?

#

if you're so against runtime bloat

river oracle
#

O

#

I've never touched it

#

Praise the lord for that

young knoll
#

Neither have I

candid inlet
quaint mantle
#

Yo guys

river oracle
#

why use springboot when I could just use idk something that's not springboot

mortal hare
#

@rough ibex would pull its hair off if he used it 😄

quaint mantle
#

QuickSort is sm easier than I expected

river oracle
quaint mantle
#

and I learned how to do things without recursion by just using a Stack

river oracle
#

quicksort suckz tho

quaint mantle
#

why

young knoll
#

But it’s called quick sort

river oracle
#

isn't quicksort worst case n^2

young knoll
#

How could it be slow

rough ibex
#

how could it lie to us

quaint mantle
#

yeah

#

But I think its average case is the best

mortal hare
#

its name as bad as imaginary numbers one

river oracle
#

yeah so its trash CH_PepeTrash

young knoll
#

BogoSort

river oracle
#

I use StalinSort exclusively

rough ibex
#

BogosBintedSort

mortal hare
#

fuck it just dont sort

#

time complexity of O(inf) to sort it

#

patented by me

river oracle
young knoll
#

BogoSort would be called BozoSort today

rough ibex
#

GaslightSort - it's sorted already what are you talking about

river oracle
#

Insertion Sort is great given that the data is atleast somewhat sorted already

#

that's why it works better on smaller datasets there's less of a chance the cost to sort skyrockets given its not partially sorted

#

Merge sort is also awesome, but it kinda fucks your call stack

young knoll
#

How about usersort

mortal hare
#

insertion sort is not bad for small sets

young knoll
#

Just tell the user to sort it

mortal hare
#

while shell sort with proper sequence is not bad

#

for bigger ones

quaint mantle
#

lmao

quaint mantle
river oracle
quaint mantle
#

there's a sorting algorithm called assume sort

river oracle
#

Stalin Sort is the best sorting alogrithm

young knoll
#

It’s not cheating it’s called offloading work to another machine

river oracle
#

its O(n)

#

i'm not even joking

quaint mantle
river oracle
#

Selection sort is by far the worst applicable one being O(n^2) guarenteed

#

Insertion sort is O(n^2) but is only O(n) best case meaning if your data is partially sorted its pretty damn efficent

rough ibex
#

OutOfScopeSort - sorting is not the goal of this project and is left unimplemented (see #42 for tracking)

river oracle
#

Merge sort is O(n log n) worst case, but it is a recursive algorithm so you use a lot of your callstack for bigger data sets

#

Stalin sort is O(n) though its by far the best sorting algorithm I also find it to be the most intuitive

young knoll
#
private static final List<Integer> sorted = List.of(1,2,3,4,5);

public static Collection sort (Collection input) {
  return sorted;
}
#

Boom O(1) sorting

river oracle
#

that's not sorting anything though

#

the input is ignored

#

let me show you stalin sort implementation

young knoll
#

And you go in the bin

river oracle
#

its pretty simple yet effective

young knoll
#

Anyone else want to question my sorting algorithm

#

Plenty of space in the bin

quaint mantle
#

Why is there so much

river oracle
#

they suck ass

#

shitty ass website

quaint mantle
#

I just googled sorting algorithms

river oracle
#

thank me later goodbye

#

yep which Is why I'm warning you

#

they're like the first result

quaint mantle
#

I think I used programiz for quicksort

drowsy helm
quaint mantle
#

So is merge sorting usually the best

river oracle
#
fun <T> stalingSort(arr: Array<T?>) {
   val first = collection[0]
   for(int i = 0; i < arr.length; i++) {
     if (arr[i] > first) {
       arr[i] = null
     }
   }
}
quaint mantle
#

or smthing

river oracle
#

mostly because merge sort is recursive in nature

quaint mantle
#

I remember the website compared something with quicksort

river oracle
#

so your call stack kinda commits suicide after a while

#

well ofc its better than quicksort since quicksort isn't guarenteed n log n

#

but again still wouldn't be as effective as shell sort on a super large data set

quaint mantle
#

I learned stuff like using a random pivot for security and making algos without recursion

#

just to fit my rubric for apcsp

river oracle
#

the thing about merge sort is Idk if you can really implement it well without recursion

#

its recurisve in nature

quaint mantle
#

isn't quicksort also recursive in nature

river oracle
#

I honestly don't think you can implement it without recursion

#

I could be wrong but I believe its impossible

#

oh you can its just more complex

#
algorithm IterativeMergeSort(A, n):
    // INPUT
    //     A = the array
    //     n = the size of the array
    // OUTPUT
    //     sorted array

    len <- 1
    while len < n:
        i <- 0
        while i < n:
            L1 <- i
            R1 <- i + len - 1
            L2 <- i + len
            R2 <- i + 2 * len - 1
            
            if L2 >= n:
                break

            if R2 >= n:
                R2 <- n - 1

            temp <- Merge(A, L1, R1, L2, R2)
            for j <- 0 to R2 - L1 + 1:
                A[i + j] <- temp[j]

            i <- i + 2 * len

        len <- 2 * len

    return A```
quaint mantle
#

look at how I did it for quick sort

#
function quickSort(list) {
  var stack = [];
  stack.push(0);
  stack.push(list.length - 1);
  
  while (stack.length !== 0) {
    var maxIndex = stack.pop();
    var minIndex = stack.pop();
    
    if (minIndex >= maxIndex) {
        continue;
    }
    
    var nextLowerValueIndex = minIndex;

    swap(list, randomNumber(minIndex, maxIndex), maxIndex);

    for (var i = minIndex; i < maxIndex; i++) {
      if (list[i] <= list[maxIndex]) {
        swap(list, i, nextLowerValueIndex);
        nextLowerValueIndex++;
      }
    }
    swap(list, nextLowerValueIndex, maxIndex);
         
    stack.push(minIndex);
    stack.push(nextLowerValueIndex - 1);
    stack.push(nextLowerValueIndex + 1);
    stack.push(maxIndex);
  }
} 

function randomNumber(min, max) {
  return min + Math.floor(Math.random() * (max - min + 1))
}

function swap(list, indexOne, indexTwo) {
  var temp = list[indexOne]
  list[indexOne] = list[indexTwo]
  list[indexTwo] = temp;
}

var list = [1,1,2,-555,5,0,0,111,10,-2,7,9,1,22,3];
quickSort(list)
console.log(list)```
river oracle
#

javascript

#

instant turn off

quaint mantle
#

well it's apcsp

river oracle
#

crushed my soul

#

day ruined

quaint mantle
river oracle
#

for my final project I used Java

quaint mantle
#

I joined the cs club

#

And they had a competition for gift cards

river oracle
#

damn your highschool has a CS club

quaint mantle
#

and yk I couldn't let anyone win

river oracle
#

dude I would wipe those competitionts wtf

#

I want to ruin everyones fun wtf

rough ibex
#

APCSP you should be able to use any language.

quaint mantle
#

so I made a 3d maze search game

rough ibex
#

APCSA uses Java.

young knoll
#

Show up with a baseball bat

river oracle
quaint mantle
#

I learned a lot from that on how basic 3d games are made

young knoll
#

Show me in the rules where it says no breaking the fingers of the opponents

river oracle
#

like I don't think they allow C

rough ibex
#

They generally mean interpreted, cross-platform, high level languages

quaint mantle
#

I was so happy to

#

I won 40$

#

in Amazon giftcards cards

river oracle
#

DUDE where was this in my highschool

#

I want to farm money from all the inexperienced children!

quaint mantle
#

now it's kinda boring

rough ibex
#

I just want to farm money

#

I don't care who it's from

quaint mantle
#

we're doing stuff with legos

#

Like bruh

rough ibex
#

💤

river oracle
#

BRO

#

that sounds fuN!!!

#

holy shit

quaint mantle
#

I promise you it's not

river oracle
#

again where was this in my HS

young knoll
#

Doesn’t sound much like cs though

river oracle
river oracle
young knoll
#

Is Lego Turing complete

river oracle
#

yeah it is iirc

#

cuz they have the technic stuff

young knoll
#

Doesn’t count

#

Just the plastic

rough ibex
#

is the universe turing complete

river oracle
#

I don't think they can be turing complete without technic, It might be possible if you can jank some stuff together with some parts that softlock together vs snapping

candid inlet
river oracle
#

I was wrong

#

its just a more complex implementation than its recursive counterpart

quaint mantle
#

Every recursive algorithm can be implemented iteratively I'm p sure

young knoll
#

You’ve just unlocked my memory of going to a robotics competition in like, 5th grade

river oracle
#

the only time recursion > implementation is in purely functional languages

#

where not every function call is put into the callstack

#

there is some other thing that goes on in functional langs I forgot what it is under the hood

#

My teachers told us in data structures my dumbass forgot though

rough ibex
#

I'm convinced that those who do pure functional are into torture

young knoll
#

Don’t kinkshame

rough ibex
#

I didn't say it was bad

quaint mantle
#

"The space complexity for quicksort is O(log n)."

#

Why is it not o(1)

#

??

rough ibex
#

I'm just saying they're likely into bdsm

river oracle
rough ibex
#

don't wanna mutate state?
stop time

river oracle
#

even assembly isn't stateless

rough ibex
#

hello yes I would like milk but without the milk

river oracle
#

every program has state so the goal to "not mutate state" is not only futile but idiotic pursuit imho

rough ibex
#

important distinction between functional and purely functional

#

functional has its uses for sure

river oracle
#

oh yeah def

rough ibex
#

purely functional is stupid

river oracle
#

likewise purely OOP is stupid

#

though

rough ibex
#

yes

river oracle
#

we live in a universe where maybe a little bit of both works best CH_WinkEye

rough ibex
#

paradigms are ways of thinking to help solve a problem

#

they are not religions

river oracle
#

don't tell that to the far OOPs or the far Functional bros

#

you'll get torn to shreads

rough ibex
#

i'll just rename myself to the unit type

river oracle
quaint mantle
#

Do you guys think someone will ever invent a o(n) sorting alg

river oracle
#

think what sorting requires

#

inspection and comparisson

quaint mantle
#

I'll ping u tmr when I create one

river oracle
#

its impossible to both inspect your current element and compare it with anything that could be larger or smaller in O(n) time complexity

#

@quaint mantle if you create one don't tell anyone

#

consult a professor at your local university immediately and ask them how to write a proper thesis

#

you will become an instant millionaire

quaint mantle
#

I know 💀

#

alr ig ima be rich tmr

young knoll
#

What if we do quantum computing

river oracle
#

that's cheating!!!

quaint mantle
#

I think I'll make an o(1) search algorithm too

river oracle
#

its FAKE NUMBERS AND SHIT

quaint mantle
#

Just for fun

river oracle
#

its impossible to beat that

rough ibex
#

gaslightsort is O(1) though

young knoll
#

Why do we stop there

#

What about O(0)

rough ibex
#
fun <T : Comparable<T>> Iterable<T>.gaslightSort(): Nothing {
  throw IllegalStateException("Already sorted.")
}```
young knoll
#

In fact let’s go ever farther

#

O(-1)

river oracle
#

computing the function actually takes negative CPU cycles

rough ibex
#

you put in the sorted list and it gives you the unsorted list

#

before it was sorted

young knoll
#

You want it sorted? Fuck you I already sorted it yesterday

rough ibex
#

if you keep going you eventually create a vacuum of space

#

and eventually loss of entropy

#

and now it's

river oracle
#
fun <T: Comparable<T>> Iterable<T>.unsort(): Iterable<T> {
  return this
}
rough ibex
#

I remember when I was really young and saw the time machine tool on a macbook and thought it was literally a time machine

#

you select a time and date and it does it

young knoll
#

Man Steve jobs was a genius

rough ibex
#

employee ID 0

#

to undercut wozniak ID 1

young knoll
#

If macs had an actual Time Machine do you think the diehard Windows and Linux uses would switch

rough ibex
#

yeah so I can invent linux earlier

young knoll
#

Yeah I guess if anyone ever invented a Time Machine they could just go back in time and invent it earlier

#

Fairly solid proof we never invent a Time Machine

rough ibex
#

we can probably observe the past

#

if you spin a black hole really hard

silver apex
#

orrrr.... ok here me out.
in 100 years, all life on planet dies
in 1000 years, it restarts over
in 2000 years, they're more advanced than us, invent a time machine, come back an realize the crap shoot this planet is, go back in the future and break the time machine
"we dont want them stealing our futuristic technology"

river oracle
#

I agree humans go exitnct and we are replaced with an advanced species of panda bears

young knoll
#

No way it would be pandas

rough ibex
#

panda bears would have died naturally if not for human intervention

young knoll
#

They are the least capable bears

rough ibex
#

panda bears are supposed to be extinct

silver apex
#

i think lady bugs have a better chance that pandas

river oracle
rough ibex
#

but we decide to defy nature and keep them because they're cute

young knoll
#

It would probably be the dolphins

river oracle
#

pandabears suck at living

#

idk how one could be so bad at staying alive

#

like wtf

rough ibex
#

sloth

silver apex
rough ibex
#

grabs onto own arm thinking it is a branch
falls to death

river oracle
#

bruh even the sloth is better at staying alive than a panda

rough ibex
#

sloths are also stupid

river oracle
#

what do you think is stupider (more stupid (Fuck English)) though

#

my money is on the panda

young knoll
#

I guess someone has to come last in the evolutionary race

river oracle
#

bruh I wonder what earth would be like if humans ended up coexisting with neandrothals instead of genociding them

rough ibex
#

probably sexier /s

river oracle
#

we also kinda genoicded the homo erectus

rough ibex
#

God fears his creation

young knoll
#

Probably for the best

#

If homo erectus was still around they would just get constant boner jokes

river oracle
#

dude fr actually maybe it was for the best there

#

imagine just tryna live your life and you just constantly get poked fun of cuz of boner

young knoll
#

Racism but it’s about boners

river oracle
rough ibex
#

good talk today

river oracle
rough ibex
#

wait that happened

#

I literally was away for 2 minutes in between that

junior anvil
#

what's the method to show something on the action bar

young knoll
#

Player#Spigot#sendMessage

#

With ChatMessageType.ACTION_BAR

tribal loom
#

Hello everyone, is this a mcpig discord?

river oracle
#

No

#

This is spigot

tribal loom
#

Oh, I'm sorry, I just got it mixed up! If anything, I'm Russian.

teal venture
#

say I create a custom item, I know how to create an item and put it in a GUI with lore and stuff like that but whats the best way to store a custom item? Like is it through assigning it a command to give to players or is there a better way to store it?

young knoll
#

You mean how to obtain it?

#

That’s up to you

#

Give command, crafting recipe, loot chests

frank flicker
#

Hey guys im helping out on a server plugin and I am trying to set a players nametag color to black, im trying a couple of different things at once but nothing's working, any ideas?
Im on 1.18.2, this is essentially what I am doing:

Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
scoreboard.registerNewTeam(key + "_2");
scoreboard.getTeam(key + "_2").prefix(mm.deserialize("<black>HOME "));
scoreboard.getTeam(key + "_2").color(NamedTextColor.BLACK);
scoreboard.registerNewTeam(key + "_3");
scoreboard.getTeam(key + "_3").prefix(mm.deserialize("<black>AWAY "));
scoreboard.getTeam(key + "_3").color(NamedTextColor.BLACK);
quiet ice
#

Whomst dared to ping me for no good reason

#

Hell, I don't even have ANYTHING to do with bungee - I've never even used it

tender shard
#

no, it's all your fault geol

glacial sphinx
#

Hello. I am having problems with NBT. So I made a items adder item with nbt: '{mynbt: "hello"}' , but when I get the item it says that has 1 more nbt tag, but then I am trying to get that nbt tag with PersistentDataConteiner with DataType String. It says it doesn't have it. Any help?

tender shard
#

PersistentData is stored in a nested NBT tag called "PublicBukkitValues"

glacial sphinx
#

So I have to set the item's nbt to '{PublicBukkitValues:{...}' ?

tender shard
#
{PublicBukkitValues: {"mynbt": "MyString"}}
#

oh and the key has to be a namespacedkey

#

so not just "mynbt" but "myplugin:mynbt"

glacial sphinx
#

myplugin will be the artifact ID or the main class name?

tender shard
#

it's what you defined in plugin.yml as name but in lowercase

glacial sphinx
#

Why it is called PublicBukkitValues?

tender shard
#

because it's visible to the client and hence public

#

on entities it's just called BukkitValues because the client can't see that, hence not public

glacial sphinx
#

Ok thx I will test it.

tender shard
#

does itemsadder not support PDC tags natively though?

glacial sphinx
#

I can only find nbt in the wiki.

tender shard
#

ah ok. yeah anyway PublicBukkitValues is correct

frank flicker
#

I see now that its the wrong paper version, so ill take a closer look thanks for the link

devout pivot
#

anyway to set the ender dragon's or of any mob's health to unlimited?

tall dragon
#

no

#

but u can set it really large. or make attacks to it deal no damage

bleak eagle
#

@tender shard how do i merge upstream changes into a fork with autosync disabled

#

preferably from idea

#

i want to merge the master of the repo that is forked into the master of the fork

#

do i have to add a separate remote?

wet breach
#

ideally you would have two branches

bleak eagle
#

elaborate if you are willing to listen to my dumb questions

wet breach
#

so how it works is one branch is for pulling upstream

#

which every so often you keep updated with the second branch

#

this way if something goes wrong you don't lose everything lol

bleak eagle
#

okay, one sec, check out the following

#
--- Y2K_/Bukkit (master) <-- NOT AUTOMATICALLY SYNC'D WITH UPSTREAM BY STASH
    --- brunoooooooo/Bukkit_y2k (master) (autosync'd to y2k_'s)```
#

i want to sync my own fork's master with the original spigot upstream

#

(it shouldn't have any conflicts)

wet breach
#

assuming the changes in y2k you forked from doesn't have changes that causes issues

#

anyways, all you do is change the remote to the further upstream

bleak eagle
#

right gotchu

#

i assumed but i couldn't find any understandable answer

wet breach
#

but this is why I recommend branches

#

branches can have their own remotes

bleak eagle
#

okay, so i can make a new branch on my fork

#

and set the remote to spigot?

wet breach
#

yep

bleak eagle
#

and then if i want master to be up to date i just merge the new branch into my master?

wet breach
#

sure and this way you have two repos you are keeping up with 🙂

#

that you can pull in changes separately

bleak eagle
#

thanks for the help

#

i guess i could keep the branch synced with spigot and master with unsynced y2k then

wet breach
#

up to you

#

just have to remember to check for updates is all 😛

bleak eagle
#

can't do it

#

it tries to push to spigot/bukkit for some reason

#

i made a new branch called bruno_from_upstream and then set its remote tracked branch to spigot/bukkit/master

#

then i cleanly pulled the changes in from it

#

and pushed them back to my fork

#

but it tries to push to spigot and i have no perms there since only md has

wet breach
#

it shouldn't, but idk how you are doing stuff

#

never had git do something I didn't want it to do

bleak eagle
#

i really can't tell if that's sarcasm

#

i think it's trying to push to the

#

oh yeah

#

it's totally doing that

#

one sec

#

did it :)

#

i forgot to switch the remote BACK to my fork before pushing

#

so it was trying to push to the readonly upstream

wet breach
#

o.O

#

never had my repos try to push to upstream

#

maybe you are using incorrect commands?

#

or maybe git has some autosync function now and that function causes it to want to send stuff upstream? would be weird to have this

bleak eagle
#
git remote add upstream https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
git fetch upstream
git branch -u upstream/master
git pull
git branch -u origin/bruno_from_upstream
git push
#

?

wet breach
#

it shouldn't be necessary to update the remote

#

pushing to your local branch also shouldn't cause it to want to send changes upstream either

bleak eagle
#

no that set of commands worked fine

#

i forgot the second branch upstream change first

bleak eagle
#

k figured it all out with tracked branches

#

i think

#

i made a pr and pinged y2k on stash to see if it's ok with them

tender shard
terse island
#

Hi, could someone help? I'am trying to make API for my plugin but I can't get it done.
Here is what I done so far based on informations I found online.
I created project with interface

public interface AgamasEconomyAPI{

    double getMoney(Player player);
    void giveMoney(Player player, double count);
    void removeMoney(Player player, double count);
}

Then I ran mvn clean install
And implemented the dependency into my 2 other plugins, one main plugin, the one I want the api to be in and other one for testing
Here is what I done in main plugin

private AgamasEconomyAPI apiManager;

@Override
public void onEnable() {
  apiManager = new APIManager(this);
  Variables.main = this;

  getServer().getServicesManager().register(AgamasEconomyAPI.class, apiManager, this, ServicePriority.Normal);
}

And then this in test plugin

@Override
public void onEnable() {

  ServicesManager sm = Bukkit.getServer().getServicesManager();

  Plugin economyPlugin = Bukkit.getServer().getPluginManager().getPlugin("AgamasEconomy");
  RegisteredServiceProvider<AgamasEconomyAPI> serviceAPI = sm.getRegistration(AgamasEconomyAPI.class);

  if (serviceAPI != null) {
    msgAll("Everything is fine!");

    economyAPI = serviceAPI.getProvider();

    for (Player player : getServer().getOnlinePlayers()) {
      player.sendMessage("Your money: "+economyAPI.getMoney(player));
    }
    return;
  }
  if (economyPlugin != null) {
    msgAll("API not found!");
    return;
  }
  msgAll("Plugin not found!");

}

But when I run it I get the API not found! message.

tender shard
#

because you print "API not found" if the plugin instance is not null

#

you should check if serviceAPI == null, instead of economyPlugin != null

terse island
#

above I have
if (serviceAPI != null) {

#

then Iam checking if plugin is null or not

tender shard
#

oh now I get your logic

#

does the API plugin enable before the other one?

#

is the second plugin soft-depending on the API plugin?

terse island
#

yes
in config of test plugin I have

depend:
  - AgamasEconomy
#

and I tested and main plugin loads before the test

tender shard
#

are you relocating any classes?

terse island
#

I don't know what you exacly mean by that

tender shard
#

are you using maven-shade-plugin in your test plugin to include AgamasEconomyAPI.class ?

terse island
#

I get it now, yes I'am using 3th project I specificaly have just for interface for AgamasEconomyAPI and I have it implemented in test plugin

inner mulch
#

Integer a = 2;

How would a construxtor look if i try to do with a custom class
MyObject a = 2;

tender shard
#

?paste

undone axleBOT
inner mulch
#

Hpw does java do it

#

Integer is a class if not primitive right?

tender shard
#

right now you're shading (including the API class file) in your test plugin .jar. So when it asks for "give me the registration for this class: ..." it asks for the registration of that INCLUDED class which ofc was never registered

terse island
#

Oh god, that was everything I needed to make?
I spent so much time looking for information online but nothing
Thank you so much for your help

tender shard
#

np

ivory sleet
#

or well

#

At runtime thats what happens at least

#

and then the other way around, it will use Number#intValue()

#

(Integer extends Number)

quiet ice
inner mulch
ivory sleet
#

:)

bleak eagle
inner mulch
#

what?

bleak eagle
#

their name for a variable is like polymorphic nonhomogeneous dynamically synchronized object signature inheritance

quiet ice
#

Polymorphy is OOP stuff

bleak eagle
inner mulch
bleak eagle
inner mulch
#

@override

ivory sleet
#

Because its their language specification

bleak eagle
ivory sleet
#

and is made to be precise, accurate and defined

#

For enterprise

bleak eagle
#

yet it's anything but clean and understandable, and I don't see it strongly relating to enterprise (?)

ivory sleet
#

Enterprise wants stability, stability requires clearly and unambiguously defined semantics, behavior, rules etc

quiet ice
#

Programmers love Latin and Greek

ivory sleet
#

if its unclear, its hard to know whether a program may behave correctly or incorrectly

bleak eagle
#

polymorphic inheritance is "clear" and "unambiguous"

#

?

ivory sleet
#

esp, when java is supposed to be write once, run everywhere

#

(Although its not)

bleak eagle
#

strong oop was a mistake

#

but now we have to live with it

ivory sleet
#

java isn’t strictly and monotonously strong oop

#

I mean sure it was the case 20 years ago

quiet ice
#

Poly = multiple
Morph = forms

Or something idk I didn't do Latin

ivory sleet
#

But they have been actively trying to incorporate for instance functional style to it

inner mulch
#

im want to have an interface that implements a static method to get the real class object of a class instead of the lying getClass() class<?> object, is this possible? From what I've tried its not. (generics arent available for static methods, at least not in the class scope)

eternal night
bleak eagle
ivory sleet
#

eh

bleak eagle
#

async doesn't have anything to do with it but it's an example

quiet ice
#

Just ignore those features

#

Ive been doing well without pattern matching

bleak eagle
#

I can ignore them all I want but it doesn't change the fact that they're features in the language that others might write and that you have to understand to read code not written by you

#

it also doesn't change the fact it's a mess

inner mulch
#

any way i can make this work without using generics?

quiet ice
#

Signature polymorphy (like intrinsics) is something only the JDK can do btw

#

And well compilers need to cater to it

quiet ice
inner mulch
#

red underline

#

under C

quaint mantle
#

One message removed from a suspended account.

ivory sleet
#

Brian Goetz acknowledges that a ton of mistakes were made 25 years ago or so, but there are two sides of java, the enterprise and the devs, the enterprise wants stability, the devs wants up to date/modern features, java also wants to target as wide of an audience as possible, making it reasonable develop for instance games in java (which has been in retrospect no very well w java)

Sure, if you think its a mess, thats ur opinion, but they want to add things such that it becomes easy to use for the average developer, one reason why project valhalla has been taking a long time. They need to care about stability for all the new features whih is why they don’t just shove it up like kotlin, take union types for instance, sure its semantically powerful, but type inference becomes a dry desert horrible to even step in.

They’re not really making attempts, they have been able to incorporate functional style and enhancing their concurrent framework a lot which is generally well received by the community nonetheless, altho 90% of concurrent framework is just AQS under the hood.

quiet ice
#

So, why would the method need to be static?

#

You can do static <T> T get() if need be

inner mulch
inner mulch
hybrid spoke
#

first of all, what are you trying to do

quiet ice
#

Inferred by the compiler?

hybrid spoke
#

second, why

quiet ice
#

It is intrinsically unsafe tho

ivory sleet
#

Its not like the java devs today embrace System.out and java’s verbose main method brunoo

bleak eagle
ivory sleet
#

But radically changing it isn’t a solution

quiet ice
#

Unless the type can be inferred via a param

inner mulch
ivory sleet
#

What exactly do you consider to be a half baked mess?

quiet ice
ivory sleet
#

:/

bleak eagle
ivory sleet
#

Definitely not true

bleak eagle
#

pretty true imo

ivory sleet
#

lightweight threading has been wanted for pretty long

#

not binding jvm threads to os threads bijectively

hybrid spoke