#help-development

1 messages · Page 158 of 1

hybrid spoke
#

what is a switch

shadow zinc
ivory sleet
#

but then again if your command class is just switching on operations like add/set/subtract/reset then you might not even have to care

pseudo hazel
#

well its for a minigame

#

I just have a command class that is the game name

#

and like the actual logic is somewhere else anyways, I just call other functions in the command class

hybrid spoke
#

damn

hybrid spoke
shadow zinc
hybrid spoke
shadow zinc
#

exactly

hybrid spoke
#

alright alright

pseudo hazel
pseudo hazel
#

how is scrolling through a single class less readable than opening 5 separate ones

shadow zinc
#

fax, your correct we are wrong

crimson terrace
#

you can have multiple methods in the same class

pseudo hazel
#

yes but I dont have a way to group the subcommands

#

other than in the command class where it already is

crimson terrace
#

inside the command class

pseudo hazel
#

well when it does I can switch over to something more complicated

shadow zinc
pseudo hazel
#

but like, it wont, and besides its a lot easier to go from this to more classes than the other way around

hybrid spoke
#

rather have a seperate class for each subcommand collected in the command class than one 5k lines command class

shadow zinc
#

69 nice

pseudo hazel
#

i mean that looks fine and all but importing something called a java command dispatch framework just to inplement a single command feels like overkill

pseudo hazel
#

explain

#

please

shadow zinc
#
pseudo hazel
#

?

shadow zinc
#

Min kille vill inte lära sig java

hybrid spoke
shadow zinc
#

damn Conclure is actually going to explain abstraction instead of redirecting him to a tutorial, respect

ivory sleet
#

Well abstraction means that you forget the details of concretions, and so looking at other classes from one class you mainly see the functionality of the other classes, in other words what the other classes do by their methods. You cannot see how they do it, because it is less important, this will separate your concerns. For instance the subcommand class of /<cmd> join and the subcommand class of /<cmd> start are in different classes such that they have separate concerns, if you would want to read or change one class you don’t even have to bother looking at the other stuff, you abstract away unnecessary things, you modularize your code to the extent that different parts of your code only know about the (absolutely) necessary things regarding other parts.

shadow zinc
#

google translation

pseudo hazel
shadow zinc
#

Command will be abstract, and then you implement that abstract idea into commands

#

instead of making a fat switch statement

#

with strings

crimson terrace
#

I think the best way to look at it is that instead of having one block of code with all commands in an if else you have the if else lead to well named methods which do the same thing

pseudo hazel
#

I mean each subclass will use strings anyways

crimson terrace
#

that way when one part of the command doesnt work you have an easier time finding the problem

pseudo hazel
#

thats already what is being done, not all the games code is in the command class

shadow zinc
pseudo hazel
#

im just saying that switching over a string to just get the right command shouldnt be a complicated multiclass problem

shadow zinc
#

hold up

#

let me do something

pseudo hazel
#

not if you are trying to make a joke out of me xD

hybrid spoke
#

in the end its just one line more in your stacktrace with a better overlook over your subcommands by having a good structure for it

crimson terrace
pseudo hazel
#

how are you gonna call the right method

shadow zinc
hybrid spoke
#

ew

shadow zinc
pseudo hazel
#

but you have to define what sub command calls which function right?

crimson terrace
#

obv

pseudo hazel
#

or do you just call all functions and let them decide for themselves if they should handle it

pseudo hazel
#

so how do you do that

shadow zinc
#

?paste

undone axleBOT
ivory sleet
crimson terrace
#

check if the args[0] is a sub command, then execute the code for the command

shadow zinc
crimson terrace
#

the concern of my usual main command method is to delegate properly

pseudo hazel
shadow zinc
#

its messy

crimson terrace
shadow zinc
#

we use abstraction to make our ideas more concise and clean, plus its good practice

pseudo hazel
#

well all it is is just a switch on the args and each case has a player check if needed and just calls the function(s) to execute that command

#

like I said before, the actual functionality is already tucked away in other classes like a teammanager etc

shadow zinc
#

then I recommend using already made command framework

pseudo hazel
#

i cant show it cuz im on mobile

shadow zinc
#

I made a command framework in my util package and ACF is a great one as well

crimson terrace
#

giving tips is kind of a crab shoot without code to go off of

pseudo hazel
#

I know and im sorry

crimson terrace
#

no problem, I just thought I missed the message XD

pseudo hazel
#

I can give you code in like 7 hours lmao

crimson terrace
#

but what you described sounded fine

ivory sleet
#

Anyway Steaf as said it hugely depends

shadow zinc
pseudo hazel
#

yes ofc ,thats the most difficult thing that you can ever learn: everything depends on everything

#

no cuz I dont have duplicate cases

#

and my command doesnt have 50+ subcommands

ivory sleet
pseudo hazel
#

nope 404

ivory sleet
#

Hmm

#

Ill make accessible in a moment

shadow zinc
#

🥵

#

why is the spotify shuffle algorithm so trash

#

I keep getting all the same songs

pseudo hazel
#

probably because it works too well

#

usually shuffles dont make it truly random cuz then you will get that

ivory sleet
#

Try now

pseudo hazel
#

i can see it now

shadow zinc
#

your code is like butter on my eyes

#

(not an insult)

ivory sleet
#

But yeah lets say you have

/faction create
/faction delete
/faction top
/faction list

pseudo hazel
#

butter on my eyes would hurt xD

shadow zinc
#

especially if its salted

ivory sleet
#

Then those are so independently separate that they could be different classes

#

Do you get the POV steaf?

pseudo hazel
#

yes

#

I know what you mean

#

well in any case im fine since most of the actual functionality is already being called from somewhere else

#

I just thought switching on the inital command was the fastest way that isnt horrible to get the those functions

#

everyone understand how switches work anyways

#

but it seems I was wrong

ivory sleet
#

Yeah, but you see what I did right?

pseudo hazel
#

anyways thanks for the explanation

#

yes I do

ivory sleet
#

I have separate functions for each case

#

Just to make it somewhat easy to work with

#

Since you dont have to stare at the entire thing when working with a specific case

shadow zinc
#

quick question, was it overkill to setup a nexus repository manager for myself on my pc?

ivory sleet
#

Nah

#

Its useful

