#help-development
1 messages · Page 991 of 1
i dont see any decryption in there
????
it does
ill change that
no need to delimit by extension then
id accept a Path as argument
apparently it does not
just use substring with lastindexof
are you trying to get the file extension?
the most graceful one
substrig it with .
int i = filename.lastIndexOf('.')
if i == -1 return false
String ext = filename.substring(i)
yep
if I have
deaths: 5
kills: 6```
in yml file, how do I read each of tabs in a list
so that I have a list of ["deaths", "kills"]
config.getSection("player").getKeys(false) or smth
String extension = file.getName().substring(file.getName().lastIndexOf('.'));
```prob this?
should work
will throw when no extension
true
could use Math.max(0, ...) and then its empty
either way you will need a null check or try catch somewhere
might as well put it here
String[] pathDelimited = path.split("\\.");
if (pathDelimited.length <= 0) return false;
String extension = pathDelimited[pathDelimited.length - 1];
if (extension.equals(String.valueOf(this.settings.fileExtension)) != true) return false;
```at this point this isnt even more work anymore
but this is gonna be a problem anyways
because no extension should be valid
if the extension is a string of length 0 in the settings
then simply call firstIndexOf and substr it
wondering what we are even discussing about at this point
me too xD
is this how I'd get stuff from yml config file
yes
this is the site to read https://bukkit.fandom.com/wiki/Configuration_API_Reference
The Configuration API is a set of tools to help developers quickly parse and emit configuration files that are human readable and editable. Despite the name, the API can easily be used to store plugin data in addition to plugin configuration. Presently only YAML configurations can be used. The API however was designed to be extensible and allow ...
well the get is kinda unnecessary right?
spigot docs about config are awful
???
why not returning the dataAccessObject instance directly?
???
what do you not understand?
your program is bad and you should fix it
Oh god not again
in your return you have playerStatsCache.get(id) which is unnecessary
great
why
because the value returned by the get call returns the same instance as dataAccessObject
because you put it into that a line before
i wrote this now to allow no extension ```java
String extension = "";
if (file.getName().lastIndexOf('.') >= 0)
{
extension = file.getName().substring(file.getName().lastIndexOf('.'));
}
if (extension.equals(String.valueOf(this.settings.fileExtension)) != true) return false;
but then theres still a problem with hidden files
.manifest
that hold no extension
you make an unnecessary call to your cache instead of returning dataAccessObject directly
happy?
it is concrete enough for any java developer to understand
it cant be more concrete without spoonfeeding code
literally
if you cant explain it in simple words then you dont understand it either
nah it is in simple words, you just cant understand these simple words
not really, you cant explain it in simple words
so explain to me your usage of the cache in your code
then tell me why
why what?
also totally ignoring the fact that this sentence is incorrect
why is it wrong?
As of right now, your method does not read from the cache, it only writes to it.
As such you need to first check if the cache contains the requested value and then yield it before doing the "more expensive" lookup.
its not grammatically correct
go cry
you expect me to understand something written in half assed English, lol
quality help it is
:p At the very least you should listen to lynx, he's correct
imagine being such a clown
At least in the snippets you given, you're only writing to the cache which does you nothing if you never read from it
nobodys forcing you to help
nobody is forcing you to be a dick
Okay, don't need to continue lol
As of right now, your method does not read from the cache, it only writes to it.
As such you need to first check if the cache contains the requested value and then yield it before doing the "more expensive" lookup.
You are caching, you are not reading from the cache
its literally supposed to read shit from .yml file into the cache
As of right now, your method does not read from the cache, it only writes to it.
As such you need to first check if the cache contains the requested value and then yield it before doing the "more expensive" lookup.
Yes, and you are not reading from your cache
yeah but you are not using the cache...
It's going into the cache, it's never coming out of the cache :p
You never invoke a Map#get() anywhere
Yes, you had one before in your return statement, but you were doing it at the end which didn't make a difference
please just read
whats your problem with that
what the fuck do you even mean by reading cache
its not supposed to read it
Why not?
why do I need to read something I wont be using
why do you have a cache then?
That's the whole point of a cache lol
lmao
because im pulling from a FILE
well it would make more sense to check if there is something in the cache before reading in the retrieveFromDatabase method
int i = filename.lastIndexOf(".");
if (i < 1) return false; // no extension or hidden file
return filename.substring(i).equals(settings.fileExtension);```
I expected you to know any better
you usually have a cache to prevent repeating expensive lookups, for example expensive I/O operations
Having this be a different method means every caller to retrieveFromDatatabase has to first check if the value is potentially in the cache and then invoke a different method.
i came up with this ```java
String extension = "";
switch(file.getName().lastIndexOf('.'))
{
case -1:
{
break;
}
case 0:
{
if (file.getName().charAt(0) == '.') break;
extension = file.getName().substring(file.getName().lastIndexOf('.'));
break;
}
default:
{
extension = file.getName().substring(file.getName().lastIndexOf('.'));
break;
}
}
if (extension.equals(String.valueOf(this.settings.fileExtension)) != true) return false;
xD
what the fuck
on server enable:
get .yml config into cache
on action:
do something with cache, get something from cache
on server disable:
get cache into .yml config
whats so hard to understand in that?
If the only goal of "retrieveFromDatabase" is to just add it to the cache, little point in returning it
but yea, looks like it works then ™️
but i want no extension and hidden files to be valid though+
in both combinations
happy?
can someone help me with my plugin
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
well it works, but I would structure this whole reading/writing differently in the first place
Trust me, I really do not care how you would do it
Im not going to refactor entire project because "you would do it the other way"
never said that 🤷♂️
.
just telling you its technically not the best code
reread
why doesnt a retrieval operation return anything
so i have been making a plugin for a minecraft smp of mine but im running into some problems
- the plugin assigns random lives whenever a player joins for the first time but it is assigning lives everytime they rejoin and on server restart
2.i made a playerdata.yml file to save data but it doesnt seem to save
3.i made it so that depending on the amount of lives u got ur name color changes but it isnt working on the server
it doesnt seem to save
ur saving the file or just writing to it?
also define not working and what youve tried
code would be helpful to help
works well enough
never said it wont work
for some reason I dont even have to check if player has those, it just creates itself
i just realized lastindex is index in string not counts of found instances
not really, just tried to improve your code
world is hard
by saying that youd do it better?
dealing with senior devs will only be harder
how helpful
im not going to be a programmer
nah I explicitly said what should be different imo
how fun
.
very helpful again
"just do it from scratch again, id do it better"
Gl getting help with that attitude
no
ok lmao
how do I save itemstacks into yml file
k
and whats not working
👆
declaration: package: org.bukkit.configuration, class: MemorySection
just pass a List<ItemStack> as value
everytime i join the server it keeps assigning random lives
even though its only supposed to do it once and thats when joining for first time
so i have been making a plugin for a minecraft smp of mine but im running into some problems
for some reason, even though i have
implementation 'org.java-websocket:Java-WebSocket:1.5.6'
in my build.grade, when i run my plugin it give
[21:19:05 ERROR]: [ModernPluginLoadingStrategy] Could not load plugin 'Minecraft_wsChat-1.0-SNAPSHOT.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: org/java_websocket/client/WebSocketClient
Caused by: java.lang.NoClassDefFoundError: org/java_websocket/client/WebSocketClient
Caused by: java.lang.ClassNotFoundException: org.java_websocket.client.WebSocketClient
im using papermc 1.20.4
are you properly running the shadow task? and using the -all jar.
im very new to java and have no idea what you talking about lul, can you say a bit clearer?
Well you seem to be using gradle.
If you want to shade a depdencny into your final jar, you need to use the shadow plugin for that
it isn't inbuilt into gradle
alr i'll try that ty
so I dont need this bood shit?
what?
bood?
oh BukitObjectOutputStream?
no, not when using the YamlConfiguration directly
Hey guys im working on a plugin that clears blocks inside a certain area. Though it only clears "non-builder" blocks, and the way I check that is by using CustomBlockData, an API made by alex, and it all worked great until I went to scale it up (500x500). I then searched for more solutions and I stumbled upon 7smile7's workload distributed which definitely helped, but the root cause of all the lag I was having was the checking of keys of the blocks to determine whether they are a builder block or not. How do you guys suggest I do this? Instead of making a new object everytime and checking the key inside, should I listen for chunk load event and get the blocks from there and add it to a list along with other events like block break and block place, and just grab the object from there? Because then I would have to check if the block is inside the area which could possibly add some lag aswell. Would like to hear your guys' opinion on this, thanks a ton.
iterating through 500x500 blocks and checking is never going to be fast enough to do it in one tick
How to do multi versional plugin, i need to get material from server minecraft version 1.16 with 1.8 version plugin
You don’t know about my supercomputer ….
I can do it in one tick
Can't keep up!
can I store entire inventory in yml file
i have a problem with the patrick choe mojang spigot remapper plugin
artifact builds and remaps fine but if its used as shaded project dependency it uses the non-remapped artifact
idk if it properly exposes a configurationf for you to depend on
should I experiment with higher tick rates then? When I tested it out, it doesn't remove any blocks at all
Alright
not sure how that works
i dont see it exposing a configuration in it's src
Yea then you probably have to create one yourself
it can take a task however
how do i do that?
configurations.register
and then you just add outgoing.artefact(tasks.reobf) or whatever
I hope the task properly defines its outputs
Hi guys
I got a question, I know it’s very basic Java knowledge thing but
How do I recall a variable later on in another if statement
My variable was set in a field
Im so dumb
Thanks anyways!
Another question
Im technically saving the position of the player, by using getBlockX Y and Z
i'm getting a
> Could not create domain object 'remappedJar' (Configuration)
Im now trying to make that if I do /setfree player it would teleport that player to the saved position, which can be found in Custom.yml file. But I saved them by coords X Y Z
Ok
and you would also need to do getLocation i think
Im not using getLocation
yea
I’m using getBlockX Y Z
target.teleport(config.getString(".X"));
you are trying to teleport the player to a string
Im trying to teleport him to those coords of X Y Z that are saved under the username of the target
whats the logic behind a gun system?
Wdym? Why would I need that if it’s all saved in my yml file?
?learnjava
For Beginners:
Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/
For Intermediate to Advanced Learners:
Oracle Java Tutorials: The official guides by Oracle for Java programming—great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/
Practice and Hands-on Learning:
Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/
Free Resources and Documentation:
Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/
Community and Support:
Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/
Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! 🎉
why not you were saving as a Location yesterday
is there a way to make this structure look better?
hey elgar youll probably know this
Bc it simply didn’t work
like, not as redundant?
whats the logic behind a gun system?
what are you trying to do
The code you had yesterday was fine and would have worked
You literally only needed one more line but my internet died yesterday
Trying to save the position of a player in my yml file if I send /investigate player command and when I set him free /setfree player he would return to the saved position
Rip I still have the old code I mean
cant you do something with PDCs?
or those dont work with players
config.set("path."player.getUniqueId().toString(), player.getLocation());
he has trouble with variables. He's not anywhere near using PDC
oh damn
and if he doesn;t understand something he just ignores it
anyways do you know how i would start building a gun system? elgar
No I just ask
like whats the logic
But Elgarl, what’s the solution for this now for this code
I only need 1 "gun" its like a shovel that shoots projectiles that build ice walls and shit but
oh yeah also
have you seen the door animation on hypixel?
its like with falling blocks I think its a 3x3 "door" with blocks that falls into the ground
its just player interact event and launch projectile
tag teh projectile, then on hit, do whatever you want
so i need a weapon. whenever the ammo hits a person a small ice "mountain" araises like 2 blocks tall, freezes for 2 seconds and then falls into the ground again
and i kinda know how thats done with like falling blocks and stuff right?
like the ice wall comes up from the ground
you can do it with falling blocks but it would be simpler with Block Entity
whats that?
No collision, Translation and does not need to align to other blocks, so can spawn/reside exactly where you want it
with FallingBlocks you have collision issues
Any solution?
you have to store a Location, or at least World name, x,y,z as your player may come from another world
Can someone help me
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
random site, not clicking
?paste
also, wrong channel. #help-server
pastes.dev should be the paste site here tbh, its wonderful
it shoudl
this gives spigot mc more power about the stored data though
Hello! I have made a SQLite database for a plugin where stores info about player's selection in a GUI. All works great when one player chooses something, but when the second player chooses another effect in the GUI, the server starts lagging for a few seconds and then sends an error in the console. I've never worked with databases before. Can someone help, please? My database code and error: https://paste.md-5.net/topiramoxu.php
Who can make a plugin that will track the accuracy of hitting the target, and will write to the player in the chat. Additionally, when the player approaches the target to issue a bow and arrows?
why are you caching a statement
and why using synchronized, doubt your code is multithreaded
don't know chat gpt suggest me that
i tried
bruh
I bet he's firing from Asyncchat or something
chatgpt sucks at jaava
sometimes he give good solutions
no. It gives what you think is good. Any dev here will tell you it sucks
yeah i know that
then stop using it xd
ai can be useful
but only if u know how to code propperly
its like giving someone stupid a task and you are a production manager
maybe it will work
but you have to review it
1 stop caching your statement, and use Connection::prepareStatement instead, that will cache it internally
and i guess you also have to close the statement then
yeah trying to stop using this shit
been a while since i did databases in java
but sometimes i use it just to recheck
#nokotlin
how do you read itemstack material type from a string?
ok, thanks i'll try without catching
i do ive used it
for how long
why not just use the default enum method
idk in like 2 or 3 projects
valueOf? idk matchMaterial does some extra magic or smth, check source
mustve been you not knowing how to use it
there has just never been a situation where i thought: „wow this wouldve been so much worse in vanilla java“
its the verbosity of java for me
as with so much other languages, but thats another story
i actually dislike the trend of making langs less verbose
why
idk just feels wrong for me
i also hate the fact that language like python are using indentation for example
some may find it easier
to me it just feels wrong
does it require exactly 4 spaces or a tab?
yh
fuckery
thank you bro i was stuck for like 2 hour and after reading your message again i fixed it
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
:/
Sorry
dm me pookie wookie
Paste
ill help u
if (healthLeft > 0.66* entity.getHealth()) entity.setCustomName(ChatColor.DARK_RED + enemy.getName() + ChatColor.GREEN + " " + healthLeft + ChatColor.DARK_GRAY + "/" + ChatColor.GREEN + enemy.getMaxHealth());
if (healthLeft > 0.33*entity.getHealth() && healthLeft <= 0.66*entity.getHealth()) entity.setCustomName(ChatColor.DARK_RED + enemy.getName() + ChatColor.YELLOW + " " + healthLeft + ChatColor.DARK_GRAY + "/" + ChatColor.YELLOW + enemy.getMaxHealth());
if (healthLeft <= 0.33*entity.getHealth()) entity.setCustomName(ChatColor.DARK_RED + enemy.getName() + ChatColor.RED + " " + healthLeft + ChatColor.DARK_GRAY + "/" + ChatColor.RED + enemy.getMaxHealth());
if (healthLeft <= 0) entity.setCustomName(ChatColor.DARK_RED + enemy.getName() + ChatColor.DARK_RED + " 0" + ChatColor.DARK_GRAY + "/" + ChatColor.DARK_RED + enemy.getMaxHealth());```
I remember that there was a way to make this code less redundant, so that only ChatColor are changed, but I dont remember what structure was used in that
TreeMap? (i dont actually know)
saw someone using a treemap with roman literals
i did
🐀🐀
tree maps are funky
Hi, how can i remove the default item lore on tools, armor, potions and so on?
ItemFlag#HIDE_ATTRIBUTES
ty
you have to actually add back the default attributes tho
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!
my plugin name is MIXELSMC
thought you were stuck or something
NO
idk we all know what happens when youre stuck
k
!verify cmon
A private message has been sent to your SpigotMC.org account for verification!
smh
valu is int
.
How to save database in plugins folder? Cause it saves in server's folder
its called ItemFlag.HIDE_ITEM_SPECIFICS now
You sure about that?
yh on 1.20
Paper moment?
true
yes xd
could be useful if you shared code
if(sender instanceof Player){
Player p = (Player)sender;
if(args.length == 0){
Location loc = p.getLocation();
loc = loc.add(0.0, 5.0, 0.0);
byte chiffre = 0;
loc.getBlock().getWorld().spawnFallingBlock(loc, Material.CHEST, chiffre);
}
}```since the spawnFallingBlock method is deprecated what is the properway to do it?
int minZ = -10000;
int maxZ = 10000;
Random rand = new Random();
int randomZ = rand.nextInt((maxZ - minZ) + 1) + minZ;
int minX = -10000;
int maxX = 10000;
Random random = new Random();
int randomX = random.nextInt((maxX - minX) + 1) + minX;```
why do i get the same value in both randoms
look at java docs
it usually comes with examples of how you can do it now
what is empty?
it is a good way to do it
you can have a hasCache method in your weapon manager
but if you need the weapon dao just leave it as it is
that would lead to two map lookups in the worst case
so the cache is a hashmap
could return an Optional if you really wanted
<String, DataObject>
optional is not my favorite
Optional<WeaponDAO>
it's a null wrapper
brush alr metioned it :(
would this work in Yaml?
no
No, since that is java code
Required running through java to return a string
ChatColor.DARK_RED returns "§4"
ChatColor.BOLD.toString() returns "§l"
So you'd be able to just do §4§lRed Virtue instead
okay
if you want it human readable add your own parser and use keys like %DARK_RED%
Yes
idk what that even is
And in the code where you call "name" from the yaml
Just do a .replace("%DARK_RED%", "§4")
kinda thing
String.replace("%DARK_RED%", ChatColor.DARK_RED.toString())
Yeah that
that screams unnecessary
When just working with chatcolors maybe yes
It's not necessary
I did say if you want it human readable
^
It can be useful in other cases where there's maybe hundreds of magic values to remember
I always find it annoying to look up the color codes
I've memorized them 😛
write a parser once and you are done for good.
I was obsessed with minecraft when I was younger, so I have them all memorized lol
&6 is the best color
I like &b
&f is best 🙂
All of the letter ones are the best
Except &6, there isn't a good letter replacement for it
Wanna make an announcement? &6
Wanna draw attention? &6
Wanna send a warning? &6 or maybe &e
I'd say it's for smth more severe than a warning
Fair
there was a time i knew all those color codes out of my head
&L is the best, cuz then you just get to scream at people
is there a way to see the chest when you spawn it via World#spawnFallingBlock
Falling blocka are not tile entities
Or what chests are
You can have a hashmap of falling block and inventory and apply it on transform to block
hi, i test to use the #setInterpolationDuration on spigot 1.20.4 but that don't work. When i test on 1.19.4 that work perfectly and when a copy/past to 1.19.4 to 1.20.4 (cuz normaly it would work) no. so idk if i'm wrong or something but idk.
Location loc = new Location(Bukkit.getWorld("world"),0 ,120 ,0);
BlockDisplay display = (BlockDisplay) (loc.getWorld().spawnEntity(loc, EntityType.BLOCK_DISPLAY));
display.setBlock(Material.GLASS.createBlockData());
Vector3f translation = new Vector3f(0,0,0);
AxisAngle4f axisAngleRotMat = new AxisAngle4f((float) Math.PI, new Vector3f(0,1,0));
Transformation transformation = new Transformation(
translation,
axisAngleRotMat,
new Vector3f(1,5,1),
axisAngleRotMat
);
display.setTransformation(transformation);
display.setInterpolationDuration(3);
when i say it don't work, i mean that the displayblock instant do the animation without duration
?paste for me
why is my command name printed after using it?
return true
Return early when you have any guard clauses. ie:
if (!(sender instanceOf Player)){
// do something before returning if needed
return false;
}```
you return false when you want them to see that message
for example when you are trying to say "hey you used this command the wrong way"
More times than not you can just return true to exit early (when it comes to commands) depends on whether or not you want that msg I suppose
how to read elements of yaml string array into java String[]
Get the path of said element, add it to the array
? I said it in the friendliest way possible and you're still butthurt
lol
can you add exceptions to specialsource plugin
int Y = world.getHighestBlockYAt(randomX, randomZ);
can some1 help? how can i do that this block cant be bedrock?
Are you trying to remove the nether ceiling? :p
Ith the easiest way would have to do with the generation to begin with
wdym "generation"
world generation
why else would you use that command lol
im not generating it im doing an rtp plugin thats spots the highest y value to teleport too
and in the nether its the bedrock everytime
how to make double chest bc just setting 2 next to each other wont work
and all of the stuff online uses outdated code
Highest block refers to the highest block within that x/z area iirc, so given that you're in the nether that will always be the ceiling. When you're in the overworld theres no ceiling so it, again, gets the highest block for that x/z area
Which could be any block
im trying todo in nether in normal it works
I know, so you'll have to use a different system for the nether
okay
Or add a block clause that doesn't search for bedrock
^ ith, I haven't seen all your code
what
But if you're using getHighestBlock for nether it will always be the bedrock ceiling
yo im dying in here 😦
i tought about smth like highest block und 120 or smth like this
If you can figure that and get it to work then for sure. I can't think of a more efficient way
ill try
It's either something like that, or do the block iteration yourself
what is iteration 😅
So like you have a list for example with 5 values
an iteration of that list would go through all 5 values and do something
okay
what do you think is easyier
Uh the first one if you can figure it out. The second means you'll have to go over all the blocks in the x/z area and then determine which is highest Y value. So basically rewriting the gethighestblock method
Also the latter would be more performance impacting if I had to guess
hmm okay
do u think this could work
Location loc1 = new Location(world, randomX, i, randomZ);
if (!loc1.equals(Material.BEDROCK) || !loc.equals(Material.AIR)){
Location loc2 = new Location(world, randomX, i, randomZ);
loc = loc2;
break;
}
}```
?paste for me
https://paste.md-5.net/bazoxuyeze.cs why if I try getting the Chest even tho it is a double chest it only gives me the 27 slots
What are you getting
Yes
oh
"my key": "my value"
are "" mandatory?
but its a bit cursed, not sure if bukkit config api supports it
yea, iirc by the official yaml specs, its required to use quotations, single or double
I don't see why it wouldn't, in the end it's parsed and generated by snakeyaml
hi, how could I make it so that if I hit a mob that is in a boat, it gets out of the boat?
Look at damage event and mount / passenger methods
hi is it possible to cancel the event of someone using an elytra, i need to make a plugin to stop people from using elytras while in combat (combatlogx)
entitytoggleglideevent
or theres an nms way aswell if that doesnt work
Use the cheat prevention expansion
Ok i post only the pastebin but the problem is the same as this message. just don't know with in 1.19.4 that work but in 1.20.4 not. https://paste.md-5.net/ikiragajit.java
why does it throw an exception
might wanna rename that to something like "Piercing"...
its not initialized
init default value for it
whats your deal
you dont even know the context
this part throws null
despite me having elements in statistics
how does it look like in config
how on Earth is it null
thats the key Im putting in, I just printed it
how does this throw a null exception
it cant have spaces or what
?jd-s
declaration: package: org.bukkit, class: NamespacedKey
read the docs
don't ask me go over to discord.gg / minecraft and ask them
its not stupid its just sensible naming practices but I highly doubt you would get that ;)
why of course
"somethinglikethis" is clearly more readable than "Something Like This"
lol
why didnt I think of it earlier
woah_you_can_use_under_scores
how to see pdc tags in game
on items?
yes
/data get entity @s SelectedItem iirc
that doesnt exist in vanilla
I literally remember someone showing me it on this discord
what your thinking of is f3+h which just that it has extra tags
did it look like this
Is there a way to get a boolean if an entity is rendered in for a player, or even better an event that's called when this changes?
I already tried listening to the entity teleport packet ||but it also triggers when you can't see the player||
And I tried getting nearby entities with player.getClientViewDistance as args||but you can see further than this||
Its not
Works fine without them
ah ok nice nice
?xy
I made code to make entities glow only for one player with packets, but if the entity leaves the players entity rendering distance and comes back it isn't glowing anymore, so I want to listen for this to make it glow again
You can listen for the add entity packet
Thanks, the spawn entity packet works
Does anyone know why everything works but the nametag remains white? Could it be that I forgot something? 😮
Wrong ChatColor import?
It needs a Bukkit ChatColor
im trying to make it so when you eat a chorus fruit it spawns a tnt on you AND THEN teleports you but i cant figure out how to spawn it
Listen to the item consume event and then spawn a primed tnt with the api
can you explain how i would do that i still dont understand
PlayerConsumeItemEvent iirc
Check if the consumed item is chorus fruit and then spawn tnt
is this on intellij IDEA because i cant find it
It looks like you got this from GPT, because thats junk
Its a mix of API and nms
i just grabbed the code from chorus fruit on intellij idea
what does nms mean
how am i supposed to remake the chorus fruit then
you dont remake it
you don't
there is no PlayerConsumeItemEvent I think on what he’s using
im a pro scripter so I know this stuff
nah u dont
declaration: package: org.bukkit.event.player, class: PlayerItemConsumeEvent
sure?
i mean yeah but heres not the right place to ask
wait
should you use Spigot or Paper if your trying to make a custom gamemode
whatever you feel like
like a completely custom Gamemode
?fork
SpigotMC maintains the Spigot server. If you are using a fork of Spigot (such as Paper, Airplane, Purpur, or other derivative works), you should seek support in the appropriate Discord servers.
are they the same
im not asking abt that but are they the same? what’s the difference
They are competing software Try both and see which one you like more
I use spigot but I just wanna know the difference
Spigot is the root, all others are derivatives.
oh, so there basically the same?
No not really
But you bat for both teams
i didn't know lynx was bi
I mean, try paper, try spigot
alr well i have 0 clue how to add the playerconsumeitemevent
Try both APIs
?event-api
@wintry elk
Paper does some changes to the plugin API some people like and some people don't like
It's still spigot compatible but yea
I would definitely learn the api first
Gotcha
but for the server they both function almost the same way right?
just some plugins work some don’t
Since you are currently trying to extend an NMS item
Well, for s server that is trying to make something completely custom, yea probably
(paper obviously a bit faster)
gotchu
but it’s not completely custom and a couple of plugins is it still compatatible
Vanilla wise, paper disables some exploits by default e.g. tnt duping. People sometimes have issues with that
Tho there is a config option
ah
But yea, I am biased on this so, don't take my word. Try both and see
Facts XD
Idk why y’all didn’t do that ages ago but ¯_(ツ)_/¯
Well, config options are a weird thing XD
E.g. the one we had for the infinite cure discount stuff
Then it gets fixed by Mojang and people are confused why their config option doesn't work
But yeah, config options for everything woohoo
so, purpur?
Config option for your config option
can you add a config option to ban choco then can you add a config option to toggle that config option
Would it be fair to say PDC is still preferred over item_name when it comes to handling your plugins custom items? that is unless you're careful with what items other plugins use to avoid conflicting names
Yes
id recommened pdc always
what if I use name just so I'm not lonely? ;o
forgot to mention this is a custom item that i want to do the same thing as a chorus fruit but spawns tnt at your original location
Is there any good resources on nms?
?xy
what exactly are you trying to do
nms has a lot of things in it
sending packets
Why
You shouldn’t work with nms nowadays
Why shouldn't we use nms nowadays? I mean, sometimes when u want to do something you'll need it
public static void setEntityNBTTag(Entity entity, String key, String value) {
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
CompoundTag tag = new CompoundTag();
nmsEntity.save(tag);
tag.putString(key, value);
nmsEntity.load(tag);
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + tag.getString(key));
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + tag.toString());
}```
No errors, the tags just aren't saving to the entities, what am I doing wrong?
In the messages I send to console I can see that it is being added to tag and the tag does contain the entities full NBT but when I run it again with a new tag to be applied it doesn't show the old tag in the new tag.
it's version dependent and tends to break with every update. if there is an api, use the api. if not and you really need nms, use a packet wrapper like packetevents
Why don't you use spigot API Persistant Data Containers ?
I prefer nbt that isn't under bukkit and plugin name
PDCs on players persist across sessions right?
like if i apply a PDC, they leave, then come back, or the server is restarted, that pdc tag will still be on them right?
oh wait obviously thats how that works its called fucking "persistent" data container
sorry i had a briandead moment
yes they do, just be careful if the server crashes and pdc data was saved close to when it crashed, it will be erased if the server rolls back
pdcs are typically for session data, if you're doing something larger use a database
Hey guys
I got a question
Why does the console say: the embedded resource “custom.yml” cannot be found in plugins?
I wrote the correct code
For new yml file:
File customConfigFile = new File("plugins" + File.separator + "Plugin name or whatever you want" + File.separator + "customConfig.yml");
YamlConfiguration customConfig = YamlConfiguration.loadConfiguration(customConfigFile);
getCommand("investigate").setExecutor(new InvestigateCommand(this));
getCommand("setinvestigationroom").setExecutor(new InvestigateCommand(this));
getCommand("setfree").setExecutor(new InvestigateCommand(this));```
^ No need for this just register the command in your plugin.yml and add aliases:
```yaml
commands:
investigate:
aliases: setinvestigationroom```
if you extended this from the source, and did not compile the custom.yml, the respective plugin data folder will not generate. This means, that go back and recompile it with a custom.yml file under your resources in your project structure or create a subdirectory in the plugins folder with the same name as the plugin and make a custom.yml file
So I need to create a custom.yml file under my resources?
like this
Sure, I’ll do. But out of curiosity, why didn’t it create the file automatically since I coded a if statement that says that if that file doesn’t exist, it should create one?
when you instance a new file, it just accesses it but doesn't create the file, there are ways to give it access to create parent directories though
Oh ok, thanks for the help
So I could easily delete all my try and catch code right?
And replace it with what u just wrote
your code works, just compile it with the custom.yml and fields in the custom yml under the resources area i showed you; make sure to have atleast one key in the yml
like so
Ok sure thanks
guys does anyone know how to make a plugin which disables observers detecting things?
Hey Its been recommended to me by a few people within here to make a class that handles messages all throughout my plugin. Where would I find a doc or blog breaking the process down for me as I don't know where to start.
hello, what do you mean by "messages"? you mean like error messages, chat messages, etc
uhh can anyone help me with this?
Chat messages and response messages. For example when someone runs the command /boat i usually use a bit of code looking like this (pseudo code ahead) player.sendMessage(MiniMessage.miniMessage().deserialize(langConf.getString("boatmsg"))
?docs
honestly, i forget what i originally asked it for, but i think i had just deemed it not worth it to use something like a mysql db xd
can you eloborate
kotlin extension functions for CommandSender::sendMessage(LangKey) are the best
@EventHandler
public void onBlockRedstone(BlockRedstoneEvent event) {
Block block = event.getBlock();
if (block.getType() == Material.OBSERVER) {
event.setNewCurrent(0);
}
}
}
?jd
I did this and it still doesnt working
i did smth like this, probably a bit of abuse
https://github.com/FourteenBrush/XCore/blob/main/src/main/java/me/fourteendoggo/xcore/utils/LangKey.kt
then add an extension function so i dont have to call asString every time
fun CommandSender.sendMessage(message: LangKey, vararg args: Any) = sendMessage(message.asString(args))
but ye kotlin
why do u choose to code in kotlin (not messing with u I genuinely want to know)
just keep experimenting with the same approach suggested, just keep in mind any block updates if you follow this approach, like piston pushing an observer will not send a redstone pulse
cuz kotlin is nicer than java, gotta admit this code doesnt look fantastic
How is kotlin nicer than java? Personal preference or ? (Genuine)
The "nicety" of a programming language is usually always personal preference
cuz its less verbose and has so much utility functions that are never gonna be implemented in java
well yes but I'd say python is less nice (still like it) because of computation time
ahh, probably make a proxy method if your string is already in minimessage format i think it's fine, you oculd just make a util class with constants if thats what those people are referring to
i dont want to make this conversation about kotlin again
ah so kinda like paper to spigot? (minus the depreciation of everything)
For some people that just isn't an issue
Real but my code is too bad for that to work (I write the most inefficient code ever)
Real but my code is too bad for that to
Also side not I'm struggling with getting adventure api onto spigot
i've gotten up to audiences but thats it
How do i send a minimessage.
ohh shoot how has it taken me this long to find it
Heyy guys
I got another issue
So I’m trying to save the location of the player when I send the command /investigate <player>, it saves the location and stores it in the custom.yml
And it tps the player to a location (investigation room)
But when I want to set the player free with /setfree <player> it doesn’t send the player back to his previous position
It just sends him to a strange location
show your code for setfree
Here’s the location it saved
hmm the problem sounds sus cannot help
Here’s the code: https://paste.md-5.net/noyupovizo.cs
The actual code starts under line 12
Investigate.getCustomConfig().getInt(".X")
I’m checking the perms
Oh yea you’re right
But what about Y and Z?
same thing
yeah like chochip said, its not querying the section
your path should be the config section of player or include player into your path
like Legnano.X, or getSection(Player).getint(x)
. is relational dot operator if you don't have a preceding key don't use it
ok so this line: "if (Investigate.getCustomConfig().getConfigurationSection("player") != null) "
is fine aside from hwat buobuo is saying with early returns
save the config section from this call
because you queried the player's name here
so like say getConfigurationSection(player.Legnano);
and then using that same section do section.getint(x)
But it’s not always Legnano that’s the problem
so then use
"player." + player.getname
use player uuid btw, players can save their name
this^^
dont eggplant me will you
Line 14 right?
Bc there is also another line that looks the same under It
Line 21
16-18 isn't necessary, since aren't you tping him to the location in the config
21, you could just remove the for loop by calling config.getConfigurationSection("player." + uuid) or his name however you wanna store it
Could I leave like 19? Is it correctly coded?
Config customConfig = Investigate.getCustomConfig();
ConfigurationSection playerSection = customConfig.getConfigurationSection("player");
if (playerSection == null) {
return false;
}
ConfigurationSection uuid = playerSection.getConfigurationSection(uuid);
if(uuid == null) {
return false;
}
target.teleport(new Location(target.getWorld(), uuid.getInt("X"), uuid.getInt("Y"), uuid.getInt("Z")));
target.sendMessage(ChatColor.GREEN + "You Have Been Returned To Your Previous Location. Follow The Rules!");
Bukkit.broadcastMessage(ChatColor.LIGHT_PURPLE + target.getName() + " has Been Let On Parole")
sent an example of how it could be implemented,just handle removing entry after setting them free
I think u did an error when you wrote ConfigurationSection uuid = playerSection.getConfigurationSection
You’re writing getConfigurationSection 2 times
you’re technically writing:
Interrogate.getCustomConfig().getConfigurationSection(“player”).getConfigurationSection(uuid);
just do getSection("players." + uuid)
can i change the size of the enderchest?
It’s not possible, uuid might not be initialised
ConfigurationSection uuid = Investigate.getCustomConfig().getConfigurationSection(“player.” + uuid)
Yes.. that is what I’m doing what’s wrong with it? First check is to check if there are any keys, if not then we return, next is to initialize the var where we hold the section we’re targeting the player with
The uuid is initialized you initialized the player in the first couple of lines as target
It’s not accurate code what I gave you, adapt it and learn from it
I never initialised uuid that’s why
Should probably revise your code with these multiple .getCustomconfig calls, it’s redundant
UUID is with the player
Player.getuniqueid
I added
UUID player = player.getUniqueId(); in the scoop
And replaced (“player.” + uuid) with (“player.” + player)
This should work
what
I think he might referred uuid to the actual uuid and not the uuid from ConfigurationSection
i have no idea what you guys been doing for so long
Trying to teleport the target back to the position saved in the custom.yml when I do /setfree <player>
With these info
and whats the issue
when someone does the command to store their location, save it, then load it back when doing setfree
can you correctly load the location?
No it saves the location when I interrogate him /investigate <player>
And no it still doesn’t work
var section = config.getConfigurationSection("player." + player.getUniqueId());
var x = section.getDouble("x");
// [..]
player.teleport(new Location(world, x, y, z));```
gimme a sec im in class rn
you should save the UUID instead of IGN
Sure I could send u the code
If someone changes their IGN your code breaks
because a player might change their name, making the data stale
Yes but it’s not a ban plugin, where the stored data is perma, but it’s rather something temporary
During an interrogation
I see so the player never leaves the server while they're in the file
so youre saving the data based on uuid already?
why dont you do it then
It doesn't have to be saved in a database/config if the server never restarts, you can just use a Map<Player,Location> right?
I will do it, I just thought that username is simpler
equally simple
Already tried with hashmaps, didn’t work
Im just now stick with a yml file
you shouldnt be checking if the player section exist, check the section "player." + uuid
well i see you handle it but why handle the case [player] does not exist
and use uuid instead "player." + player);
You should print the x, y and z to console to see if the problem is before or after that
player is initialised as UUID player = player.getUniqueId
bruh
Also, are you sure you save the x y z in the right order to config
Yes
Here’s an example
I now changed that it stores the uuid instead of the player username
so after you run your command, the data is saved correctly to the file?
Yes like that in the picture
and loadin g it?
Wdym?
does it work
Im not sure I get a warning in the console telling me that the track is impossible to find
Java.io.IOException
which line does it say this causes
well the code you sent isn't your main class
Line 34 is createCustomConfig();
And 53 is inside a try and catch statement
try { customConfigFike.createNewFile(); } catch (IOException) e.printStackTrace(); customConfigFile.getParentFile().mkdirs(); saveResource(“custom.yml”, false); }
second line after try {
That’s line 53
if !file.exists() plugin;saveResource("data.yml", false) if you have the file in your resources folder
either way check if it exists first
I asked in this chat and they suggested me to just put the file in the resources
So idk if I still need this whole code
I already have it in my resources folder
Do I still need this whole code?
is it empty in the start?
No it has “player:”
just do the thing i posted then
Should I delete something and replace with what u wrote or what
Just add it or replace it
So I’ll delete that code
if it not exists, dont call createNewFile but plugin.saveResource(filename, false) to copy it from the resoureces folder into the plugin folder
Ill delete this whole thing is it ok?
yes
yes again
if (!customConfigFile.exists()) { saveResource(“custom.yml”, false) }
Ok cool let’s try now
Should I modify something from the setfree command class?
idk
.
try it out instead
what part
Prevent the player to send any commands when I send /investigate <player>
when the player enters a command you can check if they're being investigated and then cancel the event
How would u check for being investigated
save that the target player from the command is being investigated somewhere
Could u make an example so that I can understand?
just save the player somewhere like in a collection or smt and check if they're present in that when they enter a command using the PlayerCommandPreprocessEvent
have a set of uuids for the players that are being investigated
or use PDC
there's a lot of options you can go with but preferably a set or PDC(if you want it to be persistent)
I’ll opt for HashMaps
you don't need a key and value for that
I’ll do private Map<UUID, Boolean> example = new HashMap<>();
you don't need to use a boolean, just have them in a Set if they are being investigated and delete them if they're not
try it out
I tried but it doesn’t seem to work
I’ll send the code I wrote
I added this under the method
And I wrote investigatedPlayer.add(target); when he’s under investigation
And investigatedPlayer.remove(target); when he’s set free
did you register your listener?
But the listener is in the same method as CommandExecutor
I did implements CommandExecutor, Listener {
