#development
1 messages · Page 91 of 1
Anyone understand the heap and have good experience with eclipse memory analyzer? I'm trying to trackdown why with 61 players online (61 PlayerConnection objects) ive somehow managed to use over 10gb of memory, for some reason, seems to be related to the PacketPlayOutMapChunkBulk packet but.
Sounds like you‘re on a completely wrong path
What are you actually trying to figure out
Why I'm using 10gbs of memory with 60 players on.
I was told there was a memory leak, but I've seen nothing obvious, although I am wondering why that packet specifically is seemingly accompanying 90% of the size of each PlayerConnection object.
hi
hi
Well, most likely because you told the server to use that much
No like, as I sent the picture in your dms- one playing is literally occupying nearly 1GB of memory to themselves.
how could I create like a ghost block only for 1 player (protocolLib ig) that would be invicible and would stay in place (so setGravity to false and it wouldn't drop etc.) i was trying to make it but im starting over
if anyone could help I'd be really grateful
like a falling block, it needs to be uncollidable
im kinda beginner in writing plugins so i can say b^llsh1t
1.8 💀 but yeah you already see which plugin is referencing these objects
listen right draft maps people still play them- well some do LOL
well i thought like
Player#sendBlockChange
someone made a shitty NPC plugin
cause i tracked that down below
cause he didnt flush packets
had like 1923192312 QueuedPackets
it will do a falling block?
No, it'll be a ghost block which is what you asked, not a block entity
but it won't be collidable?
607mB of packetplayoutmapchunkbulk objects in one playerconnection 😠
and could I do a highlight on it?
No
:/
If you want an entity that only one player can see look at Player#showEntity
im trying to create like a preview before placing structure @pulsar ferry
like you know, in rust
Yeah then you want entities therefore ^
so it'd be better on falling block as entity and them mb highlight for it?
Probably better as block display entities
@lyric gyro why you do keep sending me friend request?
Yes, you sent me twice already
I never even used the memory analyser wrong, I just had blind faith for the developer of the jar. Of course there was no upstream inbound references, becaues the issue was on packet received with server-debug mode on he just adds infinitely to a map with no capacity and it is only cleared manually via command 📈
lmao
Hello, i would like to know how i can replace all placeholders inside a String, so like i have a config String like "%player_name% has a ping of %player_ping%"
and i would like to replace everything at once
u want to replace
in a placeholder replacement?
theres an expansion for that I think with PlaceholderAPI.
normally i have done that with PlaceholderAPI.setPlaceholder()
but i want so not to replace a specific one.
wait im confused what you're trying to do lemme read again
you want to replace everything? as in parse all the placeholders in the string?
yes
setPlaceholders should do that as you said though
diff sigs but the javadocs says its translates ALL placeholders into their corresponding placeholders, theres' just overloads for like offline players, arrays, etc. all do the same thing tho
yes, PlaceholderAPI.setPlaceholders does parse all the available placeholders, no need to specify what you "want" to parse manually
but here i have to specify a placeholder:
p.sendMessage(PlaceholderAPI.setPlaceholders(p, "%player_name%"));
Ahhhh
so you would do p.sendMessage(PlaceholderAPI.setPlaceholders(p, "%player_name% has a ping of %player_ping%"));
hello, could someone help me make a ghost block visible to only 1 player using protocollib, it'd be falling block, i just dont know how to strat, and then if someone could tell me how to teleport it to coordinates
i'd be really grateful
i just tried and i have no idea
i told you before, you don't need protocol lib, you can use the api for that, and use display block entities instead of falling blocks
nms exists
0 reason to use this 99% of the time
I just checked, everything you need to know is easily googlable; at least come back with a failed attempt and you'll get much better support
use ignite instead of any of it ong
I want to fork deluxetags to allow for different guis for different tag groups, anyone know where I can get the repo?
i do not believe it is open source
Use https://paste.helpch.at/ for errors, logs and configs. So we don't spam the discord.
Please go into the discord server linked in https://www.spigotmc.org/resources/deluxehub-3-professional-hub-management.49425/
maybe it doesn't support 1.21 yet? 🤷♂️
what does a hub plugin need to not support, like, any version lol
from the spigot page, probably:
- tablist
- holograms
- anti world downloader (I wonder how that works)
are you neanderthal
I guess so :<
world downloaders send a plugin message packet stating it is running but that can easily be stopped on the client lmao
it might also do something chunk loading related but i dont expect that
it indeed does not after seeing the code lmao
What the fuck is a server going to do in order to prevent that bruv
I was thinking maybe the same way anti x-ray works
but that wouldn't really matter for hubs
since not much to hide below the surface
in a data model class i have a method called getTable that return an enum of type Table. It is overriding an abstract class.
@Override
public Table getTable() {
return Table.ITRequest;
}
why when i try to obtain this method from another method using :
Table table;
try {
table = (Table) modelClass.getMethod("getTable").invoke(null);
} catch (Exception e) {
throw new IllegalAccessException("Model is missing a valid getTable() method that return a Table enum.");
}
it throw the error saying the model class i'm passing in is missing its getTable method?
you're invoking the method with a null instance which would only work on a static method.
wait
hold up
may of misread my ui is miniaturized rn
wait not yea
The error occurs because you're invoking the getTable method as a static method using invoke(null), but it's an instance method.
since getTable() is an instance method (overrides an abstract method) it requires an object instance to be called, and using invoke(null) attempts to call it statically
ohhh i see now, the method was previously static but then i implement a new abstract class for required method. Thank you for pointing that out!
all good :P you should probably use specific exception handling too, rather than just throwing an illegal access exception/print the statcktrace. I.e. } catch (InvocationTargetException | InstantiationException e) {}
Any reason maven would stop shading jars into my plugin?
Haven't changed anything, ran package and the output jar doesn't contain any of the files its suppose to shade.
sounds like you misconfigured something
Haven't changed anything since I used it last so misconfigured wouldn't sound right.
the alternative is that a cosmic bit flip modified maven code in a way that it suddenly behaves fundamentally different
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/**</exclude>
</excludes>
</filter>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
```This seem right?
that part yes I guess
Yeah then no clue why its not shading.
Well that’s not the only relevant part
Made a new project, copied over the code, converted it to maven, generated a fresh pom, added the shade plugin and dependency, ran with package.
Still doesn't contain the dependency.
Then you‘re still doing something wrong
I can’t magically see the rest of the pom, so no
I'm not on PC anymore. Fresh pom generated with the maven compiler plugin written and I just added the shade plugin and dependency.
That doesn’t help at all
is it possible to to check for Number Format exception like this ?
yeah
^
ditto
How do I get my plugin to show stats on Bstats?
Thanks!
Bonjour, je souhaiterai savoir comment modifier le nombre de chunck claim ( les passer de 4 à 1 seul)
Merci d'avance.
I don’t think this is the right place
I think #general-plugins
And you probably need to ask in English
Okay, thanks
io.netty.handler.codec.EncoderException: com.viaversion.viaversion.exception.InformativeException: Please report this on the Via support Discord or open an issue on the relevant GitHub repository
is it possible to exclude these 3 class from my module or i have to move out into another package ?
What do you want to achieve? What type of module are you talking about?
i want to not expose the DataMapper, MongoMapper and SQLMapper outside the module
if i do dbConnect.mapper it will expose all class within this package
As you‘re having a module-info.java already, just put them in their own package and don’t export it
so there is no other option then, ty
I mean you can make them package private, but that probably doesn't help you
Creating my own placeholder for my plugin, how can I return my string with color?
if(params.equalsIgnoreCase("clan_role")) {
String clan = plugin.getClanManager().getClanByOfflinePlayer(player);
if (clan == null) return "";
else if (plugin.getClanManager().isOfflinePlayerOfficer(player)) return "O ";
else if (plugin.getClanManager().isOfflinePlayerLeader(player)) return "L ";
else return " ";
}
I tried just adding $#xxxxxx infront of O and L but it output that exact text, no color parsing.
if you're using more recent versions of minecraft, you using MiniMessage, otherwise, the ChatColor class
PAPI supports Minimessage coloring?
when you're making your own placeholder, and assuming your jar is added as a dependency in this plugin you're making a PlaceholderExpansion hook just translate it directly
e.g. MiniMessage.miniMessage().deserialize(message, Player)
i mean u can also write a method to use legacy class to translate hexadecimal colors
Right I see what youre saying now. Issue is, the plugin parsing my placeholder is not made by me.
Trying to get color from a placeholder to parse in EssentialsX Chat
my plugin provides the placeholder.
EssentialsX Chat and also TAB will need to parse it.
So are you making an expansion or a plugin that has an expansion in it where is the code you sent from
I'm making a plugin which has an expansion in it.
A clans plugin which provides clan related placeholders.
So just pass the string you're returning into one of them methods
TAB plugin already hooks placeholderapi
the string is ▸ but I'd like it to be colored based on their clan role.
Yes so in your plugin right, which as a java plugin I assume has a dependency for your server jar
so you'd have access to the MiniMessage class
so when you return the placeholder string
e.g. "L "
pass it through the deserialize method
you can also write your own method if you don't wanna use the new system for it, although seems rather pointless but you can find more inf o on that and how it works here: https://www.spigotmc.org/threads/hex-color-code-translate.449748/
If you want to get a String and not a component back though since im pretty sure the placeholderapi method wants a string returned not a component
You can use the LegacyComponentSerializer to achieve that too, I think itll still parse hexadecimal colors fine.
I cant pass it through the Minimessage deserialize method if I'm trying to use it in EssentialsX chat right?
i dont think essentials by default passes its messages through the needed placeholderapi method no
I dont think essentials ever has hooked placeholderapi by default
at-least it didnt in 1.8
TAB does tho
I use chatInjector plugin which does translate papiplaceholders for essentialsX
but it doesnt seem to pass them through mimimessage
Right yeah, tab is working fine, it seems to be able to parse it. Its my papi -> ChatInjector -> essentialsX chat flow thats really causing problems.
im unsure what you're directly trying to do, yes the chat injector plugin will parse ur placeholders, and if ur placeholder is passing the string through a minimessage method most likely the LegacyComponentSerializer if you want a String not a Component, it should still work all the same. So if you in your placeholder were to return eg..
return LegacyComponentSerializer.legacySection().serialize("<#f04747>L ");
than you use the placeholder in your chat injector plugin id imagine it would work out just fine
" Essentials chat does not support PAPI directly. You need to use the plugin chat injector to use placeholders in your Essentials formats. "
if you use your placeholder you just created there, that doesn't work?
I'll give that a shot. I was attempting the essentials format of color codes &#f04747 rather than Component format <#f04747>
i think newer essentials locales support minimessage by default im honestly not sure with alot of this newer stuff as i havent really even fucked around with newer mc - pretty much always been 1.8
But I know in 1.8 and im pretty sure its the same now
EssentialsChat
its self
does not pass its strings
into placeholderapi
You could always fork EssentialsChat or just use your chat injector approach for placeholders
Then when you make your placeholders whenever u use them in your chat injector plugin it should still be displayed normally, because im pretty sure it all translates the same nevertheless
yea, I would hate to have to maintain a fork of EssChat tbh.
i never thought esschat was that big tbf
ik essentials is big
never thought essentials chat was
and considering all youd be adding is what?
PlaceholderAPI.setPlaceholders
or whatever the methods called
not a insanely strenuous task
yea even with component format, doesn't parse the color code in essentials [#808080](/guild/164280494874165248/channel/808080/)O Zerek: .
so ur what, now trying to just edit ur essentials config?
to change chat formats
did &#f04747 or just #f04747 work
&# no, I'll try #
ess might be using their own custom method such as the one I showed u when linking you that thread
rather than minimessage
to maintain
backwards compatibility
or something
I think i have a problem that might solve your placeholder problems too
although i dont know if itll work for your version as I made it in 1.8 or a friend did I think
let me check
no luck with #xxxxxx format
according to the essentials config you should be able to do this though;
# A color code between 0-9 or a-f. Set to 'none' to disable.
# In 1.16+ you can use hex color codes here as well. (For example, #613e1d is brown).
I think the trouble is, with the placeholder being parsed with chatinjector, that happens after essentials has done its parsing.
So essentials does color correctly if I put those formats directly in the essentials chat format section but when passed via chat injector, no luck.
So really I need a chatinjector that can parse some hex code formats.
idk the plugin ijust sent you will purely set ur chat format with the papi parsed result, so if ur using or wanting ot use ess chat primarily for your chat formatting - the plugin I sent you alongside essentials & essentials chat are the only ones you should require~
Seems like thats basically a chatInjector. I'll try it out.
for anyone reading the conversation we sorted it out in dms 
Is there a way of sorting a json object so I would have score shown on the top line?
JSONObject bestItem = new JSONObject();
bestItem.put("score", score);
bestItem.put("supplyFactor", supplyFactor);
bestItem.put("liquidityFactor", liquidityFactor);
bestItem.put("profitPerItem", profitPerItem);
bestItem.put("marginPercentage", marginPercentage);
Output:
"FLYCATCHER_UPGRADE": {
"supplyFactor": 0.8737040984105191,
"liquidityFactor": 20.71231517720798,
"score": 19020.651041060628,
"marginPercentage": 4.36,
"profitPerItem": 1104751.8000000007
}
use a json library that preserves order
Could also format it as an array
Maybe
Oh wait nvm that's yaml
Or I guess it'd work in json as well, just not as pretty
Oh wait is this a config
Or data
If it's not config then yeah I think array is the way to go
It's data
Working on a system for getting the best flipping items for hypixel skyblock lol. Just for fun
Then when it's done, I'll implement AI to try and predict future best options
I think it could be good
<scope>provided</scope> means that that dependency will be provided at runtime
meaning that maven won't shade it because it assumes that it'll be provided
remove that line and maven should shade that dependency
(by default, it's <scope>compile</scope> which tells maven to compile that dependency into the shaded jar)
how do i use paperweight for a specific version of minecraft?
or like im trying to use the mojang remapped and I havent done it before and I keep running into issues
wdym? specify the version in the build.gradle
impressive
anyone got an idea on why Oraxen/ItemsAdder in 1.21.4 just doesn't seem to overwrite textures on inventory items, weapons or armor. It does however, when placing textured blocks seem to texture the physical block, and inventory textures work fine, so im confused. could it perhaps be something to do with paper? I mean it has a NMS impl for this version so I wouldn't understand why
loom {
splitEnvironmentSourceSets()
mods {
"mod_id" {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
}
}
I'm reading on the loom section in the fabric doc for the spilt source of mod, do I have to create module-info for it to work ?
i don't think fabric modding has any support for java modules
does any1 know where the javadoc for the minecraft package is ? i tried downloading the javadoc but it seem like there is none
Wdym javadoc
Mojang provides no javadoc lol
There's some community one, literally google it
I don't think you can publically post that
so there is no documentation for what their method do? got it
which method?
method under the net.minecraft package
that's.. not exactly it
that's for forge
if you want to see the actual "source code" (decompiled), you can use paperweight userdev
this way you can see the actual implementation
https://docs.papermc.io/paper/dev/userdev
for fabric too, it's mojmap compatible, so you could probably make it work with paper NMS
Well yeah, but they wanted javadoc, not source
well, seeing what code actually does, not what some text says it does, imo is more valuable
ofc, but that's not what they asked for
im just trying to figure out what some of the method under the net.minecraft package do, for example i know getUUID() probably return the entity's uuid, but what type of uuid they return is not availiable, does it compatile with the java.util.UUID class or not (which it might since mc use uuid version 4)
well I already answered, that there are no public javadocs available and gave a (imo) better option 🙂
sure you can use some sort of library that will provide you some sort of "docs", but I'd value seeing the implementation more
they are free to ignore my suggestion if that's not what they are looking for
i mean if i really want to see the source code i could decompile view it in intelij but i will check out paper nms
not sure if it is compatible with fabric...
you would probably only see the interface
oh, you need fabric, I totally missed that one
If you're using fabric you can just use what I sent :/
i'm not sure but i guess this is the game's entity class ?
yeah it use java.util
there is no javadocs, you have to middle click and go read the code to find out what it does, atleast thats easier with mojang mappings but still kinda a pain
Helo i need person for create big project in Minecraft , if you whant please dm me or tag me
You can use #1356509235214811257
Dm me because I am still looking to get experience, I would do it for free
Can someone compile a Minecraft Mod for me? It's my first time coding one and I'm getting a few issues while compiling.
It stucks on this
What do y'all use for web scraping these days? I used to be a heavy selenium enjoyer back in the days, is there something better/easier out there in 2025?
the tool that you are familiar with is probably gonna be easier than learning an entirely different one
but yeah, most likely there are plenty of alternatives
i usually go with python's requests package
and if i have to deal with captchas i'll pay some online service something like $0.0002 per captcha i need to solve
Hello, if I receive more arguments with my placeholders, does it have the underscores?
For example I have placeholder with the identifier test.
When I do %test_doSomething%, the @NotNull String params will be doSomething.
But when I want to do %test_doSomething_doThis%, will the params be doSomething_doThis or doSomething doThis?
with underscores
does deluxetags have an API?
My custom placeholders break when I do /papi reload, is that normal?
Restarting server fixes it tho
do you get an error or what?
also did you overide persist()?
No, basically for example if I have my custom placeholders in a scoreboard, it shows the values of the placeholders. After I reload papi, it shows %alive_size% as a text
override it as true
Has anyone made a free VPS with Oracle? I have one, but it won't let me make internal connections. How do I connect from outside to the VPS database? I'm supposed to have everything configured correctly. But it doesn't work for
allow 3306 via network security config
Is that on the oracle panel ?
yes
I'll try, thanks
Please don't open port 3306 to every person on the internet..
what can go wrong?
well, lots of things can go wrong
brute-force attacks
ddos attacks
vulnerability exploitation
I should really start using /s
is just for database and random stuff testing
There really won't be anything important there
If I were you, I'd still set up a VPN (the easiest way would be through Tailscale) for communication with the database
Why?
for reasons outlined here ^
But as I said there wouldn't be anything important anyway
Use an ssh tunnel
Can I get my expansion verified?
https://api.extendedclip.com/expansions/floodgate/
Please let me know if this is the wrong channel
it is the wrong channel
For this I wouldn't worry about it
If you're a larger server with a reason for someone to
- Figure out your database vps IP (which is a separate issue)
- Want to attack not just your main server but also your database vps
Then sure
And plus you mentioned that there isn't anything important
Sure, it might not hurt to do this for good practices, but that should be done after you figure out the basics
At least, in my opinion
nowhere in this image
but should be on this page
I know, but it's just for testing, in case I need to test mariadb or redis connections or others in my plugins.
I can't use it for that anyway because I can't connect from outside. :(
I've had an empty database hacked because Docker was exposing it with the default username/password for the service it was hosting. The IP was published exactly nowhere but they still found it
no need to publish the IP
the bots automatically scan every possible IP in the world
Exactly, that's why it's important to keep best security practices no matter how popular
everyday I get hundreds of pings from various locations for my webserver lol
Same
What's this?? I've been looking for something similar
cloudflare dashboard
Ahhh damn it
I wanna self host.
I bought another server this week and wanted to attempt to set it up as a honeypot- but I couldn't connect via IPv6 since my damn ISP doesn't support it 
It was so fun figuring that out after 4 hours of troubleshooting haha
posthog
Oe lemme have a look, thanks man
Umami is very lightweight
hi
i need someone to help me make a bot
i already has evrything evrey cod
but i need someone to help
pls dm to help
Vouch
^ hangar/paper uses umami
Should I create my event implementations using ByteBuddy? I plan to have a shitload of events and I don't feel like manually implementing them because they will all follow the same format
I currently have a system where I use ByteBuddy to generate event impls at runtime
What exactly are you generating there?
you should just generate them once with a template in IJ or something lol, then they'll be actual code
i've been forced to use Lombok for my work (stinky Java no Kotlin :/) and there have been quite a few issues with it, but it is kinda nice. but for something like that, you probably just want the actual real implementations for editing or whatevs
lombok professional :o
Ended up using this approach https://github.com/PulseBeat02/MurderRun/tree/main/src/main/java/io/github/pulsebeat02/murderrun/api/event
I'd probably just use Immutables tbh
same here, java & lombok at work lol
not sure why anyone would touch lombok
I’m looking for an experienced developer to create a custom plugin for my Minecraft server. If you’re available, I’d love to discuss the details — of course, I’m happy to pay for your time and work.
eh, well, it gets repetetive pretty quick when you are writing same thing over and over and over again (getters, setters, constructors, builders, toString, hashCode)
It's not that bad as people usually portray it to be
dont paste the same thing over N different channels
#1356509235214811257 #1356509232521810050
adding to what I already said, if one is bothered by "magic behaviour", that could potentially be said about libraries like Guice (at least from my POV). For ex. when you add @Inject on a constructor - you cant see where the constructor is actually used.
guice is still java, lombok is not
eh, well, compile-time magic vs runtime-magic
wouldnt said lombok is "not" java, the produced bycode itself is still "100%" java
techically not that different how javac turns .java to .class, just that lombok adds stuff before that
I understand that lomboks compile-time transformations are "not" really a part of java lang spec
saying lombok is not java is kind of philosofical jab, not a "technical truth"
kind of like saying JSX isn't Javascript, depends on how purist you are
bytecode is not java, it's bytecode
JSX also isn't JS
there's a reason why we have language specifications
lombok also encourages terrible design choices, because everything you do with it is basically an anti-pattern
huh, wdym?
getter, setter, equals and hashcode depending on mutable values, etc
Uhh and how are getters and setters anti-pattern?
well that's opinion, not a fact
just because you can write anti-patterns, does not mean you should
you can misuse any tool, you can abuse Spring too (@Autowired, using Field injection, using everything as @Component, abusing AOP/Proxies/Reflection, misusing @Transactional), so does that make Spring "bad"?
also lombok supports immutability and encapsulation. you can write clean, encapsulated and testable code.
4+ years that I have been working with lombok I have not encountered a single issue with it, personally
My two cents to the discussion is that lombok complicates codebases but makes code less verbose
For example, as long as you run lombok with standard data objects, normal beans etc, you’ll find it rather fine and consistent to use. The problem I have whenever I see lombok used in a project is that you always end up deviating in design, because put simply; not all classes are gonna look like normal beans- and so you eventually get to this inconsistency issue where some constructors are lombok-generated, some are written out, some getters are generated, some are written out (in the same classes even). This is complicates your codebase due to its inconsistency and ambiguity in how things should be written - the java way or lombok way.
also, there are worse things than lombok such as AOP
I'd assume it really varies on the project itself, but with thousand classes that we have at work, we haven't had any of the issues you've mentioned
Ever heard of Law of Demeter and information hiding?
Additionally, I don’t think it’s worth narrowing down the verbosity at the cost of making ur code more complicated- at the end of the day Java has its advantage in being verbose by nature to a great degree
Yeah tbh I don't like Lombok either, I just don't understand why everything that Lombok does would be anti-pattern
How is that related to Lombok tho? It doesn't matter if I create the getter with an annotation, or with a method
The point is that if you use Lombok because you want to create getters without noise, you‘re hiding your bad decisions
lombok doesn't force you to expose internals, it just gives you tools to automate boilerplate, it's still up to the developer to use those tools responsibly
I’m not sure how much you actually consider boilerplate, in my eyes that can be a bit subjective
Also if you just need data objects, then generating them from some spec would still be less verbose than Lombok and compatible with Java
that's true. usually that's just "predictable, low-value code", for ex. getters/setters, constructors, equals/hashCode/toString, DTOs. they don't express any business logic, by using lombok you remove all that "noise" and can focus what really matters for the client.
Someone should really make sure that Lombok breaks with every javac update
TLDR, pick your poison
public class User {
private String username;
private int age;
public User(String username, int age) {
this.username = username;
this.age = age;
}
public String getUsername() { return username; }
public void setUsername(String username) { this.username = username; }
public int getAge() { return age; }
public void setAge(int age) { this.age = age; }
@Override
public String toString() {
return "User{username=" + username + ", age=" + age + "}";
}
@Override
public boolean equals(Object o) { ... }
@Override
public int hashCode() { ... }
}
@Data
@AllArgsConstructor
public class User {
private String username;
private int age;
}
See, you could generate the first from a specification that is shorter than the second
Pick the sane solution or the poison
isn't that literally what lombok does?
Yea but then again, that’s a simple bean just ^^
in the real world it doesn’t always look like that, (in my opinion and experience just)
No, lombok modifies internal structure of existing Java code instead
For example spark has that protobuf stuff https://github.com/lucko/spark/blob/master/spark-common/src/main/proto/spark/spark.proto and generates Java code from that https://github.com/lucko/spark/blob/7222735880426df46205d809dcb283d041d572a4/spark-common/build.gradle#L62
Works great and doesn’t meet any hacks
And it‘s also less noise than having multiple declarations of the same thing in multiple places
well, that's a tool, yeah, but kind of a totally different thing
Hey records exist now
🙃
But yeah i know that's not the point
Records are immutable, this is not
Why is it totally different?
I can't remember when I last wrote code in a way that required getters and setters tbh
fax of the day is that fax is not dated
but, if I did and the process became annoying, I would just use Immutables :)
especially for the builder part
Can anyone give me good videos on how to learn plugin developing?
I want to start learning
there was some guy, uh, CodeRed or something, as far as videos go it seems to have good reputation but I cannot personally vouch for them
Where did you learn?
idk I just did things
lmao ok
learned C at school years ago, wrote C# in vacations
JetBrains has a pretty good java course
Protobuf is to interact with the outside world somehow, similar to why you have data objects
well, no, protobuf isnt really about interacting with the "outside world" like data objects or APIs
its main purpose is data serialization
its about doing that efficiently and with minimal overhead by serialiazing request/response into a small binary format
generating source java code via protobuf is all good on its own, but generally serves a different purpose than lombok
lombok is used for less boilerplate, if you are writing .proto schemas, you are still writing way more than if you would be by using lombok
and I dont see a reason to use protobuf if I am not planning to optimize sending data between different applications/microservices or just in general "cleaner" (subjective) code
it gets repetetive pretty quick when you are writing same thing over and over and over again (getters, setters, constructors, builders, toString, hashCode)
Alt + insert is crying to be used
true that, personal preference tbh
for me its easier to read a smaller class, than having 50 lines of getters and setters
or just don't design code in a way that requires you to have getters and setters 
doesnt work everywhere
??? How do you design java code with no getters and setters
you uh you just do
Like ofc beans/guice are a thing, but let's talk vanilla java
Public variables 😉
no lol
Oh no
things properly encapsulated n all
class BankAccount {
private int balance;
void deposit(int amount) { balance += amount; }
void withdraw(int amount) { balance -= amount; }
}
god forbid one encapsulates data
in ideal world, sure, you wouldnt use getters/setters
but in enterprise solutions, frameworks, apis, serialiazation and often pretty huge codebases, thats just not really possible (imo)
granted that i haven't written a 400k loc code base so maybe I am missing something, but in the past.. N years, the only times i've written getters/setters is to interact with the JavaFX properties system
yeah I mean I dont see how would you not use g/s in a REST Api
(maybe records)
i use records to model data, yes, if you consider those getters I have failed you I suppose, but setters are pretty much out the window for me
idk i just don't design my code in a way where they show up
i don't have a magic powder that helps me at night.. or, not for this anyway
so idk
well, you could say they "kind of" have getters if you wouldnt consider them "accessor methods", but yeah, no setters
it's not "via protobuf" but for protobuf. But it doesn't matter what it is for, the same applies for other technology as well. It is just an example to showcase that what you're doing with lombok can be done with Java too, in a cleaner way.
i've never used lombok but i don't appreciate the fact it hijacks the compilation process :(
Immutables 🥺
just dont mutate it if it doesnt need to be mutated 🤓
Does that generate the class in your project as you code or it happens at build time?
it happens at compile time, it can generate either class files directly or java source files so it's easier to debug and navigate in your ide
APs run at compile time
Wouldn't a record technically be an initalized variable? 😉
what the heck kinda goofy ahh backwards question is that?
that doesn't even make sense
You initialize it, then you get its contents.
last time i checked classes aren’t variables
I'm joking... 😉
how do I use PlaceholderAPI with Component's from Adventure?
Strings are technically legacy tho for most stuff?
for guis and items it's deprecated
yeah so parse the strings that PAPI returns to you as Components, plus your own formatting or whatever
the markdown formatting really convinced me to help you
Heyo! I'm working on a plugin that(among other things), increases the knockback effect of TNT onto other TNT. However, the issue I'm having is that the event I called isn't detecting TNT entities being knocked back, but it does for player entities. I'm not sure how else to do this. Here is the code I've made so far:
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void TNTKnockbackEvent (@NotNull EntityKnockbackEvent e) {
if (!(e.getCause() == EXPLOSION))
return;
System.out.println("We have an explosion: " + e.getKnockback().toString());
// Increase knockback by factor provide from config
e.setKnockback(e.getKnockback().multiply(TNTKnockbackFactor));
}
the system.out.println was to check if it was actually getting triggered
best bet is to listen to EntityExplodeEvent , check if it's TNT, get nearby entities, check if they are TNT
Should also debug if the event was even ran.
From there unfortunately the other nearby tnt entities don’t yet have velocities applied. So I would basically have to recode all of their behavior(which I definitely don’t know how to do)
Yeah probably xwx Although if not explosion I will be highly confused what other cause type would apply xD
Nope doesn’t proc at all even before the check
you could just look at the Minecraft code and copy paste it
This could work
make sure you are able to cancel the vanilla knockback
not quite sure how I would do that part
Is there a way to zoom in the players view? The only thing i have been able to find is some couple year old posts that suggest using a packet manually to i think simulate the spyglass.
Wondering if nowadays theres a better way?
Nope. Bow was the old way, spyglass is the new one.
That or add the slowness/speed potion.
there isn't really a way to force the client to use the spyglass tho
Wouldn't applying slow zoom in a bit? Ofc not as much as a spyglass
Pretty good tbh
ok, mattypattie
Yeap and speed to "zoom out"
beside pressure plates, buttons, tnt and target block, bell is there other blocks that can be activate by a projectile ?
Trip wire, and not sure if this would count or not but the big dripleaf can also be "activated" by projectile
ah ok ty
do sculk sensors count
How come the two jars in the run directory are not excluded from commit?
if theyre already staged you need to remove them from git tracking
do git rm -rf --cached run/
Not sure what you mean by staged?
If they were added with git add . before added to gitignore?
But yeah that works, thanks!
being tracked by git
in IntelliJ, if it shows as green, it is tracked by git.
if it's red - it's not (untracked).
you can also see it by using $ git status: Changes to be comitted, Changes not staged for commit and Untracked files.
Ah good to know, thanks!
Yea makes sense, ty ty
Hello! I just want to ask, in DeluxeMenus, is there any way of using item model instead of model data?
Wrong channel #general-plugins or #1007620980627230730
I am back 😀
Is there an easy way to parse a text component into placeholderapi so that it keeps its formatting?
does any1 familiar with method name init turn yellow even tho it have no usage? , just wonder about the behavior of the editor
i doubt it's specific to the name
it's probably because it's public
if you turn it private/package private it should turn grey
traverse the component's content and children, replace all the text with PAPI text, and return the component
wdym it doesnt exist 😭
you are looking at java.nio.Buffer and the error says java.nio.ByteBuffer
it is the same line tho
tldr build targeting the java version you are going to run on
strange, this guy specify that the source is written on 1.8 , but bumping it to 11 fixed it
--release flag 💪
did i done something wrong for it to say module not found ?
i read that this could cause by scope for the dependencies in the build script
it is recognized when running dependencies however
does the mongodb driver even have a module descriptor?
it probably doesnt have it, where can i check it ?
so it mean it support java module ?
Anybody else have trouble with placeholders not being parsed?
It registers successfully, but yet even when i do ```java
@Override
public String onRequest(OfflinePlayer player, String identifier) {
Bukkit.getLogger().info("Placeholder requested: " + identifier);
that doesn't show up
I also double checked /papi list and the expansion is there
i think it just doesn't accept _ in the identifier name
works now
That is correct. There is a PR waiting to be merged that will throw if unsupported characters are used in identifier
Why doesn't the deluxemenus plugin show the number when I type placeholder-%bolt_queue_PROFILE_UNRANKED_fireballfight_playing% in the value?
So for web development (front-end) I know its HTML, CSS and JavaScript. Is there anything else aside from javascript libraries (React, Vue)?
Wdym?
Like... Any specific libs for webdevelopment like Apache or the other one starts with an N
If you want purely client sided rendering ther are a lot of js frameworks, some languages that do js compiling like Kotlin and Elm, WASM based languages (not very used right now)
If you want server side rendering there are again js stuff like NextJs, but you can also do it with other languages like Java, PHP, Rust, pretty much any other language
If you want a mix you can throw HTMX into it and use any language you want
Yeah was thinking just java, HTML & CSS but was wondering if their was a lib to make HTML/CSS easier.
With Java there is stuff you can do with Springboot, templating libraries like ThymeLeaf or Freemarker as for CSS there isn't really much, you're very much stuck using vanilla CSS
If you want to dive into Kotlin you can use kotlinx.html which gives you some DSL for CSS as well
I still have to figure out SSL and get HTTPS working lol
What's complicated about it? Just set it up on nginx or caddy and call it a day
I'm using pure java currently
nginx is goated
Huh? Java is just what you're using for the application, reverse proxy would be how you "expose" it on the web, you don't need to set anything up in Java
if you want css to be made easier, you can try using ui libraries (shadcn is popular rn) or just tailwind
Shadcn on Java? :')
im sure its doable with enough effort
Yeah.... I just provide the html to incoming requests lol
You can use tailwind with Java but you have to use the play CDN which isn't really meant to be used on production but it does work pretty much the same https://tailwindcss.com/docs/installation/play-cdn
When you use Laravel with Blade (templating engine) and tailwind, they use vite to dynamically generate css for dev and it lets u build the project too, so definitely can figure something better out than just cdn
Eh actually idk, cause if youre directly writing the html in java that then gets compiled
Either way learning web dev thru doing everything from scratch on java is a wild way to start :D
Docker compose, always good no matter the stack or environment ^^
Maybe not necessarily a specific question but more of a general outlet that I need to bring out. One thing that makes me hate coding is that when learning basics and all that you usually never really get anywhere specific. Most guides or tutorials that I followed for Java specially never really go much further than basic knowledge, so when I want to create something new, I always get hard stuck because I just don’t know how to do it, and asking for help or googling things sometimes helps but I don’t want to look things up every minute because I’m just so new. Are there any people here that feel the same or were like this and somehow got past it? Genuine question 
One thing that makes me hate coding is that when learning basics and all that you usually never really get anywhere specific.
That is because so many people skip the basics and then get stuck on something thinking it's too complex when it wouldn't have been if they stuck around just a bit more to learn the basics
Most guides or tutorials that I followed for Java specially never really go much further than basic knowledge
A lot of times it's just better to try out on your own, decide what you want to do and go for it, go back and revisit the tutorials when you have an issue, search when you have others, etc
googling things sometimes helps but I don’t want to look things up every minute because I’m just so new
This one never really goes away, googling is a very fundamental part of programming, every time you are using a new api or a different platform you'll likely be googling
Just because you understand the language doesn't mean you understand what you are just starting to work with
Sometimes you even forget something very basic that you definitely knew and have to search just to remember how it was
TLDR: It is totally normal what you're feeling, but keep it up, google as much as you want and ask as many questions as you want, don't be scared to sound stupid for asking basic questions
I know devs are very arrogant and very often rude so it can be scary to ask but as long as you're willing to listen you'll be fine
Thanks for the kind words. I’ll give it another go at studying basics. Especially with Java I feel like there are lots of improvements made and I’m trying to get out of static abuse 
Good luck! Feel free to ask around here if you have any issue
Definitely get out of static abuse yeah, static is great when used correctly
Well okay then I’m curious to know when it’s okay to use static
I really don’t understand what it does besides being able to use a function from a different class without having to get it first
Static means that what ever you are making static be it field or method you are making it belong to the class instead of the instance of the class
Let's say you have a field called name, each instance can have their own value of name so "john", "adam", etc
When you make it static is like you are saying that no matter what instance you have or even if you don't have any instance at all, name will always be "john" (not exactly since you can change it but good enough to explain for now)
The most common uses of static are for constants, values that are never going to change and you can access it everywhere, for example
public static final int SIDES_OF_SQUARE = 4;
Another very common use are util methods, stateless methods that can be called from anywhere for example:
public static String getFirstFourCharacters(final String string) {
return string.substring(0, 4);
}
The method itself isn't related to anything in the class and can be standalone no matter where it is so it makes sense to just be a static utility method
Okay so for example if I have a class that holds integers to track the state of an object that returns a string instead of an integer, I can use a static so I dont have to create an instance of the class to use it?
Is static also okay with singleton classes?
If a class holds any state what so ever it should probably not have static members and should be instance instead
It depends on how you make your singleton, also people will argue whether singletons are good or bad in general so it's up to you tbh, but as long as you don't think of everything as singletons you should be fine using them
I am bad at explaining but I’ll give an example of what I have
I have a class called GameState. This class has static integers going from 0 to 5. Inside of my “server” class, it holds an integer between 0 to 5 that tells me in what state that server is in (lobby voting, game started). Is it okay to make these static so I don’t have to create a GameState class to use a number. These numbers have a function to return a string that just tells you what that number should mean
I don’t understand what is bad about singleton since I often work with “manager” classes that only get made once on plugin start. It wouldn’t make sense to not make it have a static method of grabbing it since there is only one at any given time
It would just require me to write way more code to have the same purpose
If a field in a class is changing like that I personally would not make it static, static is global therefore can be changed from anywhere a lot of times you want to expose as little as possible and mutable global state just sounds dangerous to maintain, at first it may sound easy but once you have a lot of classes going where a lot are changing the state of it then you'll get lost very easy, and if only one class is accessing it then there is no point in making it a global state
Singletons aren't bad per say, but they can be for example a manager like you mentioned, if I pass the manager down to the class I know for a fact that the class uses that manager, if it is just used on a method of the class somewhere it's a lot harder to know that so for maintainability of your code it is much harder to deal with singletons
I'll give some examples for the first paragraph
public class Server {
private final ServerState serverState = new ServerState();
public void something() {
// imagine a lot of code is happening here
serverState.setState(1);
}
}
public class ServerState {
private int state = 0;
public void setState(final int state) {
this.state = state;
}
}
And then
public class Server {
public void something() {
// imagine a lot of code is happening here
ServerState.setState(1);
}
}
public class ServerState {
private static int state = 0;
public static void setState(final int state) {
this.state = state;
}
}
These two are basically identical functionality wise, but on the first one the server is the only class in your entire code base that has control over the state meaning it's safer and easier to maintain and also easier to understand
Ah I think I get it
It’s hard to give an example
I don’t really know how to explain it without sending code
I mean it is totally fine if you send code ;p
Use https://pastes.dev/ if it's too big so we don't clutter the chat
Give me a moment I’m almost home and then I’ll show an example of using a static
It might sound easier to also tell you what my project even is about
I am working on a racing minigame basically with an intuitive track editor and using mobs as “karts”
I am using a static method to apply a “kart” to a player and put them inside a list
I mostly only use static methods for grabbing information from a specific player, for example what kart they’re currently using and in what server instance they are in
I'll be able to get a better idea of it when you send code but I do think that those aren't very good places to use static
Well if possible I would love to hear a better alternative so I can start applying it
One moment
you've got a gamestate class
what if one day you decide you want to run multiple kart races at once
best practices ensure code is reusable, expandable, and maintainable
Oh no that wouldnt be a problem since the game state class is just a constant
The actual state a game is in is managed from within the server class
I’ll show you
Oh that is not what I had understood from your message, if that's the case then it still shouldn't be a class with static constants but instead an enum
Actually it might be an enum
Let me check
oh no it really is a class
public class GameState {
public static final short LOBBY_WAITING = 0;
public static final short LOBBY_VOTING = 1;
public static final short LOBBY_STARTING = 2;
public static final short GAME_STARTING = 3;
public static final short GAME_PLAYING = 4;
public static final short GAME_ENDING = 5;
public static String toString(short state) {
switch (state) {
case LOBBY_WAITING -> {
return "Lobby Waiting";
}
case LOBBY_VOTING -> {
return "Lobby Voting";
}
case LOBBY_STARTING -> {
return "Lobby Starting";
}
case GAME_STARTING -> {
return "Game Starting";
}
case GAME_PLAYING -> {
return "Game Playing";
}
case GAME_ENDING -> {
return "Game Ending";
}
}
return "";
}
public static boolean isStarting(short given_state) {
return (given_state == GameState.GAME_STARTING);
}
public static boolean isPlaying(short given_state) {
return (given_state == GameState.GAME_PLAYING);
}
}
oh yeah that can definitely be an enum
Enums are a very unknown area for me
Enums are basically what you have but they make it easier to work with and understand, let me show you how that would look like as an enum
Are enums similar to a switch case
Where something that be one of the things you provided
I also have another question
Its more java related but sometimes i get confused on what final means
switches can be looked at like alternate syntax for if else chains
public enum GameState {
LOBBY_WAITING("Lobby Waiting"),
LOBBY_VOTING("Lobby Voting"),
LOBBY_STARTING("Lobby Starting"),
GAME_STARTING("Game Starting"),
GAME_PLAYING("Game Playing"),
GAME_ENDING("Game Ending");
private final String message;
GameState(final String message) {
this.message = message;
}
public static boolean isStarting(final GameState givenState) {
return givenState == GAME_STARTING;
}
public static boolean isPlaying(final GameState givenState) {
return givenState == GameState.GAME_PLAYING;
}
public String getMessage() {
return message;
}
}
it's a little more complicated than that but that's an easy way to see it imo
I understand it means a value cannot be changed after it's created, but for some things it isnt
final means the variable/field can't be reassigned, that is all
Basicall means you can't do myFinalVariable = "something new"
okay but for lists and hashmaps you can still add values to it
So that technically makes it not final right
Okay so wait you changed the class to an enum
So the enum is now a String?
It is still final, the list and the variable holding the list are different
You can't reassign the variable but you can still add to the list
For example
List<String> stringList = new ArrayList();
stringList.add("aaaah"); // adds to the list
stringList = new ArrayList(); // changes the list, final prevents this one only
No the enum is the enum, LOBBY_WAITING is of type GameState
The string I added there is just so you don't need to do the switch on the to string
Okay I understand
However I am running into something now that I didnt think about
Basically my old class had a number attached
However its an enum now, so I can't check if its above a specific number
For example, I dont want people to open the voting gui after the game goes to game starting or above
so what i did before, was to just check if the state was > 2
You'd normally check the state value directly, for example instead of state == 0 you'd do state == LOBBY_WAITING
But if you do need to show a number you can do state.ordinal() it'll give you the number of the enum value
Okay so
If i understand you correctly
LOBBY_WAITING("Lobby Waiting"), // Would return 0 if using state.ordinal
LOBBY_VOTING("Lobby Voting"), // Would return 1 if using state.ordinal
LOBBY_STARTING("Lobby Starting"), // Would return 2 if using state.ordinal
GAME_STARTING("Game Starting"), // Would return 3 if using state.ordinal
GAME_PLAYING("Game Playing"), // Would return 4 if using state.ordinal
GAME_ENDING("Game Ending"); // Would return 5 if using state.ordinal
Yes that is correct
so this would work
if (server.getState().ordinal() <= GameState.LOBBY_VOTING.ordinal()) {
server.pre_selected_mobs.put(clicked, finalMob);
} else {
MobManager.equipPlayer(clicked, finalMob);
}
Yeah
okay got it
then my next question (sorry), is it okay to use static for lists
Some context, I have a static hashmap that holds a Mob / Kart value for a player
Every player can only have one kart equipped at any given time and also cant be in multiple games at once, so it would be okay to use static then right?
It all depends on the use case, in all my projects I have at max had maybe 2 static lists
But no on your context it does not sound like a good idea to be static
This is inside of a class that is singleton btw
What do you recommend I should do instead?
public class MobManager implements Listener {
private static MobManager ourInstance;
private static final HashMap<Player, Mob> playerMob = new HashMap<>();
private JavaPlugin plugin = MobRacers.getPlugin();
public MobManager() {
Bukkit.getPluginManager().registerEvents(this, plugin);
ourInstance = this;
}
}
Small part of the code for context
If it is a singletone then it still depends on how you are making the singleton, there is generally 2 ways of doing it, one where everything is static which in this case sure the map being static is fine, or a static instance of the class as a singleton where then the map shouldn't be
In your case it is fine, but keep in mind what Piggy mentioned about singletons and how they aren't very good in general
I understand it's not perfect, I genuinely just don't know how to else do it..
Thats more my issue
How I created most of my plugins is to create multiple singleton classes that each have their own purpose to make everything work
So one is responsible for the track and knowing what everything does, one is responsible for managing servers, one is responsible for karts, another one for guis etc
TrackManager trackManager = new TrackManager();
trackManager.loadTracks();
new GameManager();
new MenuManager();
new MobManager();
``` in my onEnable
One thing I am worried about, is that if I create an instance of a class to use something once every time I wanna do it, it sounds like that will memory leak at some point
Or am I wrong
Like for example I see no other way to handle the MobManager class
How would that even work without singleton
The list would be lost
Normally you'd use something called dependency injection, where you'd pass an instance of the manager instead of making it a singleton
For example:
public class MyPlugin extends JavaPlugin {
private final MobManager mobManager = new MobManager();
public void onEnable() {
Bukkit.getPluginManager().registerEvents(mobManagerf, this);
// Assuming you need it on menu manager for example:
new MenuManager(mobManager);
}
}
public class MenuManager {
private final MobManager mobManager;
public MenuManager(final MobManager mobManager) {
this.mobManager = mobManager;
}
public something() {
mobManager // you can use MobManager here using this instance instead of MobMager. etc being static
}
}
That sounds unnatural to me
Although I do see what you mean
This sounds more reasonable in mobile development
Where you pass information from one view to another
But then I wanna ask
It is just reasonable in any development since you know what each class needs and what it'll use, managing dependencies and the code in general better
Using singleton for these classes, will this give me problems in the future for this project
Like
Generally
I don't want to pass 10 managers to a manager in order to use everything
That just sounds super inefficient
If its just one I can see why
The answer is maybe development is very complex and you could very well be totally fine with those as singletons but also you could run into issues, it all depends on how you move your code going forward
But in the end Ill end up with 10+ managers and needing all of those to communicate sounds like a pain to do with your example
You don't have to pass each manager directly either btw, let me change the example I sent and you'll see what I mean
is it how i do plugin?
Would this work?
private JavaPlugin plugin = MobRacers.getPlugin();
Is this what you mean?
public class MyPlugin extends JavaPlugin {
private final MobManager mobManager = new MobManager();
public void onEnable() {
Bukkit.getPluginManager().registerEvents(mobManagerf, this);
// Assuming you need it on menu manager for example:
new MenuManager(this);
}
public MobManager getMobManager() {
return mobManager;
}
}
public class MenuManager {
private final MyPlugin plugin;
public MenuManager(final MyPlugin plugin) {
this.plugin = plugin;
}
public something() {
plugin.getMobManager() // you can use MobManager here using this instance instead of MobMager. etc being static
}
}
You can add getters in the plugin's body and pass the plugin's instance instead, so you just get the manager from the plugin
that sounds like a better idea
I am guessing its fine to use statics for JavaPlugin haha
Since there is no excuse not to
There is not even a way to have more than one
it's fine, I don't do it a lot of people don't, but a lot of people do and at this point it's up to you honestly
Obviously I dont want to just make things work
Thats how I worked when I first started
But realistically the bigger the project becomes, the more annoying it becomes
I personally don't like it, since like I said I like to have all my dependencies declared but if you prefer it that way it's fine
I might just completely begin from scratch and implement these methods from the start
I also have heard some negative things about using abstract
Is it really that bad to use or is this more a coping thing
Huh I have never heard anything bad about abstract, it has it's uses and the uses are good, i don't know what would be bad about it
Well I think the person I was talking to at the time was a C++ coder
And he was really against inheritance
Which I still don't understand at this point
For a racing minigame it makes complete sense to have an abstract kart class that holds information that every child will need
And then adding additional functions inside each kart
Inheritance has it's limits but it's totally fine people are just annoying about things from other languages
I love calling an abstract class more a template than anything
I am not going to copy paste the same stuff for every kart
hell no
If theres one thing I learned about developers is that they are lazy
If there is a way for me to write less code I will
This is why you write functions if you use something more than once
Its the same thing
I see an abstract class as the same thing
You write something in there that every individual kart will need
I am very proud of my track editor though
Yeah sharing common code using abstract classes is totally normal
Imagine a fighting game where every fighter has its own stat codes
instead of an abstract one and then changing values
gives me chills
Basically the track editor I made without any google or whatever
the thing I struggle with most is logic
or things like serializing
I hate being full of ideas but no idea how to execute them
yeah people struggle more or less with different things
logic is become the computer, beep boop
Its hard to think about that the only things computers understand is bits
Almost 10 years into it and still relate to this 
And that humans had to find a way to communicate
so true
is python its just print hello
but i donte ven wanna know what a computer has to go through to show it on the screen
i really dont
and the funny part is that it happens in a few millseconds
As a solo developer I don't think that much about maintainability
But working on a team changes things
I dont want my co workers to see me as a psycho
i write code thinking how upset my future self will be
my first project has multiple instances of 30 ifs and elses below each other
(that's why i write bad code on purpose)
but realistically switches can also get large
And I also should write functions more often than I do now

i'd say that's what most do
Sometimes I'm just so in the flow that I just dont wanna do that right away
Or or or
This is most often the case when you have things together that should be seperate
but its easier to code when you have it there at that specific moment
so you dont have to tab as much
omg i love your banner
Yours is very good too nya
nyam
simplest (imo) way to see it is think of it like each "object" has its own properties, name, surname, age
then you need a counter how many instances of the "object" was made, then you would have a static property inside the class, which would be incremented every time the instace was created
I think I made the right choice to start with minecraft java
Since its not just java but also uses lots of minecraft knowledge
it's a fun way to start too
I like game development
mfw "make a calculator console app" 👵
When I dont have to make assets
I started with minecraft java now I work (around 3 years) full-time at a sizeable company with a pretty good salary lol
I started with Minecraft now I work full-time on Minecraft :))
I find java very similar to swift
I started with Android & Minecraft, now I work when I feel like it (self employment is hard)
but purely when it comes to classes
idk what swift looks like lemme see
Swift looks like Kotlin or well the other way around 
all i know is the logo
i understood java more easily with prior swift knowledge
is pretty swift
although they call it a struct
Its just a way to organize information under one name
Which is basically what a class is
it looks interesting
I see it as a house
aka a structure lol
its building blocks
lego bricks
everything in life is made out of multiple things
a computer would be a class
i think officially its just called a data structure
like a database of some kind
even people are a class
every person has a name, an age
whenever i need to explain coding to someone that doesnt know it i try to use real life examples
it often helps a ton
obviously
what can i say, i'm pretty classy
this is how iphone design started with that rl morphism stuff
though data structures are lists, maps (collections)
nobody knew how to use phones
so they made apps look like real life things
like an actual notebook or a tv for youtube
I really loved this idea
i think everyone calls it something else but i just see it as a house where every room has its own data
Maybe just a hotel
i mean, pretty much anything is a data structure apart from primitive types
where guests have a room number that has their stuff in it
Is it a good idea to use open source projects as a way to learn
i think it's a good idea to use OSS as reference, while trimmed down examples found in tutorials are helpful as an isolated snippet of what you're learning about, having real production code is pretty valuable imo
although, depending on the project, it can get very complex very fast
I feel like maybe rewriting a project from scratch might be good
and make sure you choose a good project to learn from, there are some terribly coded open source projects out there
But just really thinking about stuff from the start
trust me when i say that this singleton stuff and that static bs is not from me
i used a project for reference
I used it because i didnt know any better
famous last words
(but also yes)
Well I know more than a year ago
I am struggling really hard on game logic
Like realistically speaking, it shouldn't be super hard to get checkpoint logic to work
Maybe if someone gave me a general direction in how to do this
Can I explain what I want?
sure
Okay so basically the project I am working on now is a racing minigame but instead of players you get disguised as mobs
The track editor functionality is completely finished, and can be saved and loaded between server restarts which is great
Basically every "track" has the following properties:
"Finish Lines"
"Checkpoints"
"Player Spawns"
"Item Boxes"
"Speed Boosts"
"Jump Boosts"
"Teleports"
"Elytra Pads"
protected List<FinishLine> finishLines = new ArrayList<>();
protected List<PlayerSpawn> playerSpawns = new ArrayList<>();
protected List<Checkpoint> checkpoints = new ArrayList<>();
protected List<ItemBox> itemBoxes = new ArrayList<>();
protected List<SpeedBoost> speedBoosts = new ArrayList<>();
protected List<JumpBoost> jumpBoosts = new ArrayList<>();
protected List<Teleport> teleports = new ArrayList<>();
protected List<ElytraPad> elytraPads = new ArrayList<>();
All of these classes extend a general abstract class called Node
They have a basic Location variable that tells you where they are on the map
Some if not most nodes have customization
For example, you can change how fast a speed boost might make you
And for checkpoints and player spawns you can change the respawn direction, their index (number) and the radius
Basically all of this stuff is completed, and the only thing left is to well... make it work
And with work I just mean logic only while the game is active
I want to start with the most basic thing for like finish line and checkpoints
In a racing minigame you want people to go through checkpoints in index order and then cross the finish line to count as a lap
I think it's best to start with this
So I am figuring out the stuff that I need to make this work
In the gamemode class I probably need two hashmap that hold a player's current lap number and their checkpoints
Is there a way to have multiple values for 1 player?
I think that might be easier and more efficient than multiple hashmaps
Is that basically just a class
you could have a PlayerData class that holds all the info for one specific player, and then have a HashMap mapping player -> player data
uh sure
:)
It instantly filled in everything i need
public class PlayerData {
public Player player;
public int lapCount;
public Checkpoint currentCheckpoint;
}
Like come on now AI is awesome
I didn't type this
:(
the fact its wrong is why ai is bad
you just burned 50000 trees for some incorrect code :(
Well if you told me what is wrong about it I might be able to burn less trees in the future..
if you ask how to do it first you dont have to burn the trees
in what way?
Well I want some kind of class that just holds a player, an integer and a checkpoint
But it sounds overkill to make a class for just that
So I'm asking if there's something similar to it that requires less code and has a purpose
I want a hashmap with more than one value
you spent 2 minutes max trying and then asked ai but i digress, aside from the the fact the variables are public, the main problem is the fact the object is storing Player instead of UUID (player uuid), that variable changes like 5000 times a second and is prone to memory leaks iirc
So instead of a player having just an integer for lap count, i want a player to have 2 values, a checkpoint and an integer
classes are basically the way to do anything, java has record types but their members are unmodifiable, if you want mutable, a normal class it is
I have never used a player uuid in my life.. is that important?
no?
lmao
i remember something something memory leak but it was on spigot forums like 6 years ago so could be wrong
storing Player is fine as long as you get rid of it when a player quits
Everything gets removed on quits or leaves
or when a lobby is reset
I think it might be better to just use two hashmaps instead of a class for 2 properties
Do you agree with me
eh
having a class for it is fine
having a class is pretty much what everyone would do tbh
the issue with that approach is that if you want to add more data in the future you need to add another map and you need to remember to update all the thingies around it, forgot to add the player to the map? boom you'll get a NullPointerException down the line
what drugs have i been on for 5 years then 💀 o well ig
whereas if all the data of a single player is in its own type, you make sure that it's all tied together
something something, invariants, funny words blah blah
encapsulation
As long as you remember that player instance becomes invalid as soon as the player leaves you can do anything with it
whatever
Can someone also please explain me when to use private, protected or public
It drives me nuts
for fields just use private
unless you expect subclasses to access the field, then use protected
Okay so I want the gamemode class to be able to change playerdata class
but I can also just
use public voids to change it
i think thats better
so private it is
its usually private fields and then public getters/setters
private fields accompanied with public methods is the pinnacle of encapsulation
like
is that a positive word haha
yeah
public class PlayerData {
private final Player player;
private int lapCount;
private @Nullable Checkpoint currentCheckpoint;
public PlayerData(Player player) {
this.player = player;
this.lapCount = 1;
this.currentCheckpoint = null;
}
public Player getPlayer() {
return player;
}
public int getLapCount() {
return lapCount;
}
public void setLapCount(int lapCount) {
this.lapCount = lapCount;
}
@Nullable
public Checkpoint getCurrentCheckpoint() {
return currentCheckpoint;
}
public void setCurrentCheckpoint(@Nullable Checkpoint currentCheckpoint) {
this.currentCheckpoint = currentCheckpoint;
}
}
So this is all I need then
hm why would the checkpoint be null
Well when the race starts there has not bee a checkpoint passed yet
The start flag should be the first checkpoint
As a reminder, the checkpoint is purely there to respawn you there in case of death or error
looks okay, maybe I would have, for example, instead of having a setLapCount, I'd have a incrementLap() method that simply adds one to the lap count
If there is no checkpoint, it would respawn you at the finish line
Yeah but if you die before the next "first" check point then you should respawn at the finish line making the finish line a checkpoint itself
The finish line is as basically a checkpoint, but its its own thing in my nodes
incrementLap is a good idea though
i would consider the initial spawn point the first checkpoint tbh
Laps never go down
but that's me
It is basically a checkpoint, it works like a checkpoint, then I feel maybe it should be a checkpoint :')
It would require me to add an option to each checkpoint to set it to either a finish line or not
if it walks like a duck, quacks like a duck and swims like a duck, its a chicken
oooor just make a new checkpoint at the starting point when you "build" the track, as in, in code, not the user/player
you should see finish line more as an inheritance to checkpoint
its not the same
For my game I feel like it makes more sense to make it it's own thing
public interface Checkpoint {}
public class RaceCheckpoint implements Checkpoint {}
public class FinishLine implements LapPoint, Checkpoint {}
The finish line node's only purpose is to check if a player has gone through all checkpoint needed for the lap to count, and if so, increment lap
I don't know what an interface does
it's kind of like a class template, it defines what methods a class must have, but not what the code in the methods look like
I dont get it xD
classic example is some kind of Animal interface, that has a makeSound method
interface Animal {
void makeSound();
}
class Cat implements Animal {
@Override
public void makeSound() {
println("meow");
}
}
class Dog implements Animal {
@Override
public void makeSound() {
if (Math.random() < 0.5) {
println("woof");
} else {
println("bark");
}
}
}
(imagine there are more animals, i cba to do this repeatedly)
Oh its like a way to add functionality to a class without putting it in the parent got it
something like giving a car class a rocket boost
but the rocket boost is an interface
so you can add it to a class
the car class would need to implement the "boost" functionality, yeah
the important part is that, any method can take an Animal without knowing exactly what kind of animal it is
Adding up to this
public interface Checkpoint {
public Location getLocation();
}
public interface LapPoint {
public void incrementLap();
}
public class RaceCheckpoint implements Checkpoint {
private final Location location ... // example
@Override
public Location getLocation() {
return location;
}
}
public class FinishLine implements LapPoint, Checkpoint {
private final Location location ... // example
private int laps = 0;
@Override
public Location getLocation() {
return location;
}
@Override
public void incrementLap() {
this.laps++;
}
}
public class PlayerData {
private Checkpoint currentCheckpoint;
public PlayerData(final FinishLine finishLine) {
this.currentCheckpoint = finishLine; // First checkpoint is the finish line
}
public void setCurrentCheckpoint(final Checkpoint currentCheckpoint) {
this.currentCheckpoint = currentCheckpoint;
}
}
Sorry to interrupt but how can I check if an integer is one above another integer
Just checking if its above doesnt work, it needs to be exactly 1
Is it as simple as just oldIndex + 1 == newIndex
Yeah
wait really haha
int currentCheckpointIndex = currentCheckpoint.getIndex();
int hitCheckpointIndex = hitCheckpoint.getIndex();
if (currentCheckpointIndex + 1 != hitCheckpointIndex) {
return;
}
so this would be enough to return if the checkpoint you are checking isnt one index above
I'ma be honest you probably don't need to declare new variables for that
unless you're foreseeing using them more
it doesn't make a difference performance-wise but it just makes the code more verbose when it's very obvious what's being done
Oh the extra variables is honestly just for myself so I don’t forget
I know it’s overkill I just prefer it
The code might get longer at some point so idk
yeah thats kind of pointless
because if you ever check the usage of getIndex(), you will get those two variables, then you also need to check where they are used, so kind of two steps instead of one
just do whatever floats your boat tbh
if you find abc easier to read than def, go for it
if you regret it tomorrow, then you'll learn
you don't learn if you don't try shit out and get hurt
Would anyone have any idea how I would I can get like a distance (manhatten distance) function to get the function between two tiles in a grid like this?
I've tried to do this, but theres always a problem because when I try to get all the tiles with a distance 1 from a center tile. It's always wrong.
not sure if that's possible for you, but doing a different number alignment might help, e.g. making these all 0 in the first axis
if that's not possible, you could try to figure out a transformation into that representation and use it indirectly
but even with your current layout, the direct neighbors should be easy to calculate
https://stackoverflow.com/questions/5084801/manhattan-distance-between-tiles-in-a-hexagonal-grid lol the first answer seems to have the same idea I had, just rotated in the other direction
Yeah I don't I'll be able to transform it. But the thing is, the direct neighbors do work. But it's when I have a range of 5 when It starts messing up
But so If I rotate I have to change my array too or how would you do it?
I don't know how your array works, is it just 2-dimensional?
and is the rotation even important?
Uhm not sure what you mean, you told me it would be easier with a rotation right?
yeah I want to know if you need the layout you showed or if you can just use the other one directly
Ow yeah, it's for a game. That layout is for the tiles
This is how it is suposed to look like
And the green tiles are like the thing with the manhatten distance from the archer
sounds like you could just fully switch to the other representation, but otherwise I'd assume it's just an offset you need to add/subtract
But I tried that with the actual x and y values of the grid. And the things was, the value weren't lining up. Because sometimes it was 130 pixels between the one and the neighbour cell, and the other times it was 90 pixels.
Or do I have to use offsets when I use the actual x and y values of the grid?
uh oh using two different grids mixed sounds like a good way to encounter a lot of pain
Well the thing is the 2D array is just for the objects of the tiles. And the actual x and y values are there to set the tiles in place on the grid
Hahah it's probably my explaining that's the problem (sorry)
But yeah so I'm doing this project using JavaFX. And when I put the objects inside of the Grid I have to specify an amount of pixels on the x axis and y axis so they land in the right spot.
But then I also store the tile objects in my program ofcourse when I need to update something, like an image on a tile, or when I have to get the minion on that tile, ... . And they are stored in that 2D array.
I hope that makes more sense
I'll show my Tile.java class
private int x, y;
private double mapX, mapY;
private TileType type;
private Minion occupant;
private int homebase;
public Tile(int x, int y, TileType type, int homebase) {
this.x = x;
this.y = y;
this.type = type;
this.homebase = homebase;
}
public boolean isWalkable() {
return type == TileType.DIRT || type == TileType.FOREST || type == TileType.MOUNTAINS || type == TileType.STARTBASE;
}
public boolean isOccupied() {
return occupant != null;
}
public void setOccupant(Minion m) {
occupant = m;
}
public TileType getType() {
return type;
}
public Minion getOccupant() {
return occupant;
}
public boolean isHomebaseFor(Player player) {
return homebase == player.getHomebase();
}
public int getHomebase() {
return homebase;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public void setMapX(double mapX) {
this.mapX = mapX;
}
public void setMapY(double mapY) {
this.mapY = mapY;
}
public double getMapX() {
return mapX;
}
public double getMapY() {
return mapY;
}
}
I'd say the pixel stuff should be completely separate
tbh the best method for this may be to just build a lookup table
your x,y indexes into the table could be the offset the second tile is from the first, and the value is the distance
there is also probably room to remove duplicate orientations (negatives?) if you really cared, but that is probably not necessary on a small scale
since the dawn of time, lookup tables are the final form for solutions to difficult game dev problems
it should be possible to calculate pixel positions from the tile id (I just came up with that name), outside of the tile stuff. Basically you want to be able to do e.g. scaling without having to touch tiles at all
[21:26:43 INFO]: Tokiomara issued server command: /pmine give Tokiomara
[21:26:47 ERROR]: [PrivateMines] [ACF] Exception in command: privatemines give Tokiomara
[21:26:47 ERROR]: [PrivateMines] [ACF] java.lang.NullPointerException: Cannot invoke "me.untouchedodin0.privatemines.NmsHandler.checkBlocks(me.untouchedodin0.privatemines.CuboidRegion)" because "<local10>" is null
[21:26:47 ERROR]: [PrivateMines] [ACF] at me.untouchedodin0.privatemines.factory.MineFactory.createDefault(MineFactory.java:54)
[21:26:47 ERROR]: [PrivateMines] [ACF] at me.untouchedodin0.privatemines.commands.PrivateMinesCommand.give(PrivateMinesCommand.java:38)
[21:26:47 ERROR]: [PrivateMines] [ACF] at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
[21:26:47 ERROR]: [PrivateMines] [ACF] at java.base/java.lang.reflect.Method.invoke(Method.java:580)
[21:26:47 ERROR]: [PrivateMines] [ACF] at me.untouchedodin0.privatemines.acf.RegisteredCommand.invoke(RegisteredCommand.java:152)
[21:26:47 ERROR]: [PrivateMines] [ACF] at me.untouchedodin0.privatemines.acf.BaseCommand.executeCommand(BaseCommand.java:578)
[21:26:47 ERROR]: [PrivateMines] [ACF] at me.untouchedodin0.privatemines.acf.BaseCommand.execute(BaseCommand.java:513)
[21:26:47 ERROR]: [PrivateMines] [ACF] at me.untouchedodin0.privatemines.acf.RootCommand.execute(RootCommand.java:99)
[21:26:47 ERROR]: [PrivateMines] [ACF] at me.untouchedodin0.privatemines.acf.BukkitRootCommand.execute(BukkitRootCommand.java:84)
[21:26:47 ERROR]: [PrivateMines] [ACF] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:152)
[21:26:47 ERROR]: [PrivateMines] [ACF] at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand(CraftServer.java:686)
[21:26:47 ERROR]: [PrivateMines] [ACF] at net.minecraft.server.v1_12_R1.PlayerConnection.handleCommand(PlayerConnection.java:1495)
[21:26:47 ERROR]: [PrivateMines] [ACF] at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1300)
[21:26:47 ERROR]: [PrivateMines] [ACF] at net.minecraft.server.v1_12_R1.PacketPlayInChat.a(PacketPlayInChat.java:45)
[21:26:47 ERROR]: [PrivateMines] [ACF] at net.minecraft.server.v1_12_R1.PacketPlayInChat.a(PacketPlayInChat.java:5)
[21:26:47 ERROR]: [PrivateMines] [ACF] at net.minecraft.server.v1_12_R1.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:14)
[21:26:47 ERROR]: [PrivateMines] [ACF] at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
[21:26:47 ERROR]: [PrivateMines] [ACF] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
[21:26:47 ERROR]: [PrivateMines] [ACF] at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46)
[21:26:47 ERROR]: [PrivateMines] [ACF] at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:869)
[21:26:47 ERROR]: [PrivateMines] [ACF] at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:427)
[21:26:47 ERROR]: [PrivateMines] [ACF] at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:793)
[21:26:47 ERROR]: [PrivateMines] [ACF] at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:683)
[21:26:47 ERROR]: [PrivateMines] [ACF] at java.base/java.lang.Thread.run(Thread.java:1583)
anyone who can help me with this?
@icy shadow thoughts?
this is Lua but should be trivially translatable to Kotlin or java
local function hexagon_distance(a, b)
local dy = math.abs(b[2] - a[2])
local di = b[1] - a[1]
local dx
if dy % 2 == 0 then
dx = math.abs(di)
else
if a[2] % 2 == 0 then
dx = di + 0.5
else
dx = di - 0.5
end
end
if math.abs(dx) <= dy * 0.5 then
return dy
else
return dy + math.abs(math.abs(dx) - dy * 0.5)
end
end
w/ these test cases
maybe there's a slightly better way but 4 hours of sleep is not really helping with these types of things lmao. lmk if you're interested in an explanation, it's actually a pretty elegant problem to solve
a[1] and a[2] and such correspond to a.x and a.y
I think he meant to do it by hand
💀 bruh no