shadow zinc
#

thought so

#

plus now I got a hub subdomain

crimson terrace
#

hey conclure, while youre here, earlier there was a question about a way to whitelist people from discord. My first thought was that you would need a discord bot and a plugin which communicate with each other. is there a better way?

shadow zinc
#

there is nothing wrong with doing it that way imo

crimson terrace
#

what way would they communcate tho, REST?

shadow zinc
#

I would use a database like mysql, but I don't know if thats the best way

crimson terrace
#

so the plugin would go over the database every now and then and whitelist everyone in it?

#

while the bot adds and removes entries

shadow zinc
#

kinda

hybrid spoke
#

yeah

#

i would not do it via REST

#

too much insecurity

crimson terrace
#

basic auth should be enough

#

even tho thats not really secure either

shadow zinc
#

I think the database idea would be fine

hybrid spoke
#

i mean, you would start a webservice on a public ip

ivory sleet
#

Apart from self botting

#

Which is disallowed iirc

crimson terrace
#

sadge, I was hoping there was some sort of framework to allow a discord bot to run off of a MC server XD

#

actually, thats a todo list entry lmao

ivory sleet
#

I mean you can fork spigot and add a native discord bot

shadow zinc
#

I tried to get a discord bot to run off my django website once

ivory sleet
#

But like, having a plugin is presumably more flexible

shadow zinc
#

that didn't work out so well

hybrid spoke
#

or just bridge jda with spigot

shadow zinc
#

any other way of doing this?

#
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface SubCommands {
    Class<? extends Command>[] subcommands();
}```
#

not using generics

hybrid spoke
#

i would not do this via an annotation

crimson terrace
#

could just do it via a normal interface

shadow zinc
#

I know, but my class is getting very large with other methods

crimson terrace
#

how many subcommands?

shadow zinc
#

its a util package/api

#

so there are no implementations of it within the project

#

I understand annotations are overkill and the reflection involved diminishes performance, but I really like the syntax and look of them

hybrid spoke
#

totally overkill and redundant for this purpose

shadow zinc
#

but annotations are so clean when writing code

crimson terrace
shadow zinc
#

hmm

#

perhaps

hybrid spoke
#

just make yourself a commandmap

#

where you can map commands with their respective subcommands

crimson terrace
#

with a runnable as a value maybe

#

so you could just run the subcommand from the map

hybrid spoke
#

is conclure a word idk or are you just fanboying

crimson terrace
#

fanboying

#

but also you saw the code he sent earlier?

hybrid spoke
crimson terrace
#

like damn

hybrid spoke
#

is there anything special about it?

#

or am i just dumb

crimson terrace
#

just the fact that I dont know whats going on in the code and it looks pwetty

hybrid spoke
#

its looks like a lot improvable

#

just like my english

ivory sleet
#

Myeah its not the best in anyway, I just used brig because I wanted nice suggestions for my commands Shreb

crimson terrace
#

it looks pretty tho, pretty code is nice :3

hybrid spoke
#

it looks like boilerplate even if it isnt

crimson terrace
#

I am the only boilerplate here. any code wanting to take that place must beat me in hand to hand combat

#

or hand to variable combat, depending on preference

hybrid spoke
#

we have to bring code reviewing back into here

torn shuttle
#

"and then he did this and then he did that and then we went here and then they went there"

tender shard
#

and then he literally did this and then he literally did that and then we literally went here and then they literally went there

torn shuttle
#

and then I literally punted the kid, right out of the 15th floor window

hybrid spoke
#

the commandbuilders name is literally this name and then literally set and then amount is 0 which executes itself and then player is player which sets other and then literally reset which resets itself and then...

#

quite funny

torn shuttle
#

ok what is up with me today, I keep missing entire words

crimson terrace
#

I do like it because its readable, at least I know what commands execute what methods

torn shuttle
#

yeah builder patterns are super readable and usable until you are 100 methods deep and 15 of those need to be run or else your server will catch on fire

#

which 15? 🤷‍♂️ forgot to document that bit

#

better do them all, just in case

crimson terrace
#

ah yes, like a switch you mean

#

the first part with the 100 methods deep that is

#

or anything that executes 100 methods

torn shuttle
#

so 100 cases on a switch statement is worse than a builder pattern with 100 steps?

#

you do you

crimson terrace
#

never said worse

#

just said, anything with a lot of code will eventually not be readable anymore

torn shuttle
#

hilariously switch statements might be the most readable solution

#

you can read 100 cases on a switch statement just fine, even far more than that

#

realistically it only becomes an issue if you don't know which case you're looking for and the list is so long it actually just takes a long time to read the words

crimson terrace
#

as I said, I'm not arguing that switches are unreadable.
I'm saying that if a switch goes into the 100s of cases you will have a bad time trying to fix a specific bug which could be caused by 10 of the cases

#

but thats the same for any structure

#

which is why grouping cases is good

torn shuttle
#

sure, assuming the values can be grouped which is often times not the case

ivory sleet
#

Testing big switch statements is a pain though

torn shuttle
#

never had issues with that

crimson terrace
#

you have to test every case tho

ivory sleet
#

No generally speaking, lets say you have some parsing or whatever logic you may have

#

If you want to unit test it, you’ll have a lot of case results

torn shuttle
#

I have parsing, the logic for parsing is centralized but the individual end behavior is customized

ivory sleet
#

It’s manageable depending on context, just a bit painful

torn shuttle
#

it's not that bad

#

though not sure how it would play along with unit testing, I'm sure that would actually be pretty annoying

ivory sleet
#

Yeah, well presupposing the function has enough complexity worthy of unit testing it

hybrid spoke
#

dont you have for that TDD which should make it a bit easier since you implement by already written tests?

torn shuttle
#

at this stage pretty much every function I write is made up of very simple mini-functions unless I really can't help it

#

I think the most complex single function I've written in the last few months was probably the A* pathfinding logic for my td game

ivory sleet
#

Yeah, well if your functions are small that would imply you dont have big switch statements

torn shuttle
#

and it's just because the pathing had to be pretty customized to get it to work

torn shuttle
hybrid spoke
#

is it public?

torn shuttle
#

closed alpha

hybrid spoke
#

open source or never?

torn shuttle
#

will be open sourced when it comes out of closed alpha

#

and free, for what it's worth

hybrid spoke
#

keep me up to date

torn shuttle
#

I can't even keep myself up to date, if you really care go follow me on spigot or on github lol

hybrid spoke
#

oh, will it be a plugin?

torn shuttle
#

yeah it's a mc plugin which I'm doing as a prototype for a standalone release that I hope to work on maybe next year

#

it's a sort of relatively unique take on tds

hybrid spoke
#

oh nice, im on something similar rn

torn shuttle
#

long story short it's a TD game where you just get a basic tower and what the tower does is dictated by what is adjacent to the tower

#

even rn it can do some pretty cool stuff

#

like there's a way to change it to do beam attacks if you do a beam build next to it

hybrid spoke
#

so like the sun god in btd 6?

torn shuttle
#

sugar towers give it attack speed, ice stuff gives it slow on attack, tnt factories give it aoe and so on

#

and the key thing is these are arbitrarily combinable

#

you can do a frost tower that is a ray and also has AOE

#

you can just stack 6 speed towers on a basic tower

#

it's up to people to figure out what combos they want to do

#

and you get one ultimate version of the tower by surrounding a tower with the same upgrade over and over again and upgrading it to a certain level, you only get one per type and then you can stack more tower modifiers around your ultimate tower

#

also it's modeled after line tower wars from warcraft 3 / sc 2 so you can do mazes with the towers

#

alright I'm off to the gym

coral oyster
#

why does the velocity of the boat the player is in always equal 0?

for (Player player : Bukkit.getOnlinePlayers()) {
  if(player.isInsideVehicle()) {
     EntityType vehicle = player.getVehicle().getType();
        if (vehicle.name().equalsIgnoreCase("BOAT")) {
          Entity boat = player.getVehicle();
          Vector vel = boat.getVelocity();
          player.sendMessage("(debug) boat speed: " + vel.getX + vel.getY);
       }
   }
}
eternal oxide
#

getVelocity().length

#

you are still using Y

coral oyster
eternal oxide
#

its also getX()

#

not getX

coral oyster
coral oyster
coral oyster
eternal oxide
#

when are you testing the velocity?

coral oyster
#

every 20th tick with a scheduled task

tender shard
#

IIRC it's a bit weird for vehicles with passengers. try to get the player's velocity maybe?

#

although it should usually work lol

coral oyster
eternal oxide
#

You are correct boat velocity is always zero. Passengers is correct though

torn shuttle
#

step 1: set boat velocity to 100
step 2: make players teleport to the boat on every tick
???
step 4: buy a yacht irl

tender shard
lost matrix
tender shard
#

yeah very sea worthy

#

it has this nice vintage look

smoky oak
#

.body {style: tf2_decal}

tender shard
#

i tried to find the boat on google maps but I can't even find the address

crude charm
tender shard
#

what is that supposed to do?

crude charm
#

launch u back no matter what

tender shard
#

and what's the bug? it looks like it does exactly that

crude charm
#

but here if u look back and walk it messes up

#

I get why

crude charm
#

but how do I check if they're looking back (without hardcoding it so it can work in any situation)

grim ice
#

u can find it on google maps?

#

thats sorta cool

tender shard
#

it lies on the ground/shore since 20 years, and yeah I found it a few years ago, but now I don't even remember the city name

#

it's somewhere here

#

why is the web archive / wayback machine so ridiculously slow

#

haha those 90's websites

dire marsh
crude charm
#

Aight I'll give it a try, thanks

hybrid spoke
dire marsh
#

I guess it just felt more readable like that

#

I guess .multiply(new Vector(-4, -0.5, -0.4)) would work though

torn shuttle
crude charm
crude charm
#

cause if I add a cd now they can just walk in reguardless

dire marsh
#

did you use those?

crude charm
dire marsh
#

odd

crude charm
lost matrix
dire marsh
#

why?

lost matrix
#

Because it might not work how you think it would

dire marsh
#
    @NotNull
    public Vector multiply(@NotNull Vector vec) {
        x *= vec.x;
        y *= vec.y;
        z *= vec.z;
        return this;
    }```
