#help-development

1 messages · Page 2267 of 1

sacred mountain
#

heres the method, and the other screenshot is me printing it once with the method and once using sysout

glossy scroll
#

i never said you asked your question wrong, i was just suspicious that you needed help with something that could be simplified

sacred mountain
#

so it does support color but idk how to check that

glossy scroll
#

so how its done in craftbukkit is

#

Terminal terminal = ((CraftServer) getServer()).getReader().getTerminal();

#

terminal.isAnsiSupported()

sacred mountain
#

erm

#

generic java

#

standalone program

glossy scroll
#

ah

sacred mountain
#

yup

#

just asking as there don't seem to be any minecraft related questions rn

glossy scroll
#

its no issue

#

im not familiar with that

#

CB uses jline

#

maybe you could look into that?

sacred mountain
#

ill give it a go

glossy scroll
#

@sacred mountain looks like people on that stack exchange thread says it doesnt work on windows

#

they also recommend jansi

#

(which is what i said)

#

im not quite sure what the difference between jline and jansi is

#

i believe jansi might be more lightweight and directly useful for what you need

#

though im unsure

wet breach
wet breach
#

but it also supports commands being sent

#

Jansi is just the console itself

glossy scroll
#

Also, on windows, sometimes the terminal supports colors and doesnt use them

#

(basically what frostalf said)

#

then people have to use something called jansiPassthrough

#

which forces color into their console

#

benefit of using Jansi is that you have access to stuff like Ansi.Color.BLACK

wet breach
#

or can use my project above 🙂

glossy scroll
#

true

wet breach
#

it maps hex to terminal colors

#

and vice versa

#

I think it even does RGB

#

anyways, I originally created it for someone else and haven't really had any other use for it XD

acoustic pendant
#

how can i make an npc look at a player? I have these packets, but don't know what else do i need

glossy scroll
#

have you tested that?

acoustic pendant
#

yea

#

I mean, I want every time a player walks near him, he start watching them

wet breach
sacred mountain
#

btw the readme on the github for your color mapper, does it convert 256 extended ansi?

#

frostalf

wet breach
#

ANSI is almost supported on every console with an exception of a few, but what is common between them all is the basic colors being supported where as it is iffy on the extended color support

#

but you can try it out like I said 🙂

#

worse that happens is the extended color support isn't there, in which case I can update it some time to support such things

sacred mountain
#

okay so, that works, but i still need a way to check if the terminal printer actually supports them

#

i could do some hackery and print, check output, etc but im sure theres a better way

golden turret
#

how can i make this always be centered and n the last line?

wet breach
#

and from this list knows if colors are supported and whether or not extended colors work

#

because at minimum almost every console has some kind of command that lets you see the console type

somber hull
#

If I’m gonna make two versions of a plug-in

#

A premium and a free version

#

What’s the best way to do that through GitHub?

#

Make two separate branches?

waxen plinth
#

Sure

somber hull
#

Is there a way to push certain commits to two branches?

#

Or would I have to go into the other branch and update it manually

paper viper
#

You could PR I guess

waxen plinth
quiet ice
#

Keeping two branches won't work long

paper viper
#

Btw why not just make one premium version

waxen plinth
#

Commit to the free branch and rebase that onto the premium branch

quiet ice
#

Unless the changes are very contained

paper viper
#

I’d say go freemium and don’t have a free plugin

somber hull
#

I’m not familiar with GitHub beyond using it through IntelliJ to backup my code

paper viper
#

Easier on your part

waxen plinth
#

If you keep the premium features entirety in separate files it should work fine

somber hull
#

I know how to do that cause I’ve seen that button before

somber hull
#

I’ll figure it out

waxen plinth
#

Not if you build good abstractions

somber hull
#

Thanks

waxen plinth
#

Modularize it

somber hull
waxen plinth
#

Well

#

Come to think of it

#

You could use one branch

#

And have a gradle subproject for the premium version

#

Which would shade the base version into its final artifact

quiet ice
#

That would be more ideal really

somber hull
#

How would I go about doing that?

#

I’m not at my pc rn

#

Will be in like 5 mins

#

But imma save what you say

waxen plinth
#

Then look into it when you get back

quiet ice
#

At worst ServiceLoader can be used

waxen plinth
#

It's not too difficult to set up gradle subprojects

somber hull
quiet ice
#

(or maven modules at that point)

wet breach
glossy scroll
#

Spigot premium plugins are not on SEO btw

#

just be aware of that

#

freemium is the best option for reachability

somber hull
somber hull
somber hull
glossy scroll
#

they dont apepar on google search

#

example

#

(scrolling down does not make it appear)

ivory sleet
#

Uh for me premium plugins appear just as frequent as normal plugins

#

Tried with both google and safari

glossy scroll
#

maybe its just broken for libsdisguises

paper viper
#

For me I have to add “premium” at the end of it

#

To get results

somber hull
somber hull
ivory sleet
#

Hmm this is odd, maybe I have visited a lot of premium plugins in the past

glossy scroll
#

im trying in incognito as well

glossy scroll
somber hull
#

@glossy scroll Do you mean the premium version not showing up if there is also a free one

paper viper
somber hull
glossy scroll
#

well yes thats what i meant haha

#

ok i was wrong then

#

sorry i just feel like i can never find premium plugins on google search

#

thought it had something to do with it being behind a "loginwall"

somber hull
#

So im trying to set up gradle multiproject, but im not sure how it is used specifically for a plugin

#

Do i create a new package smthng like me.silentprogram.betterspawners.premium?

#

and do i have to create a "main" package?

#

And how would i build the plugin without the premium project included, and vise versa

ivory sleet
#

yea

#

Premium/src/main/java/USUAL CLASSES ETC

somber hull
#

got it

ivory sleet
#

Well don’t you have the task bar

#

Run build for the premium module

somber hull
#

And that will automatically include the root?

ivory sleet
#

If your premium module depends on your root/parent project then ye

#

Should

wet breach
somber hull
#

And what if i want to have a seperate config?

