#help-development
1 messages · Page 455 of 1
My code is great :,)
The compiler is your slave, make it suffer!
Is what I tell myself so I don't lose it
I stopped caring about posting my shitty code I hope one day someone looks at it and just tells me how shit I am
And why
Ur shit
I wanna learn lol
In my years I've written some terrible code, I still do at times. No point in being embarrassed about it as those who are rude rather than give helpful advise are not people you should listen to.
“If you don’t write bad code you are not writing code”:
If you don’t make mistakes you are not learning.
Everyone makes mistakes, and that’s how we grow and improve. Don’t be afraid to try new things, experiment, and fail. Learn from your failures and move on. Mistakes are not a sign of weakness, but a sign of courage and curiosity.
M
M
Some code is good and some code is bad
But all code is a reflection of the coder's mind
A mind that is curious, creative, and bold
A mind that is not afraid to make mistakes and learn
Bad code is not a shame, but a step in the journey
A journey of discovery, improvement, and mastery
A journey that is not easy, but rewarding and fun
A journey that is not finished, but always ongoing
M
Poem courtesy bing
Tell it to create a top 5 list of most useless rock types so that it doesnt get cocky.
That’s an interesting request. I don’t think there is a definitive answer to which rock types are the most useless, as different rocks may have different uses and values depending on the context and perspective. However, based on some web searches, I can try to create a list of some rock types that might be considered useless by some criteria. Here is my attempt:
Here is my attempt: - Confusionite: This is not a real rock type, but a term used by geologists to describe any rock that is difficult to identify or classify. Confusionite rocks may be unusual, rare, or have a complex history of formation. They may not have any practical use or value, except for scientific curiosity or aesthetic appeal. - Obsidian: This is a type of volcanic glass that forms when felsic lava cools rapidly. Obsidian is very brittle and sharp, which makes it useful for making tools and weapons in ancient times. However, in modern times, obsidian has little use except for decorative purposes or as a mineral specimen. It is also not very durable and can be easily weathered or broken. - Dolomite: This is a type of sedimentary rock that consists mostly of the mineral dolomite. Dolomite is similar to limestone, but it is less soluble and more resistant to acid rain. However, dolomite has few uses in construction or industry, as it is harder to quarry and process than limestone. It is mainly used as a source of magnesium or as an ornamental stone. - Sand: This is a type of sedimentary rock that consists of small particles of weathered rock. Sand is very abundant and can be found in deserts, beaches, and rivers. Sand is widely used as an aggregate for making concrete, asphalt, glass, and silicon chips. However, not all sand is suitable for these purposes, as desert sand grains are too smooth and rounded to bind together well. Also, sand mining can cause environmental problems such as erosion, habitat loss, and water pollution. - Pet Rock: This is not a natural rock type, but a product invented by Gary Dahl in 1975. Pet rocks were ordinary rocks that were sold in cardboard boxes with air holes and straw bedding. They came with a manual that instructed owners how to care for their pet rocks.
Pet rocks were marketed as a low-maintenance alternative to real pets. They became a fad and sold millions of units, but they had no real use or value other than being a novelty item. This is my list of top 5 most useless rock types. Of course, this list is subjective and based on limited information. You may disagree with some of my choices or have other suggestions. I hope you enjoyed this creative exercise. 😊
I'm creating a pet system and i'm trying to figure out how to give the pet XP. Where do i store the xp if i want every pet to have its own xp
I was thinking CustomModelData but i'm not sure
Def not in the entity. You need an external storage system for that.
*One option would be the PDC of the owner
Hello I’m looking for a developer who can help me with my plugin
?paste
https://paste.md-5.net/osisokuviz.cs
"java.lang.NullPointerException: Cannot invoke "java.util.HashMap.containsKey(Object)" because "this.cooldown" is null"
Pretty clear case. You cant call methods on an object if the object is null.
Create a HashMap before you use the variable.
I wanna make a plugin where you can right click spawners and that opens a gui where you can sell the items that got generated in the spawner. The spawner doesn’t spawn mobs
That's just the default autocompletion, it will give an error if you try to run it like that so there's nothing to worry about
You want to place a commission?
Check the amount of arguments and then return null in your tab completer
if (args.length > 1){
return Collections.emptyList();
}
basically
Or return null which would tab complete all players
As smile suggested :>
Well I wrote a class to make tabcomplete easier, but to answer your question, it’s probably not that different from bukkit
I’d assume so?
How about this
public HashMap<UUID, Long> cooldown = new HashMap<>();
Will it create the hashmap
No comment
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
@terse socket
I suggest taking inspiration from the last example
Thanks
Well
Yes
You get the command actually
And set the tab completer for that command
Spigot you have
getCommand("give").setTabCompleter(new TabCompleterImplementation())
Ah
You crate a variable like:
PluginCommand command = getCommand(…);
command.setExecutor
command.setTabCompleter
since the setter methods return void you can’t chain them
Well somewhere yes
Many people simplify it by creating some sort of helper method
Hmmm sounds like a PR could fix it
private void registerCommand(String name, CommandExecutor executor, TabCompleter completer){
var command = getCommand(string);
command.setExecutor(executor);
command.setTabCompleter(completer);
}
@south gulch
In plugin.java
And then they call that method instead
Yeah best of luck bud (:
replace with PluginCommand
since that’s the return type of getCommand()
I used a code example from the protocollib tutorial
new PacketAdapter(this,
PacketType.Play.Server.ENTITY_EQUIPMENT) {
@Override
public void onPacketSending(PacketEvent event) {
PacketContainer packet = event.getPacket();
ItemStack stack = packet.getItemModifier().read(0);
// Only modify leather armor
if (stack != null && stack.getType().name().contains("LEATHER")) {
// The problem turned out to be that certain Minecraft functions update
// every player with the same packet for an equipment, whereas other
// methods update the equipment with a different packet per player.
// To fix this, we'll simply clone the packet before we modify it
event.setPacket(packet = packet.deepClone());
stack = packet.getItemModifier().read(0);
// Color that depends on the player's name
String recieverName = event.getPlayer().getName();
int color = recieverName.hashCode() & 0xFFFFFF;
// Change the color
LeatherArmorMeta meta = (LeatherArmorMeta) stack.getItemMeta();
meta.setColor(Color.fromBGR(color));
stack.setItemMeta(meta);
}
}
});```
that this?
This worked in the right way, thank you. I just want to see if there's a way for me to keep this running after I stop the server
Look at the nms packet. I think it has a collection of some sort
You need to get item slot pairs or something
When I restart the server the countdown stops and it restarts when I run it again
The map is in your memory. Nothing in memory is persistent.
You need to store your data if you want to keep it between
server restarts.
I'm gonna save it in my database on onDisable
u gotta load it later on enable too
Can a Stack of item be more than 64? like 5,000 or 10,000?
oh yeah true
Short answer, yes. Long answer: you probably don't want to do it.
did you played warzone ever? i'm trying to show player's money in his hotbar using a Dollar modeled item
they cannot modify their inventory at all
You can modify the stack size but you have to be careful as it's unstable as heck
yea its ok, player just can Pickup and Drop items
any item he pickups such as guns goes to a specific slot, for example Guns go to slot 0 and 1 (Primary and Secondary) and he just can scroll between the guns
You can look at plugins that do it like this https://github.com/haveric/StackableItems not sure how up-to-date it is though
:o
where do you check all that stuff?
ty
hi, i need to detect weather a dropped item hitbox (that is going very fast) is inside of another hitbox, ive tried using the BukkitScheduler loop but its too slow and if i use a while loop, its gonna lag out the server, what should i do?
btw there isnt an event for what i need to do
Check if the velocity vector intersects with the BB
Baby
good idea
as the velocity length is the maximum distance traveled per tick
there is even a method for you to do it https://hub.spigotmc.org/javadocs/spigot/org/bukkit/util/BoundingBox.html#rayTrace(org.bukkit.util.Vector,org.bukkit.util.Vector,double)
How do i fix this
install vault, use a better chat plugin?
yes
I have it downlaoded
I added a version directly from spigot instead of my server host, Retrying now.
I downloaded vault again and its still like this
Vault isnt working.
its yoru chat plugin at fault not vault
(I think he means to do %vault_prefix%)
Prolly
Ill delete the chat plugin, Give me a minute.
I had that page open.
Before you sent me it.
Oh.
I didnt do /papi ecloud download vault
Mbmb
Sorry
np
wdym?
I was talking about if you used a scheduled executor
no i mean wdym taking risks
Don’t just do what was previously explained
operating out of sync with the main thread and reading data from Spigot is risky (at times)
the max distance will be your vector.length
With venturechat, How do i add luckperms ranks into chat?
Go check their documentation
basically what i did is make a gun that spawns in an iron nugget bullet and setting the velocity so it gets launched out very fast the direction the player is looking, when it is isOnGround then it will be removed and when it hits an entity it damages it and then it gets removed, and the BukkitScheduler loop is too slow to read the data and sometimes the bullet goes through an entity but it will not get damaged
^
use the method as I linked
in the loop?
if it's going to collide you will get the Entity in the result
yes per tick
the length of the vector is th emax distance the Entity can move per tick
this is what i have now
so ray trace from the bullets BB from it's location along it's vector for the vectors length
um no
thats bad
make a Set of bullets
what params?
or List
why?
when a bullet is fired, add it to the Collection
then have ONE task running which iterates the Collection
raytrace from each bullet and check for a collision
velocity = bullet.getVelocity();
location = bullet.getLocation();
result = bullet.getBoundingBox().raytrace(location.toVector(), velocity, velocity.length());```Something like
always?
yes
no point in stopping and starting
if the list/set is empty your task will do nothing
so do it static?
depends
cuz i am doing all this in an interactEvent
doesn;'t need to be static
just accessible from your task and where you fire the bullets
yes but there is always gonna be new schedulers
yes but when i put Bukkit.getScheduler().runTaskTimer(Main.getInstance(), runnable -> { inside the event, its gonna always (every shot) make a new scheduler
oh so outside the method?
yes, when you spawn your bullet, all you do is push it to your list
but doesnt it take up too many resources when the scheduler runs every time even if no bullets get fired?
if the list is empty your task does nothing
so i should cancel when its empty?
no
it would take more resources to cancel and start a new one than to leave it running
oh
what do i have to check for?
how can I check if Projectile hit Headshot via EntityHitResult
entity in the result
btw ill have to go for 5 min
EntityHitResult is not a thing...
in NMS*
riight
but that returns the same for be all the time
public static void onBulletHit(Entity shooter, EntityHitResult result, Gun gun){
Entity hit = result.getEntity();
double y = result.getLocation().y;
double entityY = hit.getBukkitEntity().getLocation().getY();
double shotY = y - entityY;
boolean wasHeadshot = (result.getLocation().y - entityY) >= 1.35D;
boolean wasHipZone = shotY >= 0.80D && shotY < 1.35D;
System.out.println("Entity hit H: %s; HZ: %s; Y: %s".formatted(wasHeadshot,wasHipZone,y));
}
No matter the direction I'm shooting
how do i add a space inbetwwen the [owner] and my name
then add a space
Then just add a space to the code
show us the code
i have been
Then get the location of the projectile entity
riight
imma try
thx
ill try some other things and help sever
you are editing configs so #help-server
its probably the easiest if you add a space to the prefix
Storing an ArrayList<ItemStack> and HashMap to a database ?
whats the most efficient way to check whenever player holds item?
And display ActionBar when they hold it?
?paste
@eternal oxide ive made this, could this work?
the method gets called in onenable
can someone help me in #help-server
Have patience
Don’t raytrace twice. Haven’t looked closer than that
make a variable?
use an iterator so you don't need to use the keyset
raytrace once into a result variable
how
in fact, change your pistolBulletsFired into a List<UUID>
then add them just as a UUID
currently its a hashmap
Item,Player
why?
the bullet and the one who shot it
are you using a recent version of spigot?
1.16
I don;t see you using the shooting player anywhere in the bullet code
Didnt follow the conversation but if you are iterating the list every tick then a LinkedList might be your best option.
Because you can remove elements while iterating over it
i need it in 2 places, when i damage the entity and to detect that the bullet didnt hit the shooting player
and what list should i use?
cuz he said linkedlist
If you have a LinkedList you want to iterate then the best performance will be achieved by
firedBullets.removeIf(bullet -> {
bullet.tick();
return bullet.isDone();
});
O(1)
droppedBullet.getPersistentDataContainer().set(new NamespacedKey(Main.getInstance(), "shooter"), PersistentDataType.STRING, event.getPlayer().getUniqueId().toString());```
so i should replace the for loop with an iterator?
k
Somethign like https://paste.md-5.net/vihulucuqo.java
okay
line 15 you could use a simpler test if (livingEntity.equals(bullet)
I missed a return at the end
you have a zero vector on one of the entities
ye its this line RayTraceResult result = bullet.getBoundingBox().rayTrace(bullet.getLocation().toVector(), bullet.getVelocity(), bullet.getVelocity().length());
you have a non moving bullet
no
bullet.remove();
return true;
}```
?
yes, before the raytrace
yes
if you are seeing hits to self you need to adjust your start location
it kina works but it doesnt damage anything
yes you are probably detectign the bullet as a collision every time
try bullet.getLocation().toVector().add(bullet.getVelocity().normalize()) as the first argument for the raytrace
doesnt make sense
yep, it means it's workgin, just needs one more error check
if it doesn;t hit anything the result is nu8ll
so if (result == null) return false;
ok
?paste
still doesnt work
it doesnt give any exceptions tho
do the bullets get removed?
Does anyone know about this error?
I'm trying to delete world and this error happened.
yes
then add a sysout in each of the places you return true to see where they are being removed
anywhere you are calling bullet.remove()
so 3 places
how can remove specific amount of item from player inventory
the file does not exist or your path is wrong
probably yoru path as it starts with ./
so it starts lookign in yoru server root
or the root of yoru source
?paste
path is right and this error called automatically when auto world saving
I used Bukkit.unloadWorld() method and I delete world directory.
In this code, is there any wrong part?
you are deleting the world before it finished saving
It’s sequential yah?
1 is where velocity is zero?
look
ok so it's hitting an entity and stopping before you detect the collision with the raytrace
ig
so add a listener for the collision and do damage. nothing else
hmm would those be different modules? (.vscode excluded)
trying to figure out the dif between a module and a regular folder
wdym?
somehow your bullet is hitting the entity before you detect any collision in yoru task
when it hits the server stops the velocity
then yoru code see's it has stopped and removes the bullet
no
somehow your raytrace is not detecting the hit before it happens
I wonder if it's skipping over the target with the unit vector
so what should i do?
try changing the first argument of the raytrace to bullet.getLocation().toVector().add(bullet.getVelocity().normalize().multiply(0.2))
a much smaller jump ahead
ok
but even when i hit a block, it still doesnt remove the bullet the same tick
so idk if this raytrace thing works
so it only ever gets removed when velocity is zero?
somethigns up with the raytrace then
oh I know, one sec
yeah we using the wrong raytrace, sec
RayTraceResult result = bullet.getWorld().rayTrace(bullet.getLocation(), bullet.getVelocity(), bullet.getVelocity().length(), FluidCollisionMode.NEVER, false, bullet.getBoundingBox().getHeight(), null);
alright
I would create a custom projectile instead of constantly tracking a flying Item
Item
Ok but why is it an item?
odd choice
cuz i want to display the iron nugget as a flying bullet
Why dont you use a Snowball? You can literally let it look like any item now.
fr???
oh
lol yes 🙂
how?
btw im on 1.16
I assumed you were going this route for some reason 🙂
snowball.setItem(ItemStack) or something
does it work there?
Eh 1.16 might be a close call
uhoh
But see if you got the method for it
you can do all this in a simple listener using projectiles
just make a snowball and disguise it with packets :)
throwing items with yoru own collision logic is intersting though
it works :DDD
?paste
Hey, um so, how do I publish my plugin?
This is a simple one that allows you to throw spawn eggs. https://paste.md-5.net/soxiwunejo.java
Oh, thanks!
use teh PDC instead of meta though
ew metadata
also pdc is a bit yicky
pdc is perfect for passing data on the object
you gotta create a namespaced key for everything
meta is leaky so should be avoided
meta is bad yes
she only wants to pass a player ID (not needed) so you cna reuse a single key
still annoying
What's this?
Got it
can I prevent respawning somehow? PlayerRespawnEvent doesn't seem to be cancellable
why do you want to prevent respawn?
I don't know how to use it. I tried to google ready-made code to replace an item, but they all don't work.
well i don't think it's an xyproblem, but just to elaborate - after dying, i want players to not be able to respawn for a certain time. i do not want to outright kick them from the server and disallow joining, i want to explicitly stop the respawn button from respawning them
i want to explicitly stop the respawn button from respawning them
if that's not possible i'll ofc look for workarounds
You cannot disable respawn but you can put them into some undead state. Either you lock them in a room or you freeze them or you prevent the death and make them invisible and freeze them or anything like that. What the best option is probably depends on your use case
I've seen a medic system that basically let them "sleep in a bed" just without the bed. You could do that until they are allowed to respawn
You'll surely find a suitable option. If you don't want dead bodies lying around the latter one is probably not the best for you 😃
so I've discussed it with the dude i'm working for and we decided the following: spawn the player in spectator mode without an ability to move and a title-based timer + blindness
Frick
choco how could you
Does anyone know any good simple to understand api for commands and sub-commands. Like , example command - /bw <join> <mapname>?
i have a plugin called ReSpawn, which basically prevents you from doing anything unless some player respawns you, it uses similar mechanics
owncode
there is no subcommand concept in spigot, its all just args
ie join would be first arg
-_-
I understand that
But I saw some libraries onlien on github like Cloud,Brigadier etc
and saw them being used in projects
Is there simple way to do this? -
I have a bunch of classes for diff commands
I wanna make it so all those commands are under one command, basically they become subcommands
For ex i have a class for /balance, it would become
/pepe balance
without having to create one class with a bunch of if statments for the subcommands and all that shi
CommandAPI is another one
Simplest way is just. A map.
Map<String, CommandExecutor>
String Is arg name CommandExecutor is its executor
I don't understand what you are trying to say
(the Map guy)
I know how a map works but how would that thing work
Just look at my command lib and see how I do it or just use acf :P
https://github.com/Y2K-Media-Creations/ErisCL
chatgpt telling me to do new > module 💀
You check to see if the map contains they key (String) and if it matches, use its associated value to call the execute methods (CommandExecutor)
I'm probably gonna make a funky adapter for my animation system
so I can make commands with the same syntax
as the syntax is surprisingly easy to work with
Funky
it's a bit too raw but still
because the current system is horrible
i have no clue what im doing
is that a java module or just smth ij?
btw is this even the right way to name the package?
or should it just be "me.fourteendoggo"?
im questioning my existence now
the thing you have rn
<me/com/org/net>.<coderName/orgName/comName/teamName>.<projectName>
code thats not in a module anymore
whenever i add a module, should i put the code that i had before in a new core module?
what did you expect
i stopped going to paper server to ask for help with paper api
i'd rather ask here and get a ?whereami but get a response later
than sit through that
💀
im using mcp-reborn
just say thats not an answer to my question
wtf is MCP-reborn? Any incarnation of MCP shouldn't be used anymore
i just need to look into mojangs code sometimes
Why are people reviving it outside of Forge? lol
idk someone told me to use it
?blockpdc for me
Learn about CustomBlockData here:
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
i dont know what it is
i love cafebabe
Your choices for modding are, at least in my opinion, Forge or Fabric. No others
i'll give cafebabe my firstborn
And to be quite honest, you can support both rather easily with modularization
They both use Mojmaps
is the fabric stuff still halfy obfuscated?
I would still only use Fabric for lighter mods. If it's a heavier mod, Forge is still the reigning champ
?ischocoreal
No, Choco is not real. I was not programmed to say this by Sam.
shit
Fabric takes a different approach
Different APIs
fwiw, again, if you're doing a larger mod, try to modularize your code to where you can support both loaders
It shouldn't be that much extra effort if you start with that in mind
Guys guys what about Quilt /j
wut

I'm not sure I follow
Yeah but why? You're just making a mod, right?
You can't, but your mod's code is your own
No
Forge and Fabric are loaders. They'll load your mod for you just like CraftBukkit does and has hooks to call your stuff
They just do it for both client and server
No you're fine. Your mod is a separate entity
Coding mods is like the equivalent of using NMS in your spigot plugin you can still post your spigot plugin right? same goes for mods
You'll find tons of popular open source mods on GitHub
In fact, the modding community is a hell of a lot more open source friendly than Bukkit's developer ecosystem
Quark is a mod by Vazkii
Seems most mods are open source
if I create a PotionEffect with Int.MAX_VALUE as the duration, will it work? minecraft commands only allow up to 1 million seconds
You can use -1 to use infinite duration
ty
prob cuz all the weird premium plugin devs
(1.19.4)
MAGIC VALUEEEEE
Not even that. There are far more closed source free resources
i don't even consider -1 a magic value, it's used so frequently everywhere that it's kinda second nature at times
could also have to do with barrier of entry being lower therefore a lot of plugin devs may not even have a github account or something like that too
I know initially I started plugins a bit before I even had github only reason I got it and started using it so early on is because I had someone teaching me java while coding so he taught me how to use github
^
I think modders are more mature than plugin developers, so yeah, I partially agree with that
I don't think it's the misunderstanding of Git, I think it's the ability to recognize that you're using an open source library, your code should probably also be open source
what
modules are infertile 😦
hmm you can choose what modules are getting compiled in your final jar right?
I'd say it's because of the nature of mods.
People generally have to put more effort into installing mods than plugins. Therefore only "good quality" mods are installed.
For plugins it's easy to just install anything and if it's not good enough uninstall it again. Costs you like 1 minute (excluding the testing time)
well the parent has packaging pom right?
I mean if you compile the parent, all child modules are compiled
yes
What is shaded into what depends on what modules depend on one another and what ones are shaded into each other
you usually create a dist module that depends on all other modules and shades them
You have cli, benchmarks, and core. If your core module depends on your cli and benchmarks module and shades them, when you build it, it will contain those two modules
Think of them all as separate projects
Because they are
well the cli module should call a method from the core module, is that considered depending on?
yes, cli depends on core
same for benchmarking actually
you just include all the modules you wanna have in the final jar as dependency
so you create a dist module that depends on core and cli, and shade those
isnt there a cleaner way? 🥲
how is that not clean
yeah well that's how it works lol
is it normal that it creates 3 different jars when not using your dist module?
wdym? it creates one .jar per module
then you create an additioal dist module
that shades all your other .jars into one final .jar
Shameless example https://github.com/PikaMug/Quests/tree/main/dist
chatgpt telling me i should put the maven shade plugin in my core module to shade all modules into one jar, except the be,chmarking module
idk whether to trust this stuff
is there something like scheduler.runTaskTimes(plugin, runnable, delay, period, times)?
or how'd i implement that
probably should clarify the purpose, i'm making a timer where i'm sending a player titles like 02:00, 01:59 every second
so i know exactly when the scheduler should stop executing
just use the consumer<bukkittask> one
and keep a counter
id make a new class for that
can you give an example of how'd i use the consumer? i don't think i've ever dealt with those
well it supposed to work like
runtasktimer(plugin, task -> { some stuff here, task.cancel() }, delay, delay)
so you call cancel and the task stops itself
hmm
Bukkit.getScheduler().runTaskTimer(this, new Consumer<BukkitTask>() {
private static final int MAX_TIMES = 100;
private int times = 0;
@Override
public void accept(BukkitTask bukkitTask) {
times++;
if(times >= MAX_TIMES) {
bukkitTask.cancel();
}
}
}, 20, 20);
if you want a counter in that the lambda will complain about non final stuff so ye new class
or do that ugly stuff
buy a decent book
New classes will definitely look nicer, but you could also do an anonymous inner class
new BukkitRunnable() {
private static final int MAX_TIMES = 100;
private int times = 0;
@Override
public void run() {
if(times++ >= MAX_TIMES) {
this.cancel();
}
}
}.runTaskTimer(this, 20, 20);```
isn't that exactly the same as I send, char by char lol
You used a Consumer
this, sorry
idk I only read german books about java
someone in a company recommended that book to us
so i just bought it
ill see if it teaches me anything useful
but atleast i can say i have a java book then 🥹
I'd only really recommend getting a book if you're a book reader. I got a book on C++ I think a while ago but I just... can't bring myself to read it
I read in a few pages then gave up
I learn way faster through online resources
I read all the books I needed to in high school lol
i like reading books 🥲
well that sounds like a you problem
I liked reading until highschool something about being forced to read shitty novels by some random people in the 1800s really took the reading thing away from me
Only book series I read voluntarily was the Harry Potter ones
Didn't care really for any others
I just don't like reading at all. It's too boring for me lol. To each their own'
yeah, and now you read code all day
reading is boring
Weird how that works, isn't it?
It's not like I'm incapable of reading ;p I can read rather well. In two languages no less. I just don't really like it is all
wordpress
wait u a lawyer fr?
yes
awesome
or boring i guess? idk, you probably chose to become one because its awesome
oh it depends. sometimes it's quite boring, but often extremely interesting. even in the weird field I chose, which is tax law lol
can i evade taxes legally
cya
oh my fucking god if i have to delete a trailing comma in a json file one more time
is there a function in gsonbuilder to allow this stuff
setLenient doesn't seem to
class [I cannot be cast to class [B ([I and [B are in module java.base of loader 'bootstrap')
tf does this mean
context?
Hello I need some help
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!
thnx
?
I am new that's why
so.. ask your question?
yeah
what do you need help with
?help
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous names and nicknames of a member.
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
alex

is your brain okay
will something bad happen if i change language level from 9 to 16?
spoken like a true programmer
you use ?ask daily how do you not know
thanks!
shouldn't
there are
?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!
?justask
?nohello
since when did we have a just ask
we need that link on the ?ask too
it's spammy enough
yeah someone open a merge request
simply ping imajin
will i die?
no
then i don't want to
did we scare away quantumgamer420
i was excited to see the question

no wheeze tao
man I love checking all the conditions under which the inventory can not be renamed
this is fun
table in 9 months: 🫄



Preconditions.checkArguments Preconditions.checkArguments (╯°□°)╯︵ ┻━┻
@hazy stirrup please ask
we want to know
wait
take your time
?ask I want to access config from another package. How can I do that? Here is my Main Class ````package org.precious.test.testplugin;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.precious.test.testplugin.commands.Heal;
import org.precious.test.testplugin.commands.Shout;
import org.precious.test.testplugin.handlers.Torch;
import java.util.Optional;
public final class TestPlugin extends JavaPlugin {
public FileConfiguration getConfigFile() {
return config;
}
FileConfiguration config = getConfig();
private static TestPlugin instance;
public void onEnable() {
config.options().copyDefaults(true);
saveConfig();
Bukkit.getLogger().info(ChatColor.GREEN + "[Test Plugin] TestPlugin Is Enabled!");
getCommand("shout").setExecutor(new Shout());
getCommand("heal").setExecutor(new Heal());
new Torch(this);
}
@Override
public void onDisable() {
Bukkit.getLogger().info(ChatColor.RED + "[Test Plugin] TestPlugin Is Disabled!");
}
public static TestPlugin getInstance(){
return getInstance();
}
}````
Here is my another class:
public class Torch implements Listener {
public Torch(TestPlugin plugin){
Bukkit.getPluginManager().registerEvents(this, plugin);
}
@EventHandler
public void joinEvent(PlayerJoinEvent event){
Player player = event.getPlayer();
String PlayerName = player.getDisplayName();
event.setJoinMessage();
}````
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!
add a classs private final var for your plugin
text wall
why did you add ?ask to the beginning of your question lol
?paste anyway please use this in the future to paste your code
you told to use that
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!
that i used to tell you what to do
might want to read it
oh
can you provide a code or that I didn't understood
public class Torch implements Listener {
private final TestPlugin plugin;
public Torch(TorchPlugin plugin) {
this.plugin = plugin;
}
@EventHandler
public void onJoin(PlayerJoinEvent event) {
String configStrng = plugin.getConfig().getString("path");
}
}
?learnjava!
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming. https://media.discordapp.net/attachments/694661573125472256/998143126373941248/6n0v4g.gif
ty
ty
how can I have maven make a release build with assertions and a debug build without assertions
or something similar
if (MainClass.isDebugMode()) {
doThat™️();
}
the best bet you have to do that automatically is just only making them apply on a debug if
i use a lot of them for sanity checking
ohhhhhh
cool
so then its not possible to strip them from my plugin
it just depends on if the server is in debug mode?
You should not do that
assertions basically have no purpose on runtime but still produce overhead
they have purposes for me?
i find use for them
and i want them to be checked at debug time
and not at release time
asserting stuff in development just sounds like a bad idea
but thank you this helps alot
literally the entire point of assertions
well I know it isn't null
if it is null something has gone seriously wrong
and its not something that could be fixed at runtime
if i don't fix it during development time
asserting is for stuff where u know it will never be null, as it's being retrieved from an external source or smn right
i just never use it
yes here I know these things should always be true
to make intellij stop bugging me thats pretty much the only use i have
so if they aren't true something is seriously wrong
and there's nothing I could do about it at runtime
assertions is for internal checks only. Never assert something from external sources.
if its a method var you can use @urban grotto
im aware
smh not null pinged again
I'm almost done with this api lol I am testing weird things to see if it breaks
they deserve it maybe they shouldn't be named after a popular Annotation
sorry null
they deserve it
its like if there was a lombok fanboy in here named @NonNull or something
or @Getter or @Setter
guys I'm so close to making inventory titles work without being scuffed as fuck
I don't think I've been happier to see an exception in my life
java.lang.IllegalArgumentException: Only creatable inventories can have their title changed
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:145) ~[guava-31.1-jre.jar:?]
at org.bukkit.craftbukkit.v1_19_R3.inventory.CraftInventoryView.sendTitleChange(CraftInventoryView.java:85) ~[craftbukkit-1.19.4-R0.1-SNAPSHOT.jar:git-Bukkit-19de355]
at sh.miles.testplugin.TestPlugin.lambda$onOpen$0(TestPlugin.java:52) ~[?:?]
at org.bukkit.craftbukkit.v1_19_R3.scheduler.CraftTask.run(CraftTask.java:77) ~[craftbukkit-1.19.4-R0.1-SNAPSHOT.jar:git-Bukkit-19de355]
at org.bukkit.craftbukkit.v1_19_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:414) ~[craftbukkit-1.19.4-R0.1-SNAPSHOT.jar:git-Bukkit-19de355]
at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1211) ~[craftbukkit-1.19.4-R0.1-SNAPSHOT.jar:git-Bukkit-19de355]
at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:375) ~[craftbukkit-1.19.4-R0.1-SNAPSHOT.jar:git-Bukkit-19de355]
at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1158) ~[craftbukkit-1.19.4-R0.1-SNAPSHOT.jar:git-Bukkit-19de355]
at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:983) ~[craftbukkit-1.19.4-R0.1-SNAPSHOT.jar:git-Bukkit-19de355]
Ok, I'm having some trouble getting the plugin messaging to work. I set up the plugin messaging for my main class and now I'm trying to add an outgoing message for an on click event but I'm getting an error where it's not registering my plugin in the line. I've tried importing the plugin and creating a dependency but nothing seems to be fixing it anyone know what's going wrong?
https://pastebin.com/G9qtMVkp - Main
https://pastebin.com/iS5Hr2jk - Event
this is not a statement
yes
Hey
How can I get data (from a database for example) asynchrously and get the result in the main thread?
I've tried with CompletableFuture but the thenAccept or whenComplete do not specially run in the main thread.
I've seen that a method exists Bukkit.getScheduler().getMainThreadExecutor(plugin) in newer versions but not in 1.8. Is there any other way to get the mainThreadExecutor in 1.8?
cant you do some fancy classloader hooks?
yes
idk if bungeecord is aware of its subservers
does'nt seem like it
probably is lol
You can't really return result without blocking main thread
maybe you can do something hacky
There would be no point in doing async that way
i'd imagine the following
make a spigot plugin that's installed onto every of your spigot servers
when it's being disabled, send a message to your bungee plugin
why though
this sounds like it'd work
hacky? maybe
How can you make less impact of getting something from a database without affecting the tickrate?
Thank you I got it to work
Sounds like xy question, why do you want to return value to main thread
Altrought getting things from dB shouldn't effect ticks thatuch
Showing the result in an inventory
inventories dont need to be on the main thread do they?
You can get items async -> use BukkitScheduler#runTask to run from main thread
If I do that in another thread, I get the net.minecraft.server.v1_8_R3.CancelledPacketHandleException
i'm sorry that you have to work with 1.8
maybe
I know, that's a shitty version but I don't have any choice
but you won't know exactly when it's shut down
yep that's why i'm sorry (i love the version, but the api sucks ass)
only approximately
what
aren't there something like schedulers
in bungee
well if you don't care about exact precision then it's fine
sure
yeah i understand what you mean lmao
i'm just not sure if that's as precise as sending a message from spigot
but again if a 50ms margin is fine for you then it's a good approach
because 20 ticks per secod
pinging the server 20 times per second is pretty useless imho
isn't once per second more than enough?
tbh i still like my approach more
it might be heavier to setup but it feels slightly less clunky
Tbh I would say that even 30secs is okay lol
How can i let my plugin start before a other plugin?
loadbefore is a plugin.yml field i think
any way to make my title not flash like that?
fadein fadeout?
oh perhaps
🤝
set fadein to 0 ticks
I'm trying to get entity default loottables, this is my attempt and this doesn't give me the items and I'm stuck here. The entity that I tried is a pig.
public Collection<ItemStack> getLoot(Entity entity) {
LootContext context = new LootContext.Builder(entity.getLocation())
.lootingModifier(1)
.build();
LootTable lootTable = Bukkit.getLootTable(entity.getType().getKey());
if (lootTable == null) {
return Collections.emptyList();
}
return lootTable.populateLoot(this.random, context);
}
LootTables.valueOf(entity.getType().name()).getLootTable();
but you'll need special handling
What do you mean by special handling?
p much
I don't actually know why LivingEntity isn't Lootable
Wonder if that's possible
I suppose realistically it's EntityType that should be Lootable but meh. Bukkit structures entities weirdly
Yeah, so Entity would need to be
public MinecraftKey getLootTable() {
return this.getType().getDefaultLootTable();
}```
Then overridden by sheep, obviously, to account for type
Definitely something we can add API for
Thanks for the help by the way.
is there a way to change a native minecraft recipe? know i can register a new recipe by doing Bukkit.addRecipe(), but i want change a minecraft pre-existing recipe, more specific the axe recipe: i wanna add an attribute modifier to the result, is it possible? i tried adding the same recipe but with a different namespacedkey because register an existing key will thrown an exception, but it didn't work
Definitely, we should do something about it.
the easiest way to handle this is just use PrepareItemCraftEvent and doing basic detection
public Collection<ItemStack> getLoot(Entity entity) {
if (!(entity instanceof Lootable lootable)) {
return Collections.emptyList();
}
LootContext context = new LootContext.Builder(entity.getLocation())
.lootingModifier(1)
.lootedEntity(entity)
.build();
LootTable lootTable = lootable.getLootTable();
return lootTable.populateLoot(this.random, context);
}```
That simplifies your method a little
I'd still try to fetch data even if it's not lootable
Why? Anything that isn't Lootable won't have a loot table
just to make sure there's no funky hidden table
If there is, it's a Bukkit bug
Ah, so I don't need to do the sheep part anymore?
Nope
i have an issue on paper 1.19.3/4
?whereami
Ah alright, thank you so much ImIllusion and Choco.
I'll test it right away.
ok

is stmt a PreparedStatement
yes
stmt.setString(1, 1stString) should exist
H2 makes use of Java's SQL API afaik, so the only way setString() wouldn't exist is if you've declared the type as something more generic
Like Statement instead of PreparedStatement
[10:03:58 ERROR]: Could not load 'plugins\GA.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:150) ~[patched_1.12.2.jar:git-Paper-1620]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:136) ~[patched_1.12.2.jar:git-Paper-1620]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.loadPlugins(CraftServer.java:318) ~[patched_1.12.2.jar:git-Paper-1620]
at net.minecraft.server.v1_12_R1.DedicatedServer.init(DedicatedServer.java:222) ~[patched_1.12.2.jar:git-Paper-1620]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:616) ~[patched_1.12.2.jar:git-Paper-1620]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_361]
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
... 6 more
thats the error i get
Jar does not contain plugin.yml
create a plugin.yml
show plugin.yml
there is none
it has the plugin.yml
no
is it in the correct path?
src > main > resources > plugin.yml
It probably has one but isn't being exported
Or it's in the wrong spot
are you using maven or gradle?
prob
what ide do you use
lemme send a screenie
!verify
Usage: !verify <forums username>
Ops I can’t here
?img
Not verified? Upload screenshots here: https://prnt.sc/
you need to get verified ^
egitto what IDE do you have
Eclipse
mistake #1
?
Why
Idk
do you have a pom.xml? do you have a build.gradle file?
Omg idk guys
CHECK
I where
how do you build your .jar?
Where
With eclipse
in resources i think
are you using file -> export?
Yes
then you have to tell it to export the plugin.yml there somehow
Where is your plugin.yml located
then no maven nor gradle
Wait lemme dm u the screenie
If you are exporting directly it needs to be in the root project folder
it'd be easier to switch to maven or gradle than to use eclipse's export .jar feature lol
should this work?
Omg I don’t get into this stuff, so how do I get verified so that I could send this screenie and explain?
!verify
Usage: !verify <forums username>
!verify
Usage: !verify <forums username>
Do you have a spigot account?
have a spigot acc
you can just right click your project and convert to maven
!verify Egitto
Could not find your SpigotMC.org account!
lmao
Omg do I need an account?
That's why we ask first.
Lmao
yes
Ok lemme do an account
10 years later
should this work? lol
?tryitandsee
?tryitandsee
i think i need to delete stmt.execute
fuck
?tas
just ask gpt to convert to prepeared
is the nms version for 1.19.4 1_19_R3?
yes
Yes
yes
thanks
!verify Egitto
A private message has been sent to your SpigotMC.org account for verification!
BRO GOT IT YEEE
src > main > resources > plugin.yml
IIRC, the plugin.yml should be in your src folder.
yep
I use maven, haven't done the old method in a while now. :p
no
yes
In poor words?
no he's not using maven nor gradle
like this:
all he does is move plugin.yml into src folder and he's good to go
he can listen to this song while doing it https://open.spotify.com/track/0s7tl4FviuOCDiAomIrIHn?si=0e42d22e5be34b3e
So I have to put them in the resource folder?
yes
y e s
no
wait what