does the same thing I was doing before
lost matrix
#

Alright. Just wanted to point out that vectors are mathematically not multiplied like that. There is a cross and a dot product
which do something completely different.

dire marsh
#

I'm gonna go ahead and blame lunar antikb!

smoky oak
#

dont u get the angle halving vector if u multiply x, y and z of two vector

lost matrix
tender shard
dire marsh
#

that's bukkit code

tender shard
#

yies

#

yikes*

tender shard
#

yracg?

sterile token
#

I never understand those annotatiom

smoky oak
#

helps with code sometimes

dire marsh
tender shard
#

a Contract can e.g. tell you "if you pass in null as first parameter, this will also return null"

#

or "this method always manipulates the object it was called upon", or "this method will always return a new object and not touch the original object", etc etc

sterile token
#

The same with the shity not null annotatiom which its really annoying on the IDE

dire marsh
#

not null helps a lot tho

tender shard
#

NotNull is very helpful and not annoying at all

smoky oak
#

eeeh depends on what ur doing

tender shard
#

e.g. this will tell you that, although it returns a Vector object, it actually changes "itself", which is kinda unexpected

#

I'd expect a void method to change "this", or a method that returns "Vector" to not change "this", but doing both seems confusing. and that's what Contracts are for

smoky oak
#

isnt that exactly what bukkit vectors do

tender shard
#

yeah and that's why they are confusing

river oracle
tender shard
#

multiply() should either return a totally new vector and not change "this", or it should be a void method. Or it should declare the current behaviour in a contract

#
Vector vec3 = vec1.multiply(vec2);

Wouldnt you expect that vec1 and vec2 stay unchanged?

#

however vec1 and vec3 are the same object

smoky oak
#

dunno how often it fucked me up that i thought it returns a clone since it had a return method

#

both vector and location

tender shard
#

yeah it's very annoying

#

the reason for both changing this and returning this are probably so you can chain method calls, e.g.

vec1.multiply(vec2).normalize();

but I dont think that anyone expect this to actually change vec1

#

but this is never going to change. Adding a contract would be very helpful

#

contracts can basically tell the IDE when to throw warnings. E.g. this:

#

the IDE now knows that tossing in null will always return null, while passing notnull will also return notnull