ivory sleet
#

Assuming you add it to your runtime classpath that is

#

Separate config?

wet breach
#

the better option in this scenario would be to keep your premium plugin, but just have it open source

ivory sleet
#

Listen to wise frostalf

somber hull
wet breach
#

o.O

#

if its going to be open source, then why bother making 2 resources of the same thing

somber hull
somber hull
#

Premium is gonna have more features

wet breach
#

just stick with maven if that is what you are fine with, no need to really switch to gradle

wet breach
#

most people who talk about speed improvements between the two, most of them really just don't know maven

somber hull
#

Ikr lmao

wet breach
#

and most people don't have large enough projects to truly see the differences

somber hull
#

I switched to gradle

#

And its noticably slower

#

But its easier imo

wet breach
#

well gradle is faster then maven in some circumstances, but you need super large projects to see it

#

for example, compiling firefox

somber hull
#

Idk, maybe its better for large projects but worse for small projects

#

anyway

#

If i want a seperate config file

#

For my premium version

#

Can i do that with the multiproject thing

wet breach
#

I don't see why not

somber hull
#

How?

#

I would have to override the regular config

wet breach
#

well I don't know how to do it with gradle, but with maven it is super easy

somber hull
#

IG i could just leave a section for premium settings in the config that does nothing unless you buy the premium version

#

Would make upgrading easier as the values are all there and you dont have to delete config

#

How do you guys like my path name lmao

#

So looooooooooooooooong

paper viper
#

I started with maven and migrated to Gradle so I know both. But the reason why I prefer it over maven because it is way more script like behavior rather than configuration

#

You can define methods and stuff to load

#

Since it uses groovy or kotlin dsl script

#

However, maven has a less steeper learning curve. Knowing both is important

paper viper
#

You have src/main/java as a directory

#

Then inside would be your package which would be me.silentprogram.etc

somber hull
paper viper
#

You should set maven source sets

somber hull
paper viper
#

Oh epic

somber hull
#

But how do i create a new directory in intellij?

#

im trying to get the multiproject thing working

#

BUt its very confusing and weird

paper viper
#

So what you should do is right click on the module and click new folder

#

Then src/main/java should pop up

#

Then inside of that use packages

somber hull
#

I did src/main/java

#

and it put a package

paper viper
#

No

#

One second

somber hull
#

I think its just showing up that way

paper viper
#

Delete the main.java package

#

Then right click on src folder

#

And click new folder

somber hull
somber hull
somber hull
paper viper
#

Packages and directories show up the same in file explorer. The structure is messed up tho in IntelliJ

somber hull
#

odd

paper viper
#

Try deleting your src folder completely

#

And then creating a new folder in IntelliJ in the module

somber hull
#

Yea same thing

#

i deleted src

#

and did src/main/java

#

does it matter?

paper viper
#

Yeah

#

Your package imports would be fucked

somber hull
#

Oh ok

paper viper
#

It would contain the main.Java

somber hull
#

Its not a capital J right?

#

restarting IJ

#

and removing a plugin that might be causing it

paper viper
#

I don’t think it’s a plugin

#

Wait

#

I know

#

Right click src folder, then click Unmarked Directeoy

#

Then Unmark as sources

#

Then right click on the Java folder

#

Then do Mark Directory

#

And click mark as sources directory

#

Sometimes IntelliJ messes it up for no reason

somber hull
#

maybe cause IJ is still starting up

#

but

#

only opption

paper viper
#

For the src folder?

somber hull
#

For the main.java

paper viper
#

No

#

Do it for the src folder

#

The blue folder

somber hull
paper viper
#

Unmark as Sources Root

#

Then the folder structure should collapse

somber hull
#

aa

#

yep

paper viper
#

Then click the Java directory

#

Right click on it

#

Then mark directory

#

Mark as Sources Root

#

Java

#

I meant

#

Sorry

#

I’m typing on phone

somber hull
#

Got it

#

yea np

#

thanks so much

#

in my main project

#

the main folder is bold

#

is that fine?

paper viper
#

Yes

#

Take picture

somber hull
paper viper
#

Ok yeah that seems correct

somber hull
#

alr

#

the other main shouldnt be like that?

paper viper
#

I’m not sure what the gradle module structure looks like

somber hull
#

Yea it should be fine, if i have issues then ill figure it out

#

question tho

paper viper
#

Make sure to create packages inside java folder

somber hull
#

So the way im doing this with the multiproject thing

#

Im not sure how im supposed to use classes from the premium module

#

Without a no class found error or smthng

paper viper
#

Let’s decide on your structure first

somber hull
#

Unless i have to use abstraction and interfaces and all that. But ive never had to work with that before

paper viper
#

We could have something like a common module

#

Then a premium and free module for each one

#

The common module would contain abstractions and perhaps classes used in both the premium and free plugin

#

Then the premium module would contain premium features, and the free module would contain free specific ones

somber hull
#

and the other options?

#

Ill probably do that

#

Just curious what else therer is

paper viper
#

I mean there is also a way where you could have your premium module depend on your free module because I’m assuming the premium version contains all the features in the free version but more

#

But that’s messier

#

And it’s not recommended

somber hull
#

Got it

#

But wouldnt the other one require you to repeat code?

#

Like have basically a copy on both of them

#

Or am i stupid

paper viper
#

Repeated code could be in the common module

somber hull
#

Ahj

#

Thats

#

yes

#

And then abstraction would be the other part of that correct?

#

Oh you know what, all the repeated code is what i have just finsihed

#

So now would be the perfect moment to set all thatg up

somber hull
# paper viper Yes

Got it, imma start working on this. Ill lyk if i run into any problems

#

I have discord open on my other monitor

#

so im here

paper viper
#

I mean how I do it in my library is I have an API module (which contains 95% interfaces), then a main module (which contains implementation and uses the interfaces in the API module), and then a lib module which combines all the other modules with the main module.

#

The thing is that you aren’t doing a library but instead a normal plugin

#

So you could just combine the api module and common module together I guess because it’s not like you are developing an API too

