#help-development
1 messages · Page 1991 of 1
well i got asked alot of stuff lmfao
no he is very particular about coding style
and how things work lol
Oh that is also me
My brain starts to slowly deteriorate if I realize I left some uncleanliness inside of my code.
"Shit this is completely unmaintainable," it goes.
same
not sure I have ever tried to adjust the decay distance on a basic server. - me looks at the other server
my internet be dying
the quick look says: Leaves from trees spontaneously decay (disappear) when they receive a block tick if they are not connected to any block with the logs tag (log or wood blocks), either directly or via other leaf block, with a maximum distance of 6 blocks[Java Edition only] or 4 blocks[Bedrock Edition only]. Player-placed leaf blocks never decay.
the max distance is 7, so if you want to go farther than that you would need a block with the log tag within your range - i couldn't remember what the max distance was and why we cheated
How i can replace a variable from a .yml file with anything else?
text editor ?
i mean spigot
would a cached thread pool be appropriate to load user data from a database? every time a player logs in i submit some code to the pool grab from the database
read and write to the yaml file
but getConfig.getString("asdasd"); and replace {player} with player.getName
FileConfiguration#set
im learning a bit of stuff from java's concurrent package and i wanted some feedback on my thoughts
Yes but most likely you only need one thread
Well, an async player join event does exist.
Unless there is a really slow connection or a huge amount of data to query one db thread keeps things simple
yeah most probably a query would take half a second in worst cases
Maow lol
Half a second is important to you? :p
would just need to check to avoid transaction requirements
well if it's on the main thread yes :p
who'se
I'm not sure if you're referring to the site or game I got it from...
but yes most probably theres no need for more than a thread
Either way both apply to that description.
i mean, my plugin be waiting 5 seconds o_O
as long as a bad connection does not try to connect multiple time in that time
I don't know of a dedicated site for that
So are you talking about e6
Pffft good guess
Listen it's really easy to find specific things on e6
I could've scrolled through the game creator's Twitter for like 5 hours but the other option was way easier
are there any good general spigot libs to make plugin development easier?
RedLib
There's also Lamp for commands if you don't like how RedLib does them
DM me if you need help using it
i'm making one, tho go with redlib for it
No. But there are a lot of general spigot libs to make plugin development easier.
I personally really like Lamp
Might take you up on that 😄
Are you saying none of them are good
yes
Based
Ouch
mine included
I think writing your own lib really teaches you a lot.
Yeah it taught me that having 50 services in the plugin class is fuckin' annoying and there's a reason why people use dependency injection frameworks.
oh my lord @waxen plinth you made redlib?
Yes
woah cool
Although it took me having to make my own DI lib before I understood DI frameworks.
"list" 😄
tbf a set is kind of a list?
Show the code below
I bet that could have been computeIfAbsent
computeIfAbsent is the love of my life
one-liners are beautiful
its from RedLib btw
HAHAHA
It could have been computeIfAbsent
Yes this looks like it could use some computeIfAbsent
Actually computeIfAbsent has the potential to be faster than the individual method calls since it does everything in a single method
So it truly is a beautiful method
Yeah I guess one problem with RedLib is that I have been working on it for three years
Which means that some of the code is three years old
which is why you "scrap and rewrite"
I've been making an effort to rip out and replace the parts that were old and I didn't feel like I could be proud of
Yeah
I scrapped and rewrote the config manager and block data manager recently
That's an endless cycle
But there's still gonna be bits and pieces lying around like what 7smile found
Learn something new -> rewrite old code
rinse repeat
I mean, not that what he found is particularly egregious lol
W o w
I bet you don't use enough HashMaps. That's probably the issue
hashmap
reminds me, need to read linked hashmaps
my inventory lib is almost done :D
They're really not that different
They just keep insertion order
whats the different between
Map<Object, Object> map = new HashMap<>();
and
HashMap<Object, Object> hashMap = new HashMap<>();
Nothing really. The first one is just more abstract.
so literally nothing?
Well it's different down the line, sure.
People recommend the first because of uhh one of the SOLID principles one sec
If you program against the first interface then you can change the underlying implementation without breaking your contract.
For example if you have a HashMap in there then you can very simply just change it to a LinkedHashMap without having to worry that
some methods of one implementation are not present in the other.
Liskov substitution
objects of a superclass shall be replaceable with objects of its subclasses without breaking the application
i dont really get it
Liskov substitution principle. Explains it in a more general sense.
Maow wins by ✨ using Google ✨
but is there a performance gain
SOLID is a decent set of principles
Use Map so you can quickly switch the implementation without issues.
No lol, it's just types.
I mean it's like
Performance for the developer
The variable will contain literally the same object.
Since you will be able to maintain the program more easily
But it's not runtime performance
"HashMap<Object, Object>"
this part
its the variable type
right?
so it is possible for the variable type to be different than the variable content lel
well a hashmap is a map
so ig not
no
it must have a super-child relationship
Well an object in Java is just a reference to some memory which contains a few pointers like the type, fields, etc.
At runtime, the type is used for polymorphism.
For HashMap the following types are valid:
Object (like for every other class in java)
Serializable
Cloneable
Map<K, V>
HashMap<K, V>
Fun fact: Variable types effectively do not exist in the bytecode either.
yeah so its superclasses
and itself
woa
btw how to perform a benchmark
Learn JMH
It produces the most accurate results
Well it depends on the kind of benchmark
You can benchmark execution time or memory usage.
(or both)
I'm pretty sure JMH doesn't give you the ability to benchmark memory usage?
But you could just use a profiler.
Anyway so yeah
Execution time is kinda the same thing as performance?
for (int xPlus = -16; xPlus < 17; xPlus++)
for (int zPlus = -16; zPlus < 17; zPlus++)
for (int yPlus = -16; yPlus < 17; yPlus++) {
Location location = new Location(playerLocation.getWorld(), playerLocation.getX() + xPlus, playerLocation.getY() + yPlus, playerLocation.getZ() + zPlus);
}
}
Am I an idiot, or does this code go through all locations in a 16 blocks radius?
Because it doesn't seem to work quite right
Well... you're going from -16 to 17
So, that would actually be... 32 or 33 blocks I believe?
dont call getWorld
that many times
Oh yeah
and getY and theses tuff
Well nah that's fine
Well I personally find it uglier to define 3 variables
What he really needs is a newline
but why is it fine
It should cut out the 17...
Because it's not an important optimization.
There's a good chance the JIT compiler will inline that method call anyway.
so it wont call the method again
it will store it and just use it
but wait
the location can change
so that wouldnt work
Nah it'll still probably locate the field some other way
The JIT compiler produces native code
So it can actually avoid a lot of access checks
idk how jit works
Likelihood is that it just dereferences the underlying field's pointer every time
Which is preferable
Basically there's:
- AOT = Ahead Of Time,
javac - JIT = Just In Time, the HotSpot VM
The JIT compiler acts "just in time," as it is started at runtime when a class is used often
There's actually a threshold for HotSpot to run JIT
But what it does is take the bytecode produced by the AOT and turn it into native machine code
Which is much faster, as the machine's hardware (CPU) can run operations faster than a VM
I mean, a VM is just an emulation of a CPU after all.
Oh well I've literally looked at Javac's code before so I can kinda explain it
but how do they make stuff fast
Math.
fuck
Except Javac is a pussy ass bitch and isn't really that smart.
so what it does is making code into native code
then storing the result of the code
and just using that
instead of c alling the method
every time
or what
Well it turns the whole class into native code
Good question
My ideas are dry too so I can't really help you
so it turns the wholle class into native code, and instead of calling a method too many times
it stores the return value
and just take it
I mean I can't explain exactly how the JIT works
but what if the return value changes???
I haven't peered into it since I'm not too knowledgeable on C++
Well I think the JIT makes the same assumptions the VM would
i dont even know cpp lol
Like if it's a mutable variable, then it dereferences from a pointer every time
If it's not, then it would probably just store a value
Benchmarking on the JVM, especially microbenchmarking, is hard. It’s not enough to throw a nanosecond measurement around a call or loop…
reading this
it looks easy if u use jmh
It is
poggo
I've been using JMH for all my projects (that I care enough to benchmark)
You can literally just annotate shit
ic
so what u do in ur projects that u care enough to benchmark
is clone the project
add the annotations
and try out different ways
right?
I don't either
its amazing
Unit testing is a great way to verify that your projects stay working across changes
unit tests are a god sent
You don't you need them until you use them
It also:
- Enforces good coding practices
- Allows you to work iteratively (TDD/test-driven development)
- Verifies to other people that your code works
looks like a headache
It's pretty easy tbh
public final class Test {
@Test
public void oh_god_what_have_I_done() {
assertTrue(programIsNotBroken());
}
}
Well you don't have to use snakecase
But it is conventional for tests
Well yeah that's why you test a bunch of cases
or smth
I believe JUnit's assertions throw an AssertionError (like the JVM's assert statement)
and where do i call my test methods
Your IDE
oh
The IDE'll also show you their status
e.g. it'll go through the methods and literally show you
(checkmark here) My test
Yeah
So basically to write tests
You have to follow a couple of principles
yo thats kinda cool
Hopefully:
- You don't abuse static
- You don't make your code overly reliant on a framework like Bukkit (since it's hard to test)
Yeah pretty much
JUnit uses uhh
Assertions
But it's conventional to static import its methods
I define it as a plugin framework
The implementation is CraftBukkit
Bukkit is a layer over it and other projects that support Bukkit
But I call it a framework since it provides a large foundation for plugins
Actually it would be more fair to say uhh
Bukkit is basically the interface for Minecraft, but also provides a framework for plugins (org.bukkit.plugin)
The reason for not abusing static is so you have more control over the state of your program btw
wdym
If you have code that has some static mutable value
Then you have the risk of a situation like:
value's default value is"Fuck you, World!"- Test 1: Set
valueto"Hello, World!" - Test 2:
assertEquals(value, "Fuck you, World!")(this test fails bc we didn't expect test 1 to modify the value)
That's just a single example btw
The situation mainly arises from having a bunch of static mutable state
Since it becomes effectively impossible to track those values
i dont get it tbh
yeah, more about their behavior. Just keeping insertion order is rather vague on what that means if the file gets changed
What file? A LinkedHashMap is basically the same as a HashMap with the sole difference being that the insertion order is kept.
This mainly affects iteration order.
Eh, either way it's better to store stuff as a series of objects
Well you probably need a buildsystem plugin for JMH first
Oh we are talking about JMH. What do you guys want to benchmark?
random stuff i just wanna learn how to use it
i am reading, diff and tracking yaml files, currently looking at using linkedhashmap for the diff. However, not sure that will work if something gets changed. Trying to avoid using a database
And why do you care about insertion order for that?
Unless
Oh I see
You mean the lines in the file?
yaml is inherently unordered
also unsure how yaml and treemaps play together, so linked seems like a usable option
It'll compile
Will it even compile
It's just dumb though
Okay
depends on the precompiler
You can do if (false) as well
You sure?
Yeah I've done if false before lol
Yeah i know
I swear I've compiled stuff like if (false) and it resulted in nothingness
...although actually
maybe I'm misremembering uhh
It could've been that the compiler unwraps if (true)
sensei would probably warn you about it if you use it
I'd guess so
Hah, you expect me to have a teacher/superior?
...
if (true) if (true) if (true)
I'm nice but some small group of people still think I'm an ass too, how can we prove they are wrong
Oh huh didn't know this existed
Or should we leave being nice and completely be an ass to them like what they think
you can not make someone else think - so it does not matter what you do
that doesnt work
what im doing
<build>
<plugins>
<plugin>
that shit
</plugin>
</plugins>
</build>
what are you trying to do/
use jmh
in gradle or maven?
maven
I mean most people think I'm an asshole
...because I am
At least I'm honest with them and myself :p
https://github.com/jhunters/jmh-maven-plugin/blob/master/Document.md you using this initialization ?
ok it works now
aside from it missing the opening plugin tag
gg
for that example at the top ...
i think someone just missed it in the copy-paste
readme
ok
Plugin 'org.springframework.boot:spring-boot-maven-plugin:' not found
tho
i can remove that right
Yeah I don't think you need Spring Boot...
isnt that one of the maven plugin libraries? (i switched to gradle a bit ago)
Oh I forgot they had stop
it is possible to have recpies that only work if the itemstack has a PDC entry with a certain value but disregards other values? For a plugin of mine I have a self-destructive item which contains a timer on the PDC but I want to disregard the timer for the crafting recipe
isnt there a button in intellij for mvn clean test btw
is there a way to check if a mob is focused on the player?
Gotta learn to read the docs https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Mob.html#getTarget()
declaration: package: org.bukkit.entity, interface: Mob
yeah i usually just google it and if it doesn't show up after like 5 different prompts i assume it needs a hacky solution with NMS lol, i should start doing that
thank you
Kind of. But you will still have to use some tricks
Failed to execute goal com.baidu.maven:jmh-maven-plugin:1.0.1:jmh (default) on project JMHTest: Execution default of goal com.baidu.maven:jmh-maven-plugin:1.0.1:jmh failed.
This is a simple arithmetic expression. The used numeric values wont affect the performance of it.
Unless you are loading chunks, no.
You should still check if sqrt overflows with those values. Should be a quick setup.
is there a premade library out there that handles fetching offline players using mojang's API with caching?
and what tricks are these?
and if not, how should I go about making API calls without halting the whole server?
Writing up a mock up at this instant
I have a feeling Bukkit already does this?
what the hell is goin on here
Is there a way to register and unregister events while the server is running?
Sure. But you shouldnt.
And you can use HandlerList.unregisterAll(listener) to unregister a listener
I mean it's perfectly fine to
Rebaking the event handler list every time. If there are a lot of listeners then this is not cheap.
What does bake do exactly?
its like 5 listeners
Compiled a bunch of classes and registers them via the unsafe class
Wow
Other plugins are also affected
Wait what
*And then order them based on their event priority
Why does it work that way
That's a bit dramatic I did this exact thing for my serialization lib
At least that is what paper does, spigot is a bit less optimized
Oh okay
spigot does a bunch of reflection stuff every time iirc
But at the core, it does the same thing
Cuz I was like "That doesn't sound very CraftBukkit"
I don't get why that's necessary at all
Why cant you register them once in your onEnable?
I personally think method handles would've worked just fine
Like I get they probably don't want to use reflective invocation for every event listener every time an event is invoked
Yeah exactly
That's what MethodHandle is for
is there a premade library out there that handles fetching offline players (by name) using mojang's API and handles caching?
and if not, how should I go about making API calls without halting the whole server?
Legacy versions!
It's just as fast as native invocation
how to run benchmarks
Its for a gamemode and they only should be active after the game starts
MethodHandle has been around forever though
Use a boolean
MethodHandle has existed since Java 1.7 iirc
Bukkit has also been there forever
bruh, wasnt thinking about this lol
ty
Yeah and what's stopping them from rewriting how events are handled
It's all internals so nothing about the api would need to change
Like that's so bad
if(!game.isRunning()) {
return;
}
...
Benchmarking
Did you get the gist?
I was actually considering a PR to Spigot a while back that would replace the reflective invocations with method handles
Also, method handles are a bit less performant than direct calls - and if you have events that are called very often like PlayerMoveEvent every inch of performance might help.
Yeah. Is the event.getRecepie() call required?
Method handles are comparable
Like there's gonna be the overhead of the one additional call to the method handle itself
But I'm pretty sure other than that method handles are almost exactly as fast as native invocation
I mean, it wouldn't make much difference in later versions of Java because they're gonna use method handles in reflection in said later versions, but y'know...
Also reflection is going to use method handles soon
Reflective invocations and method handle calls get jit compiled quite fast to the point
where they are indistinguishable from normal method calls.
Yeah lol
And on top of that
I'm pretty sure hotspot switches from reflective invocation to method handles after a certain number of calls
So reflection is nowhere near as slow as people expect it to be
it already does in J18
Is java 18 out yet
Nope lol
Hence soon
but you can compile it yourself
Probably not, but you can always compile it yourself
Does anyone know a reason why I would have to specifically add spigot-api as a dependency to use Player#spigot and the normal spigot depend doesn't have it 
And it isn't valhalla soon
Jank ✨

probably gonna have 20 incubations like the foreign memory api or the vector api
direction and magnitude
Right, that makes sense
But we still haven't seen much of anything other than talk of value types
"These things, they take time"
"value-based types" exist in the JDK, technically
But they're basically an internal optimization on standard lib classes
anyone?
uhm
Do you need to fetch players who have never joined
@EventHandler
public void onPrepare(PrepareItemCraftEvent event) {
recipeManager.handlePrepareEvent(event);
}
Woops should be this instead.
Ah
Spigot does that already
Is there smth like GameProfile in the Spigot 1.8.8 API?
Yeah, the player profile API exists
aaahahaha XD
Pathetic.
okay, than a other question:
How to create a ItemStack (PLAYER_HEAD) with a custom texture in Spigot 1.8.8?
No but in 1.18.1 there is.
1.8.8 is half a decade old and wont recieve any updates every. There is so much api not present in this ancient version.
Go search in old forum posts. 1.8 is a stone age version
Thank god I have the pleasure of coding for 1.18.1
completely forgot about it lol
..?
Still. For 1.16 you need to use reflections to apply the GameProfile to the head meta.
Bukkit#getOfflinePlayer(String)
I think it has an offline player cache of the last 10k users that have been online
isn't that deprecated
Yes but only to encourage UUID usage.
It may be, but it is safe to discard
what if i need more than the last 10k
...why would you need more than the last 10k?
i'm trying to create my own moderation plugin
How many people do you expect to join a single server?
It is probably safe to call async
At worst you can write your own caching DB
I think there is a property you can set to increase this if you want to. Or maybe its in the wood based fork only...
increasing it won't help, it'll still mean the plugin isn't scalable
It's not a big deal :p
wat tis mean
Then just write a huge DB
Benchmark Mode Cnt Score Error Units
Classing.loop avgt 5 309.725 ± 144.846 ms/op
How can I compress my plugin? To upload it to spigot it must be less than 10mb and I literally only have 53 lines of code and a config.yml
i already have a database set up
does this mean that the benchmark took 309ms to 144ms?>
thing is, I'm wondering whats the best way to fetch data from an API
Every time loop was called, it took 5 ms.
ooo
that sounds like a lie it took way more
without stopping the whole server
It was called 5 times
Not a good benchmark. Thats about 45% uncertainty.
And uhh
o
It took 309 ms per operation possibly
how did u know
Since it has a 144 ms error
it took seconds
Just know that 50 million cached players will probably be around 1.6 GB of memory used 24/7
or wait nvm
lmao
Call it async
And that is a VERY conservative guess
the server will only cache 500 players at a time
Welcome to:
"I don't know how performance works but I want to make something fast."
Ok but what server is going to have 50 million fucking cached players
if it runs out of space, it'll write over the old data
Error means uncertainty?
what
i dont get it
bruh okay listen
BECAUSE THE SERVER CACHES 10K ORIGINALLY
It will probably be twice of that as soemone will just add a lot of very long usernames and thus you will have around 4-6 GB of memory used up 2477
500 players in cache, correct?
You clearly imported bukkit in your jar dont you
if someone wants to get a new player that's already not in the cache
it'll use mojang's API to fetch that data
10k is quite a bit more than 500
If maven then set scope provided, if gradle ask other users
No
i'm responding to this
can u help me with it
Then a cache will not help
It will only call mojangs api if the player has never played before
You will need to fetch the data either way
otherwise it will read the offline player from disk
Paper has a method to only read from disk afaik
<scope>provided</scope>
or compileOnly "org.spigotmc:spigot-api:RELEASE"
shading is not a common practice
meh
what is the event for when a block is broken? (not neccessarily by a player)
There is none
this would mean that at a certain point, it'll be impossible to unban a player if their uuid gets uncached
Yep, by default scope, they will compile the dependency into the jar so
Also just note that players CAN change their usernames
yes ik
is there like a block update event maybe?
So uncaching might be usefull there
Nope
As you would just re-fetch the user
If you do it async there is no performance concern
I dont get why a player needs to be cached for unbanning...
hold up lemme type a whole essay to explain this then lmao
Also usually you only unban users shortly after they got banned
After 30+ days it is usually fair to assume that they won't attempt to get unbanned
wait wait wait a minute
what if there is a tempban system
longer than 30+ days
Then you just need an UUID?
lmao
does the BanList store player UUIDs and names?
Do not use bukkit's ban api
Probably not, but you can always get the player name from the uuid.
Perhaps do, idk. But I'd not
BanList as far as I have heard only stores player names and is just not up to date with 1.6+ world
Imagine using bukkits ban api with more than 10k unique users in 30 days
Also, Bukkit's ban API has integrated support for tempbans, so that isn't an issue either
how do i check when a dead horn coral wall fan is broken? not just by a player tho
here's how my whole architecture works:
when a moderator uses a command such as /ban some_player, the plugin will add that player to Bukkit's BanList and also save that player in it's own database.
Then i have an onAsyncPlayerPreLoginEvent that checks if the player is in the BanList. If so, check to see if the player's ban expired or not. If it has, then unban them and allow them in the server
just lmk if you see a problem with this lmao
You should just use your own database at that point.
Bans
Player names
Oh dear
and completely screw BanList?
tf
Why use the BanList at all then?
so if i change my name my ban is expired
i have no idea
And if someone changes their name to your old name, they get banned! :D
Also, isn’t there a ban and unban method in the player object? Or maybe the offline player object?
it is a semi-reasonable method since you can only offically change your name every 15 days
every 15 days?
30 days, iirc
Yeah, I thought so too
better be checking case insensitive to make sure people cant bypass with name modifiers
wait i remember why
i did that so that banned players still can't join in case, for some reason, the moderation plugin is disabled for a moment
however maybe it isn't worth using it then
For such critical infrastructure I usually invoke System#exit when the plugin fails to load
well that is a good point but not what i was addressing
I'm saying if the server owner removes the plugin from the plugins folder
or something
Inject security code into the server jar 😎 (don't do this, MCAM will flag you as a virus)
Then the server administrator usually does it knowing that there are consequences
hmm okay
You could allow exporting the ban list
I wanna scream, people don't understand updating my plugin isn't my full time job ;-;
i guess so
Then its the owners fault. Why would you want to guarantee functionality of your plugin when its removed?
Lol
what plugin is it
PrivateMines
okay so I'm going to remove this BanList thing then...
oh its paid then
now another thing
ye
my database will only store player UUIDs (along with other info about the ban)
well they paid money for it i understand the frustration
but still to ping me for every single message?
Scanm them
5 times, ban them
scmamagmam then
I try my absolute hardest to reply as fast as I can and I have been updating the plugin so much just today
so.. is it plausible for a moderator to use the player's UUID in the pardon command? Or should I do this whole Mojang API thing where I fetch the UUID by player name..
I can't wait for when they find out i'll be starting long hour work soon lol
Mute the server
Benchmark Mode Cnt Score Error Units
MappingStuff.tryHashMap avgt 5 ≈ 10⁻⁵ ms/op
MappingStuff.tryMap avgt 5 ≈ 10⁻⁵ ms/op
Use a GUI 😉
what does this mean btw
nah, then I don't know if people want help
10 to the negative 5th power
i still dont get benchmarks syntax
gui for what
Change the time resolution. This says nothing
Bans
List the players or smthn idk it was sarcastic
to nanoseconds?
I should make a moderation plugin... that'd be cool.
Example setup
Stealing your ideas, okay1204 ✨
True rivalry
but thats the first part
oh mine is @State(Scope.Benchmark)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Fork(value = 1, jvmArgs = {"-Xms2G", "-Xmx2G"})
and it's not for the public (kind of)
ok ill try that
I swear you know everything, lol. (This is a compliment btw)

7smile7, although a dick, is very smart 👍
i've always found 7smile to be polite
i expected them to be blazing fast
Because it has to execute the code a lot.
ig
the same reason you have to show your work on a math test
Tell that to my dad.
Literally proved to his teacher he could just do the math in his head.
just creating an object with this takes 00:03:20
I swear I've 100% improved with coding so that's good right?
It has to do a lot of invocations so you can build proper averages. Sometimes method calls randomly take a ton of time which could lead to false readings.
you are averaging, thats not a single run
Unless you do Mode.SingleShotTime
This is kind of a "cold start" mode
nascar vs drag strip - GO!
I believe it refers to the benchmarker not handling JVM warmup.
Benchmark Mode Cnt Score Error Units
MappingStuff.tryHashMap avgt 5 0.011 ± 0.005 us/op
MappingStuff.tryMap avgt 5 0.011 ± 0.002 us/op
so uh
w a t does this mean
5 runs with result average and error
what is error
This means exactly what we told you 😄
No diff between storing a HashMap in a Map or HashMap variable
you know what +- means?
Me no
+- is the error
whats Score, error
cnt is runs, avgt is average, units is obvious
but whats those two
codeblocks are monospaced
meaning all spaces take up the same width
and therefore, it is easier to read things that are centered in some way
so please...
```
do this
```
error != uncertainty
oh so what is error
0.011 ± 0.005 means 0.0115 to 0.0109 us the time clock jitter or variance is most likely the source of the error
analog to Accuracy vs. Precision
Yes
Computers are imprecise machines
does it mean it varied 0.005
precision confidence rather than varriance
so e.g one was 0.011 and one 0.016
no
so
it "could be" that, they system clock is possibly just not capable of ensuring exactly what it is in that time range
.
Computers are very precise. Its simply that so many different things can be happening at once
your one task can have so many different timings as other things also happen
so you time many passes and average them out
you can depend that your operation took 0.01us but it could be slightly higher or lower than that
aka it took 10ns it might be as slow at 12ns or as fast as 10.9 ns the result was averaged to 11ns
how about this
MappingStuff.tryHashMap avgt 5 0.012 ± 0.002 us/op
MappingStuff.tryLinkedMap avgt 5 0.014 ± 0.006 us/op
MappingStuff.tryMap avgt 5 0.015 ± 0.013 us/op
bumping my issue from earlier, I'm using PlaceholderAPI and after running /papi reload my placeholders dont work until I re-load my plugin again
you missed treemap ?
how do i show parameter names in a command like this:
get a fresh instance of PAPI before you go to use it
Use papi lazily. Dont cache anything.
Will try, tyvm
why is the hashmap 0.012 and the map 0.015
what is map?
tryMap
cot plox
wat
code please
@Benchmark
public HashMap<Integer, String> tryHashMap(){
return new HashMap<>();
}
@Benchmark
public Map<Integer, String> tryMap(){
return new HashMap<>();
}
@Benchmark
public Map<Integer, String> tryLinkedMap(){
return new LinkedHashMap<>();
}```
What.... it'd sure be more fun if computers were imprecise ahaha
You really need to use blackholes. This might get compiled to 3 empty methods
@Benchmark
public void hashMapConstructor(Blackhole blackhole) {
HashMap<Integer, String> map = new HashMap<>();
blackhole.consume(map);
}
@Benchmark
public void linkedHashMapConstructor(Blackhole blackhole) {
LinkedHashMap<Integer, String> map = new LinkedHashMap<>();
blackhole.consume(map);
}
im not caching placeholderapi though
@EventHandler(priority = EventPriority.HIGH)
public void onEnable(PluginEnableEvent event) {
MarriagePlugin plugin = this.core.getPlugin();
if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new MarryExpansion(plugin, core).register();
}
}
``` ```java
public class MarryExpansion extends PlaceholderExpansion {
private final MarriagePlugin plugin;
private final MarriageCore core;
public MarryExpansion(MarriagePlugin plugin, MarriageCore core) {
this.plugin = plugin;
this.core = core;
}
@Override
public String getAuthor() {
return "paradise";
}
public String getPartnerCustom(MPlayer player) {
return "abc";
}
@Override
public String getIdentifier() {
return "marriage";
}
@Override
public String getVersion() {
return "1.0.0";
}
@Override
public boolean persist() {
return true;
}
@Override
public String onRequest(OfflinePlayer player, String params) {
MPlayer mp = core.getMPlayer(player.getPlayer());
if(params.equalsIgnoreCase("partner")) {
String returnplaceholder = getPartnerCustom(mp);
return returnplaceholder;
}
return null;
}
}```
where did you get tryMap() from? javax says:
public class TryMap extends java.lang.Object implements Map, java.io.Serializable
A Map that can combine a number of other Maps in an efficient manner. Currently this is a brute-force implementation.
"This will return an object even if the player does not exist"
Then.. what does it even return?
says it returns an offline and/or online player
doesnt say that the offline player is/was from your server
yeah but
if i type a random UUID
what will it return
what if the UUID doesn't even match any offline player
An OfflinePlayer which encapsulates said uuid
oh ok
all UUID exist within the range allowed by the Mojang/MS auth servers, even if unassigned, the range would still exist
okay thanks
Well Server::getOfflinePlayer which takes UUID doesnt involve mojang api whatsoever
I would hope that the defined UUID range would still be enforced by how they are defined without actually going to the auth servers
Actually they must be since you pad XUID with zeros at the front to match UUID
wonders what kind of player 00000000-0000-0000-0000-000000000000 is
You could guess a million UUIDs every day from today on and not hit a single minecraft user id in years. So the chance
of this id even existing is basically 0
Give me a library idea
- Inventory GUIs
- Holograms
- Tablists
- Scoreboards
- Persistent Block Data
Really depends on your approach
all of these are milked
Ah you want something new?
Custom recipe api with more control over ingredients, results and conditions
Make me a random tick API :p
that is
a really good idea
ill do that
ty
fk im writing a resource post about that right now..
oh about custom recipe api?
yes
I dont mind
Oh okay
but more control over ingredients, what do you mean?
like have custom items as an ingredient?
Actually there is one thing i was thinking about that needs a lot of packet handling.
An observation API. With methods like:
public static Set<Chunk> getChunkView(Player player) {
}
public static Set<Entity> getEntityView(Player player) {
}
You basically track which chunk and entity is in a players view by tracking the sent packets.
that sounds like a pain tbh
With events:
PlayerReceivesChunkEvent and so on
but the recipes thing needs nms right
nope
Would anyone know of a way to check if a worlds lowest block is 0 or -64?
Do you mean the lowest allowed build depth? Or the lowest block in the whole world.
how about doing that recipes learning thing
lowest build depth actually yeah
declaration: package: org.bukkit.generator, interface: WorldInfo
https://paste.md-5.net/ziliceqodu.java - Im getting NPE on JsonFile line 38
And im testing with:
FileHandler json = new JsonFile("C:\\Users\\Usuario\\Desktop\\Pruebas\\test.json");
json.set("messages", "Hi");
man, this would be perfect if I wasn't developing for 1.8+
is it possible to generate just a singular chunk
1.8 is ancient. Half a decade old. Support was dropped years ago. You need to search in old forum posts if you want help with that version.
Map can generate NullPointerException when setting values?
Sure
how would i do it
What is your line 38?
1.8 worlds are always 0
yeah, just can't have 190k server owners hanging with the 10% on 1.18 xD
@Override
public void set(String path, Object object) { this.object.put(path, object); }
7% is on 1.8 and over 75% is on 1.16+
Hi, how could i get the ip of MongoDB in order to connect to it from Minecraft Plugin?
I think the big issue is a lot of those 1.8 servers are large
Some maps dont allow null keys
I never write null keys?
It might be time to upgrade huh
If you own the mongodb then you should know its ip
how can I check when that WorldInfo was introduced?
show the stack trace pls
Allright
i don't know where to find it
Exception in thread "main" java.lang.NullPointerException
at dev.alex.net.utilities.file.json.JsonFile.set(JsonFile.java:38)
at dev.alex.net.utilities.file.testing.Main.main(Main.java:10)
JsonFile line 38 again pls
this one
@*****.****.mongodb.net is it this?
what is "this.object"
Didnt i sent a paste?
I will check prob i didnt sent it
Ah i see the paste
Ah allright
ah ok. this.object is null.
If you would use a newer java version then the stack trace would have told you
Because every variable points to null unless you assign a value to it
this.reload()?
Doesnt assign?
7s but adding a recipe to a player knowledge book
needs nms
since u dont have a ShapedRecipe or smth
Where is your mongodb installed on?
Yes you should use shaped recipes for that
It does
like that how is the library any use if u use shaped recipes
because you didnt assign a value before calling set()
on a server in frankfurt i guess
The ip of that server is the ip of your mongodb
But the value should be get and assigned from the json file. And what about if json file its new and doesnt have content?
😕
Make sure this.object is not null at the time you call set or get. Pretty simple task.
the point is that i don't know the server's ip
just know it
Oh you got an atlas one
What if I do a world.getBlockAt(x, -1, y), in a 1.16 server, would I get an error or a air block?
yeah
air
prob
?tryitandsee
You can generate mongo credentials and a mongo address somewhere there. Just need to search a bit.
o
i wanted to start using this databases but i don't really know much, sorry for my ignorance
Everyone started somewhere. Just search around. There are also tutorials out there for those free mongo hosts.
is it the ip the one i cancelled out lastly?
iirc yes
Yes this is what you want
okay i'll try
mhh, i get VOID_AIR, this might be useful actually
void air is basically like, it dont exists right
Its a normal material. There are 3 types of air in minecraft
cave air, void air and air
hey, is there a way to just, check if a player can SEE another player?
like not having a direct line of sight
but maybe just facing the right direction
like the other player is on the side that the player is facing?
aww yeah, perfect -63 is deepslate, -65 is void 😄
raycast forward from the player's direction, and just do a simple line of sight with that
i dont mean livingentity.haslineofsight
With a bit of math. Sure. Angle between the two players and the players looking direction
no, just use a blockiterator
nahg
in the direction the player is facing
like im not talking about that is the thing
no
isnt there player.canSee(player)
i dont mean to be rude but just read the messages haha
i gave an answer to this
this is to check if the other player is literally hidden
Someonelse is confused between documents and objects?
like completely hidden with player.hidePlayer
OHHHHHHHHHH
was talking to this guy
yes
Im confuse because i dont know if mongo when saving an object create another document or save it in the same
thread 2
Something like this:
public boolean hasViewAngleTowards(Player other, Player viewer, double minAngle) {
return hasViewAngleTowards(other.getEyeLocation(), viewer, minAngle);
}
public boolean hasViewAngleTowards(Location location, Player viewer, double minAngle) {
Vector line = viewer.getEyeLocation().toVector().subtract(location.toVector());
double angle = viewer.getEyeLocation().getDirection().angle(line);
return angle < minAngle;
}
You just need to play around with the angle. It also depends on the players FOV if he is actually on the screen or not.
oh you wanted that
Yes 180° is a safe bet
don't use fixed
use the player's fov, but make sure to cap it serverside
otherwise a mod can spoof that iirc
??
if a player has a fov of 120 and you check say 70, that player can see another player but the check says no
Is the fov even sent to the server?
im checking 180˚, you cant see past that
dont think so
check the plyer settings
thats a client setting - you can have a 360 FOV on the client and teh server will never know
ohh shoot
Just a heads up: The angle is in radians (2pi = 360°)
You should also not check for >180° but for >90°
lmao ur right
got it
but ur right it doesn't account for f5
eh who cares
kind of guessing you do: "hey, is there a way to just, check if a player can SEE another player?"
yea but
it's just context
idrc in the context i mean
@lost matrix would this work?
public static final double MIN_FOV = 90;
public static boolean canSeeTarget(LivingEntity looking, Location target){
return canSeeTarget(looking.getEyeLocation(), target);
}
public static boolean canSeeTarget(Location eyeLocation, Location targetInQuestion){
Vector line = eyeLocation.toVector().subtract(targetInQuestion.toVector());
double angle = eyeLocation.getDirection().angle(line);
return angle < MIN_FOV;
}
Ah, step one again, VOID_AIR doesn't exist before 1.15...
why not ray trace in that direction with the distance between the players
Again: angle is in radians
so, Math.toRadians(MIN_FOV)?
MIN_FOV is 90 btw
Or you just do MIN_ANGLE = Math.PI / 2
Also if you ever think about lowering this from 90° then you need to take the distance into account
you are also missing obstructions
Its not about direct line of sight. There is a method for that already.
?
i dont understand
ahahaha lmao
so funny
dude's spamming lol
but he's using the word SPAM
🤣
meat
@ancient plank please ban - Spam
🤣 🤣