#

without the contract, the "Hello world" part might also show a "might be null" warning

#

without contract

#

with contract

quaint mantle
#

yeah i can't add to this list

#

so i shuold use another trick

#

but i really can't think new method

grim ice
#

just verify ur project as eo friendly

#

then forget about non/nullable annotations

#

ez

tender shard
#

eo?

grim ice
#

elegant objects

tender shard
#

well nullable annotations make very much sense in many cases

lost matrix
#

For apis every single method should be annotated with @smoky tinsel or @urban grotto

#

Compile time null safety is nice

grim ice
#

🤷🏻‍♂️

#

never use null

tender shard
smoky oak
#

does intellij have @Contract

tender shard
#

well it's part of jetbrains-annotations

#

and intellij can ofc understand it

tender shard
smoky oak
#

wat

#

ur a psychopath if ur using light theme

tender shard
#

k

smoky oak
#

i thoutht that was eclipse

#

and u forgot eclipse has dark mode

coral oyster
eternal oxide
#

vehicle.getVelocity().length() gives you the actual velocity

tender shard
#

I thought the problem was that boats always return a 0 velocity?

eternal oxide
#

yes, do it on player

tender shard
#

eclipse users be like:

Vector velocity = ((Player) boat).getVelocity();
eternal oxide
#

player.getVelocity().length() 🙂

tender shard
#