somber hull
#

ye

formal bear
#

Anyone knows how to shade jar on Linux?

somber hull
#

Wait @paper viper

#

I might not be thinking about this right

#

but

#

Does the main class have to be in the root project?

paper viper
#

Well you are going to compile two different jars from your premium and free module

somber hull
#

But what would i put in the plugin.yml

paper viper
#

So you would technically have two different main classes in your premium and free module

somber hull
#

would i have to name the packages the same thing? in both modules

paper viper
#

You have to treat as if your free and premium module are different plugins completely, but sharing some common almost like “library” which would be the common module

#

After all this is the reason why managing two plugins is annoying

somber hull
#

lmao yea

somber hull
#

BUt im treying to make it work

paper viper
#

Do you mean gradle or maven

formal bear
#

Maven

somber hull
#

OHHHHHHHHHHH

#

Could i make a resources folder in the different modules

paper viper
somber hull
#

And have two instances of my plugin.yml

somber hull
#

accomodating the different package names

#

ahhhhhhhhhh

paper viper
#

Stupid phone autocorrect

somber hull
#

ye lmao

paper viper
#

I haven’t touched an IDE for 6 days cause I’m on vacation lol

somber hull
#

oof

dense frost
#

hello, i'm currently scaling up a minigame, and trying to make multiple servers and trying to get the best one for queue for the players using redis, any suggestions?

#

im also new to redis, but i understand it well.

#

i'm not looking for codes or anything, just suggestions

paper viper
#

best one for queue for the players using redis

#

Can you elaborate on this

dense frost
# paper viper > best one for queue for the players using redis

basically, there'll be 2 lobbies, and those lobbies will try to find the best server for that player, for example if i had 10 minigame servers, how would the server know that server A1 has a player in it, instead of sending to A2, i want it to send it to A1

glad bronze
#

guys i want to get into these plugin stuff but don't know where and how, I don't have much knowledge in programming so what would you recommend? i've seen kody simpson's tutorial but it seems like many people don't like it

dense frost
#

like have a goal

#

example functional scoreboard plugin

glad bronze
#

i have actually

paper viper
paper viper
#

You could use plugin messaging

#

To communicate between servers the player count

dense frost
#

yea, i can do that but i'm trying to find the best way, messaging aren't reliable or at least that's what i've heard

#

do those Custom reach the client?

paper viper
#

Custom?

dense frost
#

i set up a custom server to read the packets and i noticed everytime i send a bungee message, random CustomPayloadOut or something like that pops up

paper viper
#

I’m not sure for that reason

#

But the only strategy I know of is plugin messaging sry

dense frost
paper viper
#

That may be too hard

#

It’s a nice thing to work up to when you have the experience to

#

But start small

glad bronze
#

like what?

paper viper
#

Maybe do stuff that is small but relates to the topic you like. That’s how I got interested

glad bronze
#

i get it

#

scoreboard seems cool

#

but i don't know where to start

paper viper
#

So learning some basic Java would be useful like OOP to help make learning the API faster

glad bronze
#

should i learn java or basics of programming or directly how spigot works

paper viper
#

Learn basic computer science, then Java, then Spigot

#

Coding is only a tiny bit of CS

formal bear
#

I dont know why does maven shade does not work on linux directory

glad bronze
#

thanks guys

formal bear
somber hull
#

@paper viper

#

So since my current "mainclass" can no longer extend javaplugin

#

Should i just create a JavaPlugin object

#

And pass the actual main class as that

#

And then just go through my code and replace plugin with plugin.getPlugin()

#

when needed

#

as plugin is always the name of my mainclass

formal bear
paper viper
somber hull
#

Like in the two new modules i have a new main class

#

But in my previously existing code, i had one m,ain class

formal bear
somber hull
#

Should i just have onEnable run my old onEnable in my old main class

formal bear
#

Everything runs currectly

somber hull
#

like

#

used to be

#

plugin.getConfig()

paper viper
#

I think it’s going to have to depend on what your goal is. I was thinking completely two different plugins in the different modules each extending JavaPlugin

#

But using the common module

somber hull
#

Yes thats what im doing

paper viper
#

Wait but why getPlugin

somber hull
#

Cause i already had a bunch of code i made

#

And to not break it

#

Because my main class no longer extends javaplugin

#

I need to get the real javaplugin to the code

paper viper
#

Is that intentional?

somber hull
paper viper
#

Is it a bootstrap class or something

somber hull
#

wdym a bootstrap class

paper viper
#

Like why does your old main class not extend JavaPlugin anymore

somber hull
#

Because i would have to copy it over and duplicate it onto the two new plugins

paper viper
#

I’m confused

somber hull
#

right?

paper viper
#

No, the main class shouldn’t be shared

somber hull
#

Right

#

So i have a old main class

#

with essential code

#

To toher parts of the plugin

paper viper
#

Do you have a GitHub for this?

somber hull
#

Yea

paper viper
#

Im a bit confused

#

Could you send link

somber hull
#

Use the 0.0.3 changes branch

#

It is the rework of the code im doing

#

It should be 1.0.0 changes but idk

paper viper
#

That doesn’t have the multiple modules tho

somber hull
#

i think it hasnt been updated

#

doesnt really matter

#

heres the project structure

#

Im thinking the main classes will run BetterSpawners.java onEnable (Ill probably rename it)

#

And anything else that version is specific to

paper viper
#

You want to completely delete the Main module and replace them with abstractions and other stuff in the common module

#

And then you want to create two different plugin main classes

#

Two different “BetterSpawner” classes

#

One for each free and premium module

#

Because they are different plugins

somber hull
#

Here leme commit some changes to explain a bit more

paper viper
#

Ok

quasi stratus
#

I keep running into an error where my gradle dependencies register in the IDE but throw ClassNotFoundError when compiled/run as a plugin.
Any ideas why this is happening? I can share any bits I need to, just ask 🙂

somber hull
#

i made changes

#

If you see on the module

#

It litterally just runs BetterSpawners as if it were normal

