#help-development
1 messages · Page 1201 of 1
the issue is you cant do anything with an Object unless you cast it
and its also used by the configuration api
I hate how java doesnt have ImmutableList<>, ImmutableSet<>, ImmutableMap<> interfaces
since you can store any object in a file (for some reason)
instead you have hacks like: Collections.unmodifiableList()
with runtime exceptions for add()
listOf(itemOne, itemTwo, itemThree, itemFour
if for some reason you needed add to an Immutable List
there's nothing stopping from java devs to implement it in standard lib
apart from backwards compatibility
val list = mutableListOf<Item>()
list.add(itemOne)
list.add(itemTwo)
list.add(itemThree)
list.add(itemFour)
val immutableList = list.toList()
ikr
and the best part there's no runtime checks
for immutability in kotlin
thus you can't accidentally call add() on immutable list like in java with Collections.unmodifiableList()
Kotlin feels like Java++ sometimes
I don't really take full advantage of the magic, but I do prefer using kotlin now adays
the worst thing is when someone provides you a list from an api which is undocumented that its immutable
whats the advantage of kotlin? just preference?
its Java, but with modern syntax and bunch of compile-time optimizations
like inline data classes
thank god for jetbrains unmodifiable annotation
Well sure it might take some playing around but hopefully they also provide you with api to replace said list
which act like fake classes, but they unwrap to be inline calls instead
Kotlin also just has better functional API too
@JvmInline
value class Person(private val fullName: String) {
init {
require(fullName.isNotEmpty()) {
"Full name shouldn't be empty"
}
}
constructor(firstName: String, lastName: String) : this("$firstName $lastName") {
require(lastName.isNotBlank()) {
"Last name shouldn't be empty"
}
}
val length: Int
get() = fullName.length
fun greet() {
println("Hello, $fullName")
}
}
fun main() {
val name1 = Person("Kotlin", "Mascot")
val name2 = Person("Kodee")
name1.greet() // the `greet()` function is called as a static method
println(name2.length) // property getter is called as a static method
}
will compile to to just require checks instead of creating new object on the heap
valhalla when (soon, the jep is open)
fun greet() {
}```
that "fun" is what gets me xD
it will exist as an object instance on compilation, but on runtime object will be erased, and will never be created, instead only raw data elements like in this case String object will be created
I guessing fun means function. its just weird to look at, i feel its better to learn java before kotlin
it will compile to smth like this:
String firstName = Person.firstName("Kotlin");
String lasName = Person.lastName("Mascot"):
Person.greet(firstName, lastName);
instead of:
Person person = new Person("Kotlin", "Mascot");
person.greet();
no additional objects will be created on the heap, except for the needed ones
probably tbh because kotlin builds off a lot of conceptual things you'd learn about the JVM from java and introduces a ton of syntax sugar
how about no keyword
it probably needs it because you declare the return type at the end of the function
fun foo(): Int {
}
typescript is literally:
function foo(): number {
}
kinda similar to ts
FunkyMethod(Int times) {
for (int i = 0; i <= times; i++) {
sout("Welcome to funky town");
}
}
Kotlin 🔫
Welcome to funky town
when do we introduce just f
We already do (Math)
}
``` kek
obfuscation would make that funny
when
@proud badge back to my point lol
f method {
}
If it returns something we do fr
fr method {
1 // also got rid of the return word here cuz its such a pain to type
}
If it has parameters just use spaces parenthesis are a pain
fr method int int {
int0 + int1
}
Instead of naming parameters because thats such a pain if they have long names you can just go by the type and increment it by 1 starting at 0
param names are what keep my sanity intact tho
yeah that's a lot of typing though
honestly we should remove those pesky curly braces too and replace them with something easier to type
{0} for arg 0
back slashes kek
save more characters
f method j
j
fr method j
1
j
fr method int int j
int0 + int1
j
J is on your home row
ffs
you don't need shift
Hmm yes
honestly the spacebar is just another thing you gotta type too I'm going to gut that out where I can
lets make this eve nmore concise
CatchYouForgotAClosingJExceptioneje.printStackTracej```
f method i i
l0 + l1
fmethodjj
frmethodj1j
frmethodintintint0+int1j
Indentation time
well in that case
How do you even parse that
you don't
Also, int is too long to type
schrödinger's code snippet
Rename it to i pls
if you're worried about parsing you could make something slightly more realistic
fmethodjj
frmethodj1j
frmethod int intjint0+int1j
you can't start your methods with a letter r if we're going to be fast about this, but I think that's a worthy sacrifice
Man I can't wait for chatGPT 6.0 to interpret my thoughts before I can
I'd just do fRealName then Ig
Unless capitalization is a syntax error
if there are no spaces it saves even more time
ChatGPT made us a parser
import re
# Tokenizer function to split the input into components
def tokenize(source_code):
# Regular expressions to capture function, parameters, and expressions
token_specification = [
('FUNC', r'(fmethod|frmethod)'), # function definition (either `fmethod` or `frmethod`)
('TYPE', r'int'), # `int` type
('NAME', r'[a-zA-Z_][a-zA-Z0-9_]*'), # identifiers (function names, variable names)
('EXPR', r'[a-zA-Z_0-9\+]*'), # expressions or variables (like `int0`, `int0+int1`)
('WHITESPACE', r'\s+'), # whitespace (to be ignored)
('MISMATCH', r'.'), # anything else (invalid tokens)
]
# Join all patterns into one regex
tok_regex = '|'.join(f'(?P<{pair[0]}>{pair[1]})' for pair in token_specification)
line_num = 1
line_start = 0
line_pos = 0
# Iterate through the source code and match the patterns
for mo in re.finditer(tok_regex, source_code):
kind = mo.lastgroup
value = mo.group()
if kind == 'WHITESPACE':
continue
elif kind == 'MISMATCH':
raise RuntimeError(f'Unexpected character {value!r} at position {mo.start()}')
yield kind, value
# Parser for the custom language
class Parser:
def __init__(self, tokens):
self.tokens = tokens
self.current_token = None
self.advance()
def advance(self):
try:
self.current_token = next(self.tokens)
except StopIteration:
self.current_token = None
def parse(self):
"""Parse the entire input."""
functions = []
while self.current_token:
functions.append(self.parse_function())
return functions
def parse_function(self):
"""Parse a function definition."""
func_type = self.current_token[1] # 'fmethod' or 'frmethod'
self.advance()
func_name = self.parse_function_name()
args = self.parse_parameters()
return_value = None
if func_type == 'frmethod':
return_value = self.parse_return_value()
return {
'function_type': func_type,
'function_name': func_name,
'parameters': args,
'return_value': return_value
}
def parse_function_name(self):
"""Parse the function name."""
if self.current_token[0] == 'NAME':
func_name = self.current_token[1]
self.advance()
return func_name
else:
raise ValueError("Expected function name")
def parse_parameters(self):
"""Parse parameters (space-separated)."""
params = []
while self.current_token and self.current_token[0] in ['TYPE', 'NAME', 'EXPR']:
param = self.current_token[1]
params.append(param)
self.advance()
return params
def parse_return_value(self):
"""Parse the return value for 'frmethod'."""
if self.current_token and self.current_token[0] in ['NAME', 'EXPR']:
return self.current_token[1]
return None
# Example usage
source_code = """
fmethod jj
frmethod j1j
frmethod int int j int0+int1j
"""
# Tokenizing the source code
tokens = tokenize(source_code)
# Create a parser instance with the tokenized input
parser = Parser(tokens)
# Parse the input and print the structured result
parsed_functions = parser.parse()
for func in parsed_functions:
print(func)
put it in review thread
no I'm not making anyone review ChatGPT code
kek
Yeah been there for a few days already
Time to get gpt to write me a gpt model
okay now I'm going to make chatgpt write code in my imaginary language
I made chatgpt write code in cum once
Call it a concept, not imagination
@blazing ocean let's make a DNA programming lang
?paste
@worthy yarrow
I'm cooking
only mistake it made was created a parameter name
I can fix that though
here is ChatGPT's concise lang parser in conciselang
f parse string j
vi tokens std.split string " " // Split the code into tokens
lp token<tokens++j
f parseToken token j // Parse each token
j
j
f parseToken string0 j
// Parse a function declaration
lp token<["f","fr"]++j
f parseFunction string0 j
j
// Parse a loop declaration
lp token<["lp","lpi"]++j
f parseLoop string0 j
j
// Parse variable declaration
lp token<["vi","v"]++j
f parseVariable string0 j
j
j
f parseFunction string0 j
lp token<["f","fr"]++j
vi functionType token0 // 'f' or 'fr'
vi functionName std.split string0 " " // Extract the function name
vi params std.split string0 " " // Extract the parameters
lp param<params++j
vi paramName param // Create the indexed parameter name (e.g., int0, string1)
j
// Parse function body
lp body<tokens++j
lp token<["j"]++j
std.println "Function Body Parsed"
j
j
j
j
f parseLoop string0 j
vi loopType std.split string0 " " // Extract loop type (lp, lpi)
lp loopBody<tokens++j
lp token<["j"]++j
std.println "Loop Body Parsed"
j
j
j
f parseVariable string0 j
vi varType std.split string0 " " // Extract the variable type (vi or v)
vi varName std.split string0 " " // Extract variable name
std.println "Variable Parsed"
j```
The fact that I can read this and somewhat understand it is quite impressive
okay I had it create pong in conciselang
here are the rules if you want to make more code in conciselang
absolutely splendid
what is the name of the aspect ratio that's inverse of normal aspect ratio formula: width / height
currently i name my helper functions as widthAspectRatio and heightAspectRatio, but this makes no sense as the aspect ratio's formula is width / height so how can i name an inverse of this function?
reciprocal maybe?
not sure if that’s the term u looking for tho
or just like, inverse ratio
damnit I keep clicking back to discord and it adds a reaction
rad I can read your mind
what am I thinking
skibidi toliet
idk you have to install the app first
no it's "kat still can't code in console smh"
why does my paste link trigger discord RAT protection kek
bc of the .py extension
breh
just change .py to anythign else. Paste will still show it
does it have diff syntax highlighting then
doesn't look like it
How would I make a per player chat censor with spigot?
Like some players want swear words to be censored and some don't
yes but the thing is i want the message to be different for others
you mean packets as in like a client receive message or something?
For example
With chat events you can just cancel the event and send the censored message to everyone
im having trouble hiding particles from the players screen, whenever i use packet.getParticles.read(0) it always returns as null
use a resource pack and set the texture to an empty one
not a bad idea since i was already considering using a custom texture pack for the server 👍
i just hope it doesnt come back to bite me laer
its weird since the packet does give me a particle in the error log particle=net.minecraft.core.particles.SimpleParticleType@3cb8e8f its just some error with enum wrapping
I've never noticed, but does the api often use cloning when retrieving data?
Ive just started learning dev for plugins and im trying to make a command but sender, label and arg is all underlined but all the imports are there can anyone help?
Did you add the spigot dependency to your project
i used the minecraft dev plugin so it should have all done it
Is Intellij up to date
noo ill update
still highlighted
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
these are all my imports
IntelliJ IDEA 2024.2.5 (Community Edition)
You're still outdated
Update
When doing an update through the UI it will only do one update step at a time
2024.3.1.1
Did you modify your pom at all?
do i send in the pastebin?
yes
ok done
Now send the link
That's the wrong way to do it
If you’re using maven for your Spigot plugins (which you should do), it’s easy to make maven automatically save your plugin’s .jar in your plugins folder. There’s two ways of doing this: 1. The lazy way (not recommended) If you only work alone on one computer, you can just directly declare the output location in...
ok so do i remove the config thing
ok
Make sure you have a Java 21 JDK set
If you are expand the external libraries in the project browser and see if Spigot is there
If it isn't close Intellij and delete the .idea folder of your project
ok
ln /path/to/your/jar /path/to/your/plugins/ 🗿
Is this correct?
@Override
public Map<String, Object> serialize() {
final Map<String, Object> map = new HashMap<>();
map.put("name", this.getName());
map.put("location", this.getLocation().serialize());
return map;
}
public static AdvancedHologram deserialize(Map<String, Object> map) {
final String name = (String) map.get("name");
final Location location = Location.deserialize((Map<String, Object>) map.get("location"));
return new AdvancedHologram(name, location);
}
Stuff like item meta and block data are clones
if rad reads that description hes gonna kill you (how dare you mention maven)
For gradle you just use a copy task ```kt
tasks.register("copyJars", Copy::class) {
from(tasks.shadowJar)
into("pathToPluginsDirectory")
}
tasks.assemble {
dependsOn("copyJars")
}
🙏
i hate java records
specifically of how it doesnt blend with getter and setters of normal classes
why couldnt they just named the getters with get prefix
my OCD kicks in seeing records not following conventions
What's an OCD
Obsessive–compulsive disorder is a mental and behavioral disorder in which an individual has intrusive thoughts and feels the need to perform certain routines repeatedly to relieve the distress caused by the obsession
well i don't have OCD (at least diagnosed) one but im kinda perfectionist and seeing things like these infuriates me
for 10's of years everyone followed JavaBeans spec of naming getters with get<Noun>() format
and Java devs be like: nope. we're gonna do something else
Fluent getters and setters are getting more common
I believe the getless thing has a meaning
it means we're never gonna get anything we want
Is it actually possible to create shaped recipes with something like:
W__
W__
W__
And the same ingredients, in another recipe, on the opposite side:
__W
__W
__W
Or is it impossible? I seem to get only one of those recipes.
what does effect the tablist texture to display the overlay texture too ?
i know its for the fake player in the metadata but i use velocity tablist and i cant send the packet for this.
register two shaped recipes?
the hat layer?
yes
the player needs to be in render distance for that to render
Hm, yes. But it seems to ignore the spaces and the other recipe overrides the other.
Register
W
W
W```
That should work I believe
I mean. I can't see your intent there. I can't see the spaces. I used _ to signify a space.
but if it is completly custom and no real existing player ... ?
i know fluent setters but what are fluent getters?
If you register as I said it will work iirc
value() for get
value(10) for set
Maybe we can get rid of getters and setters entirely
fields 🙏
Why do we use getters and setters btw
but why? isnt method suppose to tell you what it does? what if there's two different ways to get a field
I'm not sure if I explained my problem well enough. Let me try again.
So ... I have left curtain item and right curtain item. And both of their recipe is 3 wools. I use shaped recipes for both. Wools on the left-most column for left curtain. And wools on the right-mose column for right curtain. No matter where the column is when crafting -> left, middle, right, I always get the left curtain item.
Instead I would like to get left curtain for one left column positions and right curtain for right column positions.
i get it that you can know what it does implicitly
but i think it can be quite confusing sometimes
yea I agree, its a bit bizarre and may both add or take away readability. Like functions in general do stuff and thus should be named after verbs, in functional programming this is often violated but that’s cuz u have so many fkn functions and with infixes, and then different ways to reduce and compose and combine stuff, in object oriented programming where functions rather are procedures its goofy, having functions with prefix of get/set is nice cuz u can make ur ide list all getters or setters for a given type.
It's pointless to explain to you if you do not take my explanation lol
I told you already everything
mainly to add polymorphism through interfaces of retrieving certain values differently
Yes, I'm sorry but I didn't understand your explanation.
not at all
kotlin has fields on interfaces (they are just getters and setters)
also to retain ABI dovidas
Just register it as
W
W
W
and it should work by default
i guess yeah, but that's only works due to polymorphism
lets say for some data, the way you access that data changes for all clients, then retaining ABI is important in the long run
not really
:>
The issue is that there are:
- Two recipes.
- Same shape for both recipes.
- Same ingredients for both recipes.
Ah you mean like one is right and one left?
Not sure if you can do that
Yes, exactly. Sorry that I explained it so poorly. I should have shown a screenshot.
W _ _
W _ _
W _ _
_ W _
_ W _
_ W _
_ _ W
_ _ W
_ _ W
where _ is air?
Yes.
shouldn't that just work
He needs them to have seperate outputs btw
Yes, outputting different two items.
I mean just use seperate recipes then
Well they are.
Is that even possible
But one is overriding the other.
I thought the api forbid you to use air
thats not possible
ah
I guess my question was exactly that - is it impossible. And I guess I got my answer.
if its the same shape with same ingredients, it will have the same result
I'll need to think of something different.
You could prob manipulate it using the crafting event
man you guys need to check this section
saves so much time in terms of code generation
yea
Its good
but you can put like things that contradict each other and the ide flips out
my favorites
i especially like the spam of final on code generation
less bugs when writing code and hinting JVM for optimization
oh yea its great
myea, I mean I think there are occasions when this isn’t needed
but its good when the class is getting larger
verbosity schmerbosity
once you glimpsed into the endless void that is FQN in mojang sources, a few finals are nothing
kotlin cant compete
Where do I find them
i just prefer this everywhere since i dont have to confuse myself with color schemes
Yes
Speaking from experience I presume? 
Good song btw lynx
Unqualified static access
Instance method not qualified with 'this'
Instance field access not qualified with 'this'
Unnecessary qualifier for 'this' or 'super <- this one removes typed out unnecessary class name for this or super (Foo.super, Foo.this etc)
does it pick super over this?
it is 🙏
i used to try fiddling w it but could never get super to take precedence w this (mind u 2 years ago)
curious dovidas>>
You be walking that walk?
🤔
yea, like if there’s an inherited member and its not accessed with the receiver parameter this it puts super as opposed to this
and if super is possible, it yells at you for using this
cant find such rule sadly
i guess if you have such problems, maybe inheritance is not the solution
I don’t think I was the owner of whatever library I was using
I wonder does java have a dedicated linter that's separate from IDE
something like BiomeJS or ESLint but for java
spotless
annotations when
val
can someone hard-code-check me please? https://github.com/LyamRay/MobGear/blob/master/src/main/java/me/lyamray/mobGear/inventories/ForgeMaceMenu.java
🥹
@NullMarked declared on class
dont need it
again:
with @NullMarked from JSpecify library, it declares all parameters as @NotNull implicitly unless you declare parameters as @Nullable explicitly
looks good from first view but i would give few recommendations:
- Design a class which handles all your translations. Don't hardcode the strings into the plugin. Load them from configuration file or something.
- If you're running like Java 17+ or something, use switch expressions. With switch expressions you dont need to type
breakfor each case
Yea in some cases i used the switch expressions because it would give me that warning haha
?codereview btw
#1100941063058894868 is the place for code reviews. Remember to read the pinned message!
And explain a little bit more about the 'class' for all the message strings
google probably has a library
i would also probably remove magic values for slot numbers and refactor them to be either loaded from configuration file or refactor them to be inside static fields.
InventorySlot.TOP_LEFT, MIDDLE_MIDDLE, MIDDLE_RIGHT, ...
All the plugins load the translation strings from the locale/en_us.yml or something so that way you wouldnt need to recompile your plugin to support different messages and languages
You usually use Bukkit Configuration API to read configuration data for that purpose and then replace the placeholders with String.replace or adventure api if you're using paper
I mean Foundation (a plugin framework that i use) can do that in a way, using buttons but i dont really use that.. maybe ill look after that soon
https://checkstyle.org/ maybe?
Alright, i'll do some research!
this is the way for linting
i 've searched for this and Scorpionist did found what i wanted for a long time 😄
i feel like Kotlin inline value classes are such a good way to wrap OpenGL objects
too bad valhalla is still not released
THE GIF AND MUSIC IS NOT MINE
BIG CREDIT TO THE OWNER OF THEM
song,nice,cute,pug,dance,music,yeah,Kawaii,background,focus,funny,meme
me when Valhalla releases
null restricted types is gonna be yummy
mood
Why are value types so much faster than normal classes?
less memory indirection
Okay
Hey there
I was wondering if anyone knows a fix for the following.
I am working on a plugin where you can cast abilities. these abilities have cooldowns, and i thought i would display these cooldowns as the stack number.
However, setting a number to higher then 100 (i did 360 lol), aperently breaks the game. Not imidialty but whenver you open your inventory
So my question is, does anybody know a way to go over this number, without breaking the game
🥲
then i am better of just faking the bigger digits, in the place of the 100th numbers
the biggest cooldown is 360 anyways, so i only have to create a texture for 1 2 and 3
also, fork the client cause the vanilla client will blow up too
i am just going to create a mod, just so i can have a big number
pretty sure that limit is part of the codecs somewhere oto
uh is it part of the network codec?
it's clearly part of the regular codec
it's just an unbounded varint on the network codec
I had a question
So recently I published this plugin that makes a website with a normal user and admin panel where in admin panel there can be multiple accounts with certain permissions, I added console but I was wondering if I could literally add a file manager, I should be able to load and save other plugin's configs from the plugin or is that not possible?
If I can't then I'll just spend the day tmr refactoring the code cuz its horrible rn
if its horrible why not just redo it? im the type of person that would say "Eh ill do that later" than base all other code off of that and later on and go oh 💩
I mean I just need a cleanup not a complete recode, too much stuff shoved in the same class, this one specific class lol, its 2am that's why I said I'll do it tmr😭
so its said that udp is faster than tcp, altough, i tested it and it seems like tcp is faster? does anybody know why?
sounds like a rather flawed test
Udp is stateless. This means you will never know if something got your udp packet unless it sends back info it got something. This makes testing speeds difficult and not very straight forward.
Tcp requires acknowledgement that the other side received what you sent and is stateful meaning as long as the connection is open the other side is connected too or should be anyhow lol.
Udp doesnt check if the other side is even listening, you just send the packet off to where you want it to go and forget about it lol
okay
That being said, udp is handy for communications where it isnt really crucial if the other side got it or not
yes, but i heard its faster if even if you ensure it gets on the other side
It is but only because there is less overhead. That is you are not having to manage the connection and setting up any listeners as is required by tcp. You also dont have much strictness in regards to some header info(part of the less overhead)
So its not faster because it is better but simply there is less required for it to send a packet off with it
okay, but are there really any applications in which you wouldn't care if it didnt reach the sender?
Sure, when you want to provide informative notifications. Lets say in the game the client allows you to setup friends list. And then it notices your friend is online. Instead of using tcp to tell the server to send notification to your friend you are online, you could do so with udp
Because really such a notification isn't super important
true
Maybe the server wants some effect to happen on the client. Like fireworks going off because festivities. You could send that via udp since its not important the client do all that
So there is plenty of stuff you can just have done over udp, just have to decide and know is it ok if they just dont get it lol
In games they use both TCP and UDP
UDP generally has lower latency so it's often used when you're sending similar data a million times and you don't care if it's accurate
wouldnt that make the code really complicated?
Not really
Let's say, for example, when your enemy is moving. The UDP packet contains the player's final position and you kinda don't care if you miss a few
sendPacket vs sendPacketReliably type deal
It gets abstracted away
Older games when it came to setting up servers since all the services were separated. Usually your chat server was done over udp and tcp only used to just tracking purposes and admin stuff
Or when you're in a call, you don't care if the end receiver missed a couple bytes as long as the call is pretty much in real time
Games especially older ones didnt really prioritize chat and care about the order of the messages just as long as everyone got your message at some point
Even when you screenshare on discord it goes over udp
connection can drop but as long as you get enough frames it's ok
i didnt know there where that many usecases
but they have to somewhat ensure something
As i said before, udp advantage is the fact it has less overhead and management
yes
You just dont have reliability but that is ok because modern tech and networks it isnt common to just not get packets
Well it isnt like decades ago where like the percentage of not getting a packet was higher then it is today lol
in most cases it comes nowadays unless something seriously fucks up
For example when connections were dial up, udp was something you wouldnt use commonly because that type of connection is not reliable and prone to suddenly going down
I wonder if we're gonna get to a point where it's so reliable we don't need tcp
Well tcp has ordering
yeah..
Also, secure connections cant use udp either
Since you cant be sure who you are sending to
Well they can, just not as secure really. Can still encrypt the packet
Can I use spigot plugins on a paper server?
yeah
are there any good resources that explain raytracing to detect if a player's looking at an entity's hitbox?
https://imgur.com/a/VTCB60h how do i fix this error?
update your server's java version or compile to a lower version
There was a good one but the images and videos are gone
I can offer a quick explanation if you want
Please 🙏
I just saw it but it was hard to wrap my head around without them
Assuming it's this one you're talking about
I believe so yeah
I'd like to begin by stating that spigot has builtin methods for this
But it's always good to know what raytracing / raycasting is about
The basic concept around this is that we make a like that starts at the player's eye, aiming towards a direction and we see what it intersects
I see
The most basic implementation of this goes a bit like the following
Define a couple variables:
- Starting location (eye)
- Direction
- Max distance (we don't want to loop forever)
- Precision (this is essentially how much we travel per iteration)
- "offset" (basically your direction normalized and scaled down to
precisionlength)
Start at the starting location and see if it intersects any bounding boxes, if it does, hurray!
If it doesn't, add offset to it and try again
If we reach maxDistance with no matches, end the loop
The math is pretty similar to rendering a particle line, except instead of displaying a particle we just look for bounding boxes
The finer the line, the more accurate and expensive the operation becomes
There are a couple ways to optimize it but fundamentally this is it
Alright, thank you so much for your help!
I cover a couple optimizing methods here -> https://github.com/cerus/maps/issues/6
I'll be sure to check it out once I get the hang of things
Here's some old old code fore reference
Wait you said built-in methods, which ones?
Are they related to the looking_at predicate?
raytrace / raytraceBlocks / raytraceEntities
Hey - I'm trying to practice my Git when commiting files why does it have two copies of each? Example; src/plugin.yml and target/classes/plugin.yml
Target is what's been compiled. plugin.yml isnt compiled, and is transferred raw.
nothing to do with Git
Target is the directory that gets created when you compile
Should both be publishing to git?
All the files and classes destined for the jar get put there. Classes are turned into compiled format and then once compiling is done, all the stuff in target goes into the jar
You should be ignoring target directory for git
So create a gitignore file add directory to said file. But before you do delete the directory, git commit and then push that change to remove directory from repo. Easiest way. Then create your gitignore file
Once directory is in gitignore file git will stop tracking it
What is strange is my current .gitignore contains /target/
The / at the beginning means ur PC's Root directory. when in reality its not, its in ur cwd
Get rid of:
.classpath
.project
.settings
and then add them to ur gitignore
It's somewhere in the settings
im having a problem where protocolLib doesnt detect particles in particle packets on 1.21.1, it only returns as null when i try to read it
show code
Welp I broke more... I deleted the classpath proejct and settings from my github repo and then did git pull and it is giving issue snow
are you using a build system
What do you mean
I am opening my project in IntelliJ now and it has so many errors despite Eclipse not having any
you're talking about .classpath and .project files
you should be using a build system like maven or gradle
instead of relying on eclipse's hodge podge
You're using the new UI already
They want the old one
oh I read that as "get rid of the old UI"
Would anyone mind helping me figure out why i cant compile any projects with intelliJ even though it says successfull?
tried like 3 and they all either compile and dont show up the jar in target folder, say error or hang up on post compile task
This is the error
You probably have a couple outdated maven plugins
How would i go about updating that in intelliJ
Open your pom.xml and change the version numbers
a google search should find the latest versions available
i dont see a pom.xml i do see xml files though
such as?
build.xml and then these

those are intellij configuration files
that's not maven
no
C:\Users\dawse\OneDrive
Learnt the hard way
During c++ class my programs used to compile for 2 minutes (even a simple hello world) due to onedrive
Is there an API in the Spigot API that will list the plugins purchased by the user? I want to verify with Discord.
no
i want the old one ..
so i disabled one drive now intellij cant find my documents folder..
it is there though
ill move them ig
ayy figured it out
Wait are you using ant 🔫
💀
moving everything from user/onedrive/documents to user/documents
then i will go from there
god one drive is annoying
Or maybe switch to linux
the correct choice
👍
Alright back in a regular folder environment
Project shows this but wont show a build or target folder
Yea because you're still not using maven
How would i convert from ant to maven
no idea
just do it from scratch lmao
How ancient are you
netbeans ex-lover here
Bro even the netbeans people use maven
@shadow night making a tool for setting up IJ workspaces for decompiled plugins, how should I get the VF jar? I don't really wanna make a config file and don't want the user to input the jar themselves... should I just download it?
I could download it to a place and check if it exists ig
Ye download it
I could download it to the user's data dir and check if that exists
The dirs crate is
I used ant for hotreloading once
Also you could blame ant, but i cloned a maven project and that wouldnt even build
yeah im boutta just rebuild the project in maven and paste code
it works but its super l ong and annoying
yeah i got no idea whats even happening anymore. ant can get bent and ill remake the project with maven/gradle and just paste code over then it will build fine without all this mess
do you think this is fine? ```rs
pub async fn download_vf() -> io::Result<PathBuf> {
let jarfile = data_dir().expect("data dir could not be found").join("plugdecomp/vineflower.jar");
if jarfile.exists() {
return Ok(jarfile);
}
if let Some(parent) = jarfile.parent() {
fs::create_dir(parent)?;
}
if let Err(err) = download_url(VF_DOWNLOAD_URL, &jarfile).await {
return Err(io::Error::new(ErrorKind::Other, err.to_string()));
}
Ok(jarfile)
}
Yeah looks fine to me
what are you doing now
this
i got a nice malware sample and would prefer to look at it in IJ
nerd
for gradle integration
is there a way to know when a server on the proxy is stopped through bungee api?
i cant seem to find any events called related to it
you'd have to do SLP lookups
yea
What do you need this specifically for? Polling is rarely the best solution.
whats wrong with it?
Its inefficient if you have the option to use a signal instead
interesting, how do i use a signal?
you could use something like websockets ig
Events are signals for example. But anything you listen for is a signal. You have two options:
- Write a plugin which is put on the server and send a message via a socket in your onDisable
- Use a message broker like Redis or RabbitMQ (former is my fav)
Plugin messages wont work in onDisable iirc
Slightly delayed but you could check the last ping
It just depends on why you need it. Do you need to know precisely WHEN a server stops, or do you just need to know IF its still available?
Signal based handling is all fine until your server crashes badly and fails to send a signal, if you want to react to crashes as well as normal shutdowns, then I think the ping method is better in this case
Free crates plugin suggestion that works in 1.21.4? And not "excellent crates" cuz its buggy. And Item remover after item dropped time passed like shown in the photo
You can hook into jvm crashes if you are concerned about that
jvm crashes? there's no guarantee shutdown hooks run if the jvm crashes if you mean that
You can at least add a shutdown hook to the Runtime. OutOfMemory errors are caught that way, which is quite often the only real danger for a mc server. Deadlocking the main thread should also be covered iirc.
But if the process is killed or the OS dies, then there is nothing you can do. In which case polling would be the better option.
or when the jvm crashes, e.g. a segmentation fault due to bad memory, which is also pretty common
Interesting. I have seen zero seg faults in my 5 years of working with java so far. 🥲
But thats anecdotal. I would assume that its not very common. Would be interesting to find actual stats about what most often causes an ungraceful jvm shutdown.
I've seen it once
The guy had just gotten a new PC with faulty memory
causing corruption in the program
Hello, I want to print all my packages when the plugins are loading, but it doesn't work.
for (int i = 0; i < eu.stepanb.commands.size()) {
can i use lombook instead?
that will not help you
why?
because thats not what lombok doeds
yea
so what lombok does
i can add @Setter and @Getter to all my classes so it probably will work
Thanks
@blazing ocean
so how can i do it
i highly doubt that
yea
???
it really does not look like you know java very well
i know java well bro
so use reflection then
how
Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.
guava classpath my beloved
i know java bro
okay?
so google how to use reflection
if you would know java you should know reflection
thats common knowledge amongst java users
i know java but i dont know reflection
but you know java very well
yes
reflection is part of java
reflection isnt java
it is
it is lmfao
no
it is
it is
it is
no
so whats this
stepan you have to be trolling
^
which u can add to gradle
no
java.lang whats that packet supposed to mean?
reflection isnt part of java
what packet
*package
you are talking about https://github.com/ronmamo/reflections which yes, is not in java
but java does include reflection that is not that api
so how can i do that
you can use reflection without that api
read this page
we arent spoonfeeding you it
?spoon
Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.
if you refuse to read, you arent gonna get very far
bye
he totally know java very well
yes
i know bukkit
that's not java
bukkit is not java
bukkit is a library
an API
a dead one, at that
its only been dead for 10 years at this point
im still using bukkit on my server
ur on 1.7.9?
how can i use hex colors in my plugin?
Are you using legacy colors in a string?
or are you using components
legacy
Then the format is &x&f&f&f&f&f&f for #ffffff
#fffff
Assuming you're using & as the § character
??
&x&r&r&g&g&b&b
Spigot accepts hex
Not RGB
as far as I'm aware at least. If you want to use rgb you'll need to handle that on your own
then i can use the hex but how can i put an hex color?
like this
add a &x and then add a & before every letter/number in the hex code
is there anything special you have to do to get mojang mappings working for NMS? I have added the md_5 plugin and the remapped-mojang dependency to my pom.xml but the classes are still obfuscated
and before i have to use the Chatcolor.Transfercolorof stuff?
yes
No
Show your pom
?paste
Actually did you run BuildTools with the remapped flag
yuppers
sure 1 sec
ChatColor.translateAlternateColorCodes('&', HERE) what i have to put?
The string you want
thx
yup fixed. Thanks!
I dont understand. Most of the GLFW functions you need to call from main thread
but how i suppose to then have multiple rendering threads
for an application
if i can't offload GLFW.glfwSwapBuffers() which is basically needed for rendering thread to function properly
you should run your app on an "Application Thread"
wdym
inverse of control? i should offload application logic to another thread, meanwhile render everything under main thread?
what you can do is perform certain work tasks in other threads that you then push the result to the render thread
this is through LibGDX but same point holds
package sh.miles.algidle;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import org.jspecify.annotations.NonNull;
import sh.miles.algidle.screen.LoadingScreen;
public class MainGraphics extends Game {
private SpriteBatch batch;
private ScreenViewport viewport;
private Camera camera;
public MainGraphics() {
}
@Override
public void create() {
HeadlessGame.INSTANCE.start();
this.batch = new SpriteBatch();
this.camera = new OrthographicCamera();
this.viewport = new ScreenViewport(camera);
viewport.apply();
setScreen(new LoadingScreen(this));
}
@NonNull
public SpriteBatch getBatch() {
if (this.batch == null) throw new IllegalStateException("Attempted to fetch SpriteBatch before #create call");
return this.batch;
}
@NonNull
public ScreenViewport getViewport() {
if (this.viewport == null) throw new IllegalStateException("Attempted to fetch Viewport before #create call");
return viewport;
}
public Camera getCamera() {
if (this.camera == null) throw new IllegalStateException("Attempted to fetch Camera before #create call");
return camera;
}
}
private HeadlessGame() {
this.gameThread = new Thread(this);
this.tickLoop = new TickLoop();
}
public void start() {
this.gameThread.start();
Registries.freeze();
}
☝️ is this what you've provided in the code is the thing I described?
yes, though I have no clue what "inverse of control" infers, seems like an overcomplicated way to say what both emily and I mentioned
does this mean that there's no way to have two independent GLFW instances, apart from creating a new process?
not saying that its practical but im just curious
I'd assume so
You can have multiple ones
but you usually wouldn't
Contexts I mean*
If you want to handle multiple windows and such you can do so
Opengl contexts yes,
but i mean glfw itself
GLFW.glfwInit(); can only be called from main thread
you cant have glfw context per thread
thus you cant have logic be running on main thread
and multiple renderers on separate threads
not that its practical anyways to have multiple renderers running at the same time lol
Can someone help me set up a project as im clueless or is there an article or video that helps?
https://www.spigotmc.org/wiki/spigot-plugin-development/
Creating a blank plugin with:
IntelliJ IDEA and Maven
Is my suggestion
What's the error?
wait i reinstalled and it worked i think it was bugged
I give up
i give up making renderer for a game engine in java
im too braindead for this
How about you just build on lwjgl
lwjgl is just bindings for GLFW, OpenGL
im currently using that
How about just using LibGDX for you game
im forced to by uni
maybe, but there's a catch in my uni assignment to not use any frameworks or libraries that resemble a game engine
im making an art app in rust on top of wgpu which is basically a wrapper for all kinds of graphics libraries but essentially the same thing
just followed a giant tutorial so I can draw a thing on the screen
now it takes ages to make something normal and nicely abstracted
i've followed whole cherno's open gl series just to render couple rectangles on screen
🙂
yeah
Not annotated parameter overrides @NotNull parameter Does any 1 know what this means when im making a command the sender, label and args all have the erroe
not being able to use LWJGL must suck
I can use LWJGL
i cant use something more high level
like LibGDX
or game engine
Intellij suggests you add the not null annotation to match the overriden method
but I guess you just have to build for windows desktop right?
also that's a warning and not an error
ahhh LibGDX barely feels like a game engine it really doesn 't hold your hand, but yeah that sucks
i have no idea what it wants me 2 do then
LWJGL is just bindings for opengl and glfw
barebones of what you need for game engine
Yeah it's more a lib
Which is what I like about it
also what I like about it thus far
I just told you what to do
?
so i change sender and stuff 2 notnull?
yes
rust mentioned
not the compile times kekw
rust doesn't have the concept of actual libraries, hence the compile times
its not too bad
there is not a lot of code yet
I am not a person to just hoard dependencies because I need an is_odd function
I was working on a tiny project earlier today and already had to compile 300 crates
clap
clap my beloved
private boolean depc(Player player) {
String depositCoinsAmount = plugin.getConfig().getString("deposit.player-deposit-coins-3");
String depositGoldAmount = plugin.getConfig().getString("deposit.player-deposit-gold-3");
economy.depositPlayer(player, Double.parseDouble(depositCoinsAmount));
if (playerInventory.containsAtLeast(new ItemStack(Material.GOLD_INGOT), Integer.parseInt(depositGoldAmount))) {
}```
Is this the right manner to get the value for a double data-type and an integer data-type from a config file?
id probably use https://hub.spigotmc.org/javadocs/spigot/org/bukkit/configuration/MemorySection.html#getDouble(java.lang.String) and https://hub.spigotmc.org/javadocs/spigot/org/bukkit/configuration/MemorySection.html#getInt(java.lang.String)
declaration: package: org.bukkit.configuration, class: MemorySection
use it the same way you use getString
i wonder if creating proxy classes for window size like this is good practise:
private class OpenGLWindowSize extends Size {
private OpenGLWindowSize(final float width, final float height) {
super(width, height);
GLFW.glfwSetWindowSizeCallback(OpenGLWindow.this.id, (window, newWidth, newHeight) -> {
super.setWidth(newWidth);
super.setHeight(newHeight);
OpenGLWindow.this.callback.invoke(window, newWidth, newHeight);
});
}
@Override
public void setWidth(final float width) {
GLFW.glfwSetWindowSize(OpenGLWindow.this.id, (int) width, (int) this.getHeight());
super.setWidth(width);
}
@Override
public void setHeight(final float height) {
GLFW.glfwSetWindowSize(OpenGLWindow.this.id, (int) this.getWidth(), (int) height);
super.setHeight(height);
}
}
}
outer class constructs OpenGLWindowSize which will represent width and height and it will allow for outer access of setting width and height
getString("path") or getDouble("path") or getInt("path")
then i can do
OpenGLWindow window = ...
Size size = window.getSize(); // Returns OpenGLWindowSize but hides it under Size class, because user doenst need to know that this is a proxy implementation of Size class
window.getSize().getHeight() // This will be synced with GLFW and cached to a field, handled by Size class, thanks to the provided listener of Window Resize, provided by OpenGLWindowSize
window.getSize().setWidth(550) // This will set the Size's this.width field and also will invoke GLFW to resize the window, essentially syncing the statea
Figured it out
it feels so much nicer to have size in sync, but im not too sure if such proxy classes are really a good pattern
I was wondering if it's possible to disable this message from your plugin when you launch your server
Enabling Test v0.0.1
Pardon me for my horrendous English
I want to replace it with a getconsolesender
?
I want my enabling message coloured
please don't
It is a bad idea?
ansi colours are not supported on every terminal and there isn't really a reason to
Uhhhh.... ok
I know this, but I wanted to know if it was possible
It is
public static String sendMessage(String content) {
return ChatColor.translateAlternateColorCodes((char) '&', (String) content);
}```
Boom, simple
Wow
My main question was this.. but thanks
No pls
why cast to (char) and (String) legit isn't needed 🤔
I haven't played hypixel since middle school..
Please dont color your logs
i love how you're casting a char to a char
and a String to String
is that decompiled code
Why :(
then why in the fuck are you doing that
It looks ugly as hell
and is useless and annoying
dont do it
Logs are not for aesthetics
theyre for logging
No clue, it's an old project. Forgive me 🙏
no
Honestly, I should get the code reviewed
Exactly for that I'm colouring them..
no!
So I can see them better
no!
It is probably extremely horrendous
use logging levels
Info/warning/severe?
Yes
Yes
...uhhh.. no
Your text editor can highlight them
Doesn't it? getLogger().info(), .warning(), .severe()
The logger isnt what colors it
Oh, i read bad, yes it does
My terminal does support colours
Is that any better?
Log4j is what is responsible for handling the coloring, or what does or doesn't get colored in regards to messages specifically sent to the logger. As for reading them better, the coloring only is visible/applies while looking at the console at the time the message appears. Once the message is logged, there is no more coloring lol.
log4j is just a glorified system.out.println with some filehandling and networking abstractions
and?
o.O
😎
duly noted I supposed lol
how do I get item info of custom items like ecoitems:something
those are just items
are they registered anyway?
is it modded or not
you cant register new items vanilla
its just an item with custom data
what tf is this doing
https://www.spigotmc.org/resources/ecoitems-free-⭕-make-custom-items.117785/
intresting
aha so there is no way to get the default lore
And providing logic
No, its not known to vanilla
just pray that plugin has an API
well it has some, like 5 no docs
https://www.spigotmc.org/threads/free-plugin-obfuscation-guide-yworks.636361/
I'm trying to add obfuscation to my plugin but I think I'm keeping the libraries wrong, how do I do this?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
CMarco 💀
who is he
a troll that used to be in here
tbh i just realised that im developing not a game engine but opengl bindings wrapper for java
i'm probably starting this over
by implementing everything in more game engine higher level
im not even sure why im wrapping it
i love joe biden gifs
oh god hes made his way back in
the more i think about it,the more i realize generics are usually a code smell
I mean is it really worth to lose runtime type information and autobox every primitive value just because of convenience
for example
what if i have a Vector2d
sure i can have Vector2d<Float>
But then i can also have FloatVector2D which returns float insteas of Float with a generic type
valhalla
when
but no, generics are not a code smell
jvm generics might be a bit funky to work with, but that is language detail
Type erasure is the root of the problem, and the only way to solve it is to use wonky runtime class type passings over parameters
Idk guys but what Fastutil offers without generics is way better imho
soon(tm) 🙏
...doesnt the D mean double?
yes
i prefer full data type names instead of one letter ones
Vector2i sounds kinda weird
IntVector2D looks more right to me
but that's just me
TwoDimensionalIntegerVector
int vector 2 double
well vectors can be multidimensional



