#development
1 messages ยท Page 136 of 1
Oh boy it's time to teach dependency injection
Are you familiar with what a constructor is?
Anyway, you want to get rid of all that static, all of it. static is evil, you want to do basically this from the examples ๐ but with your classes
Dependency Injection
Dependency Injection is a way of providing objects with the objects they need ("dependencies"). This is usually done with a constructor, but can also be done for individual methods
Read more here: https://en.m.wikipedia.org/wiki/Dependency_injection
Dependency Injection in Java:
https://paste.helpch.at/yijawupoju.java
Dependency Injection in Kotlin:
https://paste.helpch.at/esogakutod.kt
Ok, so i shouldnt use a Main instance, instead pass in main into the constructor?
correct
Ok, let me change that rq
So like this:
Guild data: https://paste.helpch.at/lumawiveza.cpp
Main: https://paste.helpch.at/etizahuhub.java
PlayerEvents: https://paste.helpch.at/azebaxedol.java
That looks much better except that it doesn't compile lol
that new GuildData(this) shouldn't be needed, and you need to pass this when calling new PlayerEvents ๐
yeah i noticed that after i copied it lol
let me try this and see
Still getting the same error
idk where it is coming from
hm, how are you building your plugin?
ah, you need to put <scope>provided</scope> for the guilds dep too, you're probably shading it (bundling it inside your own jar) and it's doing pretty nasty things
And it's in the plugins folder?
Any ideas?
Are u shading the api?
What's the directory holding the enchantment glyphs?
no j sdded scope provided.
could you paste your entire pom here?
U might be adding realocation on dependency plugin
help with deluxe tags for some reason when i use rgb and mutliple colors and things like that
for example &#c745ff&lN&#ff15e8&la&#c745ff&lm&7
it isnt just "nam" in colors
it look like this "&n&a&m" with colors and it really fucked even tho when i type the same thing in chat normaly without it using the plugin is look fine
and i have no idea what to do
add scope as
<scope>provided</scope> on guilds and try a clean package
Im still getting the same error
btw, how are you building your plugin?
can I sort a Map based on the return value of a method of the items present in the keyset of the map?
what
Say I got a map Map<Enchantment, Integer>, and the Enchantment class has a method getWeight() which returns an integer
I want to sort the map based on what each object in the map returns using that method
enchantMap.keySet().stream().sorted(Comparator.comparingInt(o -> o.getWeight())).forEach(enchantment -> System.out.println(enchantment.getDescriptionId())); I tried doing this
use a TreeMap with a custom comparator
But it didn't do much
When I tried using a TreeMap it complained to me saying that Enchantment is not a comparable item
note that a tree map has other asymptotic characteristics
yes that's why you need a custom comparator
How would I make a custom comparator..?
something like new TreeMap<>(Comparator.comparintInt(Enchantment::getWeight)); should do the trick iirc
Oh wow okay I didn't even think of that
anyone know how I could access a variable from another class?
That doesn't automatically sort the map though does it
I gotta do the whole keyset().stream().sorted() thing
it should keep the map sorted the whole time
You would need to implement Comparable interface
Well, it doesn't seem to be sorted ๐
(as long as the weight does not change)
I try to copy a section of blocks, WE-like. However, I can't figure out how to copy double chests. Regular ones are fine, but since there are two blocks idk how to get the other one for a Block instance. I know there is a getLeftSide and getRightSide but how do I know which one is which?
Is it possible to have two sorters
If there's like 5 items with the same getWeight() value, it should sort based on another value
It's another int
.thenComparing[Int/Double/etc](...) or something like that on your comparator
Oh that's cool
uhm something's up
When adding the thenComparing, for some reason o is no longer of type Enchantment according to my IDE
yeah type infering isn't strong enough there, you can write it as .<Enchantment>thenComparing though
Im building a clean package with maven
hey where do i place the command: so it would work
left/right click
@graceful hedge smells
nah
Still having this issue if anyone has any ideas
When i am changing my minecraft plugin to 1.18 i get this error when i try compiling:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project Kingdom: Compilation failure An unknown compilation problem occurred
https://www.toptal.com/developers/hastebin/ihohuyihes.xml <-- My pom.xml
First thing you should change is don't include spigot twice
You only need to include spigot if you already have that then you don't need spigot-api
Oke thank you
You also don't need the online repo if you have it installed locally (which you probably do if you have the spigot artifact)
Yeah but i only want to solve my error tho
What else does it say?
Thats the only thing
Thats the weird thing too haha
Maybe changing the java version
But how?
Your version in the pom is set to 8 rn
But I feel like if that was the issue, it'd give you a better error message
Question, im trying to make some quests, but im wondering how i should track the progress of each quest?
Nvm, i figured out a way, but now i have an optimization question.
So the quests are configureable so im loading them from config, and currently i do it like so:
QuestType type = QuestType.valueOf(config.getString("blacksmith." + key + ".type"));
int amount = config.getInt("blacksmith." + key + ".amount");
String m = (config.isSet("blacksmith." + key + ".id") ? (config.getString("blacksmith." + key + ".id")) : null);
int karma = config.getInt("blacksmith." + key + ".karma");
String name = config.getString("blacksmith." + key + ".name");
List<String> lore = Utils.color(config.getStringList("blacksmith." + key + ".lore"));
List<String> commands = config.getStringList("blacksmith." + key + ".commands");
String area = config.getString("blacksmith." + key + ".area");
Quest q = new Quest("blacksmith", type, amount, m, karma, name, lore, commands, area);
blacksmith.add(q);
allQuest.add(q);
});```
While this works, if i were to do this for **every** player i have a feeling it will get intensive. So once i create these objects, and store them in a list is there any way to basically duplicate that list, but with different object ids? Duplicated each object? or is there a better way of doing this?
How do I delete a plugin after the server stops?
deleteOnExit doesn't seem to work ๐
I remember seeing a plugin auto updating itself and deleting the old version... but I don't remember the name of the plugin D:
If I add a shutdown hook (to unload the plugins that I want to delete after they unloaded), then I get this error: IllegalStateException: zip file closed
although the code inside (I added a print to test) works
put the new file inside the ./plugins/update folder
the server will replace it on startup
waaaaaaaaaaaaaaait what
๐ฎ ๐ฎ ๐ฎ i never knew
wait
so spigot automatically removes the old jar?
oh wait no
there's an "update-folder" setting or whatever inside bukkit.yml, check that
Lightbulb.png Note: Ensure the name of the .jar in the update directory is the same as the name of the .jar in the plugins directory for the same plugin.
hm
that's where you put the new file
paper changes that by replacing the plugins after their name, not file name ๐
plugin.yml name?
yes
๐ฎ
oh is it only 1.18
Hmmm
not that i use other versions
but if other people use it
its limited to 1.18
ยฏ_(ใ)_/ยฏ
then uh.. save the new file with the same name as "this" file?
idk lol
but yeah that's actually a really neat feature very few people know about
yep
ty
although for solving the issue without requiring the same file name, maybe I could disable & unload the plugins... manually in onDisable? ๐
hmm
so that I can delete the jar file
on windows
the disablePlugin method has a check to see if it's enabled
so I think that disabling other plugins in onDisable shouldn't cause any issues
then i can delete the file ๐
(after running some code that plugman uses)
(or plugwoman)
deleting your own file
after disabling other plugins
from code that is inside your file
currently open and running?
wack
no i mean
deleting other plugins files
but once i disable
it shouldn't be running anymore
i think
on newer versions their class loader is closed when disabling it, that isn't the case in older versions
unless you're using paper
hmm
is it possible to do that in my plugin?
close the classloader
noo why 1.13+
plugwoman
ah well
plugmanx supports 1.8
ยฏ_(ใ)_/ยฏ
yeah, you just need to get their PluginClassLoader and call .close
oh
will that unlock the file?
in windows
dunno
oh and in newer vesions the library loader class loader isn't closed so uh
basically you're in for a ride
yes, the libraries thing in the plugin.yml to download libraries on startup form central instead of shading everything
no, it's a separate one
it is, but those libraries could contain references to classes from your file
True
hmm
ill just make it so that if the file deletion errors out, then it'll just skip it until I find a solution ๐ฅด
just put the file in the updates folder lol

it's just that good
Anyone?
oh wait nvm the issue was that I was running deleteOnExit on null (nullcheck)
deleteOnExit does indeed work ๐
except for LuckPerms
all the other plugins work tho
How do I get CraftItem to work on 1.18?
final CraftItem craftItem = null;```
Isnt working anymore, it worked on 1.17
Itโs not part of the API
anyone ever used VectorDrawable? I need spoon feeding. I need a Z letter that doesn't look like this xD https://i.imgur.com/iGZlACj.png. my first time working with this
got to this. its not perfect but might have to stick with it for now https://i.imgur.com/iouWUYI.png
oh turns out I can use numbers with decimals. that's helpful
Noob question incoming
Does a tree data type exist in Java? When looking it up online, I see most people create their own implementation of Trees
anyone knows why if I do
player.damage(60);
i get 60 dmg but if I do
player.damage(60,entityDamager);
where entitydamager is a entity reference it deals only 31.0?
Yes Tree and Leaves
not that I know of, what's the use case?
Making a mod which changes the random enchantment system to a tree like enchantment system
But I figured it out
Oh IDK if it exists in the minecraft code but it existed in spigot 1.8.8
MaterialData md = b.getState().getData();
String blockType = (md instanceof Tree) ? ((Tree) md).getSpecies().toString() : ((Leaves) md).getSpecies().toString();
if(blockType != null) {
switch(blockType) {
case "GENERIC": saplingtype = 0; break;
case "REDWOOD": saplingtype = 1; break;
case "BIRCH": saplingtype = 2; break;
case "JUNGLE": saplingtype = 3; break;
}
}
I mean I'm making a fabric mode anyway ๐ ๐
yapps theyโre not talking about ingame trees
Oh
mans linked a minecraft tree
Well it is a minecraft server xD
Java 14+ contains Tree | getKind(), accept(TreeVisitor<R,D> visitor, D data)
All I could find.
Thatโs compiler stuff
Tree structures are often modeled implicitly
Though I got a question: How can iterate (depth first) through this?
EnchNode[] sharpnessNodes = {
new EnchNode(root, new EnchantmentInstance(Enchantments.SHARPNESS, 1)),
new EnchNode(sharpnessNodes[0], new EnchantmentInstance(Enchantments.SHARPNESS, 2)),
new EnchNode(sharpnessNodes[1], new EnchantmentInstance(Enchantments.SHARPNESS, 3)),
new EnchNode(sharpnessNodes[2], new EnchantmentInstance(Enchantments.SHARPNESS, 4)),
new EnchNode(sharpnessNodes[3], new EnchantmentInstance(Enchantments.SHARPNESS, 5))
};```
Is there any way to have this snippet of code work
It's annoying to have to create a bunch of variables and store them to use later
Or something similar
So create like an EnchTree class?
Which holds EnchNode instances?
Or I mean an array of those
Enchantment is a minecraft class
Can't really embed it in there
Or I mean I can, just not sure if it's really worth it
yeah then you need a wrapper
what is this for?
How do I use a particle without it flying away? I have a way to make shapes out of particles and am trying different particle effects. However, some particles (like flame) just fuqs off in mach 2.
You need the make a repeating task
How can i remove all of the messages Mongo sends on connection?
For some reason with maven whenever i do:
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>```
It doesn't work. The latest version it sees is 1.17
I understand that 1.18 changed the spigot api?
spigot = nms
make sure u ran buildtools
yeah I want NMS
but wait why do I have to run buildtools if its getting it from a repo
its not
oh
its getting from local maven repo
since you can't host the minecraft jar online (legally)
oop ok
codemc has an illegal repo
although it is illegal so you shouldn't add it to your repositories then use it so that others don't have to use buildtools to compile your plugin
Likely the max it can be, makes sense it would be set at 20
Is there any way to get the actual server TPS?
Bukkit.getServer().spigot().getTPS() I think. But its better to calculate it yourself.
How would I calculate it? Also this only works with paperspigot
I don't use paper. And just have a runnable caching the times it runs and calculate if its within 50ms of each other
Ok thanks
Does anyone know a better regex for converting spigot-style hex codes to #ffffff format? what I have works but it's pretty clunky
public static String decolorize(String string) {
if (string == null || string.isEmpty())
return string;
return string.replace(ChatColor.COLOR_CHAR, '&').replaceAll("&x&([0-9A-Fa-f])&([0-9A-Fa-f])&([0-9A-Fa-f])&([0-9A-Fa-f])&([0-9A-Fa-f])&([0-9A-Fa-f])", "#$1$2$3$4$5$6");
}
I'm not exactly an expert with regex so I don't know if there's a better way to handle the matching groups. I know that &x(&[0-9A-Fa-f]){6} matches the spigot-style hex code properly but then I don't know of a way to transform it to the #ffffff format
Aren't you able to just do ChatColor.STRIPCOLOR?
I'm trying to transform the color codes back to a readable format, not remove them entirely
otherwise yes that would have worked
Ah. One sec then
Basically &x&a&b&c&d&e&f -> #abcdef
Wait what gives you that? I use #ffffff for hex...
When you do ChatColor.of() and then toString() on it that's what it transforms into
sending that format in a raw string for a chat message sends it as a hex color code lol
it's also the format that gets sent with an item's getDisplayName() and getLore() which is what I'm trying to transform
Hmmm... yeah IDK for that then...
I'll just move the regex to a static final string and call it a day
Kinda odd it would format like that.
magic 
you need gradle for that
no.. you don't?
๐คฎ Have you looked into just using Kyori instead? I think you can make a builder to change it from weird hex format to more readable hex format
I used something like that before for a gradient chat plugin. I can send it over here when I get on
don't feel like using a massive messaging framework like that is necessary for only parsing this small situation, a fair suggestion though
So IDK about using regex but you can probs loop through the chars
public String decolorHex(String string) {
Set<String> hexCodes = new HashSet<>();
for(int i = 0; i < string.getLength(); i++) {
if(string.subString(i).equals("&") && string.subString(i+1).equals("x")) {
hexCodes.add(string.subString(i, i+6))
i = i+6;
}
}
String edit = string;
for(String code : hexCodes)
edit = edit.replace(code, code.replace("&", ""))
return edit;
}
```Pesudo code just wrote it up.
You cant use a normal set for that though, you care about the order
Not really as it loops through all retrieved codes.
Ah, I read it wrong
private Pattern mcFormattedHex = Pattern.compile("&x&([A-Fa-f0-9]){6}");
public String decolorHex(String s) {
Matcher matcher = mcFormattedHex.matcher(s);
return matcher.replaceAll(color -> color.replace("&", ""));
}
```This might work....
Well you can still use a regex for that and remove the section symbol
Ok finally got the pattern right.
Try this @tardy cosmos
String hexString = "&6Hex Colors | #ffa800H#ff9c00e#ff8f00x #ff8200C#ff7400o#ff6500l#ff5400o#ff4000r#ff2400s";
public String removeColor(String s) {
return s.replace("ยง", "&");
}
private Pattern mcFormattedHex = Pattern.compile("&x([A-Fa-f0-9&]){12}");
public String decolorHex(String s) {
Matcher matcher = mcFormattedHex.matcher(s);
return matcher.replaceAll(color -> color.group().replaceAll("&", "").replaceFirst("x", "#"));
}
I guess that's sort of one way to get around the matcher groups, it would match for things like &x&&&&&&&&&&&& though which I guess isn't horrible but the solution I had for it now might just be easier to do at this point
๐
Thanks for the attempts
np. Knew I was getting close xD
MiniMessage couldโve fixed this xd
Yeaaah that's what I suggested
But.
Looking for useful libraries/frameworks?
Here are some which have been deemed useful by the community and are used daily.
-> Menus: https://mf.mattstudios.me/mf-gui/gui
-> Commands: https://mf.mattstudios.me/mf/mf-1/getting-started
-> Messages: https://mf.mattstudios.me/message/mf-msg
-> Config: COMING SOONโข๏ธ
Someone needs to update those linksโฆThis leads to the old docs right?
Those are still the current docs, the new ones are very incomplete
Use Minimessage instead for most things
Plus you still need adventure for it as well
Oo..sorry, mb then, honestly I felt the new docs as a bit more helpful than the old one...
Well only for commands, because the old docs don't have anything for the rewrite, but since the rewrite is still not fully done I don't want to change it yet
MinecraftServer.getServer().recentTps make sure that you type .recentTps and not .getRecentTPS().
cus i assumed there was a getter but there isnt.
this requires nms unless theres some other way to get it without requiring a certain version
I just opted for that route, but I am using 1.18.2 Spigot and it says its deprecated ๐ฌ
for now its the best i could find, there might be a way to get the MinecraftServer instance through spigot but i dont know that way
Could depend on spark and use their api
Hello, API for Heroes doesn't work for me, can someone help?
does someone know how to make Tablist Prefixes in Bungeecord plugins (I tried everything i could think of but it never worked (the names just stayed white))
Also give some details ๐
?help
ยป Give the helpers some details
ยป Ask suitable questions
ยป Be polite
ยป Wait
classes, what you've tried, what Heroes is, etc.
Okay, I downloaded Heroes-expansion then reloaded papi, then tried %heroes_main_class_name%, %heroes_class_name% etc... in TabList and SimpleScore, both doesn't work
How can i remove all the jumble from Mongo https://i.imgur.com/1PxgfDb.png as well as the messages when i use saveResource() saying could not save fileLocation because name already exists?
for saveResource, check if the file exists before saving it
Hey everyone!
I'm honestly really keen in learning how to code minecraft plugins. Do any of you have any suggestions on what sort of tutorials to learn from?
Like YT videos or anything honestly.
?learn-java
Online Courses:
Online courses are also great for learning java. Some websites that offer them are:
- Coursera - Free unless you want a certificate
- PluralSight - Great courses from what I've seen. Mostly Paid
- Udemy - Never used them myself but they seem to all or at least most be paid.
My first ever course was one from Coursera. - I can say it was pretty good at introducing me to the programming world as a whole not just java.
Oracle Docs:
Oracle docs can help a lot at learning and understanding java:
- Start with this,
- Breeze through this (skipping stuff that doesn't seem relevant like bitwise operators),
- Hit this.
They're the first three from this larger thing which you should definitely go through overall. But those three should be enough for slightly better understanding of what is happening here without feeling like a huge time sink.
That one is a small part of this larger site wherein "Essential Java Classes" and "Collections" also have good useful stuff
Other services:
Some other cool services that will help you learn java are:
As you can see there are plenty of good ways to learn as long as you're willing to invest the time. Have fun learning!
quotes are not always needed for strings, only if they start with certain characters or other situations
YAML ๐ฆ
you can not force it
exactly
Look into ScalarStyle.SINGLE_QUOTED if you really wanna add / remove it
youll probablyu need to do some weird stuff though
getConfig().setString("PATH", "A string");
... all
There is only set, there aren't setThing variants
Ah yeap. Thought there was.
that really sucks tho, but like, bleh
Could try just adding .toString() to the value.
Hey guys im having issues with bungee brigadier
can anyone help a bit?
Required by:
project :Bungee
Possible solution:
- Declare repository providing the artifact, see the documentation at (link here)```
I'm trying to do a clientside glowing effect with PacketPlayOutEntityMetadata but i haven't worked with that packet in a while and am unsure what stuff to mess with.
Could anyone help?
Maybe try to take a look into this api https://github.com/InventivetalentDev/GlowAPI/blob/master/src/org/inventivetalent/glow/GlowAPI.java
i made my own server with custom ip , not any server from minehut or aternos, ITS A REAL SERVER. (1.8) Im looking for people to help me make it a pvp server like minemen!
if anyone would like to help me, dm me
How about no
How do you set a custom variables value in custom event from a listener
My event
I'm trying to set the droppedAmount from a listener
this isnt thte channel for that, your probably looking for somethng like either #970433902772617246 or #970433904517464134
I looked into that but its using reflection and hard to understand
Where is the api usage page for this?
On how to implement this in maven?
Please @ me
Thank u
if i would create a command /Test in my lobby, is it possible to execute something on a other server connected to the bungeecord?
not directly from the lobby. you'd either need a plugin on the other server and a plugin on your proxy to relay the information or some other way to relay the information to the plugin on the other server
how do I apply a gradle plugin to other subprojects in kotlin DSL?
like i have one on the main build.gradle.kts one
a plugin applied
and I need to apply it to a module
nvm found it
best way to save items in mysql? (like player inventory, or backpacks, etc)
Paper binary serialization
and with spigot?
cry
copy the Paper binary serialization method? lmao
how exactly would that work?
if i want to save a backpack for example
respecting empty slots
public static ArrayList<byte[]> serializeInventory(Inventory inventory) {
var bytes = new ArrayList<byte[]>();
for (ItemStack itemStack : inventory.getContents()) {
if (itemStack == null) {
bytes.add(null);
continue;
}
bytes.add(itemStack.serializeAsBytes());
}
return bytes;
}
public static ArrayList<ItemStack> deserializeInventory(ArrayList<byte[]> inventory) {
ArrayList<ItemStack> inventoryHolder = new ArrayList<>();
for (byte[] itemStack : inventory) {
if (itemStack == null) {
inventoryHolder.add(null);
continue;
}
inventoryHolder.add(ItemStack.deserializeBytes(itemStack));
}
return inventoryHolder;
}
these are my methods for serializing and deserializing an inventory
null 
yeah spigot really gotta do us dirty likc that
it's funny because minecraft doesn't use null items at all
and by funny i mean unfunny
thats available on paper since 1.15 only right?
yeah, i tend to support 1.8 too
๐
and spigot too
not even i hate myself that much dude
another alternative?
stop developing plugins for a version of minecraft that is 6 years, 9 months, and 22 days old?
and only represents 7% of the market share
have fun lol
lucko helper has some item serialization/deserialization stuff, not sure if it'd work on 1.8 https://github.com/lucko/helper/blob/master/helper/src/main/java/me/lucko/helper/serialize/InventorySerialization.java
weird, i use a similar thing for backpacks in other plugin
was expecting something different, but i guess is the only one approach
thanks, wonder how long would a deserialized inv is
hope it fits in a db column
for spigot and 1.8+?
those are choices you made :)
funnily enough, even your own plugins would still benefit greatly from not supporting 1.8
80% on AlonsoTagsPro
and around 80% on AlonsoTags
at least 80% Paper
and at least 75% Paper
Counter argument, 1.8 just have less bstats diversity
wtf is "bstats diversity"
so i need to get all the blocks between a player, and 10 blocks in the direction that the player is looking
the player.rayTraceBlocks doesn't really do what I need b/c it just returns the position where it ends, player.getTargetBlock doesn't really suffice either
any recommendations?
edit: gonna try player.getLineOfSight()
Sounds like you're looking for a BlockIterator! It does ray tracing and iterates along blocks in a line, which sounds like exactly what you need!
this does indeed sound like exactly I need, I'll take a look at it and try it out, thanks!
LivingEntity#getLineOfSight(Set<Material>, int) also seems applicable
It's what I considered at first, but I want it to go through blocks and go the full distance rather than stop at the first target block
It doesn't appear to stop at the first block, it goes the distance you pass in, no?
I meant it as a joke, but the likely hood the server has a plugin that would even show bstats its there.
I mean, we gotta draw the line somewhere
"all blocks from the living entity's eye position to target inclusive" not sure
my workaround was passing in a hashset containing all materials as the "transparent blocks" argument but ehh
We have these metrics, and this guy has bstats on his actual plugins lol
yea
I think for free plug-ins, I wouldnโt put the effort in to support 1.8, unless it required no extra time or effort.
However, with paid / commercial stuff, I can see the benefit supporting older versions. Naturally, you want to take as much market share as possible
I doubt youโd earn enough from 1.8 to cover the extra work you need to put in to make it work (heavily depending on what the plugin does obviously)
yeah the cost-to-benefit ratio is rarely in favor of 1.8 these days, especially with dwindling market share at currently 7%
Yeah I think it depends on what it does, some stuff is easier than others
Thatโs crazy how itโs now only 7% though
Thatโs dropped so quickly
Why would this:
@Path("list")
public static final Property<Map<Integer, Map<String, Object>>> CHAMP = Property.create(
Map.of(
1, Map.of(
"name", "test1",
"name_variations", List.of("tt", "aa"),
"skin_urls", List.of("tt", "aa")
),
2, Map.of(
"name", "test2",
"name_variations", List.of("tt", "aa"),
"skin_urls", List.of("tt", "aa")
)
)
);
throw: class java.lang.Integer cannot be cast to class java.lang.String?
that is a hell of a generic type specification lmao
It depends on the plugin type too. Which game mode the plugin is mostly used by etc...
For example with my minions plugin it's more beneficial on skyblock but it's also used in prison, factions, survival and I think atleast one towny server.
I don't have the plugin checking stats but users that have requested support usually run the following versions.
Skyblock - 65% 1.8, 25% 1.12, 10% latest.
Factions - 80% 1.8, 15% 1.12, 5% latest.
Survival - 90% latest, 2% 1.8, 5% 1.12, 3% 1.13 - 1.18
It goes on from there. Majority of users of my plugin use skyblock though so even with my newer minions plugin it was beneficial to add backwards compatability.
discord failed you. lol. there's no reply so you just look like a fool. but I assume it was to this conversation
I'm here for you โค๏ธ
the keys can't be integers
any ideas why I am getting this?
java.util.ConcurrentModificationException: null
at java.util.HashMap$HashIterator.nextNode(HashMap.java:1597) ~[?:?]
at java.util.HashMap$EntryIterator.next(HashMap.java:1630) ~[?:?]
at java.util.HashMap$EntryIterator.next(HashMap.java:1628) ~[?:?]
at java.util.HashMap.putMapEntries(HashMap.java:511) ~[?:?]
at java.util.HashMap.<init>(HashMap.java:484) ~[?:?]
at me.mrafonso.acidcore.managers.DropManager.lambda$generateDrops$1(DropManager.java:60) ~[AcidCore-1.0-all (10).jar:?]
at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftTask.run(CraftTask.java:101) ~[patched_1.17.1.jar:git-Paper-408]
at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:57) ~[patched_1.17.1.jar:git-Paper-408]
at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[patched_1.17.1.jar:git-Paper-408]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
at java.lang.Thread.run(Thread.java:833) ~[?:?]```
DropManager.java class: https://paste.helpch.at/erequwemel.cs
I will try a fix, aka making a list of items I want to remove from gensLocations and removing them all afterwards
java.util.ConcurrentModificationException: null
Caused when you are either modifying a object while looping through it. (Use an iterator)
Or when 2 threads are editing the same object. (Use concurrent objects)
heres a suggestion, iterating through the list of all generators will not take a lot of time, it is dropping the items via bukkit that takes time. idk if you are even dropping the items since acidgens now just puts it in a storage thing but regardless you dont want to do that stuff async. If you are actually dropping the item, i made a thing to optimize thatwhich would be perfect for you use case, lmk if you want it
uh, the dropping is sync, you can't drop items async
ik, youre running stuff async, thats why that error was thrown
im saying that you shouldnt do it async, even if it is just looping through the generators
actually
as I said previously, the issue was that I was looping through a list and modifying it, so I created a list with everything I wanted to remove from the other, and only removed everything afterwards
if that makes any sense
xd
I want to see what this is
can you send code here?
my bet is that you are limiting how many items can be dropped/spawned per tick
idk
lol
public static int STACK_DISTANCE = 9;
public static int MAX_STACK_SIZE = 64;
public static void spawnItem(ItemStack i, Location loc, UUID owner) {
ItemStack item = i.clone();
for (Item _item : loc.getNearbyEntitiesByType(Item.class, STACK_DISTANCE)) {
ItemStack itemStack = _item.getItemStack();
if (itemStack.getAmount() >= MAX_STACK_SIZE) continue;
ItemStack _itemStack = itemStack.clone();
_itemStack.setAmount(item.getAmount());
if (_itemStack.equals(item)) {
int amountToStack = Math.min(MAX_STACK_SIZE - itemStack.getAmount(), item.getAmount());
itemStack.setAmount(itemStack.getAmount() + amountToStack);
item.setAmount(item.getAmount() - amountToStack);
if (item.getAmount() <= 0) return;
}
}
loc.getWorld().dropItem(loc, item);
}```
no
just check if another item is near it and add to that item's count
avoids spawning an extra item entirely
never thought about that.
i plan to make my own stacker that goes past 64 however i havent had time to work on this project
but it avoids spawning extra items which is that most expensive part
ye
although in acidgens like you said, that wouldn't be an issue
since it's mostly everything digital
xd
yeah, however i dont think that the item spawning was the issue tbh
but I will keep that in mind to use next time.
nha it wasn't
but it's still a good tip
idk why he removed it
I mean, the issue was he was using skript
yeah lol
๐
i told him a long time ago
but spawning items makes kids feel like they are making more progress so removing it makes it feel more boring imo
this is going a bit offtopic btw
you right
when server is stopped, players are kicked before onDisable is called?
yeah
bcz spigot
(I Think. idk I always blame spigot lol)
but they are kicked before
They are.
mmm, so basically PlayerQuitEvent is called for each player online
when server stops
how to know in there if server is being stopped?
uhh
nah
the plugin will be enabled
what's the xy here tho?
what exactly are you trying to do and why
piggy's answer
ugh they clearly want to execute something on players. so don't think that will actually help
data is saved on inventory close event, ofc async, but on server stop you cant (iirc) create tasks, so i wanna know how to "recognize" if server is topping to not use async, but sync
unless shut down hooks are called before players are kicked idk
just save it on player quit event
save it to a list or smth
pretty sure the server waits for async tasks to complete? unless I'm misremembering and its the other way around
and then save it all somewhere when onDisable()
nitro what are you talking about? xD
idk either xd
he knows how to save data lol
xd
yeah but you can save data when player quits
rather
yeah. but the problem is that possibly spigot won't wait for async tasks
when the server is shutting down
blitz you get the question right?
yeah
try it?
try what lol?
does it wait for them to complete
so, to prevent dups, what would be the best way if i only save data on inventory close event (ofc certain inventories)
first of all, players are kicked before onDisable is called
ah yeah. the server won't wait for the async tasks to complete. or maybe it will but throw a warning. I Know it throws the warning just don't remember if it will wait or not
correct? โ๏ธ
if so, that means inventory close event and player quit even is thrown for all players
and then onDisable is called, correct?
that means in onDisable, getOnlinePlayers().length will always be 0 right?
not sure actually. maybe. idk if inventory close is called but I'd assume so. you can try tho
pretty sure yeah
so, if i wanna decide between using async (as usual when inventory closes) or sync (so server waits until database is saved)
how would i check that?
there was a serverIsStopping or sth? xd
if i had to guess the server kicks the players after all plugin's are disabled
however i would just test it myself if i were you
so yeah @shell moon some googling says that the players get kicked after the plugins are disabled
so I guess I Was wrong
but yeah. test it
just to make sure
nah
if plugin is disabled, how would they work?
idk
I do know that they're kicked 1 tick before the event is called
which is stupid
or something like that. I had problems with FrozenJoin
unless again I'm misremembering
but anyways if you try, I guess you'll find out the answers
How to know which version of SQLite is a server running? (i mean, i know latest versions use last version, but i wanna know in case it's 1.8, etc)
according to a quick google search
Connection con = yourconnectionmethodhereorwhatever
DatabaseMetaData meta = con.getMetaData();
int majorVersion = meta.getDatabaseMajorVersion();
int minorVersion = meta.getDatabaseMinorVersion();
what is the easiest way of packing a java application (console or GUI based) as a binary, executable file (exe, flatpak, etc)?
Launch4j probs
Cross-platform Java executable wrapper for creating lightweight Windows native EXEs. Provides advanced JRE search, application startup configuration and better user experience.
jlink ๐ฅบ
note that it still needs the JRE to be installed
either that or u need to make it an installer
no?
the entire point of jlink is to ship a whole runtime image with your application so the jre doesn't need to be installed
oh idk about jlink but launch4j requires the JRE iirc
or installer
either that or i never found a way of how to include the runtime image
ยฏ_(ใ)_/ยฏ
I have a biome provider, and when I set a biome to deep ocean, it sets it in f3, but still generates land there. The land has shipwrecks and ocean monuments on it, yet no water.
That's how 1.18 generation works
Biome is determined by continentalness, weirdness, humidity, and temperature noise
the same noise also does world heights and terrain generation
setting only biomes does not change terrain generation like it did pre-1.18
trying to spawn in 4 blocks of dripstone (pointing downward) and then having it fall down โ instead I'm getting. 4 blocks of dripstone pointing upward that float midair without any physics/logic impacting them 
base.getBlock().setType(Material.BARRIER);
for (int i = 1; i != 5; i++) {
Location dripstoneLocation = base.clone().add(0, -i, 0);
dripstoneLocation.getBlock().setType(Material.POINTED_DRIPSTONE);
}
Bukkit.getScheduler().runTaskLater(Plugin.getPlugin(), ()-> base.getBlock().breakNaturally(false), 1);```
fixed: fucked around with the blockdata and blockstate and it finally works 20 mins later 
Question, so im making a game system and saving it to mongo via GSON, but i keep getting these circular refrencing issues. I swear I have looked over and looked over the code several times and cannot find it. I have even commented out sections to trace where it is coming from. One save it works fine and then the next one it does not. Here are my full classes:
Game.java: https://paste.helpch.at/ekunajabol.java
Arena: https://paste.helpch.at/totakeduzi.cs
lobby: https://paste.helpch.at/ufulohogiw.java
team: https://paste.helpch.at/aranojiqax.java
Lootchest: https://paste.helpch.at/hezubabala.java
MobSpawn: https://paste.helpch.at/abafadodeg.java
Error: https://paste.helpch.at/icekorohev.bash
I feel like I have done a pretty good job seralizing everything and desearilizing it
Give us the exception you get
Recursion be like ๐ฅด
yes
it's probably trying to serialize the BukkitTask as well, you could try marking it as transient
Ok, let me try that
how can i convert a long milliseconds to this: X.YY
X = seconds
YY = 2 decimal places of milliseconds
not sure if im explaining this well enough lmao
long milliseconds = 12345L;
double seconds = Math.round((double) milliseconds / 10.0) / 100.0;
there's also: ```java
private static DecimalFormat FORMAT = new DecimalFormat("#.##"); // constant
long milliseconds = 12345L;
String seconds = FORMAT.format((double) milliseconds / 1000.0);
What's the best way to delay something by a second or so?
bukkit runnable, runtasklater
well
probably but bukkitrunnable is the easiest i think
in java itself there is an alternative (outside of bukkit)
but I'd recommend using runTaskLater
Can make your own delayed tasks.
What the best way for me too make a count down timer as I canโt seem to find anything too help for 1.18
int countdown = 60;
public void runCountdown() {
Bukkit.getScheduler().runTaskTimer(<JavaPlugin>, () -> {
countDown--;
if(countDown == 0) {
// your code
countDown = 60;
//cancel task unless you want it to repeat.
}
});
}
๐
Hey i wannas k
neither of these worked for me, the first one just displayed 0.01 and the second one displayed 0
final long timeLeft = TimeUnit.MILLISECONDS.toSeconds(timer.get(tnt) - System.currentTimeMillis());
final BukkitRunnable runnable = new BukkitRunnable() {
public void run() {
tnt.setCustomName(ChatColor.RED + "" + ChatColor.BOLD + Math.round(timeLeft / 10.0) / 100.0);
}
};
runnable.runTaskTimer(Main.plugin, 0, 20);```
well you're using TimeUnit to convert to seconds
but the issue is that it returns a long
oh right
not a double
just use ```java
double seconds = Math.round((double) milliseconds / 10.0) / 100.0;
alright
just realized i cant have the period of the runnable set to 20 lmao
or else the milliseconds part is just useless
lmfao
hmmm now how do i solve this: https://srnyx.has.rocks/java_TGWjAKwA4J.mp4
the flashing
I'd just do #.#
instead of #.##
not sure if there's another fix
wait
no thats bc it's switching
try this:
unrelated, how would i change how many decimals are shown using this method:
Math.round((timer.get(tnt) - System.currentTimeMillis()) / 10.0) / 100.0
the / 10.0 part?
o wait it would be both divisions right
so if i just wanted #.# i'd do Math.round(timer.get(tnt) - System.currentTimeMillis()) / 10.0
String seconds = String.valueOf(Math.round((double) milliseconds / 10.0) / 100.0);
if (seconds.split("\\.")[1].length() == 1) {
seconds = seconds + "0"; // if the amount of chars after . is 1, then add an extra 0 after
}
uhhh not sure, i gtg rn sorry
alright ill experiment, thank you!
use BigDecimal.valueOf(0.5).format("#.##"); that will give you 0.50
my syntax/method names might be a little off as i barely use it but that is exactly what you want
anyone knows any web api that tracks player kills and play time ona server i would like to add that feature on my discord bot
Im looking for website devs dm me
need help on how to get updated code to the original developer github? My github never seems to work using github desktop
make a pull request? I'm unsure as to what ur asking here
fetch origin
pull request, I just want to send some updated code, I can't seem to figure out how to do it. I can't even update my own github with my setup. It broke I believe when I attempted to do it from two different locations
You would need to commit and push the โupdatedโ to the git then pull from it wherever else you want it (or whoever)
Does someone know if Gson will also use any fields defined in an inherited Interface?
Like when I have this:
public class SomeClass implements SomeInterface {
public String message;
private static interface SomeInterface {
boolean error;
}
}
And the JSON I parse is {"error": true, "message": "Message here"}, would Gson use the error field from the interface or is that completely ignored?
From what I tested now does it seem to not work as boolean error; is treated as a final entry
Interfaces donโt have instance fields
wtf that is evil
everything is
How can i get the location
when the table is like PreparedStatement ps = mySQL.getConnection().prepareStatement ("CREATE TABLE Spawn (" + "ID INT NOT NULL," + "X DOUBLE NULL," + "Y DOUBLE NULL," + "Z DOUBLE NULL," + "YAW FLOAT NULL," + "PITCH FLOAT NULL," + "WorldName VARCHAR(255) NULL," + "PlayerName VARCHAR(255) NULL," + "PlayerUUID VARCHAR(255) NULL," + "Server VARCHAR(255) NULL," + "PRIMARY KEY (ID))");
so i can get the location now but my count down just doesnt work please let me know how i could fix it https://paste.helpch.at/qibobijece.java
what does "doesn't work" mean? what's the expected output and what's the actual result you get?
So what happens is i do /sp i have to type it 5 times instead of doing a count down then it goes in to the minus so it does reset
it is currently doing this https://prnt.sc/hQy5kOZmRTxR
when i type the command so im trying too figure where my code is wrong
as it doing it on the amount of time i type the command in
what the fuck is that formatting
its so ik what block is what
c# lol
its called Allman or whatever
lol
fairly certain runTask, only runs the task once
what you want to use is runTaskTimer
It runs one once per command is done
but i can try run TaskTimer
What would period be ?
and delay is that going to be 1 Tick aswel ?
okay ill test that see if that fixes my issue
also are you accessing the database every time the command is ran?
that sounds like a nice server crash feature xD
For some reason i have to type my command 5 Times for it too take me to spawn instead of 5 seconds
you only updated it for the command when it uses an argument
when you do /spawn it will still just execute runTask
ahh i didnt save it then
ill re finish that
just gotta fix an ACF problem that idk how to fix
maybe we can help?
you need to shade ACF
i have
are you minimizing?
i am not
im just rebuilding i think i have it now ima give it a quick test
issue was resolved it was just a broken bit of code
How can i cancel a task correctly
as my cancel isnt working correctly
but you did fix my other issue thanks Blitz
you should be able to cancel the task from within itself. if not you might have to save the task in a variable and cancel it from there
Iโve got the cancel writhing it sled but it ignores it
So Iโm gonna have too turn it into a variable
OTB gang
K&R still does Allman for function blocks iirc
One True Brace always puts the opening brace on the same line
Which is the style where you do
function
{
}
allman is great
Bad tastes
from now on i'll use a mixture of Whitesmiths and GNU styles
void foo ()
{
bar ();
baz ();
}
Iโve started using Allman more
I prefer it because easier to see where the brackets are
Vs having it on the same line as functions
it's just so much extra whitespace, and if you're using an IDE based on IntelliJ at least, it shows you indents and things really nicely, plus I use rainbow brackets so it makes matching brackets the same color, very nice to use
Yeah, I think for me itโs more for visuals, like sometimes Iโll visit code on GitHub if I donโt want to pull it locally just to check something
hmm, I never really had a problem distinguishing where functions start and stuff, maybe it's more of a PHP thing?
but honestly, PascalCase and Allman indentation are the biggest reasons I don't like C#/anything .NET
I mainly started adopting the style since I primarily using PHP, so could be.
I never saw the appeal of the style before, but then started using, and I find it more readable
But naturally all this stuff is preference based
yeah, yeah, I suppose it's just what you're used to
like I managed to use C# and stuff for a few things for my class, didn't really end up liking it that much
the biggest appeal is just the raw features it has over Java, and the integration with like F#
I do find it crazy how much languages overlap
When I first started programming and heard โonce you know one, the others are a bit easierโ I thought that was full of crap
But so true
the others are a lot easier lol
at least, languages in a similar area, like OOP langs
I know Java really well, and I can effectively use Ruby, C#, Python, C++, C, Kotlin, JavaScript, Go, PHP, Swift, etc. very quickly
just by looking up the syntactic differences and stuff
now languages like F#, Clojure, and Haskell, etc. are a bit harder to learn because they are fundamentally different lol
clj 
all imperative languages are just reskins of each other
Yeah itโs crazy, I think if I were to learn any, Go would be the one to spark me
no cap
man I really really want to like properly get into clj
so based
but it's so out of my comfort zone
good
why good lol
i will give you a test
ok
what does 3 evaluate to
3
a function call
yeah but what does it evaluate to
3
ok looksing good so far
no i don't sing
(defn- make-state
([] (make-state nil))
([{:keys [:zmq-context]}]
(let [execute-count 1N
display-queue EMPTY-QUEUE
sess (-> (his/init-history) his/start-history-session)
zmq-context (or zmq-context (zutil/zcontext))
halt? false
comms (comm-global-state/initial-state)
cur-ctx ()]
(->State execute-count display-queue sess zmq-context halt? comms cur-ctx))))
``` now what does this do?
it makes state
yay
when will we take over the world?
Ha ha
Hey ppl, sorry to interrupt your chat, can you please take a look at #off-topic for a sec
Hello so im currently getting this error https://paste.helpch.at/esifipakaw.sql And heres the class it that is the cause i cant find anything wrong that would cause thyis problem https://paste.helpch.at/raseteyugu.java
can you send your SpawnCommand
Also, close your PreparedStatements and ResultSets
Else, it will create memory leaks
okay will do
its all been fixed ive recoded it and used a switch statement in stead of an if statement
how can i like disable a command from being used?
i wanna make it so no one (including operators) can use /ban-ip
ping if reply
CommandPreProcessEvent
Would this work for closing it public boolean checkTableExists() { try { PreparedStatement ps = coreDatabase.getConnection().prepareStatement("USE Spawn;"); ps.executeUpdate(); DatabaseMetaData dmd = coreDatabase.getConnection().getMetaData(); ResultSet res = dmd.getTables(null, null, "Spawn", null); if (res.next()) { ps.close(); res.close(); return true; } ps.close(); res.close(); } catch (SQLException e) { throw new RuntimeException(e); } return false; }
i couldnt remember if it was in the if statement or outside of it
How do y all understand coding? It's like how do you know where to put semi colin, or where to put the dashes and brackets? Can someone explain?
Please I wanna make my own plugins because I can't find what I want.
how do you understand how to write a paragraph? Where do you put nouns or verbs or adjectives? When do you use periods and when do you use commas?
both are just a set of syntax rules, and coding even arguably has a much much simpler set of rules than english does
A simple way to begin getting used to reading and writing java is to google around for a java tutorial, and visit any one of the hundreds of relevant sites - it honestly does not matter which
download a java IDE like IntelliJ / Eclipse / Whatever, and recreate the examples provided in that tutorial
from there the world is your oyster
English is way easier btw
More people know English than coding
But how long does it take to get used to coding, like to not look at a sheet woth the place holders and stuff
few months
for the basics probably a month
but you never stop learning
my dad is almost 60, he has never learned english, never had contact with it, yet he can make some sentences and talk a bit, just by watching some videos on youtube for 2 months
yeah the syntax rules of programming languages are much more strict, enforced by a compiler that will make 100% sure, and you can use nice IDEs that will give you generally exact problem spots
like in Java, basically every line that doesn't have a {} on it will end in a ;, and for and if are always followed by the expression in ()
Syntax is easier than logic
it heavily depends on how much effort you put into trying to genuinely understand what's going on, as well as just your natural affinity for logic and problem solving
as far as just memorizing what the keywords mean, it generally doesn't take too long as long as you try using them on your own instead of only following tutorials that spoonfeed you
When I took my first programming class in high school, most of the class had a great grasp on the basic java syntax less than halfway into the school year, and that was only with a 45 minute period every weekday + a bit of homework
Anyone have any idea why this isn't working? I'm trying to disable dyeing of a leather armor
@EventHandler
public void onLeatherArmorCraft(PrepareItemCraftEvent e) {
if(e.getRecipe() == null)
return;
if(e.getRecipe().getResult().getType() == Material.LEATHER_HELMET ||
e.getRecipe().getResult().getType() == Material.LEATHER_CHESTPLATE ||
e.getRecipe().getResult().getType() == Material.LEATHER_LEGGINGS ||
e.getRecipe().getResult().getType() == Material.LEATHER_BOOTS) {
e.getRecipe().getResult().setType(Material.AIR);
}
}
How can i change it from player.getLocation().getWorld().toString() to normal getWorld again
Well... you can create a variable of the world
World w = player.getWorld();
Or if you really need to use the name you can use
Bukkit.getWorld(<name>)
Thanks I did the bukkoit.getworld
So im currently expirencing this https://paste.helpch.at/uhasagosuc.sql
And it says its inside here https://paste.helpch.at/jiyasizahe.cpp
if that did work then it would also prevent crafting of leather armor completely.
oh yes ur right!
thank you for finding that out, I wasn't thinking about that at all
when you say it doesnt work, what doesnt work?
id recommend that you put bukkit.getLogger.info(e.getRecipe().getResult().getType());
before your if leather armor statement so you can check if its coming back any type
and also a bukkit.getLogger just before the null check aswell.
basically just put some debug outputs to check your logic to see if its doing what you intend
if you get no messages then check that the event is registered.
Don't worry I already fixed it just forgot I sent a message here xD
And yes, I'm always placing some kind of debug outputs when I'm texting my logic
Hi there is it possible to :
Create a HashMap<String, Object>, (Every Value is a class that extends the Object), putting content inside...
Find the good Value with a String key
Instantiate it with a parameter
I don't want to use Switchcase, this is good for a limited amount of options.
https://pastebin.com/9JEgncbE
(Maybe what i'm asking is unclear or maybe there's a better way to do so)
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Anyone know why Hikari Wont check if a table exists or create a table
i can send the class it just goes too an SQL Error
It looks like you might want to do something like Map<String, Function<Territory, Objective>>?
Where the function gives the instance of the class
Not really, sorry if I am not understandable. I want to create a map of objectives (every objectives extends Objective but are not instantiated yet).
Then, when devs use my API, they can add their own objectives in the list. (They add possibilities)
Finally, my plugin calls a function that will use a String to find an Objective in the map. If found, I want to instantiate the found Objective, with a parameter.
Something that already work on my plugin is this.
Objective objective = null;
if (objectiveType.equalsIgnoreCase("KOTH")) {
objective = new KingOfTheHill(territory);
objective.start();
} else if (objectiveType.equalsIgnoreCase("STRUGGLE")) {
objective = new Struggle(territory);
objective.start();
} else if (objectiveType.equalsIgnoreCase("CONTROL")) {
objective = new ControlPoint(territory);
objective.start();
}
But since it is a if/elseif statement (switchcase too), it has limited optionsa dn will not include the objectives created by other devs with the API.
too many caps
create table if not exists ....
switch(objectiveType)
If you do it like I said, people who use the API can also call other methods when their object is instantiated which could be useful
Yeah ive done that for it even existed tbf
That still requires all objectives to be known ahead of time
I think I understand, like this I can even remove the map/list.
Every plugins hooked to mine will just check if the String correspond. if yes, they instantiate, etc. Else,nothing will happen. That's it ?
Yeah
What would that do?
I would keep the map though
all ur doing is checking if the objective is equal to some constants
so you can just smack the constants in a list and make the list changeable at runtime
No they need to create a new instance of the objective
The map can be useful but in that case, it is not necessary. I'll keep it in, it can be useful sometimes.
Thanks ! ^^
No problem
I would like to see how you do it without a map, so if you could send it again and ping me I would appreciate it
aight
It works too
is it possible to give an specific creeper a custom texture? (maybe 1.16+ or 1.14+?)
Creeper? Oh man
!ban
So currently i have an issue where when i do the spawn command the first time it tps me too spawn if i wait 5 minutes then do it again it pulls this
Error: https://paste.helpch.at/enebuhiwux.md
CoreDatabase: https://paste.helpch.at/qeremibaku.cpp
SpawnTable: https://paste.helpch.at/ororobeken.cpp
SpawnCommand: https://paste.helpch.at/ufoviziseq.java
seems like you're doing something silly with your database connections
no you're right your code is perfectly fine and the server just hates you and that's why it's crashing
jk
haha
the error you are getting is a result of the main thread being locked up for a long time
and the server thinking it died
how would i go about fix that
your error is with your core database class.
Caused by: java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30001ms.
at com.zaxxer.hikari.pool.HikariPool.createTimeoutException(HikariPool.java:696) ~[Core-0.0.0-DEV.jar:?]
at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:181) ~[Core-0.0.0-DEV.jar:?]
at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:146) ~[Core-0.0.0-DEV.jar:?]
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) ~[Core-0.0.0-DEV.jar:?]
at net.devcowsoftware.networkcore.core.spigot.storage.database.connection.CoreDatabase.getConnection(CoreDatabase.java:108) ~[Core-0.0.0-DEV.jar:?]
... 11 more
This means that your database isn't obtaining connection within 30 seconds (the default connection timeout period).
This also means that the network latency, or some of the queries are taking over 30 seconds to execute.
chances are you misconfigured your database address ~~/ credentials ~~^
To help solve this problem, increase your maximum connection timeout to the hikari config.
It also could be a connection limit to the database.
Could you possibly provide whether the database server location is near the server's location? and also attempt what Ivan mentioned.
i've never heard of a server that has a latency of over 30 seconds x.x
Ilbut it will do /spawn the first time and fail on the seconds so it canโt be a creds issue S it can set them as well
does your /spawn command rely on the sql database at all
if it doesn't it's possible that it never makes the connection in the first place but you just don't notice until later
They are both in the exact same rack
Is there a reason why you are selecting positions individually?
It makes no sense to do 5 selects for one location.
Itโs just massive get to get the location
It does it for multiple position across 3 servers
Iโve just been testing
I'm not sure why you are searching over a server and world name, when it should be the id, as your PRIMARY KEY is the ID.
How would I get the id tho from the database ?
kieran
Yh
i didnt realize because i didnt see you posted your code but
I don't understand why you are storing player names with the location either.
your issue is almost certainly this
coreDatabase.getConnection().prepareStatement("...");
Yh I posted everything need to help fix it
you are never closing the connection from the thread pool
How would I close it
by calling close on it lol
Anywhere specific
You shouldn't close the connection every time.
If you are closing the data source connection, you throw away any benefit a connection pool has.
everywhere you have
coreDatabase.getConnection().{...}
make it
Connection conn = coreDatabase.getConnection();
conn.{...};
//other stuff here
conn.close();
twr 
no
first link about it on google
you keep a single data source, and then use and close each connection/statement/resultset/etc
^
hikari is smart
So too close it would i do something like
{
Connection connection = dataSource.getConnection();
connection.close();
}```
and call that too each of them ?
not quite
use them as you have been but instead of doing it all in one line like
coreDatabase.getConnection().prepareStatement("...");
save the Connection to it's own variable
get a prepared statement from it and proceed like usual
then after you are done with that query call close() on the connection
Here's two examples for you @lyric gyro if you still haven't figured it out.
Here's a simplistic example for one of your methods that checks if it exists for a player.
https://paste.helpch.at/ipujofoceh.java
I'd recommend using try with resources, because you do not need to worry about closing anything.
https://paste.helpch.at/jugowowigu.java
I didn't change COUNT(*) back to *, so you'll need to do that, or switch it to where it'll get the amount from COUNT(*) and check if amount > 0.
I recommend possibly passing just the world name of the player, and not the entire player object.
With this how does it know what database too get from ?
why is command returning null?
PluginCommand command = Bukkit.getPluginCommand("bipreload");
did you register it in plugin.yml?


well you change dataSource with where you'd get the connection from?
that's a placeholder.
When using
Creeper c = world.spawn(loc,Creeper.class);
//Everything here runs after CreatureSpawnEvent was called and modified by other plugins in all priorities?
//Or it has a delay?
Does that method even call the event?
try it and see
Hello, i couldnt sign in to my old discord because i was activating my 2FA, the problem is I deleted my discord account from my authenticator by mistake, i need back and i tried everything but nothing works
Looking for discord support?
HelpChat is a Minecraft plugin and development support server and is not affiliated with discord in any way.
If you require support from discord, we recommend you to visit their official support website at https://support.discord.com
On this website, you can read their FAQs, or open a support ticket if necessary.
@lyric gyro
anyways. Discord gave you some backup codes when you enabled 2FA. If you don't have those, there's no way to recover your account. That's most likely what they'll tell you as well
Well, its gone then,๐ฃ thanks for your help ๐
So currently i have an issue where when i do the spawn command the first time it tps me too spawn if i wait 5 minutes then do it again it pulls this
Error: https://paste.helpch.at/varevagoca.md
CoreDatabase: https://paste.helpch.at/gocefusofe.cpp
SpawnTable: https://paste.helpch.at/ifevuhazuf.cpp
SpawnCommand:
https://paste.helpch.at/usenonuzeb.java
i still get the error still
Read the errors, as it clearly mentions what they are.
For example UUID of added entity already exists: EntityHorseDonkey['Donkey'/504, uuid='02b7d21a-5d09-4b25-adfc-249e5fc502a2', l='ServerLevel[world]', x=133.15, y=64.00, z=-180.85, cpos=[8, -12], tl=61141, v=false]
thats not the error thats just a spawning error
thata somthing do do with my world entitys
its te bottom bit i cant figure
Your database takes way too long to respond.
its blocking the main thread
Which causes the server to lock up as it thinks its dead.
so how would i go about fixing that its my first time every using HikariCp
It's definitely not a HikariCp issue, but rather how you do your queries.
At some point, one of your connections go null in the pool, or all of them, and the database causes the main thread to be blocked.
can i just check if the connection is null ?
No, you should fix the way you use connections
Closing connections/statements/result sets is one step forward, but because you are (currently) closing them manually, there are places where they aren't closed and are still open, occupying a "connection slot" where it's no longer needed and most likely causing some or another mem leak (see those getX/Y/Z/Yaw etc methods, if the result is found you return immediately without closing the resources)
Thankfully Java can close them "automatically" for you when you return or if an exception is thrown, that's what the "try with resources" is for, the way you're doing it now is like this
try {
Connection connection = coreDatabase.getConnection();
PreparedStatement statement = connection.prepareStatement("blah blah");
// ... set statement arguments
ResultSet resultSet = statement.executeQuery();
// use result set
// oh no! you have a return statement somewhere in here and you're not closing the closeable resources!
resultSet.close();
statement.close();
connection.close();
} catch (SQLException ex) {
// oh no! perhaps the closeable resources weren't closed!
}
Again, closing them is a step in the right direction, but since you're doing them yourself there are missing spots
The try-with-resources (or just twr for short) will close them for you
try ( // note these parentheses
Connection connection = coreDatabase.getConnection();
PreparedStatement statement = connection.prepareStatement("blah blah");
) {
// set statement arguments
try (ResultSet resultSet = statement.executeQuery()) {
// use result set
// you can safely return here, the twr will close everything for you :)
// no need to call .close() anywhere!
}
} catch (SQLException ex) {
// even if an exception is thrown, everything will be closed and cleaned up for you
}
It can be a little bit tedious to change but it's crucial for connection lifecycling and it's not significantly different in terms of "physical" code changes
@lyric gyro
so true
LMAO
shut up
fuck you
lol
Hi kgm
if i do it in this format would i need to close the connection at all ```try ( // note these parentheses
Connection connection = coreDatabase.getConnection();
PreparedStatement statement = connection.prepareStatement("blah blah");
) {
// set statement arguments
try (ResultSet resultSet = statement.executeQuery()) {
// use result set
// you can safely return here, the twr will close everything for you :)
// no need to call .close() anywhere!
}
} catch (SQLException ex) {
// even if an exception is thrown, everything will be closed and cleaned up for you
}```
you don't, java does
okay ill switch it all over too that then
Is it possible to make smoking plugin
sure /effect give <player> nausea