#

And all the code thats there

#

Is going to be shared between the two versions

#

I havent made the unique code yet

#

So is there anything wrong with doing what im doing?

paper viper
#

One second I’m walking to hotel

somber hull
#

Im still confused on how the abstraction bit works

#

Are we talking like the common base uses an interface to grab and use differing code from the two other modules?

#

Or are the two other modules the ones using the interfaces somehow?

paper viper
paper viper
somber hull
#

From the base to the other two?

paper viper
#

Then your other two modules use these abstractions

#

Implements them

#

And does different stuff

somber hull
#

Got it, so yea form the base to the other two

#

thank you @paper viper

#

very helpoful

quaint mantle
somber hull
#

Wait

#

So if i want to make a interface that is also recognized as a JavaPlugin

#

Can i do that?

#

Do i have to use Abstract Class

#

Why would i use interface over abstract class?

#

They seem to do the same thing but abstract does it better.

glossy scroll
#

Well theres a more technical definition

#

But you can implement more than one interface

#

You can not extend more than one class

#

Abstract classes usually mean you want to use a similar pattern/scheme defined in the parent class

#

Interfaces can be used for when you have different types that share something in common

somber hull
#

Got it

#

Ok so i should be useing a abstract class here

glossy scroll
#

JavaPlugin is abstract

#

Interfaces cannot extend classes

#

So yes

#

Its the only way

#

Also you dont need a class to be abstract to extend it btw

somber hull
#

ye ik

#

but i need to use the absract methods

#

Along with pass in the JavaPlugin

glossy scroll
#

yea i mean interfaces can only entend other interfaces

#

What is the goal again?

#

Sorry for not reading

somber hull
#

I have a class that needs to have absract methods, but also extend the javaplugin

#

Woah, i just witnessed the beuty of using methods to keep variables contained

glossy scroll
#

For what purpose?

somber hull
somber hull
#

But slightly different

glossy scroll
#

Hmm

somber hull
#

a free and premium version

glossy scroll
#

Yea i think taht works

somber hull
#

Their set up as modules

#

ye

glossy scroll
#

Yea thats fair

#

I use a similar schema

#

No problem with that i thino

somber hull
#

alr

#

Ill ask some picky people later once i clean some stuff up

paper viper
#

I can give some basic code tips

#

So for gradle, you can update your gradle wrapper version btw. Also you should use the gradle tool chain for specifying version

#

You don’t have to shade Gson btw, it’s provided by the server

#

Make sure to encapsulate variables and stuff

#

Split methods and create variables and stuff to make code readable

somber hull
paper viper
#

Mainly good tho

somber hull
echo basalt
#

I still use json-simple

echo basalt
#

because it's simple enough

paper viper
#

Why tho

echo basalt
#

gson too fancy

paper viper
#

Use the provided json api

#

Lmao

somber hull
#

or at least i think it is

echo basalt
#

nah too fancy

somber hull
#

if its anything like jackson

paper viper
#

I don’t think it’s fancy, it’s super easy to use lol

#

Also you can do everything in JSONSimple in Gson with the JSONArray, JSONObject

#

That type of stuff

wet breach
shadow zinc
#

K, so I made a plugin that finds that laggiest chunks and sorts them by most entities, and im sure we all know that there is no lightweight way of doing that. I'm just wondering if it should make it run asynchronous, and how would I go around doing that?

kind hatch
#

?scheduling

undone axleBOT
kind hatch
#

As long as you aren't removing the entities or modifying the chunks, you could run the code async.

#

Otherwise, it has to be run synchronously.

shadow zinc
#

oh ffs

#

its literally a bukkit thing

#

k

#

well I was about to do threading or future tasks

quaint mantle
#

No its a minecraft thing

shadow zinc
#

i see that now

#

is it literally just that?

#

put it in the run asynchronously and watch it go?

kind hatch
#

Pretty much yea.

shadow zinc
#

and we use this for like getting data from the database, or scanning over all the entities and counting up the laggiest chunks?

#

big stuff that may slow down the server?

quaint mantle
#

yes

shadow zinc
#

sweet

#

thanks for the help

#

I'm reading about something called callbacks, is that only for sql queries?

wet breach
shadow zinc
#

hmm

#

my current method is find all the entities, if an entity is found in a chunk, put the chunk in a hashmap with 1, and continue this by adding 1 to all the chunks found

kind hatch
# shadow zinc I'm reading about something called callbacks, is that only for sql queries?

Callbacks are a programming paradigm. It can apply to more than just SQL.

Callbacks are most easily described in terms of the telephone system. A function call is analogous to calling someone on a telephone, asking her a question, getting an answer, and hanging up; adding a callback changes the analogy so that after asking her a question, you also give her your name and number so she can call you back with the answer.
Quoted from Paul Jakubik

somber hull
#

Base

somber hull
#

Called lagassist

#

Idk if it’s open sourced

#

But it’s premium and I own it

#

So check if it’s open sourced

shadow zinc
#

premium and open-sourced?

somber hull
#

Idk if it’s open sourced

#

A lot of premium plugins are

shadow zinc
#

ik citizens is

paper viper
#

It’s an abstract class

wet breach
somber hull
#

Why would that be useful in this situation?

paper viper
#

Oh never mind different thing

shadow zinc
#

I found lagassist, and they actually use a similar method to what I do

wet breach
shadow zinc
#

it is a big more extensive tho

#

but my plugin isn't trying to be all that

wet breach
#

was pointing out the class that JavaPlugin implements. Anyways, you can make a plugin that extends BasePlugin and the server will be happy with that too

somber hull
#

Oh ok

wet breach
#

Except it won't work because you can only have 1 JavaPlugin, so I don't see how it would be useful to extend JavaPlugin

somber hull
#

i c

somber hull
#

They rate a chunk on how likely it is to lag

shadow zinc
#

actually nvm

proper notch
#

is it just me or there's zero indentation

shadow zinc
#

its just that specific task

#

and yeah lol

#

maybe they should try python for a week

glossy scroll
#

