#help-development
1 messages ยท Page 2082 of 1
You could probably have something like uhh
<id here>:
surname: <surname here>
name: <name here>
I don't really know much about YAML since I don't use it since it's fucking atrocious
@kindred valley
please help i wanna make plugin like login
i watch many tutorials but doesnt work
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.
still looking for a way to achieve this without sending a command as console sender
Instead of trying to follow some shitty YouTube tutorial?
If you actually knew the language, you would have no problems implementing a login plugin
I know
Work and learning is hard
But if you try hard enough (AKA, put in a minimal amount of effort instead of copy-paste)
You can achieve โจ anything โจ
i am trying to do from days
yes like this but i dont know how to band id with name and surname
Well in Java you could represent it as a Map<UUID, Person> (Assuming your id is a UUID, and Person contains the name and surname)
pretty sure you can still enchant random items
id is random int
declaration: package: org.bukkit.inventory, class: ItemStack
whaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaay
uuid is much much more likely to be unique
Is that only for adding enchantments level above the maximum level?
someone help please
?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.
pretty sure you can use it to add enchants on random items too
if that is the goal
Yeah that's the goal, I want to add enchantment on all items
Only after generating 1 billion UUIDs every second for the next 100 years, the probability of creating just one duplicate would be about 50%. Or, to put it another way, the probability of one duplicate would be about 50% if every person on earth owned 600 million UUIDs.
```From https://en.wikipedia.org/wiki/Universally_unique_identifier#Random_UUID_probability_of_duplicates
ah no its too complicated. Think if you would be a police and getting someons name and surname by his uuid...
just search by name
That
That's a lot of UUIDs
yes
the only flaw in this statement is disregarding the random generation itself generating a duplicate
Yeah but
You shouldn't take implementation flaws into account
Since they're unintentional
lol
And not part of the mathematics of a UUID
java probs has a good impl
It does
Java's random implementation is quite complicated actually...
Rust's is better tho d@m
still an oversight
?
what does rust have that is so good
I don't understand
its not an oversight, you are suppose to create your own mechanism to ensure that the uuid it generated isn't already in use
its like C++ but weird
Aaaalso
There's a good chance none of your players will be alive after those 100 years
obv
...including yourself
or will i
that isn't how random generation works
Like, UUID collision chances are astronomically low
my point being the lazy asumption that you prob wont create a duplicate so you dont have to take it into consideration
is an oversight
which is what the wikipedia entry says
Oh btw apparently Rust's rand supports SIMD
That's cool
Although most Rust things support SIMD
Alright so rust is basically "look at me fancy memory handling"
Well it's a lot more than that
My point was that while although the odds of generating a duplicate is extremely low, it doesn't factor in, how much time it would actually take to get a duplicate
There's also a very complicated type system
you could generate a duplicate on the first try
exactly
chance going towards 0
Well I'm not exactly the world's best Rust programmer :p
(Not counting java has there are Obvious advantages)
but its always > 0
At least you understand what I am talking about ๐
t h e
e r r o r
m e s s a g e s
t h e i n s a n e l a n g u a g e f e a t u r e s
w r i t e
g o o d
c o d e
N O
y e s
thats like iterating primitive arrays using while (arr[i]) {}, will prob work, but could also cause memory violation
How am I supposed to write good code if I'm trying to learn the language?
There's a period in time where you have to rely on error messages for learning
and also debugging
well I mean
or just rely on when it crashes
(because IDEs don't support C++ all too well)
cough c cough
which ive actually seen alot
Meanwhile, Rust is fucking beautiful with its error messages
C++ is def easier to wrap your head around than var x = a() => 45 * 5; x.a();
It absolutely enables compiler-driven development also no IDE is capable of perfectly analyzing Rust yet
Fine good error messages
Rust also has a proper ecosystem as it's easy to find libraries for what you want
And there's an official buildsystem and package manager
UNLIKE SOME LANGUAGES cough cough Java cough cough C/C++
i mean after ive been working alot with ArrayLists and THEN reading the documentation on it i was running furious for the potential of causing a memory leak cause it has the .trimToSize() member
What in the hell is this
Are you complaining you can't understand a language you've never learned?
It's like me getting mad at a Spanish speaker because I don't know Spanish although I do, kind of
no complaining about the error messages
Well it's quite fluent
like why is that an error?
I believe it's a memory validity thing
You can't create an immutable reference to mutable data as that mutable data can change
memory leaks happen because of developers not release object resources or instances as they are called when they are done with them or not ensuring when an object instance can just simply be lost because it is in their list and not realize it doesn't magically update ๐
Therefore rendering the immutable reference invalid
So in order to mutate the value and have an immutable reference, you'd need to drop that mutable reference before the immutable reference is created
yea but that only counts for members that never go out of scope like static members
As soon as i get free time I need to finish my lang, istg do I just need to add good error messages?
See, you don't need to clear the string. There's no point. When that function's scope is over the string will just get dropped so there's no need to manually clear it.
So
so creating an arraylist in a local scope like a function must neither be cleared nor trimmed to size if you leave the scope after ur done with the arraylist
It's good Rust tells you about this because otherwise it could result in weird errors
cause the whole thing will get gcd
Where you expect an immutable reference to not change, but it does
And it's a good thing the error is cohesive
man
unless u have a static reference to one of the lists members
just work with me on mine lmaooo /s don't please you'll regret this
you don't have to manually null out objects, however it is sometimes good practice as it helps it get GC'ed more quickly. But otherwise once a function completes anything created in the method will get GC'ed once the method exits.
It gives you a concise description of the error (with an error code), breaks it down via your own code, and then gives you a command to view the error in more detail. That is a perfect error message.
MEANWHILE
A C compiler would just spit a fuck ton of trash out
That no human could possibly process
yea which is why my arraylists cause no mem leak
(I know this because I've used C compilers lol)
Objects created in a class, however if you are wanting a class to get GC'ed then you need to ensure nothing in the class is being referenced by something
so i just do that and people will love it
?
array lists outside of a method don't generally cause memory leaks either
Well they'll certainly love the development process a lot more.
is gcc any better?
*any use
my whole point about your memory leak worries is that generally it is the developer that causes the memory leak not the system
Clang is supposedly better
ofc
but I was telling you how you can avoid memory leaks in an array list
as long as nothing in the list contains invalid references you are generally fine ๐
and then the list itself goes away as long as nothing is referencing the list
but as I said earlier a good practice though is nulling out objects ๐
nulling out objects no longer needed helps the GC do its job ๐
well yesn its a redundant call tho, like if its not needed
its not required no, doesn't mean it isn't good practice
var x = [1, {json: "pog"}, {main() => "Something";}];
x[0]; // 1
x[1].json; // pog
x[1]; // {json: "pog"}
x[1]{0}; // json
x[1][x[1]{0}]; // pog
< x[2].main(); // Something
x[2].main() * 1; // Something
x[2].main() * 2: // SomethingSomething
See the whole point of Rust's fancy memory management is that it stops the developer from doing things that will almost certainly cause issues. For example, like trying to return a reference when the reference is bound to the lifetime of a function, and is therefore dropped after it is returned (This is a problem with stuff like C/C++ and is called a dangling pointer)
but the extra call takes up processing power
can i read 1.2m files in a few seconds
no it doesn't
not yet, building it on JS then I compile to JS (basically using itself to refactor itself) and then Ill start bootstrapping it
to some more perf lang
For instance, you can't create two mutable references as that is prone to causing a data race in multithreaded contexts.
in java you can
what do you think of this @lavish hemlock
Meow at 16: talks about some college level, harvard style code and languages
Me at 20: hehe happy little api's and mc plugins
in java you can read 1m lines in 1s
more actually
indeed, nodejs too
bufferedreader
Don't even need BufferedReader :)
sexy
memory mapping
to tokenize & parse 500k or 500M lines i forgot took me 26 seconds with my parser
Spent the last 3 years basically nonstop coding lmao
with memory mapping you could probably get the down to 3-4 seconds
testing
nodejs?
not with javascript no
yeah I don't use javascript
same but i only really dabble in c#, nodejs, java havent been bothered with rust or go yet
I ban javascript usage from my projects ๐
about to make a C# mc serer software holdup
go is neat
ngl i wanna take a crack at making another mc jar
there used to be a proxy server implementating that competed against Bungeecord
it was made in GO
I'm basically Java and Kotlin only though I do want to do Rust
and it was super awesome
error handling is basically
if(err != null) {
panic(err);
}
It was called Lilypad
i got down to authorization and motds last time i bet i can get a joinable server xD
i dont know why its not showing the value of map
I happen to know that developer too
go minecraft server would be realllly cool
yes
there's a go server and its not that fast
make a server config 300 tps ๐
you can make MC 300TPS already
yeah remove old shitty code
you should change the TPS rate @noble lantern just to see what happens ๐
BRO
Let me try
i can barely runfucking 20
something
and you want me to run 40???
you can and it will
you will like the change ๐
just let me know when you test it
and I will know when you have because I have done it ๐
btw just some heads up if theres a better solution for this @wet breach , i have written my own ini parser to parse my config files. onLoad() i fill a static arraylist with the configs contents, such being standard messages for command outputs, settings like if the anticheat is primed etc. is there a better way to manage the amount of memory this takes?
Lets see
inb4 "How do you parse INI, it's not got a standard??!?!"
did I just hyper speed up mc server
wouldn't use a static arraylist unless this array is intended to last the lifetime of the application
you could use caching
so i can modify the messages my plugin sends without recompiling
an expiring cache
like a pagefile?
I think i just sped up the mc server so hard its lagging my pc
it will initially cache what you tell it initially and it will keep things in the cache as long as it meets the criteria
otherwise it expires, when the value is needed again it will fetch it again if it expired
hm
is it a config setting or do i gotta do it with a plugin wtf
so basically set an expiration time
got to modify NMS code
dont i need a subroutine to then check the expiration times of values?
have to actually go in the file nothing you can do with reflection
no, spigot server is compiled with guava which has a caching methods already ๐
they are super handy and great
hm
just use its builder and all that and the lib takes care of the rest for you
ohhh bet, CraftServer class here i come
but yea generally speaking, the values are expected to persist the entire lifetime
and only get renewed on reload
its going to be in the MC class
nothing in the bukkit/spigot stuff
that i don't think is in aikar's flags
gonna check that out later
btw ive bypassed using sql with the get player uuid by name by storing them in a hashmap which gets serialized onDisable and deserialized onEnable, and then accessed from other plugins via reflection
"reflection"
its public static
xD
:p
not sure why you would need to worry about SQL
how to fix all your minecraft server lag! simply set tps to 20!
lmao
change it and then compile
then run the server
let me know of your results ๐
i need to get offline players by their name in a safe context, so ive written my own storage system to accurately track player names with the uuid as key.
unnecessary
mm eviltoday frost i see
how do i else get offline targets by their name
OfflinePlayer is a thing in the api, you can use player names to look up their UUID's or if you have their UUID, use it to get a OfflinePlayer object easily
Me when I speed up server launch by 5 seconds
declaration: package: org.bukkit, interface: OfflinePlayer
Bukkit.getOfflinePlayer(UUID uuid).getName();
its deprecated tho because if someone changes their name without my knowledge i target a complete different guy
ik about that
their UUID doesn't change on your server unless they rejoined
i have a bad pc ok?
pro tip: turn spawn chunks off
yea but it also makes calls to the mojang auth server
- viaver, viabackwards, protocollib
thats what i got rn
oh yeah viaver will add at least 1 second
however you shouldn't strictly be relying on player names anyways
but thats my point, idk their uuid, only their name.
stop worrying about deprecations
deprecations != unusable
its not even going to be remotely removed either
this is not about the internal system, this is about an admin targeting a player. and honestly i dont always want to type in their uuid
so its about frontend
in this case using that deprecated method is acceptable
reflection it is
Hello there, I was following this guide: https://www.spigotmc.org/threads/guide-on-workload-distribution-or-how-to-handle-heavy-splittable-tasks.409003/
But I'm having an issue that I don't understand, did I missed something about the runnable comprehension or something else ?
public class WorkLoadRunnable implements Runnable{
private final static double MAX_MILLIS_PER_TICK = 2.5;
private final static int MAX_NANOS_PER_TICK = (int) (MAX_MILLIS_PER_TICK * 1E6);
private final Deque<WorkLoad> workLoadDeque = new ArrayDeque<>();
public void addWorkLoad(WorkLoad workLoad){
Bukkit.broadcast(Component.text("register workload: "+this.workLoadDeque.size()));
this.workLoadDeque.add(workLoad);
}
@Override
public void run() {
long stopTime = System.nanoTime() + MAX_NANOS_PER_TICK;
WorkLoad nextLoad;
if(System.nanoTime() <= stopTime){
Bukkit.broadcast(Component.text("can clean: "+this.workLoadDeque.size()));
}else{
Bukkit.broadcast(Component.text("cannot clean"));
}
while(System.nanoTime() <= stopTime && (nextLoad = this.workLoadDeque.poll()) != null){
Bukkit.broadcast(Component.text("try clean"));
nextLoad.compute();
}
if(DragonFightListener.dragon != null){
DragonFightListener.dragon.cleanFire();
}
}
}
When I'm adding the workload, the size of the array increase correctly, but it remains ร 0 in the run method.
Players names and UUID association on your server will not change if someone updates their name on Mojang servers until they rejoin your server. So therefore using their name will get you the correct UUID. Second, if the player has never joined your server at all, then it will look up their UUID from Mojang servers thus still giving you the correct UUID.
spawning 40000 Particle.DustTransition in causes them to appear over a few seconds in the order they're initialized in, but the method is supposed to run in one tick and also tells me it finishes in that time in the logs. Can someone tell me why? There appears to be no lag in either the server or the client.
hm
what does Component.text do?
It's a paper method, it replaces the string
aight then its still usable i guess
before ive been told multiple times that it always looks up the player from the auth server
if that player aint online rn
anyone know why this is happening ๐ค
Well this is only true if they never joined your server
missing maven import ?
you did not reschedule the tasks
so like if you start up a new server for example or reset a servers files to a clean state etc
add ithe tasks back to the head of the stack
my bad it's not from maven
tbh at this point it doesnt really matter anymore tho cause my own way to lookup uuids is already working xD
you want it to loop right
that's probably it ig, this was code that came up when I inspected spigot classes so I didn't think I'd need to import anything
i do have a loop to the effect of rotating a vector by a tiny amount 40000 times and spawning a particle at each location it points to
well just letting you know and correcting some misinformation since not everyone is actually familiar in the intricacies of the internals ๐
do you use Intellij ?
its good to know tho dont get me wrong ;)
yes
but i guess its also good to see that im still able to write my own systems
if the api fails to deliver
xD
also good
do I still need to import if I do?
you cannot change that variable in jdk13 or higher
Only if you use the annotation system ๐คทโโ๏ธ
so just delete the import
you can also enable auto import in the settings
it cleans import automatically
although ive gotta admit, ive translated my ini parser from C++ to Java, which means its written low level. in a high level language xD
๐คฃ
can anyone take a look to my problem ? #help-development message
but im honestly too lazy to rewrite it using the String api java uses
well also know that yaml lib is part of spigot so you could just have easily made use of that instead of creating some custom ini parser
im not a fan of yml and json
too bloated imo
not sure what you mean too bloated
pretty sure the yaml parser is just as fast as your ini parser
its syntax is too complex for what i need
in fact yaml supports lists directly which is what you are using ๐
funny but
i serialize some lists
xD
if i want them to persist in their exact state
yeah you can use yaml for that
like my hashmap holding player uuids and names
since you need a map for serializing anyways, yaml supports maps directly too
tbh ive just written them to a binary file so far
i suppose u mean the advantage of yml is that it can hold multiple lists at once?
I recommend looking into java's NIO package as well as using memory mapping to make loading/saving much more efficient and faster
will do later
since my serialization and deserialization is a pretty straight forward process
its easy to alterate
to clarify, I'm using particles to draw a symbol, and im using so many to ensure that it's continuous
also i put my standard methods in a "master" plugin which all other plugins then access via reflection
.eans
means
if i modify my serialization methods
i dont need to recompile my other plugins
xD
and yes i got ALOT hate for that
also good to have a separation or abstract what isn't necessary for your other plugins to always implement
thats
why i put my standard methods in my master plugin
and the other plugins only use wrappers
that then access the actual methods via reflection properly
not sure who would hate you for that, but that is actually what some here would have recommended you do
like a .dll would pmuch
because that would speed up development on future plugins
also
if u need to change their implementation
u dont need to recompile any other plugin
but the master plugin
well depends, for the most part that is true
if
i choose to change the parameters
yes
everything needs to get recompiled
names
or return types
plugins might need to update if you alter an implementation specific behavior, but like that shouldn't be a common thing anyways
its sad tho
i cant outsource bukkit methods
because the reference to the .class files is null
for whatever reason
what do you mean outsource bukkit methods?
u know how i manage standard methods
like getting msgs
my ini parser yada yada
but if i try to do the same with a method that uses bukkit objects in any way
like
ChatColor.of
i get a null ptr error
because ChatColor.class couldnt be found
even tho the master plugin is compiled implementing the api
probably because you are using the wrong ChatColor import
and actually running alongside the other plugins
nono
if i use the same code in my plugins directly
it works just fine
using the bungeecord color
this goes with any and all
no matter if its Player.class not found error
Bukkit.class not found
no
Jdk 16 sucks :((
lmao
then I am not understanding how you would get a class not found error for thos classes on the spigot server
Executes in less than a second
But that's with the print
who
line count?
Full class is 43 lines
also you can speed that up
chatcolor was jist an example. it happend with Player.class, Bukkit.class, ChatColor.class etc
rather than recreating the string builder you can save time by doing str.setLength(0);
ahh
no the words.txt
Oh
yeah, impossible to have those errors on spigot unless you are doing something very incorrectly or you are not explaining it properly
That's uh
Not a keyword
That's an identifier
and i got alot of hate here because ppl say "oh just put the source code directly into ur plugin". i suppose they never written more than 1 plugin xD.
That's stdlib code for you
You should see ByteBuffer's formatting
It's
terrible
i believe that accessing the bukkit classes uses a different path in the .jar than vanilla java methods like the string class. so my imports fail. but thats only a theory so far
The fact this is part of the standard library bewilders me.
since you know other languages and probably going to guess you probably are more familiar with C languages, do note java can make use of native C code using JNI. Only downside you will incur with this, is context switching.
Btw it had the same speed so it doesn't actually matter
oh dear lets not go down that path. i DID port my .dll for java and it DID work, ive even compiled it for linux under windows correctly(lot of painful setup trust me). but my provider blocks binary code execution ๐คฃ ๐คฃ ๐คฃ
Anyway without the print, it's like 55 milliseconds lmao
thats the only reason why ive written a .dll like behavior in java
I don't see how they would really block that but ok lol
you can tuck the .dll into the java jar just fyi ๐
by blocking access to the standard libs libstdc++18.so which c++ binaries require to be executed under linux
its outside my reachable scope
and i cant statically link it
for some reason
even if the compiler includes these libs directly into my .so file
its still giving an error that jni cant execute it
but if i run it locally on my ubuntu installation with my mc server
probably throws some weird security exception then
it works just fine
so its the providers fault 100%
but yes
i did actually port it using jni xD
for x86, x64 linux + windows
screw apple xD
I touch nothing apple related
ikr
public final class LinesGoBrr {
private static final Path PATH = Path.of("words.txt");
public static void main(String[] args) throws IOException {
final var start = Instant.now();
// Actual code
var str = new StringBuilder();
try(final var channel = FileChannel.open(PATH)) {
final var mapped = channel
.map(MapMode.READ_ONLY, 0, channel.size());
while (mapped.remaining() > 0) {
final var c = mapped.getChar();
if (c != '\n') {
str.append(c);
continue;
}
System.out.println(str);
str.setLength(0);
}
}
// hehe funni time elapsed
final var end = Instant.now();
final var duration = Duration.between(start, end);
System.out.println("Time elapsed: " + duration.toMillis() + "ms");
}
}
```try this @lavish hemlock
should be faster
@noble lantern so that test how did it go?
oh I just realized I never closed any of the shit
my problem isn't the people that use apple
my problem is apple not supporting creativity with their products
@lavish hemlock fucking try it
its the way apple treats its developers
oh btw @rough drift It doesn't work
why not?
I specifically decode the returned byte buffer
since getChar and CharBuffer don't use UTF-8
what do they use
Hey, I was following this guide: https://www.spigotmc.org/threads/guide-on-workload-distribution-or-how-to-handle-heavy-splittable-tasks.409003/
But I'm having an issue that I don't understand, when I'm adding the workload, the size of the array increase correctly, but it remains ร 0 in the run method.
Did I missed something about the runnable comprehension or something else ?
public class WorkLoadRunnable implements Runnable{
private final static double MAX_MILLIS_PER_TICK = 2.5;
private final static int MAX_NANOS_PER_TICK = (int) (MAX_MILLIS_PER_TICK * 1E6);
private final Deque<WorkLoad> workLoadDeque = new ArrayDeque<>();
public void addWorkLoad(WorkLoad workLoad){
Bukkit.broadcast(Component.text("register workload: "+this.workLoadDeque.size()));
this.workLoadDeque.add(workLoad);
}
@Override
public void run() {
long stopTime = System.nanoTime() + MAX_NANOS_PER_TICK;
WorkLoad nextLoad;
if(System.nanoTime() <= stopTime){
Bukkit.broadcast(Component.text("can clean: "+this.workLoadDeque.size()));
}else{
Bukkit.broadcast(Component.text("cannot clean"));
}
while(System.nanoTime() <= stopTime && (nextLoad = this.workLoadDeque.poll()) != null){
Bukkit.broadcast(Component.text("try clean"));
nextLoad.compute();
}
if(DragonFightListener.dragon != null){
DragonFightListener.dragon.cleanFire();
}
}
}```
you cant really change final static ints in jdk 16 :/
ive even grabbed the required header files from both a linux and windows JDK installation and copied them to my project locally so i can compile for both linux and windows under one and the same project and both under windows
problem I detect?
not really
by reflection no, that is why I said just change it directly and compile
open it in your ide or whatever change the number save it
https://paste.md-5.net/erivizogog.cs
Even using hacky solutions the program dont recognize the new value haha
well
compile the jar and then run it
says read only?
what did it output
ik cause a jar is basically just a .zip rebrand but i can copy the dll onto the server xD. just not execute code from it
change the value and compile XD
hm
since it did nothing
The problem is the != '\n' logic would not work
Since the chars are not decoded properly
In the source files from build tools this field doesnt exist
So, as it stands my solution is the best since it WORKS
public final class LinesGoBrr {
private static final Path PATH = Path.of("words.txt");
public static void main(String[] args) throws IOException {
final var start = Instant.now();
// Actual code
var str = new StringBuilder();
try(final var channel = FileChannel.open(PATH)) {
final var mapped = channel
.map(MapMode.READ_ONLY, 0, channel.size());
try {
while (true) {
final var c = mapped.getChar();
if (c != '\n') {
str.append(c);
continue;
}
System.out.println(str);
str.setLength(0);
}
} catch (final Exception e) {
// End of file
}
}
// hehe funni time elapsed
final var end = Instant.now();
final var duration = Duration.between(start, end);
System.out.println("Time elapsed: " + duration.toMillis() + "ms");
}
}
try that
I thought maybe when you were saying they didn't allow binary execution they had some program to remove binaries from user directories
but by storing and using the dll from the jar itself
that wouldn't happen
27ms, and also still does not print anything @rough drift
because its in the MC main class file
fuck
!buf.isEmpty() works just fine
It's equivalent to uhh
buf.remaining() != 0
and buf.remaining() is just buf.limit() - buf.position() I believe?
and theres actually a very good reason for host providers to block arbitrary code injection @wet breach . just imagine the damage i could do to the cluster im on if i could break out of the env by injecting assembly code with hooks
i may have looked in the wrong directory lol
well you wouldn't
one of them has a difference MServer in them
not even
depends on the environment and whether or not they jail processes
if they do jail processes then its virtually impossible
bro
well there are trojans that even break out of a VM
i feel bad for spigot devs
its rare
how yall wait for shit to compile longer than 30 seconds
yes, but that is going under the assumption the the VM process owner has privileges to do anything anyways
if not, then they are still suck in a place that can't do anything
which they bloxk
i mean theres still the legal aspect
like
to own a server hosted by a provider
u gotta give legal info
so they can just sue u anyway
it isn't about the legal aspect in this regard to viruses
viruses disregard legal stuff XD
my point is, if a virus can break out of the VM, it doesn't automatically mean that once it breaks out it could still do anything
if the VM process is jailed to begin with, the virus is stuck in the jail which disappears when the VM goes away
oh no i can put whatever file i want on their servers xD. they just dont allow the execution of everything
public final class LinesGoBrr {
private static final Path PATH = Path.of("words.txt");
public static void main(String[] args) throws IOException {
final var start = Instant.now();
// Actual code
final CharBuffer buf;
try(final var channel = FileChannel.open(PATH)) {
final var mapped = channel
.map(MapMode.READ_ONLY, 0, channel.size());
buf = StandardCharsets.UTF_8.decode(mapped);
}
var str = new StringBuilder();
char[] chars = new char[512];
while (!buf.isEmpty()) {
buf.get(chars);
for (char ch : chars) {
if (ch != '\n') {
str.append(ch);
continue;
}
System.out.println(str);
str.setLength(0);
}
}
// hehe funni time elapsed
final var end = Instant.now();
final var duration = Duration.between(start, end);
System.out.println("Time elapsed: " + duration.toMillis() + "ms");
}
}
``` @lavish hemlock try this
I am just waiting on your reaction from the test
I am surprised you are having this much difficulty XD
Ooh, this time it causes an actual exception @rough drift
BufferUnderflowException :)
anything to do with WorldBorders isnt in this project lmfao
but yea youre right ive outsourced all my standard methods to my master plugin exactly to be able to develop new plugins faster, as well as updating them all at once by modifying the implemenation
Because the file is not perfectly aligned to a multiple of 512 bytes
Which means the emptiness check does not matter because the read will read more than it can
public final class LinesGoBrr {
private static final Path PATH = Path.of("words.txt");
public static void main(String[] args) throws IOException {
final var start = Instant.now();
// Actual code
final CharBuffer buf;
try(final var channel = FileChannel.open(PATH)) {
final var mapped = channel
.map(MapMode.READ_ONLY, 0, channel.size());
buf = StandardCharsets.UTF_8.decode(mapped);
}
var str = new StringBuilder();
char[] chars = new char[8192];
int read;
while (!buf.isEmpty()) {
read = Math.min(buf.remaining(), chars.length);
buf.get(chars, 0, read);
for (int i = 0; i < read; i++) {
char ch = chars[i];
if (ch != '\n') {
str.append(ch);
continue;
}
System.out.println(str);
str.setLength(0);
}
}
// hehe funni time elapsed
final var end = Instant.now();
final var duration = Duration.between(start, end);
System.out.println("Time elapsed: " + duration.toMillis() + "ms");
}
}
fixed it
what are we doing o.o
fastest file reading possible
Okay it's like, faster by uhh
need ram usage for that
120ms I think?
POG
Which is basically a 1/10 of a second
updated this
try again
you could make it faster if you stopped manipulating the contents
yes we know
dear spigot devs i implemented those missing WorldBorder methods from the itnerfaces your welcome
its with manipulating
Oh wait
read it all as bytes, put it in a byte array until you reach the end, close out file then turn it into something useful ๐
@rough drift It's not faster, actually
I assume there was just some JVM timing shit at play
however even with that, you are still only going to get to like 30ms or so
Only way to get faster times would be to code it in a different language :)
public final class LinesGoBrr {
private static final Path PATH = Path.of("words.txt");
public static void main(String[] args) throws IOException {
final var start = Instant.now();
// Actual code
final CharBuffer buf;
try(final var channel = FileChannel.open(PATH)) {
final var mapped = channel
.map(MapMode.READ_ONLY, 0, channel.size());
buf = StandardCharsets.UTF_8.decode(mapped);
}
var str = new StringBuilder();
char[] chars = new char[8192];
int read;
while (!buf.isEmpty()) {
read = Math.min(buf.remaining(), chars.length);
buf.get(chars, 0, read);
for (int i = 0; i < read; i++) {
str.append(chars[i]);
}
}
// hehe funni time elapsed
final var end = Instant.now();
final var duration = Duration.between(start, end);
System.out.println(str);
System.out.println("Time elapsed: " + duration.toMillis() + "ms");
}
}
there
JVM bottleneck
try that
if you want to go down to 10 or below you have to toss that file into ram
oh wait
That is uhh
What we're doing
The file is memory-mapped
run this @lavish hemlock
wait
no
updated it
run it now
then not sure how its getting only 120ms lol
its loading frost
what did you change TPS to?
its counting loading and processing it
Okay so this is as fast as 64ms bc you've essentially changed how the processing works
alright join it @noble lantern ๐
yep
Instead of printing each line as an individual line
okay there
You process it as one big string
and have some fun with with more TPS!
Which is not the intended behaviour
it is
wtf it reverted to 20 in game
the output is the same no?
It's meant to treat each line individually
alright then
Like if you were working with the lines individually, not just as a print
You would have a list of strings
That's not possible here
then you must have not changed it right or maybe forgot to save the file XD
But yeah it's effectively the same speed, the prints are just not measured
should still get faster then 64ms
nono i definatly did i set the public static final int TPS to 100
./tps still says 20
public final class LinesGoBrr {
private static final Path PATH = Path.of("words.txt");
public static void main(String[] args) throws IOException {
final var start = Instant.now();
Executor executor = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors());
// Actual code
final CharBuffer buf;
try(final var channel = FileChannel.open(PATH)) {
final var mapped = channel
.map(MapMode.READ_ONLY, 0, channel.size());
buf = StandardCharsets.UTF_8.decode(mapped);
}
var str = new StringBuilder();
char[] chars = new char[8192];
int read;
while (!buf.isEmpty()) {
read = Math.min(buf.remaining(), chars.length);
buf.get(chars, 0, read);
for (int i = 0; i < read; i++) {
char ch = chars[i];
if (ch != '\n') {
str.append(ch);
continue;
}
executor.execute(() -> System.out.println(str));
str.setLength(0);
}
}
// hehe funni time elapsed
final var end = Instant.now();
final var duration = Duration.between(start, end);
System.out.println("Time elapsed: " + duration.toMillis() + "ms");
}
}
try that
Now you're measuring executor instantiation ;)
something either overrode it, or the value you changed isn't the one used
yes
or right
you need to modify the while loop @noble lantern delta stuff
Make it a static field, those basically load as fast as possible
public final class LinesGoBrr {
private static final Path PATH = Path.of("words.txt");
private static final Executor executor = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors());
public static void main(String[] args) throws IOException {
final var start = Instant.now();
// Actual code
final CharBuffer buf;
try(final var channel = FileChannel.open(PATH)) {
final var mapped = channel
.map(MapMode.READ_ONLY, 0, channel.size());
buf = StandardCharsets.UTF_8.decode(mapped);
}
var str = new StringBuilder();
char[] chars = new char[8192];
int read;
while (!buf.isEmpty()) {
read = Math.min(buf.remaining(), chars.length);
buf.get(chars, 0, read);
for (int i = 0; i < read; i++) {
char ch = chars[i];
if (ch != '\n') {
str.append(ch);
continue;
}
executor.execute(() -> System.out.println(str));
str.setLength(0);
}
}
// hehe funni time elapsed
final var end = Instant.now();
final var duration = Duration.between(start, end);
System.out.println("Time elapsed: " + duration.toMillis() + "ms");
}
}
how fast is it now?
I see someone likes to spam finals everywhere
That's me ๐ค
yes finals are good, but it was @lavish hemlock that did that
finals are good, unnecessary to put everywhere
public final class LinesGoBrr {
private static final Path PATH = Path.of("words.txt");
private static final Executor executor = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors());
public static void main(String[] args) throws IOException {
final var start = Instant.now();
// Actual code
final CharBuffer buf;
try(final var channel = FileChannel.open(PATH)) {
final var mapped = channel
.map(MapMode.READ_ONLY, 0, channel.size());
buf = StandardCharsets.UTF_8.decode(mapped);
}
var str = new StringBuilder();
char[] chars = new char[8192];
int read;
while (!buf.isEmpty()) {
read = Math.min(buf.remaining(), chars.length);
buf.get(chars, 0, read);
for (int i = 0; i < read; i++) {
char ch = chars[i];
if (ch != '\n') {
str.append(ch);
continue;
}
String line = str.toString();
executor.execute(() -> System.out.println(line));
str.setLength(0);
}
}
// hehe funni time elapsed
final var end = Instant.now();
final var duration = Duration.between(start, end);
System.out.println("Time elapsed: " + duration.toMillis() + "ms");
}
}
run that
Nah
should be fast as fucc boi
I'll just figure out the executor myself
ok, you guys are testing this wrong
Yeah yeah, benchmarking is preferred
there is a difference between cold and warm testing
cold testing involves having to wait on the JVM to intialize itself as well
warm testing would have the JVM already running then you initiate your test
we know we know
I'm not gonna set up JMH for this this was just meant to be like a 10 minute quick code snippet
you don't need JMH for this
Ike's the one who wanted to optimize it to perfection lol
can you run this tho
you just need to have the JVM already running ๐
where you can just invoke a command to make it happen
or just
Ooh it appears to deadlock :)
?
It never reaches the print at the end
?
hello hello how can I fix this?
deadlocking is fun XD
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
fuck this imma stop here
well whenever I get my IDE setup which probably will be some time tomorrow
how long does it take
I will have to demonstrate a good test in testing memory mapping Xd
to install intellij
I don't use intellij
pls help
install maven
eclipse?
NetBeans the official IDE of spigot ๐
why would you subject yourself to that?
i went over to maven cause i need craftbukkit in the future(creating custom pathfindergoals) but its super anoying to be forced to use it and its anything but user friendly
k im just retarded
because NetBeans does everything I need it to
there is nothing IntelliJ provides that I require or need that NetBeans doesn't already provide
how I downloaded some ordner but what now?
honestly from a user friendly pov
it was much more convinient to juse import the whole server.jar
dark
mode
Netbeans has that
and yes ik someone would bash me yelling "remapping"
VS Code is the Real shit
y e s
didnt find a way to develop for java in vs
You can make this faster by just appending the char array, as opposed to iterating over it per byte.
do u make more than 1m$ per year?
he does
depends
lemao
dont let him fool you
I assume the reason why is because StringBuilder likely uses array copies for this
I mean, technically you could say I do
and untechnically?
U can
oh i was talking about brutto
its not income if its not in money form
vs community licenses permit for a total revenue of 1m$ brutto/year
oh
xD
professional is only if you make like the really big money
and lets be honest
1m/y is already big
not really
even with taxes
I could easily spend a mil and not have really got much
if i made a mil a year ide shart myself
4 houses but kay
anyways there is a differences in the professional editions and community editions
which is?
professional is normally for companies
yeah that is a single house if you look at Cali
if you use community version and use it for your own things your fine
as long as your income isnt based off of using that
professional is for single developers making big money
enterprise for the same but corps
obv
its already in its name after all
Enterprise just gives you that tech support stuff
Professional I just don't have to worry about much ๐
and the license for multi user purposes
dis is marg from migrosofd
LMAO
to be fair, they can get your code working
deadass?
so all i gotta do is buy enterprise
however, quality wise on the other hand they are terrible but they will create you working code though
@rough drift You can also cut the time down to 11ms if you read the whole buffer into an array and then do new String(bytes, UTF_8)
and i get unlimited code support
private static String v1() throws IOException {
try (var channel = FileChannel.open(PATH)) {
final var buf = channel.map(
MapMode.READ_ONLY,
0, channel.size()
);
final int capacity = buf.capacity();
final var bytes = new byte[capacity];
buf.get(bytes, 0, capacity);
return new String(bytes, UTF_8);
}
}
ive always thought of that
(I know the int cast is ugly)
even with protocollib
thats why ppl from western countries going into coding
need themselves to get hired by corps
which want persistent support for their products
like sap
etc
Well coding jobs at least the serious ones are not being outsourced
wtf is wrong with my grammar today
the locations to outsource are not inherently better. Sometimes not even cheaper once you include all the other costs and what not
thats what i mean
u only outsource jobs for one time cheap ass tasks
yep
like coding the software for a cheap ass receiver u plan to sell low budget and never provide any support for afterwards
xD
only of ur a reputable company
however them Indians though make it hard to be a freelancer sometimes
because like I said how cheap they will go
donde dell me whad do do
and that is because USD is worth more then rupees
basically
There's also a 3 line solution which executes in 70 milliseconds
Although it uses Files.lines
So it's not memory-mapping
just for some rando weird comparation
however there is an upside to this though
if you want to buy some really nice business suits even 3 pieces go to India
$100 gets you what is essentially a $1k suit
and they are nice
spend $300 and you can get 3 suits ๐
wat no i don't think so atleast in my city good suits are nearly like 400+ dollars
in India?
yea
the cheap suits you are saying are basically non existent and even if you find some it won't be in the quality you mentioned
120 euro for a suit ๐คก
(not me)
not sure what you are talking about them being $400+
are you a maffia leader or something
20k is very cheap lol
that is only $263
(Passing the list is done to avoid capturing the list instantiation in the timing)
(This is 15ms)
yea not like for 300$ 3 suit
the ones I am seeing, which would be about $1k here in the US, are averaging $130-$160
i hope hes proud of himself
I am not talking about the super best
you don't need the super best but even then still not expensive for someone like me
to order one from India
far cheaper for me to order a nice decent suit from india and have it sent to the US XD
yea right it is not as expensive as US
yes you can
but by the average salery
no
the actual cost of an item depends on the average salery
relative to the price
the main reason it is cheaper to buy in india other then because of the dollar value being worth more, is because the threads come from over seas to begin with most of the time, so ordering closer to the source of materials generally results in cheaper costs ๐
in swizerland they make like 2-3x as much as we do in germany
but their items cost 4-5x as much
so they actually have less
even tho they earn more
yea the avg salary of IT person here is like 2 lakh like 2.6k $
2 lakh a month i mean
197,230 rupees a month?
yea kinda
if thats the average salery why are there scammers
scamming ppl for 500
and feeling rich about it
thats something i dont understand like
stereotype lmao
because USD is worth more
there are scammers
anyway near worthwhile
you are forgetting that average salary doesn't mean cost of living
yea cost of living is also not that much yk
average salary for IT could be above what is the cost of living lol
like for a 1500sq apartment it is 70 lakh for purchase and for rent it would be just 15 k in even capital cities
the scammers are people who are lazy and don't want to work. They only need to put in a few hours and get like 5 people scammed to make anything decent
yea but thats my point
15k in 200k isn't much and our family salary is just above 200k and yea we r fine
2k is 1% of theyre salary so its worth for 30 minuts of time
if there are much higher saleries achievable "easily"
because if they are taking home 3,000 but their cost of living is only 1,000
IT isnt really easy in most cases
that is 2,000 they are bringing in extra
I wouldn't say easily. Just because it is India doesn't mean they like to hire criminals or those who are lazy
nah but like lets be honest anyone can learn at least basic coding
its like saying you can get a job in networking in some data center right now without needing any credentials or background
its just time investment
it depends what you need to prove and what they accept as proof
in the US we just had that problem
where people stopped going to school, which means less people with degrees
but Degrees never dictated who did or did not know stuff
a lot of companies hire without degrees ngl
Well you are talking about the stereotypical India while most people here do not relate to those @granite owl
but Degrees are what businesses required
not all of em tbh
they are starting to here in the US a lot more, because people stopped going to school
ahhh i see
im aware of that
but yeah most jobs i see for jr devs require no school time just previous experiences, which doesnt have to be prefessional 5* bussinesses
people didn't want to take on school debt of $100k when you can get a job and in 4 years or sometimes less make a salary of that much without a degree at all
jr devs in cali make bank its whack
well not completely
yaya
someone paid
i'm searching for an artist so he can make me a plugin icon
50โฌish euro per school year
just looked at listings for jr devs 60k and in some cases 100k just for a nodejs dev lmfao
and per month or so for a university
@jagged thicket just for you
what?
๐คฃ
you just need to be good enough
๐คฃ
that's a lot for 64x64 pixels ๐
ngl i paid more for a server icon one time lmao
i don't need money , i don't have any expenditures and i don't take money for anything
its probably the cheapest you will find depending on quality factor ๐

i will even do it for free
pls help I cant get my maven to work .. I set the environment veriables and it workes in the cmd what do I put in intelliJ now?
then fiverr is my way to go