#help-development
1 messages Ā· Page 1893 of 1
Once i finish my menu api do you want to use it?? So you dont fuck yourselft
Show me your JavaPlugin class pls
Will it cause an error if I don't check if the item is covered before removing the item?
Wdym by covered?
But letās break the word down,
Application (the interfaceās goal is to provide an easy to talk set of interactions in regards to the application, can be only parts or the entire application)
Programming (related to that we use the interface in programming, so not a keyboard or the interface in the car)
Interface (something that offer what you can done, but not how itās done)
Removing is just setting a variable to null. There is nothing preventing you at any time to just set a variable to null.
If I don't check if there is an item before removing the item, will it cause an error
What your teme please
what
When you break it down, the term is vague enough to be applied to any project. Application could mean anything. Web Application, Server, Plugin, Mod. It's open ended.
Thatās the gist of it
Got it
L e a r n b a s i c j a v a p l e a s e y o u r e v e r y a n n o y i n g
aaa long as you can denote that the api is for an application and the fact that itās involved in some sort of programming then ye
learn basic java please your every annoying
Letās not be rude when it comes to inexperience (:
Please told me your theme
material
EXPGui gui = new EXPGui();
This "gui" instance is now the only instance you have.
Never call new EXPGui() after that again.
If you need it at another place, pass it via a constructor.
Which one?
idk
Oh
You realize this is there first plugin, and it has to do with giving an item, when all you need to do is literally search up "how do i give an item on join spigotmc" for an answer.
That its vscode?
My guy, I wouldn't be telling other people to learn java when you are struggling with the basics yourself.
Indeed but thatās not a reason to yell at them they should learn java. If you get triggered, block/ignore them simply.
I would REALLY hold back with those comments if i where you.
You need to get hold of some very basic concepts yourself.
Nah dude, im only struggling with the fact how spigot is pretty much being broken when i cancelled inventory click.
no
Hmmm
Seems to be somewhat controversial
Possibly
Look no drama is "coming along in here"
conclure understands that literally the number one most thing annoying to beginner coders is "learn basic <language>". just because it isnt confusing to you doesnt mean it is to them and gatekeeping the support channel isnt needed

What's broken about it? Because I haven't had an issue with cancelling the InventoryClickEvent.
This msg should be said to everyone who has said "learn basic java" to me in the past.
well for me in the gui it wont cancel it,
so it seems like you're no better than the people you despise - ?
learn basic java
lmao
I never said i was better then people who i "despise"?
I mean I do believe the learn java card can be played sometimes, but then you really need to tell the learner what exactly they should learn, as there are a lot of things in Java.
Lmao nice discussion
Yes because you check different instances of your inventory
Okay and that is why we are working on fixing it,
And it wont be Java, will be "learn the basic about the spigot API"
EXPGui gui = new EXPGui();
This "gui" instance is now the only instance you have.
Never call new EXPGui() after that again.
If you need it at another place, pass it via a constructor.
Should fix it
can someone help with spigot not building properly
Gotta love this error.
Myeah, spigot is integrally associated with Java
Any ideas why it can't find the config.yml?
Caused by: java.lang.IllegalStateException: Initial initialization <- Dumbest error to exist.
How do you build Trent
If you are using maven, make sure you have resource filtering in your pom
Maven -> package
^ and make sure you donāt just build with artifacts
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
You need to add mavenLocal() to your repos
Ah smile has become a gradle user
good

I was forced...
What a lovely thing about spigot development
Testing plugins without getting out Intellij
:ugly:
and it does it for you
i switched to gradle because shading in maven is too weird for my head
GRADLE?
For me its really easy
Thatās what I want to hear :3
It's arguably weirder in gradle
Wait its easy to develop/code a custom repo manager for Gradle?
well shading + relocating
is maven shading weird
I still need to get remapping worked out with gradle
remapping?
I went for the userdev plugin
This is a strange question
Can I ask questionsš
I dont know why people never post about how to develop/code a custom repo manager for Maven/Gradle
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
Depending on the capabilities this can be really complex
I assume that requires use of the š API
capabilities? IM spanish
Maybe because "repo manager" is a bit ambiguous
I think i will got the answer that I need to learn Javaš¢
Artifact Repo Manager so will be the correct one
It says its enabled
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Do you want it to access maven central? Do you need it as proxy repo manager. Do you want to implement some
sort of authentication. etc.
I mean, that usually happens with new people, but once you get past the ones who are literally uesless and spam learn java, you'll find someone who leads you in the right direction. So ask anyways.
Wdym enabled? Your pom should include that section under your <build> tag.
š
That's why. It's not under the build tag.
is there an easier way of getting a server playercount, or would i just do Bukkit.getOnlinePlayers().size()
I want to code my own Artifact Manager for my projects because i couldnt find one that fit me. Some of them need tons of things and were not stable let say. I need a simple one. That using a custom plugin its upload the Artifacts so then it can be accessible via Dependency tag
So you mean a repository
Those lines are kind of obsolete, no?
it is :p
In other world i need to code a custom Artifact Repository Manager/System
Oh, didn't see that.
I would like to know how to check if the player has the item and how much
Go for Nexus. Together with Nginx on a simple linux server.
I don't see why you would need to do any of that when you can just publish to maven local
Maybe try moving it to the top of the build tag.
oky
Working in teams that my big problems
What 7smile7 said but I would use reposilite instead as it is much lighter
But this year i will start learning about data strucutures so i think that will help me
I cannot expect much im 15 old
Well your data structures class will teach you what a linked list is etc. Not really applicable here]
You will need to check the player's inventory for that. Player#getInventory()#contains(ItemStack itemStack);
Thatās the easy way
Thanks
Not about java. In general, like Trees, etc
Yes
I think you missunderstand the message
Nope :/
Oddly enough it was detecting the config.yml earlier and then it just stopped
I don't think so
Also, ItemStack has a constructor that can take amounts. ItemStack(Material.MATERIAL, amount) You can use that to check for the amount of items.
Have fun throwing Dijkstra at everything in sight for a month
We do a little graph theory
Are you using a custom config or the default one?
Moved over to a custom config then swapped back to the default one
Learning data structures can help you, well, decide which data structures to use...
Why does a linkedlist need reversal
Well, if you are using the default one, #saveDefaultConfig() should work as long as the file is in the jar.
It is a deque
Because sometimes you have to work with singly linked lists
yea, š¦
People
Have you checked your jar to make sure that the file is in there when you build it?
Lemme decompile it, one sec
InventoryClickEvent#setCalled its not working no matter if i put it on MenuListenr class or the in the consumer InventoryClickEvent
I wanna cryy
Got it
Use my custom FileHandler
š”
Hmm. Yeah, it looks like its putting it in the jar for some reason
*not
You mean a queue
Reverse a queue
Java linkedlist goes brrr
Well a queue can be implemented with a linked list
Let me delete the file and re-open the project maybe its buggin
Yes, but if it is implemented as a linked list, then it is a deque too :D
If it is a doubly linked list
Im referring to java linkedlist
Intellij?
And I wasn't lol
yessir
Ah ok
Yeah try that. Sometimes it ge tbug
What commands are you using to build your jar?
Maybe that too
Oh great, windows has to update. gimme a min.
hahaha
?
Another soul lost to the windows update.
Who knows when they will return.
I dont understand you ref
The joke being windows update sucks and he could potentially be stuck for hours.
Or it could upgrade him to windows 11
And then he will really be fucked.
windows updates are so fast for me
@EventHandler
private void onDamage(EntityDamageEvent event) {
Player player = (Player) event.getEntity();
if (player.getGameMode() == GameMode.ADVENTURE) event.setCancelled(true);
}``` is there a better way to do this?
If your pc cost more than $1200 dollars dont talk - YOu are so funny
You got an ssd?
my PC is $900
even the same thing
That looks pretty good to me.
blind casting
No
Then check clause before casting
There was, but it then got changed to the EntityDamageByEntityEvent
check if the entity is an instance of player
Guard clause
?
Yea
alr
if you put windows on your hdd you're doing something wrong
Hey, there are large amounts of people who still use them.
I'm not one of them, but still.
SSDs are god tier.
Could you obfuscate System.loadLibrary() forJNI loading?
If you mean "shorter" then yes
@EventHandler
private void onDamage(EntityDamageEvent event) {
if(event.getEntity() instanceof Player player && player.getGameMode() == GameMode.ADVENTURE) event.setCancelled(true);
}
or its too difficult?
@EventHandler
private void onDamage(EntityDamageEvent event) {
if (event.getEntity() instanceof Player player) {
if (player.getGameMode() == GameMode.ADVENTURE) event.setCancelled(true);
}
}``` i came up with this
good?
Might as well combine the Ifs
ah k
I wont recommend deep nesting in code
You can do guard clause if your java version is still less than 14
well
if (!(entity instanceof Player)) return
It bothers me that you need extra () to use ! with instanceof
I strongly recommend adding bodies even for single lines of code.
So
@EventHandler
private void onDamage(EntityDamageEvent event) {
if (event.getEntity() instanceof Player player && player.getGameMode() == GameMode.ADVENTURE) {
event.setCancelled(true);
}
}
Lol
But this is only if he uses java14+
@EventHandler
private void onDamage(EntityDamageEvent event) {
if (!(event.getEntity() instanceof Player)) return;
if (player.getGameMode() == GameMode.ADVENTURE) event.setCancelled(true);
}
I just think this looks cleaner.
java16+ superiority
Why canāt java let us do !instanceof
coding discords be like
fr
instanceofnt
I dont tolerate code without { } when single lines, multi lines of code when its only one line, doing loops without lamda
And many others things
Read clean code by Robert C. Martin and you will wrinkle your nose at those imposters.
I have seen something really strange. A whole plugin write with classes, packages, methods, fields all in Spanish come ON
how would i players in adventure mode appear as if they're in spectator (like where their skin is 50% opacity)? packets?
true... syntax doesnt allow it currently
time to fork adoptium
Yes, you will have to use packets for that.
Mr Java himself
do (!(Object instanceof Object))
Are you being rude why
I think how other players are displayed is decided client side.
0/10 worst language
Probably because every class is an object
Java is indeed a bad language
Every class inherits from the Object class
Yet it's still one of the most popular.
Cuz it is easy
It was an example that btww
lol...
Because it is used in giant codebases and engineers are too lazy to migrate a whole codebase to a different language and would rather just patch the existing one
Or other paradigm
It's not popular because it is 'good'
I would all life prefer Java and C# instead of yeat like Js, Php, Ts, C++, etc sintaxis code 0 understable
Maybe its just because I haven't looked at Python in ages but its simplistic syntax seems more confusing to me than Java
It's popular because people are stuck with it since everyone thought it was the next best thing in the early 2000s
syntax
cosine taxes
Java is one of the hardest languages to get a grasp of.
Python, C, JavaScript and Rust are for example all way simpler to learn
Yāall are spigot devs youāve committed plenty of sins to be taxed for
I say java is easy in the sense that oop is easy
And java only supports oop
And Java its the most expensive language for paid. Here in my country a junior dev can win up to 1200 dollars
By default
Dont thought about a Senior
python isn't easy for me because I'm used to bracket-based languages and tabs are Kappa
You mean tabs that auto convert to spaces right?
I would even go as far as calling caps poggers
And Haskell is purely functional, I wouldn't exactly call it easy to learn
Python is cursed
nah because visual studio got mad at me because the code I pasted from stack overflow used spaces while I use tabs
Especially when you start using numpy
and I spent so long fixing it
Java its easier than c++ all life dont dont fuck
and c# breaks my head because it looks like Java but it has 𤮠naming conventions
I like c++ tho
C++ is such a great language
Really yeat sintax
Disregard what linus have to say
let say the method are strange, etc
I just find the memory management a bit tedious at some points
What makes it good in your eyes
rust
You do know that java was created to be a competitor to c++ right? That's why they are similar.
Making a lot of comparisons to C here
I like
cout << "Please input a number between 1 and 1000" << endl;
cin >> guess;
the syntax highlighting in discord for cpp
Uh oh. Someon lives in 1999 and uses Java 5
I think it's the ugliest thing ever
That's the part I hate.
go ask any competitive programmer
OwO<<
Not by much.
Not really
im a competitive programmer and use java
?
lol
Java can get pretty damn close to native C++ performance if you know what you are doing.
Python, now that's a slow language
JAVA always be better than yeatty C++
Huh? Do you know what procedural means
im not sure which packet will achieve this effect
They dont use c++ over java because the of the runtim difference. Its because the jvm just needs so long to start up and get hot.
After that java is on par.
Thatās why I keep my computer on the stovetop to help the jvm warm up faster
not only that, java has this thing that initiates fields to 0 or null by default
how would i wait for a certain amount of time then set a boolean, ive tried the scheduler and just wait() but idk
Not as slow as it used to be. There are plenty of projects that use python and they are pretty fast. youtube-dl is one example.
Most competitive programmers I know use python
youtube-dl is mainly data retreivement
and web scratching
most that i know use c++
It still uses python though
of how it is a good info retrieval tool
This just in: computers are fast
Omg my MenuAPI its saying that my menu its null
As stated earlier:
This is decided by the client using the GameMode of both players.
Well, it turns out none of my code works because If I remove the key from the config.yml (in plugins folder) the plugin just uses the default values from the embedded config.ymlš
Im fucked about speding more than 1 week in this yeat
Use my custom FileHandler dont you dont fuck with problems. Its much easiear
Yea, that's one of the "perks" of using the default config depending on how you look at it.
Well, a downside in this case
So custom config it is then?
YEAH
Yea, but they are really easy.
File configFile = new File("path/to/file")
FileConfiguration config = YamlConfiguration.loadConfiguration(configFile);
Then just use the instance of config for your checks.
I guess it helps to prevent users from breaking config.ymls but it takes away the customizability bc it forces the default values š¦
public class FileHandler extends YamlConfiguration {
protected final Utilities main = Utilities.getInstance(); // Your plugin instance
protected final String name;
protected final Boolean parent;
protected File file;
public FileHandler(String name, Boolean parent) throws IOException, InvalidConfigurationException {
this.parent = parent;
this.name = name;
this.file = new File(this.main.getPlugin().getDataFolder(), this.name);
if (!this.file.exists() && this.parent) { this.createParent(this.name, this.file); }
if (!this.file.exists() && !this.parent) { this.createFile(this.file); }
load(this.file);
}
public void reload() throws IOException, InvalidConfigurationException {
this.file = new File(this.main.getPlugin().getDataFolder(), this.name);
if (!this.file.exists() && this.parent) { this.createParent(this.name, this.file); }
if (!this.file.exists() && !this.parent) { this.createFile(this.file); }
load(this.file);
}
public void save() throws IOException {
save(this.file);
}
protected void createParent(String name, File file) throws IOException {
this.file.getParentFile().mkdir();
if (this.main.getPlugin().getResource(name) != null) {
this.main.getPlugin().saveResource(name, false);
}
this.createFile(file);
}
protected void createFile(File file) throws IOException {
file.createNewFile();
}
}
?paste
use pastes for large code blocks
Allright
Its no so large, but ok...
I actually made a really simple custom config. I'll show you guys when I get back. Going to get dinner
it is quite large :)
Where's the load method in that class?
just do FileHandler config = new FileHandler("config.yml", true) and then on resources create config.yml and the content to that yaml
And then for getting/setting, etc use config#set()/config#get, etc
The boolean parent (false) its used when you want to load file that doesnt exists on your resource folder
I get that, but in your constructor and in your reload method, you are calling a method called load(File file). Did you paste the whole class?
load() its a method from it supper class (YamlConfiguration)
Ah
Take this in mind
you can also just have it ignore the default values for config keys... contains(String path, boolean ignoreDefault)
Talking to?
If you need help dm me
@tired dagger ^
help pls
I suppose but the default values persist (in game)
A question can a Hashmap/Map get clear cuz using Singleton?
Because im debbuging my code because my menus map its empty. And i think its caused by the singleton
please no
wait for one thing why is ur main class named Utilities
is that your plugin name lol
Its my library class
And it doesnt extend javaPlugin
Definitly this was the problem
do what every developer does
they take a bit of their name and add smth like lib
VeraLib
Or do what Adele does and turn to Latin
It does work
I will put it: SpigotLib
I see a project on my GitHub feed called Hershboka and I have to click on it to see what itās about
lol
That its a wrong practical
The name should be descriptive
technically my plugin names are descriptive
Yeah Adele smh my head
just in another language
@ancient plank better than me
i usually pick some random word
hope, ivy, calamity, guardian, mocha
configurator
it be like that
Calamity sounds like a terrifying plugin
Be gay, do crime?
guardian rips off GameSense's get good, get gamesense
get good, get guardian
except its not a cheat and not for the same game
then you prob want to have better cohesion
spigot's jira issue tracker
Because im doing a custom gui and it detect click event on player menu when im saying only detect it on custom menu
Not on player menu
Btww
player menu?
Im using custom menu
But when i click on player menu it detect as im clicking on custom menu
and what do you mean by player menu?
Its so strange
His normal inventory
Like when you open a gui you have the default inventory from minecraft
If I mount an entity using PacketPlayOutMount, does the server recognize that I'm mounting the entity or as the passenger of the entity?
it should be detected
why?
I only want to block the event when you clicking on custom menu (the one on the top)
Then check if the clicked inventory is equal to the top inventory
then you have to check for its inventory holder or however you implemented the gui
it isn't a bug
what does it return?
Sorry it was event#getView#getTopInventory
So i think its that one
yes
try to debug it yourself first
many jump into asking others without spending the effort to debug the problem
Obviously
I wont ask for help before testing it
I love so much testing that i configure Intellij Debug settings for starting a Spigot server locally and export the jar directly there
you can also add debug code too to see what is going on through out the code as well
or as it is common called, to walk through it
It has a name that type of debug
debug code is whatever you want it to be
whether it be outputting the data some object has to the console, to names etc
I call it the lazy method :p
kind of, but you don't need to check anything, just as long as its informative enough you know where in the code something is at
Yeah i now
Does ready has an option for sending/receibing Json Obejcts without parsing them to json string?
Use GSON instead of Json Object
Isnt the same thing?
Gson parses Json code
Or im wrong
GSON is api for Json, so you save a lot of time
By Json code you mean the Json content?
Yeah
Nothing forget, i just remeber slots counts from 0
So yea GSON is very easy to use and when you need to do more complex stuff you have pretty good GSON configuration
But how, because ready doesnt have an option for seding/receiving json payload
It only supports string
Json can easily be converted to and from a normal string
The point of Json is to covert class to string and in the other way
How i only kno using Json#toJsonString()
I need a simple way of sending custom class object via ready
That what i need
Redis*
Sending where?
You just read data from Json onpluginEnable and save to Json in onpluginDisable
Read about Repository desing patern it could be useful in your case
Allright thanks
But repository in what way?
Related to Objects right?
Its a class to get/insert/delete/update objects
Between database and your Application
Why database?
Redis is database right?
I will create a system with Packets, let say you create TestPacket with some parameters. Then i need a way for sending/receiving that Packet object from/to Redis
And the Issue is to read packet from string to its class?
Yeah
Mediator desing Pattern is good for this purpose
Right thanks for recommendation
Or just create method Public <T>T convert(String key, Class<T> classDestination)
And them how i parse the methods/fields with the data?
But its great that method
You need to figure out implementation for that method it was example
can anyone here make me a really simple plugin that hooks onto placeholder api? i literally just want the plugin to return a value set in the config when %vlands% is sent (with placeholdeapi)
my tried have failed
also, whats the equivalent of world.getBlock() for 1.8?
world.getBlockState(event.pos).getBlock();
this?
?jd 1.8.8
I didnt understand the first part of your question
the placeholder thing?
No but i didnt understand what he want to do
i want to make a placeholder plugin that returns a value that is set in the config
Send the code
?paste
i dont have any
im on a phone
Ahh allright
I sent request, told me when you are and when i see it it will help you
Oh nice finally i think my Menus api its working
When you have a value on a map and you add the same value, its overwrited or not?
I'm trying to make a system where players can claim a reward every 12 hours. I was thinking of using a cache like this:
private Cache<UUID, Long> cooldown = CacheBuilder.newBuilder().expireAfterWrite(12, TimeUnit.HOURS).build();
to add players to the cache when they claim the reward, then have it automatically removed after 12 hours. is that a good idea or is there a better way to do it?
I dont recommend like that, zuz what happen if server go off?
Do you save that cache right?
wdym
what do you recommend then?
Wait have you understnd?
I understand the problem, but what do you suggest I do instead?
Like that cache its temporal. So if server goes down the cache will get cleaned
yes I understand
I see
any other way to compare arg name ? also how do i check if player is op
alright I'll look into it more, thanks
Wait what are you trying to do?
^^
Allright if you need more help just ask here
š thanks
making a sw plugin and a op can choose a kit by doin somth like /kit <arg = insane">
@pine island player.isOp() for the op check I believe
sw = skywars*
yeah
yep i know that
Ok
1 sec
?paste
Over there please
ofc
This link you join, paste your code, press ctrl + s and copy the link
resume?!?
make it so the arg can be either "normal" "insane" "amplified" and give the loot acrdingly
i dont know
You dont need args.getName()
i have no clue why i added that
You should use args[index] in others words you should use args[0].equalsIgnoreCase()
ohkl
yeah it's just args[0] args[1] etc
tysm!!
Your welcome
I recommend you learning the basics about java and spigot api
@sterile token do you know any tutorials for sqlite?
BEcause you will have many problems then
I can help you with that
I had worked many times
i know the basics i woke up like 15mins ago
Just dm and ask what do you need
Or ask here
yeah I honestly don't know where to start with sqlite
couldn't find any tutorials online
Do you kow what its right?
Let start from the begin
yes, I've worked with mysql & sqlite from a server owner perspective countless times, just not from a development standpoint
Allright
What do you want to do
Because SQLite its database for local storage (one plugin)
I want to make a plugin that lets players claim a reward (do a command) every 12 hours.
Ah allright
no syncing or anything, very simple stuff
I will make you a simple example
I have my api with many things and include databases for MySQL, SQLite and MongoDB
Oh sweet, thanks!
have you guys gotten the hacktoberfest shirts
Issue: Texture on stone slab is not being replaced with a dirt block texture
Stuff I have troubleshooted: I have looked over my JSON file for the models and textures, I have looked over my code, I have looked over the download and host of the resource pack
Stone slab overwrite JSON
{
"parent": "minecraft:block/slab",
"textures": {
"bottom": "minecraft:block/stone",
"top": "minecraft:block/stone",
"side": "minecraft:block/stone"
},
"overrides": [
{"predicate": {"custom_model_data":1234567), "model: "block/dirt_slab"}
]
}
dirt slab JSON file
{
"parent": "minecraft:block/slab",
"textures": {
"bottom": "minecraft:block/dirt",
"top": "minecraft:block/dirt",
"side": "minecraft:block/dirt"
}
}
public class Sqlite {
private Connection connection;
public void connect(JavaPlugin plugin, String name) throws Exception {
File file = new File(plugin.getDataFolder(), name);
if (!file.exists()) { file.createNewFile(); }
this.connection = DriverManager.getConnection("jbdc:sqlite://" + file);
System.out.println("Connected to sqlite " + name);
}
public void disconnect() throws Exception {
this.connection.close();
System.out.println("Disconnected from sqlite ");
}
public Connection getConnection() { return connection; }
}
Would appreciate if someone can figure out why the overwrite on the texture isn't working
why is it not giving me import class option?
oh wow, very cool
First you should create an instance of that class, I recommend on Main class.
i forgot to add () whoops
Shouldn't it be getInventory().add not getInventory
For adding things: MainClass#SqliteInstance#getConnection()#prepareStatement()#executeUpdate() -> void
For getting things: MainClass#SqliteInstance#getConnection()#prepareStatement()#executeQuery() -> ResultSet
It need one parameter
prepareStement("Here goes sql code")
A fully example would be
This is how you create a table
getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS table (uuid, age)").executeUpdate();
preparedStatement() prevent you from being hacked
Yeah its prevent sql injection
it removes all sql Injection stuff
And not only that
Ok, sweet
It do it easy for queries, if not you would need to put the values inside this `
You understand right jack?
I'm also getting an UnhandledException from
Sqlite database = new Sqlite();
database.connect(this, "data");
what did I do wrong?
yes the query formatting
Yeah
Full eror please
what is This?
send full class
An example i did for him
this jack
o i right wrong
i didnt write jdbc
for sure first argument should not be this
public class Sqlite {
private Connection connection;
public void connect(JavaPlugin plugin, String name) throws Exception {
File file = new File(plugin.getDataFolder(), name);
if (!file.exists()) {
file.createNewFile();
}
this.connection = DriverManager.getConnection("jbdc:sqlite://" + file);
System.out.println("Connected to sqlite " + name);
}
public void disconnect() throws Exception {
this.connection.close();
System.out.println("Disconnected from sqlite ");
}
public Connection getConnection() {
return connection;
}
}
this is the sqlite class
Wait its something wrong
its jdbc
Not jbdc
It was my error
change its on getConnection() method
oh really? What would I do instead?
you shoudl try-catch the method connect()
cuz you need data folder
For the db file
It wont be created on the heaven
the whole method?
Not only the connect() method
and the disconnect and getConnection method can thrown exception
You shouldnt keep your connection opened
why i created method disconenct()?
Look the code again please
š¤
I sent wrong emoji
have you seen?
public class Sqlite {
private Connection connection;
public void connect(JavaPlugin plugin, String name) throws Exception {
try {
File file = new File(plugin.getDataFolder(), name);
if (!file.exists()) {
file.createNewFile();
}
this.connection = DriverManager.getConnection("jdbc:sqlite://" + file);
System.out.println("Connected to sqlite " + name);
} catch (Exception e) {
System.out.println("Error with sqlite");
}
}
public void disconnect() throws Exception {
try {
this.connection.close();
System.out.println("Disconnected from sqlite ");
} catch (Exception e) {
System.out.println("Error disconnecting from sqlite");
}
}
public Connection getConnection() {
try {
return connection;
} catch (Exception e) {
return null;
}
}
}
hmm, like this?
Declare the variable "Sqlite sqlite" out of your onEnable() method. And then on enable just do: sqlite = new Sqlite(this,, "dbname")
yeah
I mean, the connection object should not persist. Or idk, do you send connecting/disconnecting message every transaction?
Yeah
Manya dont critice my code
I do it as example model
When the connection object persist?
I don't understand though, the class doesn't have a constructor
so what>
Do you agree with me or Manya?
getting this
Idk why he critices my code
When you set it as field...
I think they're just trying to help
My wrong, new Sqlite()
wdym?
Just put sqlite = new Sqlite()
HikariCP is fast enough that you can obtain a Connection, execute SQL, and then return it back to the pool many times in the course of a request.
It is a Best Practice to only hold Connections in local variables, preferably in a try-with-resources block, or possibly passed on the stack, but never in a class member field. If you follow that pattern it is virtually impossible to leak a Connection or accidentally share across threads.
ITS A SIMPLE EXAMPLE
What dont you understand
try
{
sql.connect(this,"Name");
}
catch (Exception e)
{
e.printStackTrace();
}```
does hikaricp come with spigot?
try this code
No, Its an extra library
worked ty
is it using over the default library?
What i didnt understand?
default sql library with spigot
Spigot doesnt have any default sql library with it
even simple examples can teach you bad practices
it has sql connector and sqlite in it
org.sqlite.JDBC ?
why cant i create a plugin for 1.8?
So instead of criticing just help you
Which version??
why would you want to use 1.8?
I create 1..8x plugins. no other versio
its a skywars plugin ;-;
idk, for a very long time
1.8 is like 7 years old ;-;
It is deprecated
No, you are still using java.sql.DriverManager for SQLite. "jdbc:sqlite://FILENAME"
dang any work around?
java.sql Meaning it comes from java itself.
Global networks for letting you know are BASE 1.8x VERSION
but if I use a real db I should use hikaricp?
Yes
loud minority
If global networks do something thst doesnt means its good
pvp is better on 1.8
Yeah
agree to disagree š
No
most servers I've interacted with are using either 1.8 or 1.12.2 a minority I've encountered are actually dealing with 1.16+
^^^
Yeah
SO for discussions go to #general please
alright is there a way to make a 1.8 plugin in intelli j?
maven project? or Java Project?
^
yes, generate plugin for 1.18 and adjust maven file to support 1.8
nope i use maven 1.8 still dosnt show up
š
#general
Dont play a moderator
Anyway, you should download Spigot Build Tools and build Spigot 1.8
I recommend 1.8.8 R3
why not 1.8.9 lol
1.8.8 is the last 1.8 server version that I know of
It is client side only version
please don't use 1.8 š it's literally just outdated software, full of exploits, and unsupported
He's got a point though. This is a channel for development purposes. Not opinionated version comparisons.
better pvp smh
you can use a plugin to achieve that
pff 1.8 is srill unsupported here
For dicussions go #general
^
Here as said Shadow its for development help
Extremely primitive abd monotonous pvp bound to the mouse clicking capability
^^^
I wotn dicuss anymore
For building Spigot version (you want), you should use Spigot Build Tools
You can find a tutorial on SpigotMC webpage how to use them
just a simple command then i can import it to my IntelliJ folder
If your project its maven you should add it as dependency like this:
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>jar-name</artifactId>
<version>your-version</version>
<systemPath>your jar route</systemPath>
</dependency>
Are you in the same dir?
i dont think so...
Linux or windows?
He?
try running it as administrator
If windows do cd C:/Usuarios/YouUser/Desktop
alr
And then run the other command
I dont understand you
WSL
Ahh
HE run the same as me
I run a system that its a comination of linux and windows
Chads just run Linux.
Just open a cmd and run:
cd C:/Usuarios/YouSystemUser/Desktop
I think
You should move to desktop route if you have the BuildTools.jar there
In other words the jar, should be in the same route as you
@sterile token trying around with the code a bit more, did you find it somewhere or come up w/ it yourself?
What?
did you follow a tutorial I can check out?
Yeah
i forgot to download the build tools .jar
Look. Wherever you have the jar file is the directory you need to run the command in. Usually when you download something itāll be in your downloads folder. Iād suggest moving that to a new folder and running it in there as the jar will create directories and files that might be hard to find if you are in a crowded directory.
A tutorial of what? SQLite (Java Implementation) or SQLite (Queries)
For queries, you just need to know SQL
Ok
Like search on google how to create a table with SQL, the same for adding values, etc
You should take in mind that SQLite its a relational database, and the data its store on tables with key-value system
Thanks for correction
Haha
I can only understand relational
Is this object oriented
Yeah
With mongo you can save/get/update/etc directly an Object (document)
That what i understand
Wow, I havent met with a situation where I need that lol
Cuz there is always jackson for json files
In terms of java
I need it because if not i have to harcode array saving with MySQL/SQLite
That what i dont like about SQL db, that they are relational
And when you need a value related with other table we dont talk anymore. HaHaHa
I mean
relational databases has advantages as well
There are joins
Yes but the problem start when i dont understand how the relations works
I now basic sql queries
Not advanced with joins, relations, etc
Ah i think after i learnt joins, I cant think of a problem that cant be solved with rdbms hahaha
Foreign keys are cool
And yeah that
A question
How do you get player view on InventoryOpenEvent?
With getViews() right?
i think so
Is it a getViewers
Allright
It gives all views i think a Set<> or array
All viewers yes
Firefox
I forgot telling you that for check if player is op just do: player#isOP()
yep i know that
OperaGX ā¤ļø
JavaFx webview
Why you dont have option getView() on InvOpenEvent and on InvClickEvent, invCloseEvent you have it
Dont need of checking
just do: if (player.isOP()) { return true }
You should
Inherited from InventoryEvent
yeah
No
Im explaning him
That its not necessary to == true, because player.isOP() will return true/false
On InvOpenEvent you need to getViewers()
well yeah but its just a few more characters dosnt really matter
Idk why+
In my case intellij warn me
Ohh
Yea
this 1.8 build is taking so long ;-;
guys how to add essentials api, its always error on me Cannot resolve org.bstats:bstats-bukkit:1.8
._.
Im really idiot idk why i didnt see
you have the discord?
Probably yeah
yep
Google its your best friend
:)
imma dm u
ok thanks!
its called MOSS for some reason
Do you know about menus?
Cuz im having an inssue when opening menu B from menu A
In menu A i cannot take the items, but on menu B yes
The build tools?
yeah that finished up
maven
allright go to pom.xml
for 1.16
In pom.xml go to you dependencies section
Add this dependency
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>jar-name</artifactId>
<version>your-version</version>
<systemPath>jar-route</systemPath>
</dependency>
version will be 1.8.8?
Yeah
And it doesnt matter because you have it locally
Let say, if its on repo you should know the version
And then just reload the pom
wait i cant find the jar which one?
Wait what?
the last part?
In my case i have a folder on desktop called Dev there i have spigots, etc.
it created this
Please help
Ahh i think you have to compile the jar
cant i create a project in eclipse and move the folder to my intelliJ projects folder
Intellij has an option i think for importing it
yep it does
Oh lol
ill try creating a eclipse project 1 sec
I know what will definitely work
I think he has to compile that folder for getting the jar
But running the buildtools should automatically install the relevant jars to your local maven repository
I love multi module projects. Hahaha i have installed my multi module project more than 20 in less than an 1 hour
Ah alright
The jar should be on folder C:/Usuarios/YourSystemUser/.m2
Yep
That the location right?
@pine island are you using any build systems for your project
He use maven
Great then just include in pom.xml the dependency will do
So he wont use this so?
That its what i use for using depencies that are not installed on my local repo
System path not required
So he just need to add it as normal depency
Yep
Allright
no jar here and in the folder
there
.m2/repository/org/spigotmc/spigot-api/1.8.8-R0.1-SNAPSHOT/
Or watever version you intend to use
there
Vscode
Oh lol
What no one use for java
I hate
Yeah like its not so normal
I thin kyou use the Vscode IDE
Because there are 2 verions
There is a version that its an ide If not how you will compile projects etc
Or that what i ithink
Hum
Uff
?ask
https://www.youtube.com/watch?v=x5cCbd7MZgw found this for my error
In this episode of the Spigot MC Plugin series, I show you how to create a plugin on most versions of Minecraft, even those not supported by the IntelliJ MC Dev Plugin. #Spigot #SpigotTutorial
Join the Community! - https://discord.gg/cortexdev
ā Kite is a free AI-powered coding assistant that will help you code faster and smarter. The Kite plu...
What that?
Just big uff that he uses mvn clean install
1.8.8 java plugin in intelliJ