they probably made it in notepad++

#

not even\

#

i cant think of a single editor that doesnt auto indent

shadow zinc
#

default windows text editor

#

notepad

glossy scroll
#

wow. its every single file

shadow zinc
#

at least they are consistent lol

glossy scroll
#

honestly my best guess is that they disabled CRLF in git or something

#

because it looks pretty well written

carmine nacelle
#

probably a basic java thing but i havent had to do this before. I have a string: 1*!*2,2*!*3 I need to split at the comma AND at the *!*, so I need to get each item between the commas as an array so I can split it again. Basically the items separated by *!* are related and the comma separates the list.

glossy scroll
#

String.split?

carmine nacelle
#

I need to get 1*!*2 so I can call array[0] to get the 1 and array[1] to get the 2.

glossy scroll
#

i cant help but feel that you're serializing something in a bad way

#

whats the end goal here

carmine nacelle
#

storing a list in pdc.

glossy scroll
#

right so if its integers, your best bet is to use INTEGER_ARRAY

carmine nacelle
#

which u cant do so i gotta use strings with manipulation.

glossy scroll
#

absolutely not, there are array data types

carmine nacelle
#

extremely limited ones

glossy scroll
#

errr no

carmine nacelle
#

theres 4 types

glossy scroll
#

1*!*2,2*!*3 what list is beng stored here

#

i need to understand this a bit better

#

whats the output

#

[1,2] and [2,3]?

carmine nacelle
#

yes

#

then need to split that again

#

to reference the 1 and 2

#

then the 2 and 3

glossy scroll
#

alright so i have two suggestions

sterile token
glossy scroll
#
  1. use a byte output stream to serialize an object into an array of bytes that can be put into a BYTE_ARRAY data type
  2. use PersistentDataContainer[] and store the arrays inside them
carmine nacelle
#

i am using a persistentdatacontainer just not the arrayed version

glossy scroll
#

honestly i would just go for option number 1

#

number 2 does require some nms/reflection

#

i store 3d arrays like that in PDC currently

iron glade
#

someone experienced in python here who could help me?

shadow zinc
#

I got a bit experience

#

made a neural network that didnt work

#

ik ik, absolute genius

#

also