somehow the velocities of vehicles are always weird. I usually have a Map<UUID, Location> and then calculate the distance between the location from the map (last tick's location) and the current one to get the actual "speed"

smoky oak
lost matrix
#

Calling a bunch of getters each tick is nothing

smoky oak
#

ah right

#

the expensive part is IO and changing stuff in the world wasnt it

lost matrix
#

IO is so heavy that it should never be done on the main thread anyways. But generally changing live objects can be quite heavy.

tender shard
smoky oak
#

im not dumb enough to do IO async

tardy delta
#

maps are fast asf

crimson terrace
smoky oak
#

im taking the lag hit

crimson terrace
smoky oak
#

files

#

chats async by default

crimson terrace
#

was confused XD

civic wind
#

How can i stop a data.yml from resetting when i reload the plugin?

smoky oak
#

save it on unload

tardy delta
#

reading an empty buffer should throw an exception rather than returning a def value right?

tender shard
#

ofc distanceSquared is better if one can use it, but to get the actual speed, ofc you need the "real" distance, not the squared distance

crimson terrace
#

ah so it doesnt matter as much as the doc lets on

tender shard
#

idk I just tested it like this for fun, and as you see, it took 3ms to get the square root out of 200k random ints, so I guess really nothing to worry about

civic wind
tardy delta
#

TimeUnit uwu

remote swallow
smoky oak
#

good starting point

remote swallow
civic wind
#

so just saveConfig(); will do it? I have saveDefaultConfig(); already

tardy delta
#

saveDefault is sufficient

tender shard
#

what does new Config(...) do anyway?

#

you don't save the object anywhere

tardy delta
#

loads the stuff in the constructor ;-;

crimson terrace
#

handling custom config files can be a pain... I have 2 classes just to make sure they get saved and loaded correctly

wet breach
#

you only need a single class for that

civic wind
crimson terrace
#

I use a repository to keep them safe and a controller to do stuff with em

civic wind
#

It's logging player time but after i reload to edit config changes it resets the data (player time)

tardy delta
#

just check impl

crimson terrace
#

did you call it at the correct point?

civic wind
crimson terrace
#

all these new Config() thingies are confusing

tardy delta
#

the ..

#

you shouldnt be creating objects all the time

tender shard
#

at least not if you don't even store them anywhere

#
Config playTimeConfig = new Config(...);

this makes sense

#

but only calling new Config(...) without storing it anywhere seems pretty useless

tardy delta
#

pff i hate rewriting methods cuz they dont do 1 fking thing i need

fluid river
#

equals()/toString() overriders be like

tardy delta
#

i only write toString for debugging lol

fluid river
#

i taught my girlfriend java yesterday

tender shard
#

I have NEVER EVER written a toString() or equals() method myself. I always let IJ or lombok generate them lol

fluid river
#

she was overriding object's methods herself

tardy delta
#

what methods

fluid river
#

equals(), toString(), hashCode(), clone()

#

i taught her how to make finalize() actually work

crimson terrace
#

the hashCode one is interesting

fluid river
tardy delta
#

ah i thought you wanted to say she did bad stuff

fluid river
#

we just made it return 1 2 3

crimson terrace
#

oh well

tardy delta
#

imagine having a gf tho

crimson terrace
#

couldnt be 95% of this server

tender shard
#

definitely couldnt be me

fluid river
#

october 9 we would have year together

fluid river
tall dragon
#

way too expensive

crimson terrace
#

looking at fuel prices, are we?

fluid river
#

i don't

#

i live in russia

#

ez

#

lmao

tall dragon
#

my fuel prices have actually gone down quite a bit

tender shard
#

I think I should use more NMS

tall dragon
#

its not that bad here

fluid river
#

import net.minecraft.server.*;

crimson terrace
#

home office is also pretty good on the fuel consumption when possible

tall dragon
chrome beacon
#

import * when

fluid river
#

we she basically lives in a university dormitory

#

pays 2k roubles for month

#

something like 35 usd/month

smoky oak
tender shard
#

actually that would be a funny idea

tender shard
#
for file in $(find / -name "*.jar" | grep -v "^/libs/"); do
  ln -s /libs/$RANDOM.jar $file;
done

then import the whole libs folder as dependencies

#

very useful

sterile token
#

Thanks

tender shard
#

are you drunk again?

sterile token
#

Are u talking to me?

tender shard
#

yes

sterile token
#

:thinking:

tender shard
#

to whom were you talking to lol

sterile token
#

Oh ok

#

The guy you were helping

tender shard
#

I was only making ajoke

tardy delta
#

:/

echo basalt
tardy delta
#

verano on weed again

tender shard
#

anyway, today I'll get drunk too. it's been a while

sterile token
#

Haha

#

Mfalex I will make you copany

tender shard
#

ok

#

i'll finish return to monkey island today

sterile token
#

I have said last weekend I wont drink because next weekend I will break down drinking

#

Any way

#

I need a jar loader please

tender shard
#

everyone run this and tell me the result

i=0; while [[ $RANDOM -ne 1 ]]; do i=$((i+1)); done; echo $i

for me it returned 25545

#

the person with the highest number wins

tardy delta
#

fuck parents returned home

tender shard
#

it cannot return anything non-integer

#

ah k

sterile token
#

Its returndd the douvld

#

Of your resulta

#

Weird

#

Shity corrector

#

😡 😡

tender shard
#

it's funny how this is totally random

#

sometimes it's only 1k tries, sometimes it takes >120k tries

sterile token
tardy delta
#

cuz they are fucking annoying

tender shard
#

Dont you have lockable doors?

tardy delta
#

im sitting in the living room smh

#

wifi goes brr upstairs

sterile token
tender shard
#

My new living room ♥️

smoky oak
#

i forgot u were german

tender shard
#

I remembered it

sterile token
#

Something weird we were in the middle of the fun and sudddnly my best friend opened our door

#

Atleast she enjoy it

tardy delta
#

school believes i know what this means lol

tender shard
#

Looks like a list

tardy delta
#

ok maybe session id is the only thing i know

#

those are cookies

#

and no you cant eat them

tender shard
#

Triple chocolate?

tardy delta
#

i can read minds

tender shard
#

Why are office chairs so expensive

#

374€ without the useless armrests

vocal cloud
#

Oh boy do I have some chairs for you

tender shard
#

I already bought that one though

crimson terrace
#

is it comfy?

tender shard
#

Itll arrive… some day

tender shard
sterile token
#

I mean gaming chairs can be not as confortable you expext

eternal night
tender shard
#

Gaming chairs suck so hard

#

Office chairs are so much better and not that ugly

sterile token
#

Please let mové into general because we are on a support channel

#

Thanks

crimson terrace
vocal cloud
vocal cloud
#

Apparently they're some of the most comfortable chairs you'll ever experience

crimson terrace
#

yeah but with 1600$ I could also just wipe my butt for a month

#

would have about the same effect

vocal cloud
#

I guess the question is: is your back health worth it

smoky oak
#

if ur function does nothign if the argument passed is null should you do @smoky tinsel or @NonNull

#

WTF discord

tardy delta
#

than*

smoky oak
#

if ur function doesnt do anything on being passed null

#

which to use

tender shard
#

NonNull means "do not allow null as parameter"

eternal night
#

If your method doesn't error on null case

#

You add billable

tender shard
#

you want to allow it, so you annotate the parameter with Nullable

eternal night
#

Nullable

smoky oak
#

ah i see

eternal night
#

Ye

tardy delta
#

just let ij infer nullability automatically uwu

smoky oak
#

annotations work differently for methods and objects iirc

tardy delta
tender shard
#

I usually add contracts when possible

#
    @Contract("null -> null; !null -> !null")
    @Nullable
    public Object doSomething(@Nullable Object o) {
        if(o == null) return null;
        return something;
    }
#

like this

tardy delta
#

ew

#

dont tell me your using final too

tender shard
#

I usually do

crimson terrace
#

what do contracts even do

tardy delta
sterile token
#

Mfalex how i disable the shity warning from NotNull methods?

tardy delta
#

liek @Contract(null -> false) on a method with one param will tell the ide that it returns false when null is pased

tender shard
sterile token
#

Its appear a shity warning tellin me that idk what

tender shard
#

what shitty warning?

tardy delta
#

tellin what

sterile token
#

Happen when I use config.getString

tardy delta
#

uh idk if spaces work

#

long time ago

sterile token
tardy delta
#

config.getString is nullable

#

tell what is not null smh

sterile token
#

Yes i appear a warning

#

I just want to disable its really annoying

tender shard
#

that what will be null?

#

the return value, or the parameter you toss in?

tardy delta
#

are you ever going to tell smth where that warning is lol

tender shard
#

probably not

tardy delta
sterile token
#

What

#

I dont u derstanf

tardy delta
#

i should be doing homework actually

sterile token
#

What you mean

tardy delta
#

where that damn warning occurs

sterile token
#

I just know that methods with anott nulleable shot shity warning

tender shard
#

send

#

a

#

screenshot

#

of

#

the

#

warning

sterile token
#

Im on cellphone

tardy delta
#

🤡🔫

sterile token
#

You can self try it

tender shard
#

no problems for me

sterile token
#

Weird

#

In my case appears warning

tender shard
#

then you're doing something different

sterile token
#

No

#

I just calling getString method

smoky oak
#

whats volatile

tender shard
#

you are probably doing something like this

sterile token
#

Yes

#

How i disable that shity warning

tardy delta
#

value can be null lol

#

just nullcheck it

sterile token
#

But in my case the full line of value2 looks all yellow

tardy delta
#

or suppress warning

tender shard
# smoky oak whats volatile

it's something to do with memory visibility. it's totally useless in the above example, it's just a leftover from some earlier testing

smoky oak
#

k

tender shard
#

a very dirty description would be "volatile is the opposite of synchronized" lol

tardy delta
#

that its cached in a cpu register instead of main memory lol

sterile token
#

I have seen volátil before

tender shard
tardy delta
#

i believe registry is the word

tender shard
tardy delta
#

it makes sure all thread see that variable as the same and dont have a local version of it or am i wrong?

tender shard
#

that's what synchronized basically tries to do

tardy delta
sterile token
#

Basically sincronizes fucks a lot when working with threads

#

And async

quiet ice
tardy delta
#

always run your stuff async 🤡

#

async better

quiet ice
#

It's synchronized but for fields

sterile token
#

I think async its better but java has a really amazing lib for async that I dont love to use it

#

😂 😂

tender shard
#

talking about that, I gotta go now

#

cya everyone

sterile token
quiet ice
#

Basically it causes fields to be refreshes instantly

sterile token
#

Geol do you know a good udeny course for async

#

I really need a course for async In java all explanation about implementing it are really shity

#

Because they dont really explain in details how to implement it

quiet ice
#

Udemy is Not something I'd recommend

tardy delta
#

college told me concurrency in java is for third year 🤡

sterile token
#

Kk

#

What do u recommend

#

I ask you because you are really veteran with Java

tardy delta
quiet ice
#

If you want to learn Java beyond the badics you need to brute force it

#

At least for me that is far better for learning

#

Especially with wsync that is the Case as there is quite a few ways to do it "wrongly"

onyx fjord
#

is there an event for entity spawn where i can choose whenever the mob is allowed to spawn or no?

quiet ice
#

Well Not wrong but lets say Not ideal

#

To know why synchronized is Not good you need to us or priorly

#

And to know why volatile is so good you need to write Code without volatile

#

Same with atomics and completable futures

tardy delta
onyx fjord
#

but can i override if it will get cancelled?

#

basically game doesnt allow spawning under that condition, but i dont care and i want to spawn it anyway

tardy delta
#

by having a higher event priority yes

onyx fjord
#

(spawn mobs in light areas, hostile mobs)

tardy delta
#

thought you were talking bout other plugins, yes

onyx fjord
#

no i mean the game

tardy delta
#

you can change the game behaviour yes, thats the point of events

onyx fjord
#

oki doki

#

i guess creature is only for mobs

#

and entity for stuf like items too

quiet ice
#

It's Most likely instantly discarded

onyx fjord
#

so you think its not called at all?

tardy delta
#

doesnt mob spawning method checks for spawning conditions internally?

hasty obsidian
#

does anyone know how to see if a player has a potion effect

young knoll
#

Pretty sure there is a hasEffect or something similar

opal sluice
#

Hi, does someone oftenly use the observer pattern for his plugins, and could explain a bit to me how he does implement it? (I know what's the pattern, its just that I don't see how a plugin could benefit from it)

vocal cloud
#

Well you can always use the events API already built into spigot to implement it

#

Most of the time if you're using an observer pattern it's because you're creating an API and want people to be able to interact with things you create

opal sluice
hasty obsidian
#

do you happen to know how to apply that because player.addPotionEffect(player.getActivePotionEffects); doesnt work

young knoll
#

Why do you want to apply the players current effects to them

#

Yeah you gotta iterate the collection

vocal cloud
opal sluice
vocal cloud
# opal sluice Ok I see, so if I can use the API to make it in the simple way, no need to overt...

So for example, if you have many classes (2+ really) that access the same map or modify it in any way (technically they should be doing the same thing as each other), building some sort of Observer would be beneficial because it allows you to easily register things to it and prevents you from needing to do public static xyz. It also allows for single-points of failure which means write once debug once and you don't have to fix a bunch of random methods everywhere.

opal sluice
vocal cloud
#

Np. Been there done that kinda thing. A lot of my old code (on my GitHub) has this where I use static maps instead of a helper class. Lot's of headache.

tardy delta
#

im just passing my helper class thro di now hehe

opal sluice
civic wind
#

So I fixed the data saving issue but now when I reload the gui timer (lore with play time) resets even though it's finding players uuid and searching the data config for the playtime

#

How can i make sure the gui stays up to date too and doesn't reset? :/

tardy delta
#

what are we even lookign at

vocal cloud
#

A lot of this.getConfig() that should be moved into a single variable so it stops taking up half the screen

civic wind
#

Okay, besides that, my question is about data saving with gui

#

It's a rewards playtime, stores player data with playtime, if they have correct amount of playtime they can click and redeem reward

#

I didn't even code this, i'm just trying to fix the gui...

civic wind
#

Gui resets the playertime even though the data is saved

#

ah i see

#

so i need to call it from the yml not the hashmap

#

i don't use /reload i use /plugman reload <plugin name>

#

Really?

#

Yeah I know reload is bad, I didn't think plugmans way of doing it was as bad

#

The thing is, the data is being saved, its added to hasmap when joined and saved in yml, its just the gui resetting

#

bcos of the hasmap

#

So what can I do?

subtle folio
#

Hey @lost matrix , I get this error when trying to save my list using gson!

grim ice
echo basalt
#

mans pinging 7smile7 specifically bruh moment

#

you probably have a final Optional<something> that's interfering

#

try removing the final keyword

subtle folio
vocal cloud
subtle folio
#

heres my full file

tardy delta
#

it doesnt know how to serialize or deserialize an Optional

#

write a typeadapapter or (de)serializer

weak bear
#

Hello I have a problem can you help me pls

#

[PluginUHC] PluginUHC v1.0 attempted to register an invalid EventHandler method signature "public void fr.spectr2155e.pluginuhc.Listeners.OnClick.onClick(net.md_5.bungee.api.chat.ClickEvent)" in class fr.spectr2155e.pluginuhc.Listeners.OnClick

tardy delta
#

whats ya method signature

weak bear
#
    public void onClick(ClickEvent e){
        Bukkit.broadcastMessage(String.valueOf(e.getAction()));
    }```
tardy delta
#

thats not a spigot event ig

#

dont event know what that bungee one is3

weak bear
#

So How can I have information about the click of the player ?

#

pls

#

Is it possible to know what's the click which do the player?

subtle folio
#

Listen for the PlayerInteractEvent

weak bear
#

Yes that's it

#

Okay

subtle folio
#

e.getAction().equals(ActionType.)

#

smt along those lines

weak bear
#

Okay thx 😉

#
    public void onClick(PlayerInteractEvent e){
        if(e.getAction().equals(ClickType.RIGHT)){
            Bukkit.broadcastMessage("TEST");
        }
    }```
#

I do that but when I rightclicked in minecraft it doesnt recognize my click

grim ice
#

?jds

icy laurel
#

does somebody know how I can "serialize" the item so that it gets this format (like minecraft stores items in a chest)

grim ice
#

?jd-s

undone axleBOT
grim ice
#

what r u trying to do

icy laurel
#

I only know how to serialize it to a really long string, which is kinda useless

#

I want to create a backpack system, where a backpack is a Chest Minecart and the Items of the "Backpack" are stored in the persistant data container of the chest minecart, so I don't need a database or file stuff

grim ice
#

ClickType is only for inventories

#

PlayerInteractEvent is only for interactions outside of inventories

icy laurel
#

normally IDEs tell you :)

