#help-development
1 messages · Page 2009 of 1
Yeah
So that makes sense
You could use runTaskLater and loop through all online players to set that block to the new one and back with Player#sendBlockChange as gush said
I'd do a failsafe that you cache the tasks somewhere and manually call them if onDisable gets called
i was thinking that
I would not change the blocks at all
I would just use Player#sendBlockChange
so even if the server crashes, the blocks are still intact
if we are still talking about the glowstone trail
I had no idea that was a thing
we are
it is 🙂
nope
of course you'd have to send it to all players
unless you want only one player to see it
bruh
1.16+
btw @tender shard What kinda blog software did you use?
regular wordpress
Oh I see
my main website also uses wordpress lol
btw is WordPress free w/ custom domains...?
no idea, I'm hosting it myself
lol i done the same
yeah well I don't use them, I got two dedicated servers lol
https://github.com/gush3l/DelayedBlocks/blob/master/src/main/java/me/gushel/delayedblocks/DelayedBlocks.java made something like this for a 1.8 server, if you still need help check here
yeah but they great for testing lol
for (HomeModule module : manager.getPlayerHomesList()) { // this line somehow causes this exception
if (module.getLocation().getWorld() == null) {
SetHomes.sendPlayerMessage(event.getPlayer(), "Your home with the name \"" + module.getName() + "\" was deleted automatically. World is corrupt.");
manager.removeHomeModule(module.getName());
}
}
ConcurrentModificationException: null
sure, that's true
lol my RAM is 70% full but the CPU is only at 2% lmao
you cannot remove stuff from a collection while iterating over it
there are basically to ways to solve this:
- use a copy of your collection or another collection where you add the elements to be removed later
- use an iterator
you have 125gb ram and 50gb of storage? 💀
so i should add them to a new list then remove them from the collection?
alr
yeah or you use e.g. List.iterator()
no I have 2x3.84TB NVMe, 50GB is just the / partition
how tf do you use nearly 70GB ram
8TB of nvme? bruh
it's proxmox running some VMs and containers
yeah my backup server has 4x10TB
💀 💀 💀
but both are RAID1 so only 50% capacity
And I couldn't get around on getting a 1TB ssd in a year 🤣
so proxmox has 3.84TB of storage and the proxmox backup server has 20TB of storage (non-SSD, just enterprise hdds) lol
What do you store on that much storage?
backups
every VM gets backed up hourly, daily, weekly, monthly and yearly
bruh
if i were to make a custom enchantment system should i use persistent data containers or the enchantment class?
I'd use PDC
because actually the enchantment class isnt meant to register custom enchantments at all
so that already tells you it's not meant to be used
I have a question about jdbc database integration in a bungeecord server. I am recently using hikaricp for my connection pooling and read things about how too many connections greatly increase transaction queue times. Now i was thinking to make a sort of plugin that has postgresql jdbc and hikaricp. I would use this plugin as an api for other plugins to get connections from as i dont want too many plugins all making connection pools. I was wondering if i could make a bungeecord plugin that gives out connections to plugins inside a spigot server. Would this be possible?
Those spigot servers are connected to the bungeecord server ofc
you do realize that Mysql can literally handle millions of connections
Also no, bungeecord cannot give spigot plugins connections
if you have long transaction queue times then you need to relook at your setup
The spigot servers and the bungee servers are not the same
They can’t share resources
I dont have that, i was just wondering if i could connect bungeecord plugins with spigot plugins
so i dont really need a connection pool?
No
The connection pool isn’t for the database
Creating a connection on the minecraft server is slow
The connection pool creates a bunch of connection objects that wait for you to need them
yeah
So you can establish a connection to the database much more rapidly
It has nothing to do with the actual database server
so 1 plugin api that has a connection pool per "sub" server on a main bungeecord server is fine?
Yes
k thanks
I never close a connection 🙃
keep in mind, that if you have issues such as connection limits being hit, you have to modify the db server config files. By default MySQL or MariahDB are conservative out of the box and most times this does alright.
You should use a connection pool and close the connection to return it to the pool
yeah default is 151 connections lol
that's like... 5 plugins using hikari
and you already hit the limit
this is impossible if you are using TCP, unix sockets are different so doesn't really matter except memory being exhausted possibly in this way. But TCP there is a max time frame a connection can be active.
hikari points out that having too many connections based on cpu core count is discouraged
this same for amount of connection pools?
I think its referring to the amount of pools and not the connections themselves
hikari uses a connection pool itself
Yeah, you don't want a lot of pools, this is a waste. Pools are similar to Worker queues
too many of them and you just have a bunch of useless objects doing nothing and occupying resources
The point of that is you want a pool that isn’t too large
So basically your threads can block more and CPU time isn’t being split across that many threads at once
A saturated pool will be faster than a larger pool that lets all your threads progress
would you need to split up connections per pool based on cpu core count
like lets say
you have 16 cores
thats 32 threads
but you need 3 pools
would you do 3 pools with 32 connections
or 3 pools with 10 connections
cuz they are still on the same cpu
Why do you need 3 pools?
we have multiple spigot servers on the bungeecord
Ah so it’s 1 pool
how
Per program
So 1 pool
which other plugins can request pools from
the pool should automatically scale. Like it should open new connections once 80% or 90% of the connections are in use or sth like that
how would i have only 1 pool if i have 3 spigot servers that all need database?
Because each spigot server is independent
Each spigot server is running in its own JVM
Don’t think of them additively, there’s a lot more going on
It’s 1 pool on each server so optimize that 1 pool independently of other servers
k
So we have 24 threads. Best to do 3 pools with 8 connections or 3 pools with 24 connections?
We talking about the cpu now
each spigot jvm has a pool
3 spigots on a bungeecord
k
How many cores do you have
connections = ((core_count * 2) + effective_spindle_count)
cpu only matters in terms of objects, the connections themselves are not based on your cpu
hey so i got the dependency right but it keeps doing this
here's my code
TextComponent discord = new TextComponent("Discord");
discord.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Join Our Discord !").create()));
discord.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL,"link"));
discord.setBold(true);
discord.setColor(net.md_5.bungee.api.ChatColor.DARK_AQUA);
discord.toLegacyText();
return discord;
}
}```
i mean its used to calculate amount of threads your cpu has
CPU matters in terms of threading, having a bunch of threads in excess of your cores will slow them all down
Well probably best we don't have complex discussion and confuse this person right now 😛
but yeah
It’s ok to do a bit of time-slicing, you don’t need to strictly be the exact number of threads. If you have 16 cores go for 16*2=32
Why are you converting it to legacy text
If you read the article they sent that’s what they’re optimizing for
that was one of the things i tried to fix it, it didnt work even without it
How are you sending it @west oxide
oh
Player.spigot().sendMessage
^
You can’t
append other components to it
The line needs to be part of the component
You can’t treat it as a string
^
https://gist.github.com/justisr/7a7449adac931a066c51
Or you can use this.
Wouldn’t solve their issue, that’s pretty much what the spigot API is doing
I can make an item unbreakable by setting the durability to -1 correct?
No
Just use setUnbreakable
You can make an item unbreakable by setting the unbreakable attribute
You don’t have to do anything hacky
Before creating 24 threads for a connection pool because you have a 16 core cpu, why not try starting with 4? I mean, sure you can create them, but I doubt you are having issues where you need that many.
This is a good point
Less is more
Ok thanks lol
2015 answers moment
you can always increase the amount later as you need them
but if you are not hitting some resource barrier
best to not use up all the resources just because you can
or even half
You need to be doing a ton of queries to warrant a large connection pool
4 threads can easily handle up to 200k connections
true
how do i open build tools as a file in intellij to view all the nms code? i forgor
honestly idk what im doin, if you say so then you're probably right
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
i'm still very much learnin
what's that mean
should read it, will help you obtain the appropriate jars to use in a project in regards to nms
i don't understand
how can i equal a player to PlayerMoveEvent. PlayerMoveEvent does not allowing player.
i dont have this
@kindred valley you don't have enough understanding of Java for anyone here to help you
why not?
learn how to code in Java and then come back
How can I create YamlConfiguration instance in BungeeCord API?
I want to do something like:
YamlConfiguration conf = new YamlConfiguration();
conf.set(...);
...
send code
?paste
they are probs literally trying PlayerMoveEvent#getPlayer
bad advice many people learn Java while coding a plugin
what's the difference between # and .?
that's what I'm thinking
and that's a bad thing
or just PlayerMoveEvent.getPlayer()
Good advice actually
i see everyone using # but i always use .
I learnt java while doing spigot and it was very annoying
. is for the actual code
is used to denote instance methods
is for javadocs
you learn a lot of bad habits trying to hack spigot code together
i don't get it
hi guys, can you do in a plugin that automatically spawns a command block with specific commands in specific positions?
I learned java while doing spigot I did perfectly fine it's more challenging for sure but if it keeps you into it just do it.
PlayerMoveEvent.getPlayer looks like a static method
I also learned java from spigot which is why I highly recommend not doing it
So # is used to differentiate
iirc yes
don't know how
but yes
i don't know what static is
i started java from school then used it for spigot
Okay
o_O
see this is what happens
you have to have a basic working knowledge of the language to make any headway
before you make fun of me, i should mention that i have some certain learning disabilities
that means i cannot watch an hour long tutorial like you do and understand as much as you do
What about reading
reading is even harder
i'm not making fun of you
I learned java alongside spigot though If I don't understand something I did it in Java first before applying it to spigot
i'm telling you, you have to learn java first
it seems that you were implying certain things
i used java for around 4 years before jumping into plugins
im not implying anything, im stating outright that you don't know java and shouldn't be making plugins yet
but thats because i realized plugins where a thing at that time
im learning along the way, that's how i do it with my disabilities
spigot is too complicated if you don't already know java
anyways, i have not come here to argue
this is like trying to read Hamlet without learning English first
can someone tell me or link me a tutorial on how to open the spigot buildtools jar with intellij to view nms code?
this is their code from earlier btw: #help-development message
wait what
yes
that looks like r/programmerhorror or how was it called
pretty much
theyve updated it
use jdgui
If you want to view nms code you can just look at the source inside he buildtools folder
or thay
I think it’s spigot/spigot-server
what's that?
they meant "the" probs
because inside he buildtools ain't correct english iirc
java decompiler
gui
you drag a jar in
And it recompiled it
decompiles*
idk what that means
you can see all the code
IntelliJ also has one built in
there's a plugin for intellij to browser jar files
basically breaks apart the jar into classes
and it has decompilation builtin
i've done this before, i had a project with all the buildtools stuff in it, i just forgot how to do it again
how would i make player damage an entity with a damage cause of projectile
do i need to open the buildtools as a module thingie?
like in project structure > modules
I don't think you can
What he is doing is perfectly fine don't be so critical I see no issue with it unless he tries to sell what he's making. Whatever gets you into it imo is OK even if it's more challenging.
spawn an arrow above em /s
...
cant access
thanks mate
You cannot specify damage cause with the API
I do see an issue with it: he's hurting himself in the long run. Trying to learn through spigot will put you into the position of never understanding what you're doing and just memorizing a ritual of steps and you won't be able to do anything else
are you actually trying to do PlayerMoveEvent.getPlayer
you know you get an instance in your event handler
I've been there and it's a massive pain in the ass to fix after you've started
That’s why we use #
Do e.getPlayer()
or event.getPlayer()
whatever you called it
they probs don't even know the named it
hmm okay i can probably set a nbt value on the entity for that, how would i make the player damage the entity
alex, sadly i don't see any other way to do it with my disadvantages
I've seen their code they aren't completely clueless
I have actual university level computer science education experience and students trying to do things they don't have the prerequisite base knowledge for have the most issues
Player#damage(target)
alright if you say so
if you learn by doing, then learn by doing something simpler
oh its that simple..?
I don't believe they are an English speaker so I can't understand what they want
yes
getFrom()
Gets the location this player moved from```
As long as you are in a modern version
iirc there's also a type, otherwise i am mistaken for fabric
spigot is a very specific java API and is therefore far more complicated than a beginner project should be
Its hard to just sit down and learn Java I tried on an off to do that with languages for years and never could get into it
yes, and?
There is no type
need to call this from event
then... do so?
I asked MD about it and he said a plugin damaging an entity will always be a damage cause of plugin
Which I guess makes sense
But it’s a bit annoying
Well tbh I just mostly randomly coded stuff for a couple years
from shit code to less shit code
i think my current way of doing things is the best way i can (asking people and watching short tutorials here and there). i learn things and eventually i'll learn how to do them in a better way more and more
I don't even know how to make a regular java program
spigot is too complex for a beginner
I keep thinking I have to make the main class extend javaplugin haahhahaah
even i get confused sometimes
and there lies another terrible side effect
when im doing this it blocks all player from jumping. I want to call this method when DeathEvent called.
what
you've learned a ritual to do specific things without really understanding why
You can't call a method
Event
Bukkit event
no
i know, i mean
Blood ritual
they want to run getFrom() when PlayerDeathEvent is triggered
executing
the problem is that event does not have it
alex i think you just have a different prespective of things, that doesn't mean anyone's right or wrong
i have the benefit of having been where you are and knowing it's the wrong path to go down
End of the day you can do what you want
Don't have to learn a certain way
you either learn
yes but i don't think you understand the current choices that i have
or memorize
and i have experience educating students with learning disabilities in computer science
lol
do something simpler before jumping into spigot
i gave potion effect to player when DeathEvent is triggered but even blocking jump player can move.
what ar eyou trying to do?
you're trying to do calculus without learning algebra
you want to stop player from moving?
oh is it learning spigot without learning java?
yup
you can learn java from spigot
yes?
a couple things, right now just opening the buildtools thingie to view nms code
its like learning java from making a game
it's a bad way to learn java
yes
while this may be the case, this also doesn't mean it is our responsibility to teach you either. We can help point you to the appropriate resources however, you need to learn how to learn on your own and if that isn't ideal, then probably best to seek out schooling.
you shouln't do it tho
then first leanrn java :D
Spigot is not beginner friendly at all
first learn basic java
I suggest in the PlayerList class you put a Boolean variable and then when the player dies, set it to true and in PlayerMove check if it is true and if so cancel
yeah but you're also learning java while using the API
this is the equivalent of learning quantym physics from knowing 2 + 2
thats a really big stretch
spigot is not even close to beginner friendly, and the community is full of bad habits because plenty of people want to make plugins without learning
you're shooting yourself in the foot
different people have different opionions, i have come across people that want to teach me a bit and that works for me too. i won't be suprised if there are resources out there that could help me sometimes, but that doesn't mean that showing me resources all the time will always help
you get the point
U don't even need to learn java itself just learn data types, oop, basic programming knowledge
I came from a very beginner level of c++
and you're shooting server owners in the foot, if your plugins containing bad habits start to lagg their servers.
straight to spigot
they haven't learned that yet either
While you may have a differing opinion, no one is obligated to do anything here either. Just remember that.
Or if your plugins forget to run staff async
of course
that's why there's so many lol
Just:
- Learn java
- Make sure you learnt it
- Learn it more
- Make hello world plugin
- Learn more java because you didn't learn it you liar
even today i helped a server track down a plugin that executed a mysql statement syngronous every time a player joined...
I didn't even know this server was a thing
I learned Java through spigot and it took me years to un-learn all the bullshit I picked up
I used YouTube videos that taught me methods that looking back now are horrific
you should try to learn java from using spigot if you want to, it is most certainly not the best thing but keeping your passion alive is more important
I did something similar, but not because i don't know its because i completely overlooked xD
I think that is probably the hardest thing to do, unlearning bad habits and it isn't so much as unlearning it, it is more rather learning to use the better ways over the bad ones XD
Are sql statements that bad?
after you have enough passion to sit through the boring stuff you will actually start learning
beginners working with databases makes me want to scream
no, but you should execute them async
they hold up the main thread
but dont learn plain java if you dont want to, your passion is more important than learning the best way
no
its not
lmao
passion comes last
uh... oops
you first learn
it really does not
then you apply
yes
sql statements aren't bad but if you run them sync your game has to stop until the database call finishes
learn primitive data types
which can take more than 50ms, which means it has to wait for multiple ticks sometimes.
oop
learn concepts
im telling you man, i've made all the mistakes you're making right now and you're screwing yourself over
learn syntaxes
if an art teacher just teaches a kid with passion colour theory and the boring stuff they will kill that kids passion to do art
learn wording
there's videos on YouTube that are barely 10 mins
If your SQL database is local it should be pretty fast tbf
no
which explain basic concepts
yeah and they will learn those while using spigot
and repeat
i think you should try seeing from my point of prespective
true, i still think even then you should be going async tho
if i told you "What's Composition?" what would you reply
i've been in your shoes and im telling you, you'll regret it later
my programming class at school has me doing block coding on minecraft education edition
ok lemme ask you this, what do you think i should do
thank God it has python and javascript
if youre starting something new with passion, try to keep that passion alive
i think you should make simple base Java programs and learn the data types, collections, how to write methods, etc
Can you believe I'm learning the stuff in year 9 that I learnt in year 6
i'm doing that, just not the way you want me to
OH wait we are talking that NEW
yes, but don't make it your focus
yes
they're easy languages
i'm actually not that new
yes i know
what do you know?
no you aren't, spigot is not basic
but TOGETHER?
you can switch between
jeez man
is what I meant
i've been learning java and spigot for a good couple months now, it's been very slow though given the way i'm learning
you don't learn 6 languages when you're born
@red sedge
curriculum wants me to do block
then... do block
I always just do it in js and then convert to block
but that's boring
I don't learn anything
if you know java, spigot is not that hard. just keep the javadoc closeby :)
Yes you have to learn how to use javadoc
they don't, that's the problem here
the only docs i use is spigot docs, for java i just look at short tutorials
people ask alot of questions here too. that they can find out themself with one search one the javadoc
i ask a bit too much here
But first go to javadoc
No one does
If you can't find what you are looking for then ask here
sometimes. but usually the javadoc comments are sufficient.
The javadoc is unloved
Unfortunate
@lean gull if you know java nough to make plugins, start by making small things that you want in minecraft for example idk removing that shit mob called phantoms, while doing that you will learn teeny bits of information each time
definetely not the best way but it will keep you wanting to make stuff
Typically I'll answer a question even if it's a trivial javadoc search unless the wording of the question tells me the individual isn't capable of using the information if I gave it to them
I personally struggle with finding things to do
I have so much passion and want to code I jsut have no ideas
Be like me
99% of the time i need someone to explain things to me, i haven't really tried java docs before but i won't be suprised if it's just a bunch of text that is exteremly hard to understand. checking my theory now
Have ideas but no motivation
same lol hahahaha
Javadocs are very simple to understand
you will learn stuff as you use the API and language itself even if you're at the absolute beggining
That’s what they are designed for
I usually just make small stuff give up on it halfway and then stop programming, come back 6 months later, repeat from step 1
ok 10 seconds in and i don't understand anything
Well don’t give up that quickly
jsut start from making small stuff
they use words that i do not understand quite frequently
idk /fly or smth
Press a few buttons, if you know Java you’ll see how it’s put together
when beginners ask me for a project i always tell them, make something like an airdrops where you place a torch, a chest falls from the sky with some random items. it contains a lot of different aspects while not being too difficult. could be a fun thing to make for you.
goodluck.
Do falling blocks work with any block or just blocks that have gravity
they can be any block yea
awesome
@lean gull look up tutorials for mechanics like /fly after a while you will start to look up tutorials for random things instead of whole mechanics
but you need to look for whole mechanics to get to that point
You can make chests fall?
Yes
if you want to leanr java from using spigot
You can make anything fall
sure you can.
Some things don’t render tho
you can use armorstand holding / wearing a chest, you can use falling blocks
you can use normal blocks but that's lame
not to mention inefficient
take note that if you use an armor stand you need to take care of rotation and size
since the block would be a mini block otherwise
make it with a giant zombie that has a chest on its head, that'd be cool... trust me :)
Is there a way to get a player head of a specific skin, even if that player doesn't have that skin on? I remember looking at this a bit ago, and something about skin signatures
iirc you can just turn a string into a skin
theres some specialized serialization for that one iirc
There’s a new API for that
but they do need to wear the skin at that time for that to work
PlayerProfile
nms or spigot
spigot
true
Hi, I've this method for creating a ItemStack
but i want please can leave the Durability value empty
ow, thanks
and durability changes the item type ? like a blue glass or red class insted of default glass
In 1.old, yes
its a 1.8 plugin, because plugin is for bedwars
lol, that is so true
Use mojmaps ;/
look it up
How to check if config already exists in plugin folder (or you don't need to)?
saveDefaultConfig will handle that for you
Otherwise just get a file instance and use .exists
How can I get config in other class? (this.getConfig() doesn't work)
Quick question, I see some plugins having a custom inventory GUi with a close inventory button inside of it, which item material do they use for this?
This item to be exact
Uh, can you help me?
Material.BARRIER?
BlockWord(event, words);
BlockMessage(event, words);
ReplaceWord(event, words, "text to replace the word with"); ```
why this code not working?
Methods names starting with uppercase letters 🧐
I was so conufsed at first I thought this was sudo code
git log
you probably commited local. didn;t push
Different branch?
should it be fine to set org.bukkit.Material's ID to -1 for new non-legacy materials?
what?
im currently trying to update spigot to first 1.19 experimental snapshot and there are new blocks, so can I set their materials' IDs to -1?
TARGET(22637, AnaloguePowerable.class),
/**
* BlockData: {@link Switch}
*/
LEVER(15319, Switch.class),
/**
* BlockData: {@link LightningRod}
*/
LIGHTNING_ROD(30770, LightningRod.class),
/**
* BlockData: {@link DaylightDetector}
*/
DAYLIGHT_DETECTOR(8864, DaylightDetector.class),
/**
* BlockData: {@link SculkSensor}
*/
SCULK_SENSOR(5598, SculkSensor.class),
SCULK(-1),
/**
* BlockData: {@link SculkVein}
*/
SCULK_VEIN(-1, SculkVein.class),
/**
* BlockData: {@link SculkCatalyst}
*/
SCULK_CATALYST(-1, SculkCatalyst.class),
/**
* BlockData: {@link SculkShrieker}
*/
SCULK_SHRIEKER(-1, SculkShrieker.class),
/**
* BlockData: {@link TripwireHook}
*/
TRIPWIRE_HOOK(8130, TripwireHook.class),
/**
* BlockData: {@link Chest}
*/
TRAPPED_CHEST(18970, Chest.class),
/**
* BlockData: {@link TNT}
*/
TNT(7896, TNT.class),
like this ^
non-legacy materials' IDs aren't used as I see and getting ID for non-legacy Material throws an exception, also they seem to be completely random
so im asking if i could use -1 for them
but they need ids no?
kinda but modern materials' ids aren't used and can't even be retrieved from other classes
Modifying tab completion for vanilla commands
What do you mean?
The client performs physics and tells the server how it’s moving, the server validates that movement and corrects if necessary
For non-player entities yes, for players no
That’s why you can freeze your minecraft and stop falling for example
Right
No?
Because players don’t have physics
Haha so funny
hey , if am getting this error in a for loop does it mean that my arraylist is null ?
java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0```
A lot of work
It means your ArrayList is empty
If it was null you’d get a null pointer exception
how does your for loop look like?
ahh okay thank you
Something like for (var x : list) does not throw such an IndexOutOfBoundsException ideally
And for (int i = 0; i < list.size(); i = i + 1) does also not throw an IndexOutOfBoundsException
I = i + 1 omg
List<Map.Entry< String,Integer>> list = new ArrayList<>(plugin.getPlayerManager().orderByElo().entrySet());
Player player1 = Bukkit.getPlayer(list.get(i).getKey());
int elo = list.get(i).getValue();
if (i == 1){
sender.sendMessage(Utils.CC("&d#" + i + " &7" + player1.getDisplayName() + " &d("+ elo + ") &7elo" ));
}
if (i == 2){
sender.sendMessage(Utils.CC("&6#" + i + " &7" + player1.getDisplayName() + " &6("+ elo + ") &7elo" ));
}
if (i == 3){
sender.sendMessage(Utils.CC("&b#" + i + " &7" + player1.getDisplayName() + " &b("+ elo + ") &7elo" ));
}
else{
sender.sendMessage(Utils.CC("&a#" + i + " &7" + player1.getDisplayName() + " &a("+ elo + ") &7elo" ));
}
}
}```
i want to get the top10 players
i also have this
HashMap<String,Integer> list = new HashMap<>();
try {
PreparedStatement ps = plugin.SQL.getConnection().prepareStatement("SELECT * FROM " + tableName + ";");
ResultSet rs = ps.executeQuery();
int elo = rs.getInt("ELO");
String playerUuid = rs.getString("UUID");
while (rs.next()) {
list.put(playerUuid,elo);
}
} catch (SQLException e) {
e.printStackTrace();
}
return list;
} ```
public HashMap<String,Integer> orderByElo(){
UUID randomUuid = UUID.fromString("3e8eac9d-c886-47a1-937c-5f0dfdf6114b");
HashMap map = getCustomPlayer(randomUuid).getAllPlayersId();
List< Map.Entry<String,Integer>> list = new ArrayList<>(map.entrySet());
Collections.sort(list, new Comparator<Map.Entry<String, Integer>>() {
public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
return o2.getValue()- o1.getValue();
}
});```
You'd need i < 10 && i < plugin.getPlayerManager().orderByElo().entrySet().size(); (please cache that list)
that is what 7 months of learning programming in school does to you
okay i fixed the previous issue but this code isnt changing swear words
String msg = event.getMessage().toLowerCase().replaceAll("[*]", "");
for (String words : getConfig().getStringList("bad-words")) {
ReplaceWord(event, words, "*"); // Use this if you what to replace the word in the chat with an new one
}
}
}
private void ReplaceWord(AsyncPlayerChatEvent event, String words, String s) {
}```
do you know why theres 1 player registred (me) on the db it still throws that error ?
Because you try to get the 2nd player in that list, which does not exist
ok
Also, use Bukkit.getOfflinePlayer unless you really want them to be online
otherwise it'll throw an NPE
sigh
Any reason why this doesnt get set to the correct item?
Main Code:
private static ItemStack getRandomItem(String crateType){
int totalWeight = 0;
ItemStack item = new ItemStack(Material.TNT, 1);
Boolean found = false;
Random rand = new Random();
String rewardData = "Crates.crateRewardData.";
FileConfiguration conf = EmeraldsPlugin.jp.getConfig();
for(String s: conf.getStringList("Crates."+crateType)){
totalWeight += conf.getInt(rewardData+s+".Weight");
}
double r = rand.nextDouble() * totalWeight;
for(String s: conf.getStringList("Crates."+crateType)){
if (conf.getInt(rewardData+s+".Weight") >= r && !found) {
item = new ItemStack(Material.getMaterial(conf.getString(rewardData+s+".Material")), conf.getInt(rewardData+s+".Amount"));
}
}
return item;
}
Config:
Crates:
basicCrate:
0: DiamondRewardBasic
1: EmeraldRewardBasic
crateRewardData:
DiamondRewardBasic:
Material: DIAMOND
Weight: 25
Amount: 5
EmeraldRewardBasic:
Material: EMERALD
Weight: 5
Amount: 25
I cannot use it at school
you mean in the for loop ?
I somehow forced my teacher to adopt i++ but that is about it
at net.dv8tion.jda.api.utils.MiscUtil.tryLock(MiscUtil.java:169) ~[swapnocraft-1.0-SNAPSHOT.jar:?]
at net.dv8tion.jda.api.utils.MiscUtil.locked(MiscUtil.java:131) ~[swapnocraft-1.0-SNAPSHOT.jar:?]
at net.dv8tion.jda.internal.requests.ratelimit.BotRateLimiter.stop(BotRateLimiter.java:169) ~[swapnocraft-1.0-SN```
what does this error mean?
can someone please tell me why this returns an empty list ...
I'm someone that absolutely loves their flatfile storage so I cannot really comment on the SQL being used there. But you should really cache it
i gotta learn that
wait is it something new that i gotta learn or did you mean that i get data and put it in a variable once and then to get it just use the variable ?
so i changed it to this what i got from spigot thread
Player player = event.getPlayer();
if (!player.hasPermission(BYPASS_PERM)) {
String msg = event.getMessage().toLowerCase().replaceAll("[-_*]", "");
for (String words : getConfig().getStringList("bad-words")) {
replaceWord(event, words, "*"); // Use this if you what to replace the word in the chat with an new one
}
}
}```
now its not giving the error but its not changing swear words
How to get config in other class? (spoonfeed with function please)
Basically I want you to not repeatedly call a method when you do not expect a change in the contents of the method.
The PreparedStatement ps = plugin.SQL.getConnection().prepareStatement("SELECT * FROM " + tableName + ";"); call is extra problematic as it requires an NIO operation which could take quite a long time to complete
HashMap<String,Integer> list = new HashMap<>();
try {
PreparedStatement ps = plugin.SQL.getConnection().prepareStatement("SELECT * FROM " + tableName + ";");
ResultSet rs = ps.executeQuery();
int elo = rs.getInt("ELO");
String playerUuid = rs.getString("UUID");
while (rs.next()) {
list.put(playerUuid,elo);
}
} catch (SQLException e) {
e.printStackTrace();
}
this.allPlayersIdElo = list;
}
public HashMap<String, Integer> getAllPlayersIdElo() {return allPlayersIdElo;```
is this good ?
Can you help with that?
someone help .-.
Getters are one of the most common methods in Java :p
So I need to do java public static FileConfiguration config; in main and java config = getConfig(); in onEnable?
i think even if he helps you now you'll still have to learn about getters
Here's an example of getter you can do (am also still new to this btw)
yeah but they asked for it lol
Lemme show you a better example
This is a common pattern in Java called a POJO/DTO (Plain Old Java Object/Data Transfer Object):
public class MyData {
private final String s;
public MyData(String s) {
this.s = s;
}
public String getValue() {
return s;
}
}
It does two things:
private int iteration;
@Override
public void execute(Player player, String[] args) {
iteration = 0;
int arg1 = Integer.parseInt(args[0]);
Location loc = player.getLocation().getBlock().getLocation();
Bukkit.broadcastMessage(String.valueOf(System.currentTimeMillis()));
for(iteration = 0; iteration < arg1; iteration++){
loc.getBlock().setType(Material.GOLD_BLOCK);
changeLocation(loc);
}
Bukkit.broadcastMessage(String.valueOf(System.currentTimeMillis()));
}
private void changeLocation(Location location){
switch (getDirection()) {
case 0 -> location.add(distance, 0, 0);
case 1 -> location.add(0, 0, distance);
case 2 -> location.add(-distance, 0, 0);
case 3 -> location.add(0, 0, -distance);
}
}
private int getDirection(){
int direction = 0;
int iteration = this.iteration;
for(int j = 1; true; j++) {
for(int k = 0; k < 2; k++) {
iteration -= j;
if (iteration < 0) return direction;
direction = (direction + 1) % 4;
}
}
}
any suggestions for improvements in this algorithm to generate islands?
Hold data, and allow you to access it
You'll commonly see classes like this when you need to store multiple values in one.
Also, you can add a setter if s is not final (AKA if it's "mutable")
Because mutability is bad in Java :)
And people need to learn constructors anyway
I got my code to work yay, But is there a reason why my random system is sometimes returning the TNT, which is meant to be a false value?
int totalWeight = 0;
ItemStack item = new ItemStack(Material.TNT, 1);
Random rand = new Random();
String rewardData = "Crates.crateRewardData.";
FileConfiguration conf = EmeraldsPlugin.jp.getConfig();
for (int i = 0; i < conf.getInt("Crates."+crateType+".Amount"); i++) {
String s = conf.getString("Crates."+crateType+".Items."+i);
totalWeight += conf.getInt(rewardData+s+".Weight");
}
double r = rand.nextDouble() * totalWeight;
for (int i = 0; i < conf.getInt("Crates."+crateType+".Amount"); i++) {
String s = conf.getString("Crates."+crateType+".Items."+i);
System.out.println(r);
if (conf.getInt(rewardData+s+".Weight") >= r) {
item = new ItemStack(Material.getMaterial(conf.getString(rewardData+s+".Material")), conf.getInt(rewardData+s+".Amount"));
}
}
also hi @lavish hemlock!
Hi
you should use constructor to tell java that a class must have a certain object
and you can't create an instance of it without
I'd also like to explain why getters/setters exist
In object-oriented programming (y'know, where classes come from, and what Java follows)
You have a core principle known as "encapsulation"
Sorry trying to find a chart rn
Here:
The word, “encapsulate,” means to enclose something. Just like a pill "encapsulates" or contains the medication inside of its coating, the principle of encapsulation works in a similar way in OOP: by forming a protective barrier around the information contained within a class from the rest of the code.
In OOP, we encapsulate by binding the data and functions which operate on that data into a single unit, the class. By doing so, we can hide private details of a class from the outside world and only expose functionality that is important for interfacing with it. When a class does not allow calling code access to its private data directly, we say that it is well encapsulated.
The idea to make only the important, necessary parts of data/behaviour accessible publicly.
for loop
So basically goal of this code is to make block under player glowstone and replace it with last block but problem is that nothing happens
@EventHandler
public void onMovement(PlayerMoveEvent e) {
Player player = e.getPlayer();
World world = player.getWorld();
Block block = player.getLocation().subtract(0, 1, 0).getBlock();
Material type = block.getType();
if(type != Material.GLOWSTONE && type != Material.AIR) {
block.setType(Material.GLOWSTONE);
player.sendMessage("asd");
try {
Thread.sleep(1000);
} catch (InterruptedException i) {
i.printStackTrace();
}
block.setType(type);
}
}
}```
See, by directly exposing a field as public, it makes it harder to encapsulate.
its about ~30 indexes, how ?
can u send an example
i know what is loop, but idk how to do it for this
its not just from 0 to 8
for( int i = 0; i <= 8; i++)
then make an array/list of the indexes
ow, nice
anyone free? 🙂
On top of that, if you need to later remove the field in an update, anything that still uses that field will completely break.
With a method, you can just deprecate it.
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!
Ask your fuckin' question, not "is anyone available" :P
what should i use instead?
this
you know like in hypixel duels you have players with blocks below them spawning and dissapearing after few seconds? thats what im trying to make
It's called a trail btw
The channel is incredibly busy atm :p
You probably just got lost in the middle of it
🙂 ok
alr
Dont use Thread.Sleep()
TimeUnit.TICKS when /s
thank you ill try using scheduler
is it possible to extend an enum?
Nope
it is
Fun fact though, enums can implement interfaces
uhu
they can technically extend a class too
^
All enums extend the Enum class
and afaik, they're all also final, therefore you cannot inherit an enum
oh no you cant, i thought it was possible in earlier java versions
Wellllll
Enums were introduced in Java 1.5
So "earlier Java versions" doesn't really go that far back
anyone can help please ?
its returning an empty list
wanted to get it sorted by elo
also i did store the list on a variable onEnable
am getting that from it
Question: How to set special arrows for skeletons? Just need a rough direction, can't seem to find any relevant methods from its interface.
this wont return anything as you didnt call rs.next()
and you are still putting the same thing in the map
so do your int elo = ... in the while(rs.next())
ahh thank you man
and preferably something supported by spigot api
amma try that
anyways whats the parallelism in a forkjoinpool?
parallelism – the parallelism level. For default value, use Runtime.availableProcessors
You can just modify the fired arrow
ok that's not optimal
actually, my problem was changing the projectile of pillager to fireworks
but I thought skeleton is a good analogy
probably not
Sigh. XY me to death.
lmao
whats the besr way to manage per player config files
Just do this then
I will prefer the loaded projectile to be fireworks
hey im using config.set("booleankey", true);
and it's not actually writing to my file, any ideas why not?
save it
i have the yamlconfig working as if i edit it manually it works
ohhh ok
thanks
fileConfig.save(file)
Then get the item in the mainhand if it's a crossbow swap it for a crossbow with a firework
Crossbows have item meta
What's the easiest way of looping through each of the sections under the section "items"?
section.getKeys(false).forEach
thanks
I know about the method
I will try that. I just wanted to know if there is a provided api for fundamentally changing the type of projectile from the source, I guess not.
I will see how
You could take a projectile event and then delete the projectile, replacing it with the one you want
I don't think any event is fired, no patches for PathfinderGoalCrossbowAttack
thanks for repeating what evryone is saying haha
Configuration section
Since the result can be null and looping through it will result in a
Boom
Ale.
Alr
So you need to change your spigot libraries to the latest version
In your case 1.18
If you don't use NMS then you don't have to worry about anything
anyone have a tutorial for making guis with an Inventory instance?
Ideally you'd use a dedicated library for that
Yeah i know but when i do that, spigot methods aren't recognized
Are you using spigot or spigot-api?
i take the spigot used for running server
And which methods exactly are not recognized
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
:o thx u so much
That is why you should read the release notes
And perhaps you should use maven or gradle
gradle is easy enough and is much better to integrate both maven and gradle dependencies
Or just be me and use your own build tool
how would i write a piece of code thats constantly updating (like a bossbar with a timer that updates with every second)
It is quite annoying to use an in-house build tool at first but after a while you get used to it and will feel the power
your choice, it doesnt matter
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Google it ^^
ty
so im makin a server with guns, and i want to have an easy method of creating the guns. all guns need to have some basic stuff like reload speed and abilities and whatnot. is there any way to make like an easy manager for this?
..
Okay so is the delay in taskdelay in ticks or ms?
Everything is in ticks
no i don't mean something that can make the guns, i mean a java thing for me to make that i can add default values and requirements for the guns
You'd have to set up crafting yourself somehow
yeah i saw you change it
what do you need to realize
he was using the old "Turbo" button on his server case 😛
o
Player#playSound iirc
no i mean
i made a anti swear pl
so
its giving a message
i want to give a sound with the msg
like dragon sound
Player#playSound

anyone?
how to use the sound here?
public void onPlayerChat(AsyncPlayerChatEvent e) {
String msg = e.getMessage();
List<String> words = getConfig().getStringList("bad-words");
for (int i = 0; i < words.size(); i++) {
if (msg.contains(words.get(i))) {
e.setCancelled(true);
e.getPlayer().sendMessage(sc("") + ChatColor.RED + "Swearing Is Not Allowed!")
e.Player.playSound(Player.getLocation(), Sound.ENTITY_WITHER_SPAWN, 1.0f, 1.0f);
;
}
}
}```
A gun interface
But if everything is going to work the same, just extend a gun class
Or have defaults in the interface
wdym?
oh lol my mistake
e.getPlayer() not e.Player
wait
man did too much C#
Fr fr
Types aren’t variables, you should save the player to a variable ‘’Player player = e.getPlayer()’’
And then just use that everywhere you used type Player accidentally and everywhere you used e.getOlayer repeatedly
Java is a hard language
Why isnt this working?
Bukkit.getScheduler ().runTaskLater (this, block.setType(type), 40);
Space
still isnt
^^^
so i have to do that in main thread?
probably 'not working' means error
Hi i want so my players get a message on the screen when thay go to nether and end
if someone can say whats wrong beacus i don't get a message now ```
@EventHandler
public void onPlayerChangedWorldEvent (PlayerChangedWorldEvent e) {
Player player = e.getPlayer();
if(e.getPlayer().getLocation().getWorld().toString().equalsIgnoreCase("world_nether"{
player.sendTitle("empty", "empty", 20, 40, 20);
}
}
}
Pls help and tag me
onEnable of your plugin (probably)
ye
Bukkit.getScheduler().runTaskLater(plugin, () -> {
Bukkit.getScheduler().runTask(plugin, () -> {
// set the type
})
}, time)```
We need to make the "DONT USE BUKKIT API ASYNC" warning bigger
we need pinned messages
well doesn't the stacktrace always exactly explain what the problem is?
Idk
but yeah 99% of just send their stacktraces here without reading them
I've never accidentally used bukkit API async
me neither but I've seen a ton of stacktraces from other people doing it lol
it usually tells you exactly that you are accessing API async and you mustnt do that
or people that dont know they have to watch the console
Can you guys tell me what’s wrong? It says I’m getting an OutOfBoundsException on line 34 saying its out of bounds on an array
does anyone know what the ender pearl cooldown thing is called? like the fillup thing and how it doesn't let you use it
?sike
show code
Player#setCooldown(Material) I think
declaration: package: org.bukkit.entity, interface: HumanEntity
does it only work for types of an item, or can i also do it with like items that have a certain nbt tag
it works for Materials
you can of course listen to stuff like PlayerChangeHeldItemEvent and simulate a per item cooldown
so if someone switches from your custom diamond_hoe to a normal one, you remove their cooldown
and apply it back when they switch back to your custom model data diamond hoe
Index out of bounds, I wonder what that means 
it mean's you're not drunk enough
Yeah I can’t figure it out
ran out of fingers
you try to access array[n] although array.length is smaller than n+1
you try to send a letter to 123 Some Street although there are only 122 houses on Some Street
BigDecimal[] arr = new BigDecimal[0];
BigDecimal bd = arr[-1];
-1 indexer of an array doesnt make sense
there is no -1th element
it starts counting from 0
so arr[0] is the first one
Ok so if I do
arr[-1] = …
Then it should work right
no
NO
?learnjava
ever see a bad for array decrement loop?
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.
it starts at 0
hey guys i want to ask if any of you know how to ask questions on microsoft without the feedback and stuff
ask questions on microsoft?
microsoft is broken rn?
just hit the maven reload button and it'll work
or run BuildTools with --remapped option
huh
ok but is there any places that i can ask about this
The problem is photoshop isn’t the default photo app
???
but all this time it just opens on the "Photos" app but now it doesnt even open
they are just viewing photos and windows either updated or broke the app, they need to reinstall it
Is photos a windows store app
poor jeff
reinstall the photos app?
Yes
its automatically downloaded to the pc but idk why now its broken
#help-development isn't the place for talking about non-development stuff
I understand that I just don’t know if it’s on the windows store to reinstall
ik sorry
how can i generate a void world? afaik you need to override generatechunkdata from chunkgenerator but it's deprecated
Do it
so im not sure if it would work
you only have one? time to buy two more
Hi i want so my players get a message on the screen when thay go to nether and end
if someone can say whats wrong beacus i don't get a message now ```
@EventHandler
public void onPlayerChangedWorldEvent (PlayerChangedWorldEvent e) {
Player player = e.getPlayer();
if(e.getPlayer().getLocation().getWorld().toString().equalsIgnoreCase("world_nether"{
player.sendTitle("empty", "empty", 20, 40, 20);
}
}
}
Pls help and tag me
send it a few ticks later
oh wait
the code doesn't even compile
is that your actual code?!
yes
i have a second screen which is bigger but i cant use it all the time
did you recode the compiler or something
Here you can use this to prevent code wrapping
lmfao
that would not compile
you think there is something wrong if you have a missing ) ?
it's poseble