#
        if (world == null) {
            Chunks.getChunksWithMostEntities(10, result -> sendChatData(result, null, playerAsPlayer));
        } else {
            World finalWorld = world;
            Chunks.getChunksWithMostEntities(world, 10, result -> sendChatData(result, finalWorld, playerAsPlayer));
        }```
#

on the topic of java

#

how is this for asynchronous?

#

so chunks gets it asynchronously, and then it processes the data into json

#

when the world is null is finds all the chunks

sterile token
#

You could make use CompletableFuture

shadow zinc
#

maybe, if I knew how to and what even that is

sterile token
#

I recommend reading about it

shadow zinc
#

is it like javascript promises?

sterile token
#

I dont really know about js promises

shadow zinc
#

yeah, its a bit weird

#

Ik there is a part where the code continues on while it does other stuff, not threading tho

sterile token
#

I find this link

#

Maybe you can find a better one

shadow zinc
#

I found the docs

#

but eh

#

this looks more pleasant to read

sterile token
#

What looks more pleasant?

shadow zinc
#

what you sent me

sterile token
#

Oh ok

shadow zinc
#

also, this wont completely stop the server since its threading?

sterile token
#

I think that CompletableFuture allows you to catch a result after it finished the execution

paper viper
#

Yes by the handle method

shadow zinc
#

I mean this is good for other applications that use java that aren't minecraft, but does it have any clear advantages over what I'm currently doing?

paper viper
#

CompletableFuture is the go to thing for asynchronous

#

For normal Java

#

At least

shadow zinc
#

but for spigot?

paper viper
#

I also use it over the scheduler

#

But it doesn’t matter

#

The scheduler uses CompletableFuture iirc

sterile token
shadow zinc
#

getchunks is

sterile token
#

Yeah spigot scheduler internally uses CompletableFuture

shadow zinc
#

so its more if I wanted to learn about how it all works and really understand?

#

not it really being anything worth using if I'm not bothered?

sterile token
#

I can explain async as simple as i understand it: it allow to do multiple operations at the same momment without each getting interfered

paper viper
#

Well, I wouldn’t think of it like that attitude…

shadow zinc
#

is it more efficient?

sterile token
#

pulse

sterile token
paper viper
#

you are going to use it eventually somehow lmao

sterile token
#

Pulse also would be a good man and help with mongo?

paper viper
#

No I have no idea

sterile token
#

Im still facing issues =><=

#

Oh sh****

paper viper
#

I have never used Mongo

sterile token
#

Oh ok

#

Where i can ask

shadow zinc
#

so its more if I want more control over what I'm doing as my tasks get more and more complicated?

sterile token
#

Also you cannot use Async because your ass sings

paper viper
#

Perhaps Together Java discord

brave sparrow
#

One thing to note is that spigot async uses a pool of threads allocated by spigot, whereas in your example you’re able to use your own thread pool

sterile token
#

Alex

#

Explain him more about async

#

Im not so experienced

brave sparrow
#

It doesn’t really matter, you can do either way

paper viper
#

There’s not rlly much more to say tbh

shadow zinc
#

lol ik about enough async

sterile token
#

Because as i have said you cannot use async because you want to use it. There are special things and momments when you need to use it

shadow zinc
#

I did ask a bunch of people if I should use it

paper viper
#

I mean this is an appropriate case

shadow zinc
#

yeah

#

see I asked to make sure

#

also I saw another plugin use it for the same reason

#

so I had reason

brave sparrow
sterile token
#
  1. I never said that you shouldnt be using async
  2. You also should know when to use it and why
shadow zinc
#

scanning over chunks and finding the ones with the most entities

shadow zinc
sterile token
#

In that case yes, its better to use it. Because while you are looping over the chunks the server get lagg or block the thread

brave sparrow
#

As long as you’re able to iterate over the chunks asynchronously it’s fine

shadow zinc
#

well I actually use the entities to find the chunks

#

not the chunks to find the entities

#

to find the chunks

brave sparrow
#

In reality you’re unlikely to have so many chunks where you’d experience a noticeable speed up from the multithreading

shadow zinc
#

Yeah, I also give the user an option to scan for a specific world

brave sparrow
#

You might end up with more overhead from the threading than you save by taking it off the main thread

#

This doesn’t seem like a use case for async really

shadow zinc
#

so

sterile token
#

Oh lmao mongo is making me getting really mad. It only problems, problems and more problems

shadow zinc
#

lol I use mysql

paper viper
#

Then don’t use it lmao

brave sparrow
#

At most you’ll have what, a couple hundred chunks to check through

shadow zinc
sterile token
#

Pulse i must use it i wont like to lost more days trying to convert everything into SQL

brave sparrow
#

You’re not going to get into extremely high collections of entities before the server is lagging due to that anyway

paper viper
#

Why did you choose Mongo

#

If you don’t know it

#

Lol

shadow zinc
#

because its trendy

sterile token
#

I know it but the erors its has

paper viper
#

🐑

sterile token
#

the errors are so shity

#

Imagine it has an error because the host where i test it doesnt have mongo on port 27017

#

Imagine lmao

#

I ill open a 5th thread on github

#

Lmao in 2 days opened around 4-6 issues requests

#

Lmao i will do it until their answer me

paper viper
#

Spamming issue requests are not going to help

sterile token
#

I know but looks this s**

#

com.mongodb.MongoCommandException: Command failed with error 18 (AuthenticationFailed): 'Authentication failed.' on server 127.0.0.1:27018. The full response is {"ok": 0.0, "errmsg": "Authentication failed.", "code": 18, "codeName": "AuthenticationFailed"}

#

It so amazing and the credentials are right

kind hatch
sterile token
#

Shadown please

#

Help me!!!

shadow zinc
#

lets go, async worked

sterile token
#

SO must work}

#

I dont know why doesnt lmao

shadow zinc
#

is the port open?

sterile token
#

It a hosting

#

So its open

shadow zinc
#

okay, so is running on the same server as the application?

sterile token
#

Yes

shadow zinc
#

strange

sterile token
#

Yeah

#

And i checked 20 times the code

#

And the credentials are right

shadow zinc
#

try make another account?

#

to test

sterile token
#

I cannot

#

I dont have access

shadow zinc
#

bruh

sterile token
#

Its a hosting they auto assign credentials

#

😂

shadow zinc
#

ffs

kind hatch
#

Does your password contain special characters?

sterile token
#

also i dont know why the pussies of the host doesnt use normal mongo port

shadow zinc
#

maybe you need to contact them?

sterile token
#

Only camel and uper case letters

shadow zinc
#

Its either something you did something wrong in the code or these hosting idiots messed something up

#

which one do you think is most plausible?

sterile token
#

Im thinking something with my IDE or Host because i still having an issue on 1.19 when using a mongo code for connecting , from a 1.12 plugin which works perfect on 1.12

#

But on 1.19 doesnt work

#

Its the most strange thing

#

😡

kind hatch
sterile token
#

Shadow

#

Can we fix the other issue?

#

The one that the mongo code works perfect on 1.12 but no on 1.19

#

When it doesnt affect spigot things

#

SO im fucking annoyed with that

#

How the heck the same code doesnt work on 1 version but on the other yes

#

🤡

kind hatch
#

It could come down to the version of Mongo that you are running. That 1.12 plugin could be running an older version of it while the 1.19 plugin is running something far newer. That could lead to versioning issues with what's currently being hosted on your machine.

sterile token
#

but the isue is with a codec

#

Because let say as i cannot use codec for location on mongo. I created my own class for parsing the locations

#

That works perfect on 1.12 but using the same code the codec on 1.19 doesnt work because it said that property x from vector contains 2 diff types

#

When im not using vector in the codec registations

#

😬

#

I cand send a picture if you want

kind hatch
#

Please do, because I have no clue what you are talking about.

sterile token
#

Yeah

#

1 sec

#
public class StorageManager {

    private final Main plugin;
    private MongoClient client;
    @Getter private MongoCollection<Claim> claims;

    public StorageManager(Main plugin) {
        this.plugin = plugin;
    }

    public void open() {
        Logger.getLogger("org.mongodb.driver").setLevel(Level.OFF);
        this.client = new com.mongodb.MongoClient(new MongoClientURI(""));
        CodecProvider provider = PojoCodecProvider.builder().automatic(true).register(Cuboid.class).build();
        CodecRegistry codec = CodecRegistries.fromRegistries(MongoClient.getDefaultCodecRegistry(), CodecRegistries.fromProviders(provider));
        this.claims = this.client.getDatabase("test").withCodecRegistry(codec).getCollection("claims", Claim.class);
        this.plugin.getLogger().info("Connected to database");
    }

    public void close() {
        this.client.close();
        this.plugin.getLogger().info("Disconnected from database");
    }
}
#

Im using that code on the versions of the plugin, right?

#

That code works pefect on 1.12 plugin

#

But no on 1.12

kind hatch
#

Well the error you gave is an issue with authentication. The codec part is probably fine, it's just fixing your connection.

sterile token
#

No no

kind hatch
#

Which comes down to what version of mongo you are running.

sterile token
#

wait forget the other error

#

When im using the code i send above on 1.19 i get this issue

kind hatch
#

Then the driver probably changed somewhat in 1.19 vs 1.12

#

It probably has new methods or a different implementation.

sterile token
#

no

#

Its the same driver

#

I checked 10 times

#

bruh it so fucking strange

#

Im not shocking

#

When on 1.12 works perfectttt

kind hatch
#

Yea, it's the same driver, but the implementation could be different between the versions. I'm not sure if it's included with spigot, but the mongo driver may have changed if it is included.

sterile token
#

what?

#

Im using the same mongo driver and same StorageManager class

#

So MUST WORK

#

I dont know why it doesnt

#

Im thinking the spigot its having a code issue/bug or my IDE is bug

#

Sorry for being rude but im stressed

#

Because the storage manager and driver is the same so must work the code

#

I also never using Vector neither Location

#

I just parse Location from bukkit into my CLocation object

#

Maybe im crazy

kind hatch
#

How much of the Location object are you parsing?

sterile token
#

Howm uch?

#

I will send CLocation so you can see it

kind hatch
#

Are you serializing the entire location object or are you just grabbing x, y, and z?

sterile token
#

And saving it on CLocation which then mongo save it on the claim object

#

I will search for you a example from db

#

As you can see i never saving anything which contains a Location

#

Because location internally uses a Vector, and vector gives the exception i sent on paste

#
{
  "cuboid": {
    "world": "world",
    "x1": 252,
    "x2": 260,
    "y1": 66,
    "y2": 74,
    "z1": 74,
    "z2": 239
  },
  "flags": [
    "Build"
  ],
  "location": {
    "pitch": 0,
    "world": "world",
    "x": 256,
    "y": 70,
    "yaw": 0,
    "z": 235
  },
  "members": [],
  "owner": "hz5tv5G9ev6A0W4V9LH9sQ==",
  "type": "User",
  "uuid": "6E7dWAf6ubXr48DuHTwTuw=="
}```
#