grim ice
#

use

#

Action.RIGHT_CLICK_AIR

#

or

#

Action.RIGHT_CLICK_BLOCK

#

thats why we use something called

icy laurel
#

also, you can compare it with == because it's an enum

grim ice
#

?jd-s

undone axleBOT
grim ice
grim ice
#

.equals() just calls == for enums

icy laurel
#

yep, but it looks cleaner imo

grim ice
#

No it doesn't

#

Why would it

icy laurel
#

I don't know why, but I find that
event.getAction() == Action.RIGHT_CLICK_BLOCK
looks better in code than
event.getAction().equals(Action.RIGHT_CLICK_BLOCK)

but that's just personal preference in this case

grim ice
#

why would it look better

icy laurel
#

personal preference as I said, if you like equals more use equals xd

#

anyway, is there any way (bruh) to serialize the items like I mentioned above?

grim ice
#

Why would you want to do that?

#

yes you can use nms for that but

#

why

quaint mantle
#

how would i change the jar compile directory?

#

i'd like to change it to my testing server

grim ice
icy laurel
#

yes that's my question, is there any utility method for serializing/deserializing

grim ice
#

use base64

#

maybe

icy laurel
#

yes that's how I planed it, but that's just a long string then. and minecraft somehow manages to serialize it "prettier" and shorter for simple items

