#help-development
1 messages · Page 2267 of 1
i never said you asked your question wrong, i was just suspicious that you needed help with something that could be simplified
so it does support color but idk how to check that
so how its done in craftbukkit is
Terminal terminal = ((CraftServer) getServer()).getReader().getTerminal();
terminal.isAnsiSupported()
ah
its no issue
im not familiar with that
CB uses jline
maybe you could look into that?
ill give it a go
@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
you need to first figure out what console is being ran. Not all consoles will report if they support color codes and if they do which ones. You will have to maintain your own list also this might be helpful for you that I created
https://github.com/frostalf-games/ConsoleColors
Jline contains Jansi
but it also supports commands being sent
Jansi is just the console itself
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
or can use my project above 🙂
true
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
how can i make an npc look at a player? I have these packets, but don't know what else do i need
have you tested that?
yea
I mean, I want every time a player walks near him, he start watching them
i'm on a mac/linux
get the direction the player is in, get the inverse, set the head to look that way
btw the readme on the github for your color mapper, does it convert 256 extended ansi?
frostalf
eg
no it is for the basic ANSI colors if I recall but feel free to test it out because I can't really say I remember that specifically lol
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
neat alr
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
how can i make this always be centered and n the last line?
not entirely sure, but I just know that most programs that involve colors just keep a list of the console types
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
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?
Sure
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
You could PR I guess
Just rebase one branch onto the other
Keeping two branches won't work long
Btw why not just make one premium version
Commit to the free branch and rebase that onto the premium branch
Unless the changes are very contained
I’d say go freemium and don’t have a free plugin
I’m not familiar with GitHub beyond using it through IntelliJ to backup my code
Easier on your part
Oh awesome
If you keep the premium features entirety in separate files it should work fine
I know how to do that cause I’ve seen that button before
Might be an issue
I’ll figure it out
Not if you build good abstractions
Thanks
Modularize it
I’m still learning good code practice
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
That would be more ideal really
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
Then look into it when you get back
At worst ServiceLoader can be used
It's not too difficult to set up gradle subprojects
Alr
(or maven modules at that point)
just make sure you follow the rules on this
Spigot premium plugins are not on SEO btw
just be aware of that
freemium is the best option for reachability
Wdym?
SEO lmao?
like the premium rules, ive read those like 4 times over
search engine optimized
they dont apepar on google search
example
(scrolling down does not make it appear)
Uh for me premium plugins appear just as frequent as normal plugins
Tried with both google and safari
maybe its just broken for libsdisguises
Why?
Maybe
im trying in incognito as well
this also shows a bunch of redacted links 💀
@glossy scroll Do you mean the premium version not showing up if there is also a free one
Yeah mainly the pirated ones
I got to libsdisguises premium by seraching that
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"
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
got it
a
how build
And that will automatically include the root?
if you release a free plugin of your premium version, then the premium version must still be different from the free one otherwise you won't have a premium plugin
And what if i want to have a seperate config?
the better option in this scenario would be to keep your premium plugin, but just have it open source
Listen to wise frostalf
Yea their different
Ik, im gonna have the project open on github, but not share the link explicitly.
o.O
if its going to be open source, then why bother making 2 resources of the same thing
Idk, ive never done anything with gradle before. I used maven for a long time
Their different
Premium is gonna have more features
just stick with maven if that is what you are fine with, no need to really switch to gradle
too late
Ive been using it
most people who talk about speed improvements between the two, most of them really just don't know maven
Ikr lmao
and most people don't have large enough projects to truly see the differences
well gradle is faster then maven in some circumstances, but you need super large projects to see it
for example, compiling firefox
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
I don't see why not
well I don't know how to do it with gradle, but with maven it is super easy
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
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
The base of the package name seems incorrect. main.java should not be in your package. That should be part of the source directory
You have src/main/java as a directory
Then inside would be your package which would be me.silentprogram.etc
lmao im stupid
You should set maven source sets
Im using gradle
Oh epic
But how do i create a new directory in intellij?
im trying to get the multiproject thing working
BUt its very confusing and weird
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
I think its just showing up that way
no option
Packages and directories show up the same in file explorer. The structure is messed up tho in IntelliJ
odd
Try deleting your src folder completely
And then creating a new folder in IntelliJ in the module
Oh ok
It would contain the main.Java
Its not a capital J right?
restarting IJ
and removing a plugin that might be causing it
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
For the src folder?
For the main.java
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
Got it
yea np
thanks so much
in my main project
the main folder is bold
is that fine?
Ok yeah that seems correct
I’m not sure what the gradle module structure looks like
Make sure to create packages inside java folder
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
Let’s decide on your structure first
Unless i have to use abstraction and interfaces and all that. But ive never had to work with that before
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
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
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
Repeated code could be in the common module
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
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
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
ye
Anyone knows how to shade jar on Linux?
Wait @paper viper
I might not be thinking about this right
but
Does the main class have to be in the root project?
Well you are going to compile two different jars from your premium and free module
But what would i put in the plugin.yml
So you would technically have two different main classes in your premium and free module
would i have to name the packages the same thing? in both modules
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
lmao yea
Wich im fine with that
BUt im treying to make it work
Shading on Linux?
Do you mean gradle or maven
Maven
Read this guide here: https://maven.apache.org/plugins/maven-shade-plugin/ make sure to not shade spigot lol
And have two instances of my plugin.yml
Stupid phone autocorrect
ye lmao
I haven’t touched an IDE for 6 days cause I’m on vacation lol
oof
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
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
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
i'd recommend to just write a plan and start on it
like have a goal
example functional scoreboard plugin
i have actually
I’m assuming you are using bungeecord or something for the servers?
yes, i am
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?
Custom?
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
I’m not sure for that reason
But the only strategy I know of is plugin messaging sry
no problem, i'll just try to figure out a way
That may be too hard
It’s a nice thing to work up to when you have the experience to
But start small
like what?
Maybe do stuff that is small but relates to the topic you like. That’s how I got interested
So learning some basic Java would be useful like OOP to help make learning the API faster
should i learn java or basics of programming or directly how spigot works
Java syntex
Learn basic computer science, then Java, then Spigot
Coding is only a tiny bit of CS
I dont know why does maven shade does not work on linux directory
thanks guys
Show pom
@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
Path in Linux, /home/przemek/projects
Sry I’m not entirely sure but you running the correct maven goal right?
Wdym here
Like in the two new modules i have a new main class
But in my previously existing code, i had one m,ain class
It worked on my windows PC so
Should i just have onEnable run my old onEnable in my old main class
Everything runs currectly
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
Yes thats what im doing
Wait but why getPlugin
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
Is that intentional?
old main class*
Is it a bootstrap class or something
wdym a bootstrap class
Like why does your old main class not extend JavaPlugin anymore
Because i would have to copy it over and duplicate it onto the two new plugins
I’m confused
I would have to because i cant have it run anything differently if the main class is shared by the two plugins
right?
No, the main class shouldn’t be shared
Right
So i have a old main class
with essential code
To toher parts of the plugin
Do you have a GitHub for this?
Yea
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
That doesn’t have the multiple modules tho
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
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
Here leme commit some changes to explain a bit more
Ok
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 🙂
alr
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?
One second I’m walking to hotel
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?
Have you shaded your dependencies into your JAR?
The common base contains abstractions (interfaces and stuff) and contains common code between the two other modules
where are the abstractions used?>
From the base to the other two?
Then your other two modules use these abstractions
Implements them
And does different stuff
Got it, so yea form the base to the other two
thank you @paper viper
very helpoful
PulseBeat top 5 #help-development helpers all time
hel ye
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.
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
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
yea i mean interfaces can only entend other interfaces
What is the goal again?
Sorry for not reading
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
For what purpose?
I had to change one line and it affected my whole project
Two seperate plugins that share core code
But slightly different
Hmm
a free and premium version
Yea i think taht works
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
it is? and i havent switched from jackson to gson
Mainly good tho
meaning making them private and puting them into get methods
Yeah
I still use json-simple
because it's simple enough
Why tho
gson too fancy
its easy what are you talking abt
or at least i think it is
nah too fancy
if its anything like jackson
I don’t think it’s fancy, it’s super easy to use lol
https://www.spigotmc.org/wiki/included-libraries-in-spigot/ for libs included
Also you can do everything in JSONSimple in Gson with the JSONArray, JSONObject
That type of stuff
there is BasePlugin if you need it
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?
?scheduling
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.
oh ffs
its literally a bukkit thing
k
well I was about to do threading or future tasks
No its a minecraft thing
i see that now
is it literally just that?
put it in the run asynchronously and watch it go?
Pretty much yea.
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?
yes
sweet
thanks for the help
I'm reading about something called callbacks, is that only for sql queries?
the most light weight way to do it, is to either scan region files not in use or use chunksnapshots so you can search through the chunk in another thread
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
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
There’s a plug-in that does this
Called lagassist
Idk if it’s open sourced
But it’s premium and I own it
So check if it’s open sourced
premium and open-sourced?
ik citizens is
BasePlugin is the class that JavaPlugin extends/implements
Why would that be useful in this situation?
Oh never mind different thing
I found lagassist, and they actually use a similar method to what I do
because you needed something abstract
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
What i needed was to have my abstract class that extends javaplugin
Oh ok
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
i c
they have a chunk scanner is wqhat i was referring to
They rate a chunk on how likely it is to lag
Am I right to say that this only runs asynchronously when its a player requesting chunk analysis? https://git.entryrise.com/stefatorus/LagAssist/src/branch/master/src/com/entryrise/lagassist/chunks/ChkAnalyse.java
actually nvm
is it just me or there's zero indentation
they probably made it in notepad++
not even\
i cant think of a single editor that doesnt auto indent
wow. its every single file
at least they are consistent lol
honestly my best guess is that they disabled CRLF in git or something
because it looks pretty well written
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.
String.split?
I need to get 1*!*2 so I can call array[0] to get the 1 and array[1] to get the 2.
i cant help but feel that you're serializing something in a bad way
whats the end goal here
storing a list in pdc.
right so if its integers, your best bet is to use INTEGER_ARRAY
which u cant do so i gotta use strings with manipulation.
absolutely not, there are array data types
extremely limited ones
errr no
theres 4 types
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]?
alright so i have two suggestions
https://paste.md-5.net/relijumixe.csOh lmao mongo is getting every day mad and mad
- use a byte output stream to serialize an object into an array of bytes that can be put into a BYTE_ARRAY data type
- use PersistentDataContainer[] and store the arrays inside them
i am using a persistentdatacontainer just not the arrayed version
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
So lovely mongo lmao
someone experienced in python here who could help me?
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
You could make use CompletableFuture
maybe, if I knew how to and what even that is
I recommend reading about it
is it like javascript promises?
I dont really know about js promises
yeah, its a bit weird
Ik there is a part where the code continues on while it does other stuff, not threading tho
I find this link
Maybe you can find a better one
What looks more pleasant?
what you sent me
Oh ok
also, this wont completely stop the server since its threading?
I think that CompletableFuture allows you to catch a result after it finished the execution
Yes by the handle method
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?
but for spigot?
I also use it over the scheduler
But it doesn’t matter
The scheduler uses CompletableFuture iirc
Is it that async?
getchunks is
Yeah spigot scheduler internally uses CompletableFuture
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?
I can explain async as simple as i understand it: it allow to do multiple operations at the same momment without each getting interfered
Well, I wouldn’t think of it like that attitude…
is it more efficient?
pulse
Spigot cheduler uses CompletableFuture so its the same thing
you are going to use it eventually somehow lmao
Pulse also would be a good man and help with mongo?
No I have no idea
I have never used Mongo
so its more if I want more control over what I'm doing as my tasks get more and more complicated?
Also you cannot use Async because your ass sings
Perhaps Together Java discord
what?
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
It doesn’t really matter, you can do either way
There’s not rlly much more to say tbh
lol ik about enough async
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
I did ask a bunch of people if I should use it
I mean this is an appropriate case
yeah
see I asked to make sure
also I saw another plugin use it for the same reason
so I had reason
Use it for what
- I never said that you shouldnt be using async
- You also should know when to use it and why
scanning over chunks and finding the ones with the most entities
Ik, I understand what you are getting at
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
As long as you’re able to iterate over the chunks asynchronously it’s fine
well I actually use the entities to find the chunks
not the chunks to find the entities
to find the chunks
In reality you’re unlikely to have so many chunks where you’d experience a noticeable speed up from the multithreading
Yeah, I also give the user an option to scan for a specific world
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
so
Oh lmao mongo is making me getting really mad. It only problems, problems and more problems
lol I use mysql
Then don’t use it lmao
At most you’ll have what, a couple hundred chunks to check through
depends on the server
Pulse i must use it i wont like to lost more days trying to convert everything into SQL
You’re not going to get into extremely high collections of entities before the server is lagging due to that anyway
because its trendy
I know it but the erors its has
🐑
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
Spamming issue requests are not going to help
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
Sounds like a networking issue. Or you didn't set a proper port in your connection.
lets go, async worked
All the credentials are the same from the hosting, address, port, user and password
SO must work}
I dont know why doesnt lmao
is the port open?
okay, so is running on the same server as the application?
Yes
strange
bruh
ffs
Does your password contain special characters?
also i dont know why the pussies of the host doesnt use normal mongo port
maybe you need to contact them?
No
Only camel and uper case letters
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?
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
😡
Looking at the documentation, port 27018 is technically one of the default ports. It looks like it's used for connection sharding.
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
🤡
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.
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
Please do, because I have no clue what you are talking about.
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
Well the error you gave is an issue with authentication. The codec part is probably fine, it's just fixing your connection.
No no
Which comes down to what version of mongo you are running.
wait forget the other error
When im using the code i send above on 1.19 i get this issue
Then the driver probably changed somewhat in 1.19 vs 1.12
It probably has new methods or a different implementation.
no
Its the same driver
I checked 10 times
bruh it so fucking strange
Im not shocking
https://paste.md-5.net/esuxufanid.sql issue on 1.19
When on 1.12 works perfectttt
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.
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
How much of the Location object are you parsing?
Are you serializing the entire location object or are you just grabbing x, y, and z?
Im grabbing the world name, x, y, z, yaw and pitch
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
What does your CLocation class look like then?
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
So, is your CLocation what is supposed to be put into the CodecProvider?
Well, you make it sound like the CLocation class is what gets put into the codec and is then saved to the database.
That logic only applies to the API, not external libraries.
Im starting 1.12 server to send a cap because im looking like a lier when im not lying
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.
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?
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?
Im testing a prvovided host
They just auto assigned the dbs
Mongo driver is the same version on the 2 projects
Ok, but what version is on the provided host?
I don't know the commands either. I don't use mongo.
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")) {`
Arrays.AsList("command1", "command2")
public List<GenericItemType> getCompatibleTypes()```
instead of this
return Collections.singletonList
I keep getting this error: https://paste.gg/p/anonymous/a0eecb6ec7954d988ffd6208a899fe93
I believe it's something to do with my if check.
what is my plugin version not changing on https://api.spigotmc.org/legacy/update.php?resource=103183
its been like 30m
You're using the legacy api
so it takes a while?
I think the old API takes like an hour to update.
whats the new one?
Whats the question?
Your exception is thrown because you dont check if the array has N elements before accessing the element at index N - 1
How would I do this check?
o.O
I may know, just don't quite know what you mean :P
just check how many elements are in the array before you access it...
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
I see, so StringUtil.copyPartialMatches(args[1], Arrays.asList(COMMANDS2), completions); is trying to get something that doesn't exist?
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"]
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?
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
Sure something like that
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;
}```
You are still not checking for constraints enough
Why does the user have to type in 5 words for the first word to be auto completed???
like is there a way to list multiple items?
What shall I do to check for more constraints?
More if statements
Yes. I can think of at least 10 ways right away to "list multiple items"
You need to be a bit more precise.
Do you want to initialize a List with multiple elements?
@Override
public List<GenericItemType> getCompatibleTypes()
{
return Collections.singletonList(GenericItemType.RANGED_WEAPON);
}```
I would like to add more items here
like list more
Then list more
List.of(X, Y, Z)
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?
I would strongly suggest having a separate tab completer per command and not one for all.
This should be all for one command (mines)
Play around with StringUtil.copyPartialMatches and read the javadocs to find out what exactly this method does.
And then try to understand what your code does line by line. Not just a bit. Fully understand it.
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.
is there a specific setting in intellij i have to enable to have it automatically download sources jar for maven dependencies
Right side you have a maven tab
ill be damned there is
ye ik of that way just didnt know if there was a way to make it do it by default
yeee
intelliJ is simply nice
true
what about compiling then
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
seems so simple
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?
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
does it have to do with a spigot plugin
no
then ask somewhere else.
there are a lot of java servers
google it
ask on forums
etc
I tried
Is anyone here fluent in Inventory Framework?
sqlite is pretty simple.
You get the jdbc driver for sqlite and connect to a db. If it doesnt exist then it will be created.
From then on its just plain old sql.
SQLite - Java, In this chapter, you will learn how to use SQLite in Java programs.
Anyone have any suggestions on when I export my plugin with maven, that its not including the plugin.yml in the src?
firstly it's not in java. secondly I have already started working with it, I just have one issue that I wanted someone to help me with.
If you don't want to I'm not forcing you, I just asked for help and that's it
Are you asking on how to compile your plugin with maven?
Whats the problem
I dont think they have a resource folder
I used to not have one
I dont remember why
No, I've done it before but when I shade the plugin it doesn't include the plugin.yml in the jar.
I just threw my plugin.yml in src
o
Do you have a resources folder?
nvm what they said
No resource folder, I just place it in src
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++;
}
});```
Yeah dont. Create a resources directory.
If your IDE is not trash then its created automatically when you create a maven project
What language are we talking here? sqlite cli?
resource directory in the src?
sqlite3 with node.js
when this is finished, it is not 1 but when I use it outside of this function it is 1
So javascript
yes
show some code
function yourCode() {
console.log("goes here")
}
.
here
Thank you! So what i'm learning is eclipse is trash.
I use intelliJ for plugins
Might have to take a look into it.
good luck with it
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
or do u use something
You use variables which are never defined like "row"
I need to see everything you are referencing
My own library.
But im working on a project that uses Triumph. Its quite decent.
i cant think of one scenario where i've needed an inventory lib
Because you have your own?
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++; } });
No because when i need something like an inventory map
.........
. .
. .
.........
this is like 7 lines of code

???
Sound like you never wrote complicated guis before. It takes hundreds of lines of code even with a framework sometimes
So the issue im having with inventory framework is that i cant change the item im currently clicking on on click. if that makes sense
what type of complicated gui