That is a example

#

So as you can see everything is working okay in 1.12x

#

In that json location represent the CLocation object

#

@kind hatch

#

Sorry for pinging

#

I just want to explain it carefully

kind hatch
#

What does your CLocation class look like then?

sterile token
#

1 sec

#
@Getter
@Setter
public class CLocation {

    private String world;
    private double x, y, z;
    private float yaw, pitch;

    public CLocation() { }

    public CLocation (String world, double x, double y, double z, float yaw, float pitch) {
        this.world = world;
        this.x = x;
        this.y = y;
        this.z = z;
        this.yaw = yaw;
        this.pitch = pitch;
    }

    public CLocation (String world, double x, double y, double z) { this(world, x, y, z, 0, 0); }

    public Location toBukkit() { return new Location(Bukkit.getWorld(this.world), this.x, this.y, this.z, this.yaw, this.pitch); }
}```
#

Like that

kind hatch
#

So, is your CLocation what is supposed to be put into the CodecProvider?

sterile token
#

What shadow?

#

I didnt understand

kind hatch
#

Well, you make it sound like the CLocation class is what gets put into the codec and is then saved to the database.

sterile token
#

I dont know but if as how its works on 1.12

#

Should work on 1.19

kind hatch
#

That logic only applies to the API, not external libraries.

sterile token
#

Im starting 1.12 server to send a cap because im looking like a lier when im not lying

kind hatch
#

It's not that I don't believe that, it's that your issue is coming from a codec issue. The codec likely changed based off the error.

[03:13:58 WARN]: [org.bson.codecs.pojo] Cannot use 'Vector' with the PojoCodec.
org.bson.codecs.configuration.CodecConfigurationException: Property 'x' in Vector, has differing data types: TypeData{type=Integer} and TypeData{type=Double}.

So, something probably changed in the PojoCodec class that requires the data you input to be a bit more strict.

sterile token
#

Lookthe same code works perfect

#

ait

#

cap get wrong

#

Now yes

#

Look

#

Althought im never using vector class on the Claim object

#

Have you seen shadow

#

Did something like these happen before

#

That a code works perfect on 1 project but no in another proyect?

kind hatch
#

My bet is still on an issue with what version you are running vs what your projects are expecting. What version of mongo are you running on your machine? Do you have any other version installed? If so, are you sure that your servers are using the same one?

sterile token
#

Im testing a prvovided host

#

They just auto assigned the dbs

#

Mongo driver is the same version on the 2 projects

kind hatch
#

Ok, but what version is on the provided host?

sterile token
#

how i know?

#

I dont remember the command

kind hatch
#

I don't know the commands either. I don't use mongo.

sterile token
#

Allr

#

1 sec

#

i will searc on internet

#

i wil lgo to toilet 1 sec

lime moat
#

How could I make something like this work? ```java
private static final String[] COMMANDS = {"reset", "tp"};
private static final String[] COMMANDS2 = {"stone", "wood"};