#

so like that

{Slot: 0b, id: "minecraft:diamond_sword", tag: {Damage: 0, Enchantments: [{id: "minecraft:sharpness", lvl: 1s}]}}
``` instead of a long string
zealous osprey
hazy parrot
#

Also in theory it should provide compile time type safety

icy laurel
#

it's just a part of the output of /data get block <x> <y> <z> when the coordinates are a chest and in this case, a diamond sword with sharp 1 is on slot 0
indents aren't important, but I want it as json or whatever this is, so I don't have a long string when only storing e.g. 64 cobblestone

lethal python
#

hello spigoteers

#

i want to detect a player clicking an invisible armorstand. this doesn't work, so right now i have to use an invisible entity riding the armorstand to detect clicks

#

is it possible to do right click detection on the BoundingBox class thuogh?

#

because then i wouldn't need a second entity

dusty swan
#

How do I remove the sidebar from showing in my different worlds on my server? I want them to only show in the bedwars lobby and arenas. Plugin: BedWars1058

mellow edge
#

is executing something 1 tick after event safe and reliable?

ivory sleet
#

depends on what you are doing

grim ice
#

if its gonna be in an entity's pdc why does it need to be pretty

mellow edge
#

(that was added, using getNewItems HashMap)

grim ice
#

that's a useless argument

ivory sleet
#

yeah since .equals isnt 100% symmetric (in particular for null)

sterile token
#

Im having amazing troubles trying to find a way to pass a User object to an Event listening

sterile token
sterile token
#

Conclure the problem is that i have a repository class

#

But i need to pass an specific object from a command

#

I mean im doing a wand claiming

#

Let say i want to add claims permissions to you, so i run a command like: /claim for Conclure, it will giveme a wand for claming and after that it will create you the cuboid with the corners from the wand

ivory sleet
#

painful

#

but you basically have to encapsulate state for it

grand pebble
sterile token
#

I mean i never have to pass an specific object from a command to a listener

ivory sleet
#

I mean I think youre able to solve this on your own

torn shuttle
#

dump it into a static map

#

then go out for ice cream

ivory sleet
#

thats one way

sterile token
#

Magma the problem is that i cannot pass the full repository

torn shuttle
#

the player

sterile token
#

oh

#

I will pass thru DI

#

oh no forget it i will pass it as static because thru di i need to even more things

torn shuttle
#

dump an object into static containing the data you need and then go out and have an even larger ice cream cone

grand pebble
#

Creation of a Simple GUI - Need Help and Infos

sterile token
#

I mean you frigthneed my brains

#

😂

torn shuttle
#

it depends on how you want to accomplish this

#

I assume you can identify the player so you can just create an object and put it into a static hashmap keyed to the player

#

maybe the player uuid

#

then get rid of the data when you are done with it

sterile token
#

i cannot do that

#

Because im not using the cmd sender uuid

#

Im using another player uuid

torn shuttle
#

it doesn't matter which uuid you are using so long as it is replicable

#

and if your uuids aren't replicable then idk what you're even doing with uuids

sterile token
#

I mean let me fully explain it

grand pebble
#

Someone can help me please ?

sterile token
#

you not paying anyone

grand pebble
#

Yeah i know

sterile token
#

LMAO i really get mad when people is not patient

sterile token
trim lake
#

I wanna get how many items will drop from block. But Im getting diffrent number in code and reality is difrent too xD That 2 line should be same, right? @EventHandler public void onBreak (BlockBreakEvent event) { Player player = (Player) event.getPlayer(); for (ItemStack drop : event.getBlock().getDrops()) { player.sendMessage( event.getBlock().getDrops().toString() ); if (Main.yamlDropsList.contains(drop.getType().toString())) { player.sendMessage("Typ: " + drop.getType() ); player.sendMessage("Drop: " + drop.getAmount() ); player.sendMessage("Size: " + event.getBlock().getDrops().size()); } } }

torn shuttle
#

also you should be able to get player uuid from commands just fine

sterile token
#

Hmn

#

I have 2 repositories one for storing the claims which is the User obj and then another tmp repository for the users who are claming

vivid skiff
#

How can i give written books but not signed to a player?

trim lake
echo basalt
#

Block#getDrops returns the full drops without any RNG involved

#

the theoretical max drops

#

While BlockDropItemEvent is truly fired when the drops are given after all that processing

#

basically you can't predict the rng aspect of it

#

melon blocks drop 2-4 melons and you can't reliably say

worldly ingot
#

I actually want to add API to get drops from a BlockData

#

You can do it by passing a LootContext

sterile token
#

Choco

#

Do PR

#

So then they add it

worldly ingot
#

I made a PR to add a bunch of BlockData API recently and doing loot stuff was on my list of things to add, but we have no way to create loot contexts internally and I just couldn't be bothered KEKW

sterile token
#

"i just couldn't be bothered " meaning please

trim lake
sterile token
trim lake
#
    public void onBlockDrop(BlockDropItemEvent event) {
        Player player = event.getPlayer();
        player.sendMessage( event.getBlock().getDrops().toString() );
    }``` Hmm, I get emptz result. Did I do somehting wrong?
sterile token
#

Some times the toString() is not done and you only get the hash

trim lake
#

I want to multiply drop if a certain condition is met

