#help-development
1 messages · Page 83 of 1
TRAPDOORS TAKE 0.8125
public void flushAllWorlds(){
NightWatch.getInstance().getLogger().warning("Flushing all worlds!");
int outOf = getAvailableWorlds().size();
int successful = 0;
for(World w : getAvailableWorlds()){
w.save();
if(WatchUtil.deleteDirectory(w.getWorldFolder()))
successful++;
}
NightWatch.getInstance().getLogger().info("Successfully flushed " + successful + " / " + outOf);
}
public static boolean deleteDirectory(File path) {
if (path.exists()) {
final File[] files = path.listFiles();
for (final File file2 : files) {
if (file2.isDirectory()) {
deleteDirectory(file2);
} else {
file2.delete();
}
}
}
return (path.delete());
}
ye I understand. But what are you trying to achieve? like what do you wanna do? Do you actually need those values?
i dont even know anymore mate
💀
intellij shows that the method is being used
so im guessing its important
plus if i remove the method the file goes from 1126 to 642
i think
check where it is used then?💀
Ok ok I'm on my phone so I can't open the .java file. What does the huge switch method return?
this method is used to change the npc's Y
uh
Hey, how can I create a sphere in Minecraft with armor stands?
ok so -1 when isBlock() is false.
Next?
wait so all the 0.xxxx is hardcoded? 💀
yes 😭
Spigot has api for this 1.19
i had no clue
You can get the bounding box of a block
declaration: package: org.bukkit.block, interface: Block
just when
oh my god
rope time
"This isn't exact"
LETS GOO
I LIVE ANOTHER DAY
also lemme clarify another thing
this method isnt JUST for each block
huh
What is the goal here?
change npc y level 💀
he doesn't know 💀
ive edited the files so much intellij refuses to show me usages
I know a hacky workaround that I'd love to see implemented but it's dirty af 💀
Then use the method I sent
"This isn't exact"
Well that's because it's a box
yeah
Want the exact thing use https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/Block.html#getCollisionShape()
declaration: package: org.bukkit.block, interface: Block
the workaround this maniac used
was hardcode each value
for each corner
for each block
and each one of their blockdatas
honestly i might as well just use citizens
hey how to make player.setCooldown() cooldown itemstack not material?
Got a better idea
what 💀
You create a file to save all of the blocks and states and heights and also the servers version.
Then for each new version (or when file empty or whatever) you iterate all blocks and states to update the values by (now the crazy part) - spawning each block in each state and dropping a snowball on it. Then when the snowball hits the block you check it's y-Level
I'll just check which chunks the player can see from that location, and send them in as ghost-chunks
Use the method I sent ._.
fuck google and its shit fucking SEO
Or use Citizens :p
fucking sucks
stupid fucking idiot
this was all i needed
Will take like a minute per update (or you serve it from a database and run it with each update)
and google decided to put this on the second fucking page
second page on google💀
Google is best
look at the project
no don't say nickelback
can someone help how to add cooldown effect for itemstack?
Bro is having a mental breakdown
brother
the terminator project
it makes the npcs
as human as possible
it uses the same exact algorithm
this shit fucking 1.8 project uses
AND ITS 10X FASTER
PLUS ITS UPDATED
and the guy who made it is a youtuber
with yt rank on hypixel
so it also hardcodes everything?💀
pls let it be the snowball method 💀😂
im actually intrigued
how DOES this guy get the lowest block
ALSO
wanna know how good terminatorplus is
so um, I had this bug with minecraft where any versions 1.18 and above would freeze every 1 second, meaning the graph would be some thing like this:
300 -> 1 - 250 -> 1..etc
so well i used some jvm args i got recommended which ill send later,
and that fixed it, however after 3 days the bug is back, but i realized something, when the bug was fixed i had 2gb allocated and it was using 2.7gb, but when the bug still existed it was using 2gb flat, so i thought maybe that was the problem, i just tried allocating 3gb or 4gb and no luck.
the jvm args are here: https://pastebin.com/3mK9yZFf
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
look on youtube "1000 dream speedrun horsenuggets"
I'm on vacation chilling in a pool reading #help-development . I don't wanna watch a video now 😂
he replicated dream's playstyle 💀
I've told you what to do
yeah but you're not horsenuggets
sadly
alr imma stop using #help-development as #general
Happens atleast 10 times a day anyway
You know he isn't getting the height. He's letting vanilla take care of that
They do if you use the tick method
aren't packet npcs non existent for the server? How would he use the tick method
yes
packet npcs are entirely clientside
even citizensNPC
to give them gravity they get the block under the npc
ye that's easy
and make yo
oh my god
how did i not see this
they take an armorstand 💀
make it fall 💀
and get its height 💀
i didnt know what that is
they dont make the armorstand render to the player 💀
so it doesnt lag you 💀
Does anyone know how i can fix these errors: https://paste.md-5.net/ohaqisewag.sql
im coding in 1.8.9
is there anyway to using player.setcooldown for itemstack?
and the server java version is 8
second option then
and how?
set the compile version in maven
nah 1.8
Hey, I want to make a sphere map generator. How this works is that you can enter a string (ex. ## # # #) and it will generate the required armor stands and wrap it around a sphere. How can I do this?
the sole number changed with v11 iirc
wdym
like that
ye
k
probably using packets
Any ideas?
still the same error :/
you want to do what
hmm
might have to downgrade your java version then. Install jdk8 and use it for that project
Hey, I want to make a sphere map generator. How this works is that you can enter a string (ex. ## # # #) and it will generate the required armor stands and wrap it around a sphere. How can I do this?
I literally replied to this text anyways
make sure you actually recompiled using mvn clean package before starting to downgrade tho
No. Cooldowns are per material not per ItemStack
Thank you for the elaborate reply.
Perhaps I should call it "observer input", but I meant just working with listeners, to get a good routine in. I guess it derails into general java practices, and not spigot specific things. I was just wondering if there is a "standard" among plugins, kind of like a boiler plate. (excluding the docs and the Intelj plugin)
Just use sin and cos
Math time :)
Yes there is some boiler plate. Like the plugin.yml, the registration of commands, registration of listeners in onEnable aswell as the onDisable
plugin ideas?
theres a forum place for those i think
people submit plugins they would like to see made
I refuse to go there
you wouldnt get it
Hi, i want to start learning how to make mods. Should i learn fabric or forge?
Fabric is cleaner
mixin is pain
Ok thx. Ik this isn't related to spigot but thx anyways
so um, I had this bug with minecraft where any versions 1.18 and above would freeze every 1 second, meaning the graph would be some thing like this:
300 -> 1 - 250 -> 1..etc
so well i used some jvm args i got recommended which ill send later,
and that fixed it, however after 3 days the bug is back, but i realized something, when the bug was fixed i had 2gb allocated and it was using 2.7gb, but when the bug still existed it was using 2gb flat, so i thought maybe that was the problem, i just tried allocating 3gb or 4gb and no luck.
well then i tried reinstalling minecraft and other things, even with the bug existing i get 2.7gb usage, but that doessnt do anything.
the jvm args are here: https://pastebin.com/3mK9yZFf
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I don't see how this is dev related, but are u using some kind of container hosting (pterodactyl or wisp for example)
check timings
i had 2gb allocated and it was using 2.7gb
this made me think you are using container, if that is the case you should remove-XX:+AlwaysPreTouchflag
as it preallocate all ram and makes container freeze
if you are not using container hosting, you should do as FourteenBrush said
what even is this
no i dont use that
how?
idk what a container is
nvm then, check timings
yes actually, my ram gets preallocated, since when i start the game it's instantly 2gb
/timings enable wait few minutes and /timings paste
anything about client side lag shouldnt be asked here?
well where do i ask then? not many people are knowledgeable about about jvm args and such
except in coding servers
youre just saying your fps is dropping every sec?
hmm got something related where i only had 2 fps on a good gpu for a while
thats why im sure its not about my pc
other servers?
yeah then i woner why it's only in 1.18 and above
i tried in single player
same thing
its even in the main menu dude
did you have the thing that the animation in the main menu is stuttering?
hoping thats an english word
I bet it was an AMD gpu
jk
had it on both my gpus
yes
the game freezes
though, i get 300 fps after it freezes
then boom
back to 1 fps
and its only in minecraft 1.18 and above
like this? #general message
No
for me it like
the animation is silky smooth then
it freezes completely
then continue
then freezes
does anyone know how i can change my jdk in intellij
thx
Why so many Java 17 installs
cuz they have bugs and i needed to take another one
like assertion errors in the C code :/
I just replace the existing install
still gives me the error
wtf
are you sure you are rebuilding the jar and that you are updating it on your server?
Hello! I wanted to make my armor stand's head pose match the player's pitch and yaw and this works:
armorStand.setHeadPose(new EulerAngle(Math.toRadians(playerLocation.getPitch()), 0, 0));
but I don't understand why it does. How can it be the good yaw if I don't provide it?
you might be spawning the armorstand at the playerLocation
which passes the yaw internally
yeah but isn't the head pose independant to the armorstand's entity rotation?
it's relative
how did this happen
maybe your api version is out of sync with the server?
like
if you import the server jar directly
will that method exist?
🤔
that doesn't sound like it makes sense
It’s been a really long time since I have and I don’t have a computer at the moment to try and code the player hiding in parallel with you test it out, I’m sorry
how do i include a gradle module into a maven project
it's not happening on my server, dude says he's running 1.17.1 paper
guess I'll go ask them
maybe it's just not a thing on 1.17.1 🤔
try catch
it doesn't exist on paper 1.17, it was added in 1.18
Multimap<Attribute, AttributeModifier> defaultModifiers = ArrayListMultimap.create();
try {
defaultModifiers = type.getDefaultAttributeModifiers(EquipmentSlot.HAND)
} catch (NoSuchMethodError expected) {
}
type deal
fantastic
so I'm guessing it also wasn't on spigot back then
well that's a bummer
what did exist back then?
actually it was added in 1.18.1
do you have a link for a 1.17.x api page that I can check out?
for paper or spigot?
spigot
package index
I'm good, I was looking at it again and I should be using the attributes from the item meta anyway
which did exist back then
figured what out? Didn't you say they drop an armorstand like an hour ago?
hm actually should I? this is going to take some testing
iirc the attribute modifiers on item meta did not include the default modifiers?
maybe not
try
new ItemStack(Material.DIAMOND_SWORD).getItemMeta().getAttributeModifiers()
Death or respawn event triggers first?
imagine respawning before dying
Not like that
Under spigot 1.10 its like that ahahahahahh
Not sychronized
well maybe it's just time to tell people to update
there's about 5% of people using this plugin on a version older than 1.18.1 anyway
▶️▶️▶️▶️__1.1__◀️◀️◀️◀️
Its 1.10 are you coming from monkey?
i love minecraaft new versions
Slanderer
a bugs generator!
ive encountered more bugs with the new versions than with legacy ones
would it be possible to use class as one of data parameters in enum
like this
so XpBottleAsset and CashNoteAsset extends AssetExetnsion
private final Class<?> clazz;
for example
I would need to be able to have getter
so I can loop thru all values
of enum
and make instance of each class
XpBottleAsset and CashNoteAsset both extend AssetExtension?
yeah
so you want a getter to get the corresponding extension?
yeah
your mom sucks

Wtff
Well both probably wrong statements
ok thanks
Why he told my mom sucks for no reason
I guess if you start throwing baseless claims out into the wild
others are bound to appear
Ok
how dare you to summon me
Your mom also sucks brush guy

i figured out A*
and how to spawn npc
and make them move in a quite goofy fashion
https://paste.md-5.net/lavesuhico.cs
Why is this not working.
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
because it's trying to drop it at -200 y? it will just despawn
also dont get the world twice
no its working in my other projects
that not the point
what is line 35 in your main class
you are trying to get index 244 while array length is 14
Caused by: java.lang.IndexOutOfBoundsException: Index: 244, Size: 14 at java.util.ArrayList.rangeCheck(ArrayList.java:657) ~[?:1.8.0_212] at java.util.ArrayList.get(ArrayList.java:433) ~[?:1.8.0_212] at de.itembingo.main.randomItem(main.java:35) ~[?:?] <------------------------------------------------------------------------------ at de.itembingo.commands.TestCommand.onCommand(TestCommand.java:16) ~[?:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[server.jar:git-Spigot-db6de12-18fbb24] ... 15 more
your randomItem impl doesnt work
why are you using unparametized arraylist
yeah your arraylist is not big enough for the length of Materials
so many things wrong there
all about this method is scuffed
is that the itemstack constructor with an int as data?
true
also looks like that constructor is deprecated
dont even have that constructor anymore
im trying to get an random string out of my config
but i dont know how
xd
so i tried that
lol
look, you are making list out of 14 entries in your config, after that you try to get random element from that list which length is much more then 14
save the Material::name()
mhm, but how did you came to the idea to use Material.values() as your bound?
of course you would get outofindex
well..
^, you should use length of your stringList from config
as bound
and instead of instantiating a new random every time, use Random random = ThreadLocalRandom.current()
and find different way to implement it, other then using deprecated constructor
that will probably work if provided with a magic number
probably the material id ot smth
before that it was just a random item from material.values
Honestly
in most cases you want to use the ThreadLocalRandom
not its parent
it allows for more uses but in this case it probably doesnt matter
only use Random if you need a custom seed
why
it has a better performance
fourteen brush
the reason I said that
is because you're using the superparent of ThreadLocalRandom
it doesnt
thought so
its literally the same only that for multithreaded design you should use ThreadLocalRandom.
also ThreadLocalRandom saves the instantiation of a new Random object everytime. the only advantage Random has is the custom seed you can invoke
instead of
Random random = ThreadLocalRandom.current();
you would use
ThreadLocalRandom random = ThreadLocalRandom.current();
Because
nextInt(int origin,
int bound) only exists in the class ThreadLocalRandom, not in its parent class
you dont need that?
though in this case it doesn't matter, since you dont really need an origin
with a list that starts with 0
you need an index from 0 to size - 1
thats to much for me xd
however if you use the Random type, you cant specify the origin for the random number
itll always start from 0
im im the learning process of java and i dont know what a "superparent" is
there is no superparent
yeah i mis typed that
then you just do random.nextInt(max) + min or smth lol
got a small issue, so im setting a buyPrice and a sellPrice. since a double can't be null ive made transaction handling BigDecimal. now the issue is when i get the config section SECTION#get() which should return an object it keept returning a double, class java.lang.Double cannot be cast to class java.math.BigDecimal any reason why?
its set as a double so it returns a double?
yaml doesnt know how to serialize a bigdeccimal
Im not getting it... How can i choose a random String out of a config stringlist
list.get(random.nextInt(list.size()))
-1
Maybe BigDecimal.valueOf()
makes sense thanks.
https://paste.md-5.net/igesekoweq.js tf wrong with that switch? all good with elseifs
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
would not work, double always returns a value and i need to check if its null 🙂
Upper bound is exclusive
ye im looking for tha error
this is still unsolved, just in case someone knows the solution ~
btw config.getString("items." + item + ".type") equals command
like this?
no serializing/unserializing should happen
about thing you have sent me
I got small problem
don tell me i forgor to break;
there are no breaks in that switch
shouldnt it like umm
end anyway? cuz that doesnt match next cases
or it uses last as default maybe?
o i can use the lambda switch
Explain your problem pls
Hey, so, what I'm trying to do is calculate a sphere (which I already did) and wrap a map around it
How would I wrap something around a sphere?
meh
it is part of enum and should be taken from enum
(as in changing the color of the armor stands using a string map like # ## #)
What do you mean by wraping a map ?
first thing i may think is using a bifunction string, plugin instead and ignoring the string in some cases
kinda sucks
enum isnt ideal
I think I got better solution will just put string in PlayerPointsHandler class
someone got a whitelist plugin?
and add getter to AssetHandler for id
Go to #help-server
It's built into Spigot
or weaken the access of the function and call the function::apply method
outside of the enum hmm no wont work
i need to reload entire server for it to work
Hello, i have problème with my api
?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!
dessie beat me
(as in changing the color of the armor stands using a string map like # ## #)
means black and space means default color
Is there an event for when the player spawns in after death?
What is the context ? What are black and space ?
PlayerRespawnEvent perhaps?
Than kyou
What??
Black is a color and space is a key
Explain your project 😂 you literally say : i created a sphere (where ? How ? What ?), And i need to wrap a map.
How do you want us to help you?
will this work
?tas
If it's red, it's not good
please store that list as a variable lmao
and use the generic version of the arraylist
how
List<String>
I literally explained whatever you needed to help, is there anything else?
Full tutorial for using Generics in Java!
Generics in Java can be very confusing for beginner Java learners. Generics are one of the coolest features in Java, but the syntax may not make a lot of sense at first.
In this beginner's Java tutorial video, we'll talk about why generics exist, why they are useful, and all the ways you can use generi...
I created an api and I store the list of my players. When I call the list but in another plugin, the list is empty. Have you idea ?
Honestly I have no idea what you mean either
😮💨
is custom player
There isn't even a context 😔
Some code or a picture of what you're trying to accomplish would probably be helpful
Okay wait a minute
How do you call the list ? What manages the list ? Is it a static class, a static list ? Paste your code
ok
welcome to #help-development
my brain is not working
i can't put picture
?paste
You need to verify
watch the vid i sent
You'd have to understand basics of ArrayList before using them
array list is an generic class, look that up on google
does that mean my arraylist can be a set?
or a player
or a dog
why not a cat
^
a giraffe
i have 3 and a half
like this?
does the half one on my wall count?
wtf
Question. I created a public void in my main class to process specific events(not return things just process them). I then tried to access this class from another file to use it and it says I can't access it in a static environment without making it static. Is their a way to get around this? my reference code is TimeBoundItems.setEquipmentPacketProcessor(new allEquipmentPacketProcessor()); by the way
Yes
then i have 7 1/4
Nice
When it's red, it doesn't work. Try hovering the error
cuz cat always sits on my keyboard
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
I personally suggest you to learn java first
I also have a pet goose /njk
yummy
is there a cool method to format seconds to hours minutes and seconds but for example without saying 0 hours and shit?
dynamic kinda
use a Duration and handle 0 cases yourself
@hasty prawn are you a wizard ? Please explain me that sphere map image
Oh did they DM you the same image? lol
Yeah
He didn't understand the image, and since I'm not a good explainer, I thought he could ask you
# ## defines where the color goes in the sphere, when there's a hash, it's black in the sphere, when there's a space, there's a space of color in the sphere
So your list doesn't contain the same stuff that other plugin ?
i can infitlty press that lol
that is a golden image
Ohhhhhhhh
Thx
why are you loading the list twice
In my api, my list has all player connected, but in another plugin this list is empty
I don't like to say this, but learn java. You've reached a point you'll have to learn before continuing
Same server, same time ?
yes
Are you sure you haven't shade your api in the plugin ?
shade ?
Include the class of api in the plugin using it
ohhh yes
Hey so I need to set up a scheduler for multiple instances of cooldowns, delays, and so on. I could make a jank one myself, but because each player on a server will probably have multiple instances of schedulers allocated to them, I was wondering if anyone has a well designed one or knows how to make an efficient one
All you need is a map
Map<UUID, Map<Ability, Long>>
Cooldowns doesn't need a scheduler, it's just a time difference (until you don't want to display some animation)
dont use schedulers for cooldowns tho
alright
What
you don't have idea ?
You should use the scheduler for cooldowns
Yes
If you didn't include the class, then you should try putting the list not static and fetch the plugin instance through Bukkit#getPlugin
But scheduling is part of that process too, often
No ? Just compute the time difference when the command is executed for instance
another plugin
implemented my cooldowns like this
main API
If you want to show the progress or have a sound play when the cooldown ends, you use the scheduler
my fonction
fonction
you janked my KingdomPlayer class
yeah
Don't be doing O(n) lookups like that
then use a task as redempt said
use a HashMap by UUID
heh
I asked this dude to send this image for me, anyway
and whats that supposed to be?
lmao
# ## defines where the color goes in the sphere, when there's a hash, it's black in the sphere, when there's a space, there's a space of color in the sphere
Spherical barcode
my mom is a sphere
why does that matter
im out
the image
still no context
THANK YOU
?
UUID -> and decrease the int each tick or whatever
No
When 0, it's done
Don't do that
So what I am trying to do is wrap this string containing spaces and hashtags around a sphere made with armor stands
for cooldowns?
create your dedicated cooldown class i'd say
Play sound when cooldown down
gud code or shit
just see if it expired using some math every time you query it
Works too
Why not +=
if you want like a timer
StringBuilder 😢
StringBuilder really doesn't matter here
Yes
The output is small enough that it won't make a difference
so im setting up a skills plugin, where you'll have activated abilities and such, these active abilities will have things like durations, cooldowns, etc. Also need to do something like attach metadata to dropped items and players for a specified duration
betta?
Will have a leading space if there are 0 hours
true true
StringJoiner is probably what you want here actually
just do smth like
class Timer {
String name;
Runnable run;
int ticksLeft;
boolean active;
public Timer(String name, int len, Runnable run) {
// ...
this.active = true;
}
public void tick() {
if (!active)
return;
ticksLeft--;
if (ticksLeft <= 0) {
run.run();
active = false;
}
}
}
prolly want to do smth like this
If you don't need to ping players when done, don't use scheduler
And use enderpeal animation to animate your cooldown
um i would need to
how does that one work?
things like ability deactivate notifications for the player
for cooldowns, use some math every query, for timers (like playing a sound when the cooldown is done) use a timer class
It's basically just StringBuilder that uses a delimiter
Which you pass in the constructor
alright
delimiter means separator right?
how will hours be less than 0
Yes
ye
actually initialize your string with ""
because ur checking > 0
so 30 minutes will fail
because thats 0 hours
not more than 0
and the string will be null
Don't do this
i make it a string joiner ill check if it all works
What's the point of that when you could just schedule a delayed task
ok
though that does essentially the same thing as the Timer class
How can i check if the String that getting gettet out of the config is an existing Material
What
Did you mean Material ?
i always create items by having config options for material and shit, initialize meta and the itemstack and then add stuff to meta and connect the modified meta to original itemstack
i think thats how it should be done
Why
yeah sry
You can store an ItemStack directly in config
how does one look?
What
wdym
like how would example one look in config with meta and stuff
Try to get a material from the string, if it exists then it's good but if not it's not valid
Set one and find out
i was too lazy to do all the crazy configs so i just made serializer and deserializer 😴
how xd
Is it easy to develop some sort of a utility that redirects all native MC crashes on Ubuntu Server (you know, the one that gets logged in Spigot.jar root folder as 233564324.log or something)
to folder of my
choosing?
That could be a bash script
Material#valueOf I guess
Material#getMaterial or Material#matchMaterial is better
Definitely
If you use valueOf it will throw an exception if it does not exist
stupid keyboard
bash script that does what?
getMaterial will return null if not found
You can do matchMaterial(String) != null
Which will mean it exists
java -jar whatever.jar
mv $(ls *.log) /path/to/logs```
ok thx
and how can i turn it into an itemstack now
cool! will that include crash.log? since its not the one that goes into /logs/
besides, i am using docker so I was trying to move it as soon as its generated, since when i destroy the container as soon as it crashes, i lose data 😦
is there any way to redirect it ever before its created?
new ItemStack(Material)
?jd-s
they would have to also schedule it no?
Not that I know of
duh im dumb aperantly
dam. would be easier if whole spigot.jar wouldnt already die with it in case of crash 😂
process. i mean
hmm wait
is there any sort of event being called on crashes?
but its one of those internal thingies, i think it is even above paper and spigot
mojang vanilla server stuff? idk
Maybe you could add a shutdown hook to know when it crashes
no on a fishing rod
nice
Yea Runtime#addShutdownHook or something
is this from spigot? or literally linux, lemme see
lol
it will be executed when the jvm cleans up right?
yeah thats the question i guess
wondering what a server crash means on jvm level
if the jvm crashed, no shutdown hooks are guaranteed to execute
yeah it is not even "paper" or "spigot" crash, i assume i ran out of RAM so whole core server of minecraft died
„When the JVM begins its shutdown process, it will start all registered hooks in an unspecified order. After running all hooks, the JVM will halt.“
No more than a System#abort i guess
why is there an error
if u want to u can also do:
ApplicationShutdownHooks.add(hook);
in line 16
it says that its null
1.8 im out
xd
1.8 user with the best java coding ever
or if permission for shut down hooks
Yes 😭
is not on then itll fail as well
securitymanager being null :/
Just make the world a variable smh instead of spelling it out twice
that wont change anything
It changes the code from not being that nooby
You create a null itemstack...
ok wait
fun fact
u can get all the shut down hooks
with reflection tho
cuz the field is private
makes sense
private static IdentityHashMap<Thread, Thread> hooks in ApplicationShutdownHooks
just get the keyset, and there u go its all the hooks
this will work if the file doesnt contains the player uuid?
applicationshutdownhooks??
compare strings with .equals, not ==
and there is a getString
java.lang.ApplicationShutdownHooks
Yes, it will return null if it does not exist.
doesnt seem to exist for me
Oh yea, use equals and not ==
how can i fix that xd
im new to java and spigot
if (blablabla.getstring().equals(blablabla))
If you're checking for a UUID in a YAML file, you're probably going to want to use UUID#toString(). That is, player.getUniqueId().toString(). Also, don't forget to check for null.
string getting concatenated
Do not do this
?
why is it still returning null
it is possible to create a section that contains the uuids instead of this?
what exactly do you wish to achieve there?
don't do
config.getString().equals("something")
do:
"something".equals(config.getString())
(the answer is most likely yes either way)
the last one will not throw an npe
yes yes i was saying to use getString and equals smh
though you should reverse it to not get an npe
can't you just do java ItemStack itemStack = Material.getMaterial(randomItem) == null ? randomItem() : newItemStack(Material.getMaterial(randomItem));
2hex always showing up to say smth and then disapearing
huh how
Or even better
you cant
that will pretty much throw an npe
"".equals(config.getString("daddy"))
why should it
UwU
sussy
oh actually nevermind
yeah nevermind that will work
i smell alot of bad practice here
Not NPE but maybe a StackOverflow
If the config su**s
why a stack overflow?
If there is no valid material
even shorter
return Material.getMaterial(randomItem) == null ? randomItem() : newItemStack(Material.getMaterial(randomItem));```
Infinite loop
just rewrite the damn thing lol
Is there a way to get the source location (or entity if possible) of ClientboundSoundEntityPacket (PacketPlayOutSoundEntity)? I don't want to use protocollib
looks ugly asf and you dont multiple methods
is that inside randomItem()?
thats the point
but then what is getRandomItem() ?
Minesuchtiii, is the code you sent inside randomItem()
That fetch the config and get a random string from the list
How can I add a path this is what I have
config.createSection(namespace.replace(":",""));
config.set(namespace.replace(":", "") + ".whitelist", true);
config.set(namespace.replace(":", "") + ".can-float", true);
config.set(namespace.replace(":", "") + ".water-collision", true);
List<String> comments = new ArrayList<String>();
comments.add("blocks:");
comments.add("- Material");
config.setComments(namespace.replace(":", ""), comments);
BlockLimiter.getInstance().reloadConfig();
when i type "Sussy" in the config and thats not an Material it should try a new random thingy
I think you can do config.getStringList("your path")
@agile anvil it shouldnt throw a stackoverflow, except if the code is inside randomItem()
It's inside randomItem
why does ij still scream at me
does randomItem() call getRandomItem
why is there a random when ur not using it btw
god this chat is so random
i just had to say the pun
LOL
ok anyways, what's the problem here
this? xd
In AA, with an AK, melee, finna set it like a playdate better vacate, retreat like a vacay, mayday (ayy)
it just a test
i will make smth out of it later
List<String> stringList = config.getStringList("materials");
if (stringList.isEmpty()) throw new IllegalStateException("badly implemented");
Random random = ThreadLocalRandom.current();
String materialString = materialList.get(random.nextInt(stringList.size()));
Material material = Material.matchMaterial(materialString);
if (material == null) throw new IllegalStateException("badly implemented");
return new ItemStack(material);```
whats so difficult about it lol
never catch a null pointer exception 💀
bruh
- you dont get what he means.
- that's not the entire point
fuck that looks ugly
never catch a runtime exception*
k watch this
Yes
if (itemMeta.getPersistentDataContainer().get(getVoucherTimeKey(), PersistentDataType.INTEGER) == null) return 0;
return itemMeta.getPersistentDataContainer().get(getVoucherTimeKey(), PersistentDataType.INTEGER);
it still complains
I do get what he means. IntelliJ wouldn't be complaining if he did actual null checks
because itemMeta might be null. Are you checking that?
theres a getOrDefault
I think it would be better practice to do .contains(player.getUniqueId().toString() instead of .contains("" + player.getUniqueId()) but the execution will be the same.
not gonna mention it being null is impossible
because it triggers a function that checks if itemmeta is null
why is it still returning null wtf
i have this, how can i remove the player without removing the entire list?
you are recalling the function if it is null
nothing's gonna change when its null once
that did the trick
??/
wdym
that was intellij malding btw
wdym
it wouldve compiled normally
ah
and ran normally
not very intellij
Over an array, which is faster, a for-i loop or an enhanced for loop?
hello, do you know any way to exclude 0 in the java method Random().nextInt("int") pls ?
this is where my confusion comes from
depends @rough drift
It's the same, just the enhanced fetch all items
+ 1
No @agile anvil
If Material.matchMaterial(randomItem) is null the function is called again checking for that exact thing again
that's wrong
Are you trying to add players here? You can do like `List<String> whitelist = config.getStringList("Whitelist.Players");
whitelist.add(player.getUniqueId().toString());`
oops let me format that
the enhanced for loop is a lot faster
no need to call getItemMeta twice as it will create two copies, it doesnt just return it
lol
for low iterations
Either use one with 2 bounds or just do +1 after you got your number
which are under 2000 or so
Math.max(1, Random().nextInt())
however for higher numbers of iteration, the traditional forl oop
i thought about this, but over it double hance of getting 1 then, and i dont want this
is faster
Oh that's nice, didn't know it was reading directly the list
huh no
Depends, cause get the item number x of a list is way slower than just reading values after values
if every time it is 0, i change this to 1, then, for every 0 and 1 i got 1 si yes it double
do not use Random()
Random#nextInt(5);
returns 0-4. Do +1 at the end and you will get 1-5. How is that double the chance?
Do not use Random
Getting item 290 needs you to go through all 289 first items
okay i'll test thx
so i see in some people code they add after integers an L or a D or something, does this do anything?
what
long and double
i'll test your threadlocalrandom
ah
L converts to long D to double f to float
kk
somehow, but it's mostly convention
ty
You can use random with non custom seeds if it isn't meant to be secure. Although I also use threadlocalrandom
But for secure randoms you should use SecureRandom anyway
Use a custom physical Random based on the clouds. Really reliable 😂
why is it still returning null wtf
oh and btw
@timid jetty
java will automatically think of 100000 as an int
so u would need L to tell the jvm to use it as a long
Random does too
as far as i remember
No it doesnt
From Java 17
? it's based on the current System time.
new Random() is the same as new Random(System.currentTimeInMillis())
might also be nanoTime() idk
No mine is one of the safest random, literally based on the weather. But you'll need some detectors to use it ^^
ive seen people catching npe and out of bounds exceptions 💀
in their onCommand
No it does not. @frosty tinsel
Yes it does