@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
    final List<String> completions = new ArrayList<>();
    StringUtil.copyPartialMatches(args[0], Arrays.asList(COMMANDS), completions);
    if(args[0].equalsIgnoreCase("reset")) {
        StringUtil.copyPartialMatches(args[1], Arrays.asList(COMMANDS2), completions);
    }

    Collections.sort(completions);
    return completions;
}``` *something* meaning this: `if(args[0].equalsIgnoreCase("reset")) {`
dim palm
#

Arrays.AsList("command1", "command2")

quaint mantle
#
public List<GenericItemType> getCompatibleTypes()```
#

instead of this

#
return Collections.singletonList
lime moat
#

I believe it's something to do with my if check.

quaint mantle
#

anyone?

#

quac

shadow zinc
#

its been like 30m

quaint mantle
#

You're using the legacy api

shadow zinc
#

so it takes a while?

kind hatch
#

I think the old API takes like an hour to update.

shadow zinc
#

whats the new one?

lost matrix
lost matrix
lost matrix
lime moat
#

I may know, just don't quite know what you mean :P

lost matrix
#

just check how many elements are in the array before you access it...

lime moat
#

Yeah, I'm sorry I have no idea 😅

#

I've rarely worked with arrays

lost matrix
# lime moat Yeah, I'm sorry I have no idea 😅

If your array looks like this:

["some", "param", "other"]

And you try to get the 4th element with the index 3 (which does not exist)
Then the index you are requesting is outside of the bounds of the array.
The array has the bounds 0 and 2. And trying to access an element outside
of those bounds throws an ArrayIndexOutOfBoundsException

Very logical and very descriptive

lime moat
#

I see, so StringUtil.copyPartialMatches(args[1], Arrays.asList(COMMANDS2), completions); is trying to get something that doesn't exist?

lost matrix
#

If a player starts typing a command

/command some param

Then you have only 2 params in the tab completion. ["some", "param"]
For every new letter the player writes, the event is fired again.

/command some param o
-> event with ["some", "param", "o"]

/command some param or
-> event with ["some", "param", "or"]

/command some param or
-> event with ["some", "param", "or"]

/command some param or n
-> event with ["some", "param", "or", "n"]

/command some param or no
-> event with ["some", "param", "or", "no"]

/command some param or not
-> event with ["some", "param", "or", "not"]
lime moat
#

So, I would need to use something like if (args.length == 5) correct?

#

Basically checking if reset as it has 5 characters is the arg?

lost matrix
#

And at the beginning your command looks like this:

/command

Which results in an empty [] array.
Accessing anything (even with the index 0) will throw an exception

lost matrix
lime moat
#

I've done a few variations and I can't seem to get anything to work. ```java
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
final List<String> completions = new ArrayList<>();
StringUtil.copyPartialMatches(args[0], Arrays.asList(COMMANDS), completions);
if (args.length == 5) {
StringUtil.copyPartialMatches(args[1], Arrays.asList(COMMANDS2), completions);
}

    Collections.sort(completions);
    return completions;
}```
lost matrix
lost matrix
lime moat
#

OH

#

I see

quaint mantle
lime moat
river oracle
lost matrix
quaint mantle
#

I would like to add more items here

#

like list more

river oracle
#

Then list more

lime moat
#

I also have it :P

#
public class Mines implements TabExecutor {
    private static final String[] COMMANDS = {"reset", "tp"};
    private static final String[] COMMANDS2 = {"stone", "wood"};
    private Main main;

    public Mines(Main main) {
        this.main = main;
    }

    @Override
    public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
        final List<String> completions = new ArrayList<>();
        StringUtil.copyPartialMatches(args[0], Arrays.asList(COMMANDS), completions);
        if (args.length == 2 && args[0].equalsIgnoreCase("reset")) {
            StringUtil.copyPartialMatches(args[1], Arrays.asList(COMMANDS2), completions);
        }

        Collections.sort(completions);
        return completions;
    }``` It also puts `reset` as a tab completer. How can I remove that one?
lost matrix
lime moat
#

This should be all for one command (mines)

lost matrix
#

This is not a difficult problem if you know the very basics of java.
And with basics i mean the type of stuff you learn in the first 2 or 3 weeks.

lime moat
#

Alright

#

I started learning about 5 days ago :P

buoyant viper
#

is there a specific setting in intellij i have to enable to have it automatically download sources jar for maven dependencies

buoyant viper
#

ill be damned there is

lost matrix
#

You can also enable it on default i guess

#

intellij search is nice

buoyant viper
# lost matrix

ye ik of that way just didnt know if there was a way to make it do it by default

buoyant viper
ashen quest
buoyant viper
#

true

golden kelp
#

just use jshell

#

😌

ashen quest
#

what about compiling then

golden kelp
#

make your own version of jshell and write a mc server software from scratch and then use your window as a server

#

and execute code yourself when a player does something

ashen quest
#

seems so simple

desert loom
#

when I set a villager's profession it reverts a split moment later back to None, anyone have an idea as to why that happens?

harsh totem
#

Hi, I know this isn't really related to java but would anyone help me with sqlite please?
I have nowhere to ask for help

somber hull
harsh totem
somber hull
#

there are a lot of java servers

#

google it

#

ask on forums

#

etc

harsh totem
somber hull
#

Is anyone here fluent in Inventory Framework?

lost matrix
lost matrix
robust pike
#

Anyone have any suggestions on when I export my plugin with maven, that its not including the plugin.yml in the src?

harsh totem
lost matrix
somber hull
#

I dont think they have a resource folder

#

I used to not have one

#

I dont remember why

robust pike
somber hull
#

I just threw my plugin.yml in src

lost matrix
somber hull
#

nvm what they said

robust pike
harsh totem
# lost matrix Whats the problem

I used db.each function to change a variable's value and then use it but this variable returns to it's original value (before the each function) when I use it outside of the function

            db.each(`SELECT * FROM users`, (err, row1) => {
                    if (row1.level > row.level){
                        ranknum++;
                    } else if (row1.level == row.level && row1.xp > row.xp){
                        ranknum++;
                    }
            });```
lost matrix
lost matrix
robust pike
harsh totem
lost matrix
harsh totem
lost matrix
harsh totem
#

yes

lost matrix
robust pike
harsh totem
robust pike
harsh totem
#

good luck with it

somber hull
#

7smile

#

what do u use for guis

#

do u do it all yourself

harsh totem
# lost matrix Not enough code

how so? you want the part where I connect to the db?

        let db = new sqlite.Database('./stats.db' , (err) => {
            if(err)
            {
                console.log("Error Occurred - " + err.message);
            }
        });```
It is connected
somber hull
#

or do u use something

lost matrix
lost matrix
somber hull
#

What do you think of inventory framework?

#

Im checking out triumph rn

quaint mantle
#

i cant think of one scenario where i've needed an inventory lib

lost matrix
harsh totem
#

db.get(`SELECT * FROM users WHERE id="${member.id}"`, (err, row) => { if (err) { return console.error(err.message); } if (row === undefined){ db.run(`INSERT or REPLACE INTO users (id, level, xp, last_message) VALUES (${member.id}, '0', '0', '0')`); } var name = member.nickname || member.user.username; if (isAlphaNumeric(name) === false){ name = "username"; } var ranknum = 1; db.each(`SELECT * FROM users`, (err, row1) => { if (row1.level > row.level){ ranknum++; } else if (row1.level == row.level && row1.xp > row.xp){ ranknum++; } });

quaint mantle
#

No because when i need something like an inventory map

.........
.       .
.       .
.........

this is like 7 lines of code

quaint mantle
#

???

lost matrix
#

Sound like you never wrote complicated guis before. It takes hundreds of lines of code even with a framework sometimes

somber hull
quaint mantle