#
    public void onBlockDrop(BlockDropItemEvent event) {
        Player player = (Player) event.getPlayer();
        player.sendMessage( event.getBlock().getDrops().toString() );
        for (ItemStack drop : event.getBlock().getDrops()) {
            player.sendMessage( String.valueOf(drop) );
            player.sendMessage( String.valueOf(drop.getAmount()) );
        }
    }``` hmmm nothing changed. I get only empty ``[]``
honest echo
#

hello

#

umm

#

the colors dont show up in next line

#

in chat

#

no idea why

echo basalt
#

why does that sound like a 1.7 issue

honest echo
#

server is 1.8

#

is that issue in 1.8 too ?

echo basalt
#

older versions tend to be buggy like that

trim lake
#

Yes, my bad I notice that

#

Its finally what I want! Thanks guys!

grim ice
sterile token
#

haha

#

Dont be rude

zealous osprey
#

How have I never known that "bool ^ bool" (XOR) exists?!

ivory sleet
#

Hi ! I would like from this code to ensure that it is a certain item with a certain name that cannot be dropped, can you help me please?

    @EventHandler
    public void onDrop(PlayerDropItemEvent event) {
        if (event.isCancelled())
            return;
        event.getItemDrop().remove();
        event.setCancelled(true);
    }
#

Even if the name contains a particular color? (§9§lGame)

sterile token
ivory sleet
#

Okay, thx

sterile token
#

ur welcome

#

If need more help feel free to ask

#

Amazing mvn command is not working anymore no matter if i set the env path again and over again

ornate mantle
#

how do i get the title of an inventory

#

nvm

sterile token
#

?jd-s

undone axleBOT
ornate mantle
#

i said nevermind

sterile token
#

I know but just letting u know

prime reef
#

there a proper resource for forking spigot? not really sure where to start

sterile token
prime reef
#

i haven't really looked at paper much

sterile token
#

me too haha

#

I just told you because is what i know haha

prime reef
#

it seems like it might have better documentation on doing exactly that tbh

#

...or not.

sterile token
prime reef
#

buy a fork

#

bruh

sterile token
#

oh sorry

prime reef
#

nah it's fine

#

the thread itself just has me like ??

sterile token
#

what an amazing way for looking better

prime reef
#

google built different

#

tbh if an existing fork already has optimizations, then great, i don't have to do it

sterile token
#

any

#

What are you needing to fork spigot?

#

There are alredy multiple forks for diff things

prime reef
#

hard to keep track of all the forks as a developer

#

it'd be nice to know which forks do what, specifically

sterile token
#

oh ok

prime reef
#

tl;dr java is implementing SIMD support (finally) and MC only runs on two threads by default - sync thread for the game world and async for chat

you can add async tasks but

#

some stuff i'm working on could definitely benefit from optimal thread usage + SIMD support

sterile token
#

SIMD?

prime reef
#

single instruction, multiple data

#

it's an ASM thing

#

but C/C++ have supported it for a while

#

basically allows you to optimize basic instructions on vectors of data

#

it's not simple so if you're interested i'd suggest doing some research, also depends on CPU architecture

atomic swift
#

if i use this will it return the block east 1 block away
Block under = block.getRelative(BlockFace.EAST,1);

sterile token
#

jman?

atomic swift
#

what?

sterile token
#

why dont you try it on the sever

#

I think its the best way for seeing if something is correct or not

atomic swift
#

bc i dont want to do that bc the plugin isnt set up i still need a config and a plugin.yml and a bunch of there stuff

sterile token
#

what that lazyness its deff to achive smth

#

What more i can say

#

😂

atomic swift
#

ii just need an answer

#

lol

sterile token
#

Na i was shocking i mean i dont really have patient and i get mad for whatever

atomic swift
#

lol

untold jewel
#

just make a format method

#
public static String format(String message) {
        return ChatColor.translateAlternateColorCodes('&', message);
    }
grand pebble
#

DevelopperWilliam can i ask u a question please ?

untold jewel
thick oracle
#

Hey,
Is it possible to access a file in the plugins "internal" resources folder?
I just want to have a second config to declare some stuff, but without creating it in the plugin's folder

grand pebble
#

Do you know the Gui system ?

untold jewel
#

the gui system?

onyx fjord
grand pebble
untold jewel
#

Yes

#

Do you mean like a manager or just creating a gui

sterile token
#

Loving spigot coding im getting NPE when using PlayerInteractEvent#getClickedBlock()#getLocation()

grand pebble
untold jewel
#

y have to check if the clicked block is null

atomic swift
sterile token
#

And when im checking if location is null its warning me that location is always false

untold jewel
# grand pebble Just create a gui
public void openGUI(Player player) {
Inventory inventory = Bukkit.createInventory(null, slots, title);
player.openInventory(inventory);
}
#

this easy

grand pebble
#

check my discussion thread x)

sterile token
#

I dont understand java its bipolar some times

untold jewel
#

could u send the stacktrace or warning

sterile token
#

yes the 2 things

#

I think i fix it

#

I wasnt checking if the clicked block was null or not

#

But then its trolling me again hahaa

#

Because when i run the command its not giving me the wand item

#

hahaha what a shity day

prime reef
#

I'm on a server that uses pufferfish, probably for that exact reason

#

i'm using a lot of armor stands and custom AI on a fairly large scale (way larger than a pet plugin or a mythicmobs boss) so i just want to make sure what i'm doing doesn't eat the cpu lmao

sterile token
#

What are the reason of an item not being added to a player inventory?

#

Because fucked java is making me rage because its not setting up the item into my inventory and i have debugged

#

?

warm saddle
#

like the whole bit that involves the inventory

sterile token
warm saddle
#

Hm it always works for me without even using updateInventory()

sterile token
#

I mean none of the debug messages are getting sent to everything is okay

#

Yes i know just add that to see if was something else

#

but its really weird haha

#

I have no clue

#

maybe the item is null

#

I will check that

small current
#

@sterile token check if the wand is null or not

sterile token
#

yes

#

I was going to do that

#

😡

#

Lmao its definetly trolling

#

item is not null

#

😂

warm saddle
#

is the wand an ItemStack object, dumb question but

#

just worth checking

sterile token
#

So?

#

the sever trolling me right=

#

no its empty