#help-development
1 messages · Page 765 of 1
is this correct to do something to each entity that's been scanned
or did I do this wrong as well
It's like watching a gore video and discovering how much you can bend the human body
This beginner Java tutorial describes fundamentals of programming in the Java programming language
@storm crystal That’s a fine loop
Yeah about that, there is no code to show, the code I have doesn't work
Yeah anonymous classes sure
Like you don't even think about it
I can't figure out a way to compare them at all
Show us anyway
Just show us where you are at
alright
int PURPLE_R = 150;
int PURPLE_G = 80;
int PURPLE_B = 150;
int TOLERANCE = 60;
return (PURPLE_R - TOLERANCE < color.getRed() && color.getRed() < PURPLE_R + TOLERANCE) &&
(PURPLE_G - TOLERANCE < color.getGreen() && color.getGreen() < PURPLE_G + TOLERANCE) &&
(PURPLE_B - TOLERANCE < color.getBlue() && color.getBlue() < PURPLE_B + TOLERANCE);
}```
Maybe name the entity variable smth else
Maybe the mustache guy was right
I know it's not polished I just need it to work atm
Cuz what the hell
There is probably some fine examples on this https://stackoverflow.com/questions/15262258/how-could-i-compare-colors-in-java
RGB is not a good color space to check for color differences if you aim for perceived difference for humans.
I am alien
can I just do this
since Im not using i at all and just refer to living entity
I tried the solution they had, it didn't work very well.
Looks better
I tried messing with the tolerance and everything but nope
Just call i entity and it looks even better
Let me get my computer vision script out real quick. We had a nice method for comparing perceived color distances.
More different ways to compare
Like a anonymous inner class?
nope
Sounds dumb
nah nah watch
how do sound and category look like, whats the base volume and pitch for sound effects?
Probably 1 and 1
Mental asylums couldn't handle you, that's why you're out
If you google it you can find plenty of examples I am sure
fun onCreate(ctx: Context) {
class CreateResponse(val something: Int)
...
val response = CreateResponse(15)
ctx.respondJson(response)
}
Ah
Man just make it outside or use many variables
I trick gson into serializing it without exposing needless classes that arent use outside the rest handler
Oh
Well I guess
now to be fair, that is pretty bad. I would actually abstract the Requests and Responses into a separate dependency, so it can be made part of a lib that calls the rest api as well
then it can also be unit & integration tested without duplicate code
but if you're not doing that, then it's great
@lost matrix I just noticed that it was because my tolerance was too high
sorry but all is well
it's not as crazy as it sounds, off the top of my head, local classes are useful for making a thread-safe singleton easily for example
Untested code. Let me know if this works.
public double calculatePerceivedDifference(Color from, Color to) {
float[] fromYuv = new float[3];
float[] toYuv = new float[3];
ColorSpace colorSpace = ColorSpace.getInstance(ColorSpace.TYPE_YCbCr);
from.getComponents(colorSpace, fromYuv);
to.getComponents(colorSpace, toYuv);
float dx = fromYuv[0] - toYuv[0];
float dy = fromYuv[1] - toYuv[1];
float dz = fromYuv[2] - toYuv[2];
return Math.sqrt(dx * dx + dy * dy + dz * dz);
}
- YUV color space btw
ok I'll see if it works rq
PS: there was a * missing
dy +
is this a proper way of catching if player is interacting with nothing and then just ignore the rest?
A euclidian distance between two vectors in a color space.
So max would be... 2.0 i guess
Nope
Made it like so
You should never catch a NullpointerException in java
ok well it's throwing a Unknown color space error atm, but I'm just going to use what I have no because it seems to be working fine
I'm trying to create a 1.8.9 spigot plugin using the IntelliJ "Minecraft Development" plugin but it only goes down to 1.12 how do i change that
No
thanks for the help though
why
Forgot the ! 🤓
Time machine
@storm crystal If they have nothing in their hand right?
...
That’s what ur going for?
But just let the plugin create a 1.12 project and change the version in your pom.xml
nah but fr
You don’t
kk
This might throw some nasty exceptions. Should be fine i guess (?)
We don’t want it anymore
Then check if it’s null or air
Your IDE tells you that there might be something wrong with your code by underlining it with yellow lines.
This should be fixed if you want your code to run without problems.
We don’t want exceptions to be thrown is probably the easiest way to explain it
Yea xD
It can be null if player in login state. i think.
Bruh this is itemstack
Yes
You can calculate the YUV by hand as well. In case you want that still.
Don’t trust itemstacks to not be null
Also
Also itemmeta will always be null on air
Makes it really easy to check for euclidian distance of your colors
what does this mean
Deprecated methods are candidates for removal and should not be used.
There are always alternatives if a method gets deprecated in Spigot.
(Aside from two or so exceptions to this rule)
Player#getInventory() -> PlayerInventory
PlayerInventory#getItemInMainHand() -> ItemStack
how do I check if it returns an empty collection
Collection<T>#isEmpty() -> boolean
whats ->
return type
You know
If you went through some basics in a java programming course. That’d be super duper cool
l-learnj
You know
last time I checked it's not a strict requirement to pass some kind of exam to be allowed to type here
It’s not. It’s just painful to see you making very basic mistakes that could easily be rectified if you spent an hour or two learning via a course.
Yeah but it is a little bit rude if you didnt put in a bit of your time into getting the basics done to be honest
We’re not always nice and helpful, so please do take your time in getting some basics down. We do not expect you to know everything, nor should you really cause we don’t. Just like general layout of the language as well as general conventions would be a major improvement in your efficiency.
Alright it’s marked ss notnull
Right after the getItem line. Put “if (!item.hasItemMeta()) return;”
Also what is getType telling you?
Checking objects if they are null after using them is not useful
thats literally what I did?
where did I use it
That’s not after, but before
pretty funny since using try and catch actually removes that problem
im not using it to anything yet Im just declaring it
You are using it
Yeah. Then just try catch with general Exception
This removes all problems
Sry it’s not marked as notnull i see i see
You just gotta move the pieces you already have here around
You are calling getType() on your item
But if item is null at that point, then you get a NullpointerException.
ItemStack item <- declares the item variable
item.getType() <- takes the object referenced by the item variable and attempts to call its getType() method. This will throw a runtime error if item is null, because null objects can't have methods called on them
you would want to check if it's null after declaring it but before using it
might as well do it since its the only one working so far
nuh uh, didnt work
Check
If you catch a NullpointerException like that, then im not going to give you any further advise on your code.
You didn’t try yet
you still havent told me why I shouldnt do it
if you are missing fundamentals, can you atleast try to not be rude
why not use something made to catch errors to catch errors
Sec
Because it simply hides a fundamental problem with your code.
Its like kicking your cats excrements under the fridge and calling the problem solved.
Because try catch blocks are used to catch unexpected exceptions.
Your exception is not unexpected. Its even ensured to happen.
A NullPointerException is an error that happens when you try to use a variable that has no value. For example, if you declare a variable like this:
String name;
and then try to do something with it, like this:
System.out.println(name.length());
you will get a NullPointerException, because name has no value assigned to it. It is like trying to measure the length of nothing.
One way to avoid NullPointerExceptions is to check if the variable is null before using it, like this:
if (name != null) {
System.out.println(name.length());
}
This way, you will not try to use a variable that has no value.
Another way to avoid NullPointerExceptions is to make sure that you always assign a value to your variables when you declare them or soon after, like this:
String name = "Alice";
System.out.println(name.length());
This way, you will not have any variables that are null.
Some people might think that catching a NullPointerException with a try-catch block is a good way to handle this error, like this:
try {
System.out.println(name.length());
} catch (NullPointerException e) {
System.out.println("Oops, name is null!");
}
However, this is generally a bad practice for several reasons¹²³⁴:
- Catching a NullPointerException means you are hiding or ignoring the actual bug in your code. Instead of fixing the problem that causes the variable to be null, you are just covering it up with a catch block. This can make your code harder to debug and maintain.
- Catching a NullPointerException can make your program behave unpredictably. For example, if you catch a NullPointerException and then return a default value, you might end up with incorrect or inconsistent results. For example, if you catch a NullPointerException and return 0 for the length of a name, you might end up with wrong calculations or comparisons later on.
- Catching a NullPointerException can make your code less readable and understandable. For example, if you catch a NullPointerException and then print a message or log an error, you might confuse yourself or other developers who read your code. They might wonder why you are catching this error and what it means for the logic of your program.
Therefore, it is better to avoid causing NullPointerExceptions than to catch them. You should always initialize your variables with proper values and check for null values before using them. This will make your code more reliable, robust, and clear.
Source: Conversation with Bing, 29/10/2023
(1) java - When is it OK to catch NullPointerException? - Stack Overflow. https://stackoverflow.com/questions/18265940/when-is-it-ok-to-catch-nullpointerexception.
(2) java - What is a NullPointerException, and how do I fix it? - Stack .... https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it.
(3) Is it a acceptable approach to put try catch wherever null pointer .... https://softwareengineering.stackexchange.com/questions/187175/is-it-a-acceptable-approach-to-put-try-catch-wherever-null-pointer-exception-occ.
(4) Catch NullPointerException | OWASP Foundation. https://owasp.org/www-community/vulnerabilities/Catch_NullPointerException.
(5) java - Null Pointer exception within a try catch block - Stack Overflow. https://stackoverflow.com/questions/21288433/null-pointer-exception-within-a-try-catch-block.
longer than my phone screen 😭
@storm crystal
Java is a popular and powerful programming language that can be used to create various applications, including spigot plugins for Minecraft servers. Spigot plugins are pieces of code that add or modify the features and behavior of the game¹. To create spigot plugins, you need to have a good understanding of the Java basics, such as syntax, variables, data types, operators, control structures, methods, classes, inheritance, interfaces, exceptions, and collections².
Learning Java basics before using it for spigot plugins is the best way to start because it will help you to:
- Write clear and efficient code that follows the Java conventions and standards³.
- Avoid common errors and bugs that can cause your plugin to malfunction or crash the server⁴.
- Use the spigot API and documentation effectively to access and manipulate the game elements⁵.
- Debug and test your plugin easily using various tools and methods⁶.
- Extend and improve your plugin with more features and functionality using advanced Java concepts⁷.
Asking basic questions without at least trying to learn is rude to the ones answering because it shows that you are not willing to put any effort or time into learning Java. It also wastes the time and energy of the people who are trying to help you. There are many resources available online that can teach you Java basics, such as tutorials, courses, books, videos, blogs, forums, etc⁸. You should use these resources first before asking for help. If you still have questions or problems after trying to learn, you should ask them in a polite and respectful way, providing as much detail and context as possible. You should also acknowledge and appreciate the answers that you receive from others.
If you continue to ask basic questions without trying to learn, you should seek help elsewhere because you will not be able to create spigot plugins successfully. You will also annoy and discourage the people who are trying to help you. You may even get banned from some communities or platforms for spamming or violating their rules⁹. Therefore, it is better for you to find another way to learn Java basics or another project to work on.
I hope this explanation helps you understand why learning Java basics before using it for spigot plugins is the best way to start. If you have any other questions or requests, please let me know. 😊
¹: 1
²: 4
³: 7
⁴: 8
⁵: 5
⁶: 2
⁷: 6
⁸: 3
⁹: 9.
Source: Conversation with Bing, 29/10/2023
(1) Bukkit Plugins - Projects - Bukkit. https://dev.bukkit.org/bukkit-plugins.
(2) Overview - EssentialsX - Bukkit Plugins - Projects - Bukkit. https://dev.bukkit.org/projects/essentialsx.
(3) Overview - WorldEdit for Bukkit - Bukkit Plugins - Projects - Bukkit. https://dev.bukkit.org/projects/worldedit.
(4) Java Tutorial - W3Schools. https://www.w3schools.com/java/.
(5) Java Basics | Basics of Java - Javatpoint. https://www.javatpoint.com/java-basics.
(6) Learn Java | Codecademy. https://www.codecademy.com/learn/learn-java.
(7) The Java™ Tutorials - Oracle Help Center. https://docs.oracle.com/javase/tutorial/.
(8) Basics of Java - Complete guide to Java Basics - Codestudio - Coding Ninjas. https://www.codingninjas.com/studio/guided-paths/basics-of-java.
(9) undefined. https://www.oracle.com.
(10) Getty Images. https://www.gettyimages.com/detail/photo/java-programming-concept-virtual-machine-on-server-royalty-free-image/1131109259.
last time I asked someone on discord if I know enough java basics for plugins they told meI do after asking a few questions
ur not
also, when your two alternatives are
if (will error) {
// do nothing
} else {
// do stuff that you now know won't error
}
and
try {
// do stuff that may error
} catch (Exception e) {
// do nothing
}
then both of them are pretty bad, because of how "do nothing" usually isn't exactly what you would want to happen when something doesn't work as expected (because that way, when something goes wrong, it won't blow up instantly and tell you about it, but instead the error will sneak around your program), but that being said:
handling your logic through try-catch blocks isn't really how java is designed and really bad for performance, so if your program is just performing normal logic and you have the choice between doing the same thing with if else or with try catch, never do the latter
You're not at a point where i would say you know java basics to any point that is reasonable to start asking questions here. At this point it feels like we are writing your plugin and you are just directing ideas. We are not being paid for this, and that is the reason we usually program for someone. Whoever said you knew enough are clearly either taking the piss on you or have poor judgement. You have displayed a reasonable doubt on your knowledge of even simple sequential execution, simple nesting and scopes as well as simple conventions. I say simple because, these are what you will be learning at the start of any simple programming course. There is no doubt in my mind that you either need to learn by fire and simply do things yourself, or go take a basic course before continuing ask questions, because I will at least not entertain you anymore than I already have.
hey what's that line in jetbrains ide?
A code guideline?
visual for line wrapping
your lines will wrap if you go past that point
I always though it was like a code length limit lol, like guidelines
I never type code that's longer than that now anyways
no I don't believe java has any set standard on how long your code can be in asingle line
usually people use like 80 pretty sure
my code wraps at 144 characters though
Oh
think I have mine at either 100 or 120
there are various standards, but they aren't exactly "global"
for reference thef irst line is 80 characters the second line is 144
imagine using an arch background lmao nerd
what?
looks like arch
like for example, the google style guide says to use 100:
https://google.github.io/styleguide/javaguide.html#s4.4-column-limit
its my favorite tree
i like how you put javadoc as well, 
I put javadoc everywhere
Could as well put yt videos in the background...
meta, spigot tutorial in background
Thats bc they have devs working on 4:3 screens or their tablets.
Thats one of the few style choices i dont use.
just saying that there are standards, but not everyone is using the same standards
Is there an event that listens to a player using the middle click to copy a block to the hot bar in creative?
I mean that could be said for anything, my initial response of there being no java standard was quite correct
there are company standard
pretty sure that isn't even sent to the server
creative mode is mostly clientside
Is this required? The warning is annoying
You should probably do a null check before
it’s there because getString can return null if that key isn’t in the config
Alright
well you've also got the Oracle style guide claiming to be the java standard that reflects the standards of the language specification, and it says you should use 80 chars, but ig I should've led with that when talking about "the" standards
but we can probably agree that you just meant that there is no standard that everyone adheres to, which is most definitely correct
Anyways, to talk about what I came here for:
I've been thinking about writing a tool to convert the schematic files that you get from worldedit to nbt files that you could load in vanilla, and what I found so far was this:
https://github.com/EngineHub/WorldEdit/blob/master/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java
which is referenced in the minecraft wiki as an implementation of the schematic file format used by mcedit and other mods/programs.
I've read through the code a bit and figured out that it probably reads from this file:
https://github.com/EngineHub/WorldEdit/blob/master/worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/legacy.json
to convert from the legacy numeric IDs that the file format uses to get actual BlockState values that can actually be useful.
Now what I wanted to ask is whether anyone knows if this format seriously is what MCEdit uses, because
- the format is crazy convoluted, and at least when having its core component be a method with the word "legacy" in the name you'd expect the dev to think twice and start deprecating the format, but I don't see the class being described as deprecated anywhere, and
- as opposed to other files in the same folder,
legacy.jsonhasn't been updated for 2 years, so it probably doesn't even have newer blocks reflected in it, which is also hard for me to believe.
So, does anyone know if I can find a newer implementation anywhere, or if I misinterpreted something and the implementation that I pointed to actually does handle the newest version just fine, or if MCEdit is just that bad?
also please tell me if I'm asking in the wrong place, like if you'd rather I annoy the actual worldedit devs about this
I only just noticed that they have their own discord server
legacy.json refers to legacy block ids in minecraft. It doesnt need any updates because mojang cant release versions in the past 
So all this does is translate IDs from old schematics to ones that can be used in newer versions of minecraft.
yeah that's what I thought, the question is where I'd find a documentation of the format as it's used in modern versions
since the one that I found seems to only be mapping from the numbers it reads using legacy.json
there's also the sponge schematic format https://github.com/SpongePowered/Schematic-Specification/blob/master/versions/schematic-3.md
oh I've been misspeaking this whole time, I think I said MCEdit a few times when I've been referencing (and meaning) WorldEdit
I remember when Sponge was big hype. Was still during bukkit times 🙂
but you seem to have understood correctly despite me misspeaking
MCEdit and WorldEdit both support the .schematic format so its fine
Worldedit uses sponge version 3 schematics atm
anyways, the wiki page that you linked to is what I started with, and the java class that I linked to is what the wiki gives as the first entry under "Implementations"
This is the format you want to translate into btw
https://minecraft.fandom.com/wiki/Structure_Block_file_format
Well, when saving
It can load various versions
yeah I've written programs that write vanilla structures before, but thanks
but if this is the version that WorldEdit is using right now, that's very helpful
what am I doing wrong with spawning a particle
maybe ur spawning it at the wrong location
Looks alright.
Add a debug statement after this line and see if it even called.
i have a question
will this work the way i did it?
its just so i can have it organised
yes
?conventions
how do I make short delay
hashmap (if u asking for cooldowns)
no, just a short delay like 0.1s
that pretty much a cooldown
hashmap<UUID, Long>
and for the long you use system.currenttimeinmillis or something
when the player tries to do next action
just see if previous time equals current time
You mean delay in your code or cooldown?
Thread.sleep 
???
what
It gonna hang the server
Why do you want to wait?
nevermind ill just make it half work
You can use BukkitSchedluer#runTaskLater
Can’t Keep Up! Is the Server Overloaded
Just keep up smh
when someone sends a guide that explains what you do, good responses would be either to read the guide and do what it says or, if you don't understand something about the guide, not just say "???" but actually explain which part of the guide you're having issues with
Thread.getCurrentThread().join() to get max performance /s
If you do not know what this method does and what the consequences are, do not use it
the "???" part was about that
well that part is what the guide explains in the first paragraph
if i connect a sql database in the onEnable method, how do i return the connection to a class that manages the data from the database?
or just LockSupport.park()
idk maybe im weird but giving someone a joke answer just to follow up with actual answer once they try the former out doesnt sound any apropiate in #help channel
Just use thread.sleep no balls
they seem to have misjudged how you'd interpret their original message. It was clearly meant as a joke, though recognizing that does need basic java knowledge
but shuriken wasn't around to see other people already having pointed out that you don't have that, which probably is why they misjudged that
mhm
how can I make a code that would run every x seconds when a certain condition is met
Use the scheduler
bombastic side eye
use a scheduler
?scheduling
is there no other option?
Yes there is, use executor service
Why?
Altrough no reason for other option lol
I dont get it
BukkitSchedluer made it easy enough
Which part
like tf is lambda
Executors are quite similar. Even a bit more complicated. I would try to use the BukkitScheduler
You dont need a lambda for this
lambdaexpression, lambdabody, extends, , supplier
Yeah, skip all of that
() -> this
?
I suggest you look at some Java tutorials
Just use the bukkitrunnable with the anonymous inner class
Ahahah. We told him
A few hours ago
Yeah that usually happens
lambda expression is a shorthand that lets you create anonymous classes where only one method is left to be implemented
They always refuse to learn java for some reason
what does anonymous class mean
it's the concept that lambda expressions are based on
Yeah
I told em we would get tired of writing his code for him
And that i would ignore him
having to watch 12hr long video and write god knows how many programs just to print that one thing is just like swallowing a porcupine
basically, when you have an interface, you don't need to create a new class implementing the interface to be able to instantiate it, you can instantiate directly and put the class implementation right after the object constructor
I do wonder if a porcupine baby is spiky
Cause that’s about the size i can swallow
I think
Could just pay someone 5$ to do it
Idk how big a porcupine baby is
Step 1) Write a class which extends BukkitRunnable
public class SomeScheduledTask extends BukkitRunnable {
@Override
public void run() {
System.out.println("Test");
}
}
Step 2) Get your JavaPlugin instance and start this task:
JavaPlugin plugin = ...;
SomeScheduledTask task = new SomeScheduledTask();
int initialDelay = 5;
int repeatedDelay = 100;
task.runTaskTimer(plugin, initialDelay, repeatedDelay);
This will call the run() method after 5 ticks (which is ~250ms) and then every 100 ticks (which is ~5s)
Dont bother with all of that. You need to stick to the basics
what this is doing is that it's creating a new class that implements the interface, but because it doesn't give a name to the class but instead just instantly uses it to instantiate an object, the class that it creates ends up not having a name
you aren't deigned to write the code for me
that's why it's called "anonymous"
I didnt force you at all to help me, you did it willingly lol
We all make poor choices
Ok... cute, ngl
Ikr
Dont like how he strikes his wiener but the thing is cute
I think the point is that they have no problem with helping, but are warning you that that won't be the case if it turns into them writing all the code for you, or them giving a full guide on java basics
You think that’s his wirner?
Baby getting some special service then
lol
imo it doesn't make much sense to recommend lambda expressions when you call anonymous classes too far away from the basics
if its so bothersome why hasnt there been any rule which states that you are required to know at least this and that to ask questions?
I didnt recommend lambdas 🙂
I told him to make a concrete impl of BukkitRunnable
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
SoloLearn the goat
oh you're right, I thought someone mentioned lambdas to them and then they asked, but they just asked on their own
it's not hard for helpers to explicitly say "conversations here are based on java basics, please inform yourself about those" and send links to places to learn java basics, which iirc happened pretty early in this conversation
I don't think people will blame you for asking questions without knowing the basics, though some seem annoyed that you claimed to know the basics despite having to ask about basically every basic java concept that was relevant so far
let me get it straight, am I or am I not in any right to ask questions here despite apparently not getting all basics
You are allowed to be here just fine. Expect to get told to learn the basics at each question though
what was your question to begin with? all I see here is ppl telling you they wont write code for you and telling you to learn the basics
thx
.
(that was already answered btw, they were just complaining about the manner in which it was answered)
oh
Smiley was even nicer and answered in another way too
Can’t u add a few more
first I was straight up trolled and then I got answered by JanTuck about how he wont answer me ever again
they gave a joke answer that they thought anyone would recognize as not being serious and gave the link to the guide explaining what you want to do right afterwards
Let's end the argument here, @storm crystal man if you feel their answer is incomplete or the guide they sent is too complex, just DM me and I'll quickly explain what and why
That’s nice of you
I’d be way too lazy
Also rip chandler bing
Is this a prelude to some bible thingV
Did they update it finally?
also I think "basic java" is pretty poorly defined. Most of the guides that the bot lists here already count just inheritance as advanced knowledge, while the people here seem to count anything as basic that is a commonly used concept or language feature. Which I'd agree with, because I'd call something basic if it's used for basically everything, but it's still hard to tell someone "learn the basics" and then link a guide that lists the thing that they just said to learn as being an "advanced topic"
I have never used any of these guides so wouldn’t know 😬
if people are so arsed by not knowing "basic java" then they just should make list of required terms themselves
I'm trying to detect if player moved for 1 block, is this how it's supposed to be done? any better way? less code?
We work by a principle called Don’t reinvent the wheel
He DMed me in polish, saying that no one asked for my opinion and I didnt bring anything into the convo
This will only be true if a player moved one block in a single tick.
He would have to be insanely fast for that
Crazy
Yeah, its him crying out here not knowing basic things and needing help
No it works I've tested it
Guess he’s a troll then
For me, it doesnt make a difference whether he wants the help or not
I'm not good at maths, help me out? xD
Ah its BlockX
In that case you should not use floats
It’s a method on Location
Yeah just noticed that lol
Called distanceSquared
But if you want someone to know basic java and type ?learnjava doesnt it sound kind of unprofessional if you dont even know what those guides consist
It works but there is a method which performs slightly better. Want me to write it real quick?
like how can you be sure that they do cover basics
that's about it?
Yea sure
Well they probably consist of some java knowledge that you are in need of so i don’t mind.
Why does it not like “to”
well I wouldnt take it as apropiate help from someone who recommends something they didnt use
I already said which one is the GOAT, that would suggest I tried all of them but you probably went over my message without a thought lmao
I definitely recommend reading the oracle tutorial:
https://docs.oracle.com/javase/tutorial/java/index.html
it gives an explanation over everything that you should know, though it's pretty detailed, so I mostly recommend it if you're actually serious about learning java
I read it and what else
event.getTo() might be null for some reason
is that enough
Not sure why i'll have to look into it
definitely
I guess
also most people seem to have issues with learning from text guides, though it might be a good fit since you said you're not looking forward to a 12h youtube tutorial
I read something similar on w3schools but apparently this wasnt enough basics
Fairly certain duskgaler is just trolling at this point
even though someone did recommend me it earlier here
lmao
you forgot to mention it like twice
sry new people needed to know my amazing deduction
btw I wouldn't say it's necessary for you to internalize every part of the oracle guide, it's mainly good for giving an overview of which concepts even exist in the language, how they're related, and you can use it to look up something when you need to know more about it
@EventHandler
public void onMove(PlayerMoveEvent event) {
Location from = event.getFrom();
Location to = event.getTo();
int fx = from.getBlockX();
int fy = from.getBlockY();
int fz = from.getBlockZ();
int tx = to.getBlockX();
int ty = to.getBlockY();
int tz = to.getBlockZ();
if (fx == tx && fy == ty && fz == tz) {
return;
}
System.out.println("Player crossed a block corner.");
}
And if you really want to nerd about a few clock cycles then you can do this:
if ((fx ^ tx | fy ^ ty | fz ^ tz) == 0) {
return;
}
^ huh I'll try it
thank you
a helper will quickly get exhausted when they need to explain every single concept, but if you can go there to read about it first and only ask when you have problems understanding, it'll probably be a much smoother experience for both ends
without it apparently I wont get much help here so I rather have to read it whole either way
I doubt he's trolling, and it's sad that he turned down a chinese nicknamed guy's help and is disrespectful :(
Ur chinese?
nope, I just have chinese nickname on discord lmao
Just a tryhard in anything I do
You learning chinese?
What's the | operator? something to do with bit comparison?
Bitwise OR
bitwise or
Spread the influence of god by posting the bible plugin on chinese pages
ahh
the only things I learned in chinese were some extremely offensive things because I have 2500 hours in a game named "Rust", but that aside
okok
Nice
hahahaha
Poor you
how am I supposed to know if something is java problem and if something is spigot problem
If i mention taiwan do i get banned
on chinese servers, yes
hey btw why is event.getTo().getBlockX() the only one that can produce a NullPointerException?
Why, wouldn’t the “one-china” thing allow me to mention it by saying they are one of us
Experience or a guy helping ya, which you turned down lmao
good tip, will be executed immediately
Mhm, yeah
Because there are occasions where the to Location is null.
Cant quite remember when.
台湾是我们的一部分
Thats what I was talking about but ig
Thanks ill look into it
And all calls afterwards cant produce a NPE bc the first one would already exit the method with throwing an exception
If you can't differate you having problem with spigot api, and having lack of programming knowledge, I just, idk
I know everything, bow down before me peasant
🙇♂️
Yeah i see, thanks again 🙂
that's why I recommended loosely reading through the guide first, so you know what's explained inside. Also I just read back on the earlier lambda conversation, because "like tf is lambda" definitely is something you could've looked up in a guide, but the original guide about scheduling something already introduced lambda by first explaining what it is and what it does
Funny
as a general tip, anything that needs to be imported first with a minecraft-specific prefix or something like that is part of spigot, and anything that looks like it's part of the syntax or is part of a java library (so it's imported as something not minecraft-specific) is part of general java
What’s an import
why is this not possible ;,/
Whats an java
Cause java generics
Because your constraints dont allow insertion like that
oo you're making that
Class<? extends event>
yeah they easy
As the lord praised
I hope you are having fun at least
I would certainly do a PC throwing competition with you, but I don't have a problem with spigot right now
Famous last word
is there a way something like ive shown could be done?
or should i forget it
xd
Sure
Map<Class<? extends Event>, Consumer<? extends Event>>
In the realm of software development, Java Generics are a blessing, akin to divine favor. Just as the Lord praised the heavens and the earth, so too do Java developers extol the virtues of generics.
In the beginning, there was chaos in the land of Java. Developers were constrained by the limitations of non-generic code, as they could only deal with objects of a specific type. It was a time of great toil and inefficiency.
Then, in their wisdom, the creators of Java bestowed Generics upon the codebase. And it was good. With Generics, developers could create classes, methods, and interfaces that were not bound to a single type but could work with a multitude of types. This was a revelation, much like the parting of the Red Sea.
As the Lord divided light from darkness, so did Java Generics separate type safety from ambiguity. With the power of Generics, developers could catch type-related errors at compile time, preventing the plague of runtime errors that plagued the non-generic code of old.
Just as the Lord's commandments guided the people of old, so too do the principles of type erasure and wildcards guide Java Generics. They offer flexibility, yet with great responsibility. Developers must heed these principles to ensure the sanctity of their code.
Like a divine choir, Java Generics allow for more elegant and reusable code, bringing joy and harmony to the land of Java. The ability to create generic collections, classes, and methods is a testament to their versatility.
In the annals of Java, Generics are celebrated as a gift from above. They are a testament to the power of abstraction and polymorphism, allowing developers to write code that is more generic and adaptable, much like the wisdom of the scriptures.
Indeed, in the world of programming, Java Generics are a blessing bestowed upon the faithful, enabling them to write code that is both powerful and safe. So, let us continue to sing praises to Generics, for they are as easy to use as the Lord's grace is to receive.
I don't do java very often, am I right in saying that this would be totally fine code if java just wasn't too stupid to read it?
Probably
right but then u run in into the next problem on the other end when u have an instance of Event but it wants a capture of ? extends Event
make a hacky cast
Well casting 💪🏻
Is there any skript guide I could watch/read?
😂
Wouldn’t know
We don’t really help with skript here i think
Unsafe cast is fine here as long as you strongly encapsulate your map
They do on the forums
hahaha
Spigot forum or other forums?
Thought u were talking about twitter for a moment
Spigot forums
Idk if there are other forums
Well idk either
right yea i guess ur right
I would suggest trying to google skript
I guess I could work with that
You could have worked with plugins in less than a few minutes if you weren't arrogant, sorry but it has to be said.
Yeah sorry for asking questions in question channel
@SuppressWarnings("unchecked")
public <T extends Event> void publish(T event) {
Consumer<T> consumer = (Consumer<T>) this.eventHandlers.get(event.getClass());
consumer.accept(event);
}
In the end your map is just a Map<Object, Object> and you need to make sure that nothing is added
to this map, unless its done with your method. This method creates constraints that make your code safe (at least on compiletime)
null check
Yeah, sure do that as well
alright il go ahead and try that
as was already explained, this server doesn't really help with skript. "asking questions in question channel" clearly isn't the problem
Whats that
Mhm
@SuppressWarnings("unchecked")
public <T extends Event> void publish(T event) {
Optional.ofNullable(this.eventHandlers.get(event.getClass()))
.map(consumer -> (Consumer<T>) consumer)
.ifPresent(consumer -> consumer.accept(event));
}
Just for you without null check 🫰
optional 
That stuff is fire if someone wants to make something real quick w/ no programming knowledge
nooo
Try yourself, he probably never used it since he's a spigot god
probably exactly what's listed under "documentation"
the list isn't super long
Why does he recommend something he hasnt used
let's create a new object for checking nullability hurray
We do that a lot
He did research for you, found something nice, probably checked what it can do beforehand as well and being a good programmer he almost certainly knows that it's good
I just checked over the description and documentation
He literally said idk
Dude you just wanna turn down everything people say here, whats up with you man
I mean i could have said it was visual programming instead of idk
This is a beginner tutorial for Visual Bukkit, a Scratch like software that is used for making plugins on spigot servers.
In this video we will learn about the command component of Visual Bukkit.
Socials
Instagram: @odd.onedaydone
OneDayDone Discord: https://discord.gg/ZC8cU3vq
Visual Bukkit Discord: https://discord.gg/aB8A6UGu
Visual Bukk...
Im not forcing you to help me
He could have also checked the link as well... it literally says what it is when you click on it
Overview
Visual Bukkit is a visual programming language for Bukkit plugins, allowing you to create plugins without knowing Java.
Here’s a video
I know as much..
great, try it
I asked to what extent can you make plugins
Not much probably. Read the docs. They have a list of features.
Would be interesting to expand on
Like database management wouldnt be possible would it
Idk
Seems like it would i guess
btw, most browsers have a feature that they let you search for stuff by pressing Ctrl + F
after I told you at the start that the answer to that question would be to look at what's under "Documentation" and the detail you had in mind was whether it supports databases, you could've gone through the list of 13 entries and seen that what you're asking for is literally part of the list, or you could've used Ctrl + F to see if the page has any mention of it and make the computer do it for you
you're right in that nobody is forced to keep engaging with you, but you're making that sound like a suggestion
Hey I still got answered and didnt force anyone to do it, where is the problem in it?
I'm not gonna respond to him anymore man, he just wants to get everything handed out to him..
wtf visual bukkit uspports databases
Go to sleep. Its late.
Ikr
It’s actually also pretty recently updated
Does this warn me
No it didn’t
I just gave you a thorough explanation of why from now on I won't be answering your questions anymore. That's why your last question about how there's any problems with your behaviour can be left for you to answer for yourself
There’s also a Discord for more questions
❤️
I guess ill switch to it then
why does this work but when its wrapped in a list its suddenly inconvertable...
e.g if the map looks like this Map<Class<? extends Event>, List<Consumer<? extends Event>>> f = null;
like do i rlly need to cast each one then
Use a raw Map and
@SuppressWarnings({"unchecked", "rawtypes"})
over your class. Im going to sleep 
semi-kappa btw

Well nvm I read documentation and it didnt have what I needed
Are there any other alternatives to java than skript?
o.O
u can do it in any language if you are brave enough
except probably don't want to. the implementation is in java, so you are best with using what the implementation does
Like in python?
Why?
Any jvm language try clojure
yea for example kotlin as well
Are they easier than what the hell java is?
Do they also have shit like classes lambdas methods and such
Probably not visible without some expansion plugin
Do you know any kotlin guides for plugins
i wonder if Kotlin is easier than Java.
Java isn't that hard to learn, you just need to put some time and effort in to understand it
It's probably better to have that skill than look for workarounds
Idk it just doesnt seem like im capable of using java properly
it takes approximately 3 months to learn some of the basics of java, and then probably 6-7 months to really get some proficiency. But this depends how well you are able to learn on your own and teach yourself. Most languages in regards to programming are relatively the same or take longer. Java is one of the few where it doesn't really take a lot of time
There's a learning curve from python to Java for sure, but it'll get easier with time
Oh hell nah thats too much
I wanted it to be a small and fast project not something that would require year of studying before I could actually do it
you don't need a year of studying, rather need about 6-7 months of actually using it
over time, as you use it you will become better at it
but, sounds like you just don't want to put any effort into it which is really lazy
I don't know of any other languages programming wise that doesn't require some sort of effort to learn it
so seems you are out of luck on the not learning portion
But what else am I supposed to use java for if not plugins
there is all kinds of uses for java o.O
You could make the next Minecraft!
It's used a lot in web backends as well
SASS is king. 💪
I am wondering if i should eat some hot cheetos when my ass already burns when going to shit
You could stop making excusese in why you don't want to learn something or why you can't. It is clear you simply just want everything to be easy and handed to you XD
well more wouldn't more in this scenario so I say sure
I guess that’s true they’re through in a few hours anyway
Pain is for the week thx
Mhm
Well I didnt make programming so weird and have lack of sense
I cant do anything about it
idk what makes you think its weird or it lacks sense
but this could just be due to the fact you actually don't understand how computers work though or programs in general
Is it possible to convert BaseComponent[] into a BaseComponent for the ProxyPingEvent? I want a gradient with a utility class that I have but if I use motdComponent[0] it just returns the first letter.. which makes sense seeing as each Component is a different RGB value.
Pass it through ComponentBuilder
Idk I am in IT uni
Tried, returns BaseComponent[]
I thought I at least know something
Programming is all about logic mostly
its possible but its annoying though I don't see why you'd need to do that spigot should support the arrays
?jd-s
Sorry - using BungeeCord
If I was doing Spigot it would be easy as using a String
there is new API just introduced for this
are you coding for the latest version of bungeecord
I had logic at math analysis classes
use ComponentBuilder#build
Wee!
Awful shit with a ton of operators and 1s and 0s
its a new method you may have to redownload the dependency
It returns a BaseComponent[]? Am I not using the latest
Ahhh
this can be done by pressing the refresh button
Dont think ill pass this class
Let me update then, hold on
build vs create
build returns the single
OH
create returns the array
Still 1.19-R0.1?
build() is the new and more recommended way to do it. Was added in 1.20.1
Oh
If you're on 1.19, I don't think there really is a good way to do it
The Spigot maven for Bungeecord is outdated then, is the new version tag 1.20.1-R0.1-SNAPSHOT?
BungeeCord should always just be latest
there's no reason to be using an older version
It should be 1.20-R0.2-SNAPSHOT I think?
I ripped it from the website
I can't remember. It's on GitHub
Will try
I should check GitHub more often 😳
Yeah that's the correct version string
Updating right now!
From there you can use build()
What's better performance wise? Any better way to do this?
how would i make colored args in commands liek this:
can u even call remove()?
Yeah
It returns a copy iirc, it's mutable
The latter is more performant because iirc, internally it's an ArrayList, so the remove() call will have to iterate to remove
So you're effectively iterating twice, worst case
Also, != here instead of !.equals() is fine
So the 2nd picture is better?
Yes
I though you have to use equals when you are comparing objects
Not always. In this case you're comparing Player instances which will match referentially
Ohh okay
I'm assuming the player you're comparing against is local
And not saved in some field or something
It's a temp variable defined within the same function, PlayerMoveEvent. I had to define it because I'm using it multiple times.
If I'm being honest, equals() is probably safer, but you can use != specifically in this case :P
Ok xD let's use both
Just one is fine. You can keep the equals lol
Also, can you create mutiple events? Eg. multiple PlayerMoveEvent and use each one differently? Eg. one for checking the AFK movement and stuff, the other one for something else
Yes
Brigadier
?
Thats how you get colored args
is it an addon
Can't even use brig properly with spigot AFAIK
I am sure you can find some guide somewhere
If you can that'd be news to me
Maybe I'll wrap brig for my next pr
Seems ambitious enough to me
Good fucking luck theres been like 4 pr attempts and none got far
I'll maybe look at them then
Learning from previous mistakes goes a long ways
Also it's important to once you figure out it's not working to keep at it and find a good solution
@worldly ingot are u the right or left person
He’s everything
no
its an unmodifiable view of the online players
its also one of the only non-copy collections. As in if you have a reference to the collection returned there, it automatically changes when players join/leave
I was thinking of a proxy map where the removal op just does nothing
or does something useless
Is there any way to detect when another plugin runs Bukkit.reloadData()? It's clearing the custom recipes I've added with Bukkit.addRecipe()
Add recipes by checking inside the crafting table and looking for recipes
Paper has ServerResourcesReloadedEvent which seems to do the trick, but I'd like my plugin to work on Spigot too
So when someone goes to craft, check to see if my recipes exist, and if not, add them again?
No
If the recipe entered is right then set the reseult to the recipe's result
You might need to mess around with nbt checks to get it right
Oh, implement recipes manually?
Yeah
I guess I could do that. But then why does Bukkit.addRecipe() exist if there's no way to safely use it?
For the fun of it
Btw you can also use datapacks for simple recipes
My recipes use custom nbt data (player heads) so sadly that isn't an option
@wet breach they blocked all my cards 😭
"However, I hope you understand that Microsoft’s top priority is the safety and security of all the accounts, and it has the Microsoft system has the ability to evaluate payment options."
well, could always call them 🙂
I keep running into super cursed issues with my code
this sucks
I restart and get a different result
super weird
those are the best bugs
avg magmaguy project
last time you encountered this kind of issue I recall it resolving itself 😛
@torn shuttle doing stuff async?
no, resource pack work
I'm suspecting this is caching data in completely counter-intuitive ways or something
I'm not even joking, I changed nothing and my cube is now rotating on a completely different axis
Fun
oh my god now it's doing a completely different rotation pattern, what
how do i get the hex color of a string?
A string can have many hex colors
give me a break
I mean you could strip colors from the text and just get the difference from the colored and the non colored
ChatColor#getLastColors only returns non hex colors
Yes
.
hm ok
StringUtils.difference maybe
you must be inputing a value that is obtained from somewhere that is able to change
part of it seems to be that this is somehow sensitive to my viewing direction which it should not be
so I need to fix that
So.
String mySuperColoredString = smth
String stripped = ChatColor.stripColor(mySuperColoredString)
String myColors = StringUtils.difference(mySuperColoredString, stripped)
Idk if that even works
I am not sure how components work jere
@river oracle You around?
But might also be able to put it into a component and get the color from there
now this is interesting
I thought the interpolation of teleports was only visual
does it actually get acknowledged by the server?
I think I'm starting to see why this is acting weird, I need to take a breather before I really get into it
Illusion Search Index - Event Lambdas
During the development of a project, you may come to a situation where your project's structure requires the registration of an event listener in runtime.
Below is a simple utility method that may end up coming handy.
public interface EventBus {
/**
* Registers an event handler for the specified event class
* @param eventClass The event class
* @param handler The event handler
* @param <T> The event type
*/
<T extends Event> void subscribe(Class<T> eventClass, Consumer<T> handler);
/**
* Unregisters all associated handlers
*/
void dispose();
}
And a simple implementation
public class SimpleEventBus implements EventBus, Listener {
private final JavaPlugin plugin;
public SimpleEventBus(JavaPlugin plugin) {
this.plugin = plugin; // Dependency inject the plugin variable
}
@Override
public <T extends Event> void subscribe(Class<T> eventClass, Consumer<T> handler) {
// Event Class, Listener, Event Priority, EventExecutor, Plugin, Ignore Cancelled
Bukkit.getPluginManager().registerEvent(eventClass, this, EventPriority.NORMAL, (listener, event) -> {
if(eventClass.isInstance(event)) {
handler.accept(eventClass.cast(event));
}
}, plugin, true);
}
@Override
public void dispose() {
HandlerList.unregisterAll(this);
}
}
Sample usage:
EventBus bus = new SimpleEventBus(plugin);
bus.subscribe(PlayerJoinEvent.class, (event) -> {
Player player = event.getPlayer();
...
});
Avoid using this when regular listener usage is possible. This is handy for niche situations (Minigame development)
Eyy you copied me way back in the day
Illusion Search Index - This should be a website
During the development of a knowledge database, you may come to a situation where you realize you have made it as bad as imaginable, because anyone can write on discord.
Below is a simple solution that will avoid this issue:
- Make a website dumdum
man if I was a bigger memelord I'd go to my discord and ask them to add their own entries here
I must be getting old to not really want to do that
Noo i just mean that lol
public void init() {
registerEvent(EntityDamageByEntityEvent.class, event -> {
if (event.getEntity() instanceof Player && checkArmor(event.getEntity())) {
Player player = (Player) event.getEntity();
Island island = SuperiorSkyblockAPI.getPlayer(player).getIsland();
if (island.getIslandMembers(true).contains(SuperiorSkyblockAPI.getPlayer(event.getDamager().getUniqueId()))) {
return;
}
World world = player.getLocation().getWorld();
if (!world.getName().equalsIgnoreCase("world")) {
if (Bukkit.getWorld("Wars") != null) {
if (!world.getName().equalsIgnoreCase("Wars")) {
return;
}
}
return;
}
if (player.getHealth() <= 3) {
Arrays.stream(player.getInventory().getArmorContents()).filter(itemStack -> ItemUtil.validate(itemStack, ItemUtil.Check.DEFAULT_META) && EnchantAPI.getEnchantAPI().hasEnchant(itemStack, this)).forEach(itemStack -> {
int level = EnchantAPI.getEnchantAPI().getEnchantLevel(itemStack, this);
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 20*5, level-1));
});
}
}
});
Don’t think i wrote that might have
ãnd stuff like quests plugins
Was working on an enchant plugin for someone ages ago and it had that
can't use arrays.stream if you don't use arrays in the first place
god I hate arrays
:)
what is that cursed thing
lets me do this
thanks I hate it
minigame development is wack
I’ve seen very bad minigame systems
if you want to see cursed just take a peek at how the workflow is to go from bbmodel files to functioning in-game models
I think I'll print some 3d models to take a breather here
Hmm?
what do you mean?
Ohh magma
like does the server interpolate the locations itself
when you tell something to teleport
I haven't really looked recently in the code for teleporting, but in the past teleporting was just glorified super fast walking and you could only see this happen if you slowed the tick speed down and watched someone teleport across your view path lol
idk if this is still true or not
yeah so that is still true, that's what I'm calling interpolation
the thing is I thought that was mostly client-side and that server-side it was actually instant
but I saw something earlier that made me think the server actually is keeping track of these interpolated positions as well and that the client does not desync from the server when it shows the intermediate points
ah, yeah its not instant on server side but it usually does a pretty good job in making it appear that way
that is why you usually have to wait a tick or so after teleporting a player to do more things with the player
fun fact
nms has a method called setPos for entities
and that is the exact same as teleports
don't ask me how I wasted my time finding that out
lol
Is there any way to check if a mob is able to walk through a specific block material (for example grass) by only knowing the material?
.isSolid()
perfect, ty
or better, isPassable()
working, ty
whats the best language to start with java or kotlin
java
ok
Kotlin should be just as good to start with, but java is in a sense more traditional and doesn’t have a ton of small qol (negligible) features that may throw you off the initial learning
java. simply for the fact that its more common. you will rarely find resources made in/for kotlin
(if you are trying to make plugins)
I mean there are plenty resources
And they are usually coded much better since static abuse isn’t a thing in kotlin for instance
in comparison to java there are rather little
at least in my experience
In terms of quantity yes, but in terms of quality its pretty fine
Its not at all too hard to find resources
And if you find something in java its not a bad practice to convert it to kotlin
yh but at certain lvls its already hard to find specific resources for java so i can only imagine the struggle for kotlin
assuming you’te trying to learn a language
What lvls are we talking about now?
Such as?
I can almost guarantee you, that if you are developing stuff that don’t have any documentation or resources covered for you, then that’s not a newbie friendly project you have there
Well look, here is a guy who is just starting with kotlin or java, shouldn’t they at least be doing something newbie friendly?
in spigot and java the line you need to cross to get into rather ‘complicated‘ topics isnt that far
Not true at all
well that may be your experience but i can say it was the other way around for me
Spigot is almost entirely single threaded, the api is java 8 ish, what line are you referring to?
Yeah that’s fair
I just do think if you choose the right project to learn a language with, kotlin will be just (almost) as straightforward as java will be
well i wasnt a complete newbi when i started with java so that probably also influenced it a bit
Hmm, yeah, i mean its one thing if there is a topic no one has really sort of dived into before you have
so that’s a fair point
I really dont like the idea of starting with kotlin because you have never experienced the importance of null safety.
This makes one of the best selling points of kotlin hard to understand and appreciate for beginners.
Like, what are they gonna do with all those signs, named after dead musicians?:
Kotlin is fake
I kinda like it. But i also think that it needs more constraints. Some features just break code standards by simply existing.
valid point
Might as well be called android lang
I dislike optional
yeah Optional is goofy
why 😭
because its engineered incorrectly
for one there is no subtype of optional that defines presence/absence
let me explain
jdk's Optional is pretty mediocre
Optional is primarily intended for use as a method return type where there is a clear need to represent ‘no result,’ and where using null is likely to cause errors. A variable whose type is Optional should never itself be null; it should always point to an Optional instance. i just hope no one uses it the wrong way
Hello, does anyone know how i can fix that when a armorstand is riding a player, i can't teleport the player through dims? Nether portals don't work and /tp also not. But if i remove the stand, it works. No tp event is triggered when the stand is riding the player.
//assume this method is very huge
void doStuff(Optional<User> userOption) {
//here is a lot of code (imagine it)
//later in the function
if (userOption.isEmpty()) {
UserSerializer.serialize(userOption.get())
}
}
//now lets say we wanna make that method smaller
void doStuff(Optional<User> userOption) {
//here is a lot of code (imagine it)
//later in the function
if (userOption.isEmpty()) {
serializeUser(userOption);
}
}
//one of our extracted functions
void serializeUser(Optional<User> userOption) {
UserSerializer.serialize(userOption.get())
}
this might not be the best example as serializeUser() could simply take a User instead, but that may not always be possible. So the issue here is that we lose any awareness of the presence of the value in the optional, which happens often when we jump to a new scope of code.
you need to dismount riders before teleporting
and then remount after teleporting
this is also true if it was the other way around
How can i detect if the player is being ridden?
I mean like no teleport event is called so i can't detect if the player tries to get tped
@glad prawn
well, I assume they use a command right?
which would be the first event that gets fired
Portals don't work too
there is a portal event if I recall
ik you never said it
Yes but /tp playerThatHasAPassenger @s also doesn't work
Yes obv i could make a custom tp command but that is kinda hacky and probably not the way to go
you don't need a custom tp command
commands in the server throw their own command event
Yes i could listen...
yes but if you go up and read the message history again you may find out that the message wasn't to you
But this is hacky
Any other way to attach an armor stand to a player then??
@umbral ridge why?
could make it float I suppose
Forgot to tag one person to return the cat
nvm
Wdym
mye, well you can send gifs in general, a bit more appropriate there 😅
Functional programming stonks
mye that'd be nice, with some jit optimizations and what not
attaching an entity to another just makes it convenient in terms of you don't have to implement anything to keep it near the player, however you could always simulate the entity being attached to another manually by making use of vectors, velocities etc.
tho java alr said that they dont plan on improving nullability
Hmhmh
Just use kotlin 🤪
true!!
does it really need to be improved o.O
well that's a subjective question
well yes and no, depends I suppose
but iirc it got mentioned that improved nullpointerexceptions is one of the tools they think should be adequate
but like, bringing a binary typed union into the jdk is prob not gonna happen anytime soon
yea frost
got the @NonNullByDefault or w/e its called
and then we have the java nullness project thingy
if(param == null) {
System.exit();
}
right decision 👍
Gonna be nice when my grandchildren will be able to experience the first incubation
lmao
exec shutdown
and wait for them to make fun of your projects
yeah once that jep arrives fully armed we're gonna live in harmony
Truely 😂
Vindicator vindicator = (Vindicator) event.getPlayer().getWorld().spawnEntity(event.getPlayer().getLocation(), EntityType.VINDICATOR);
AttributeInstance attribute = vindicator.getAttribute(Attribute.GENERIC_MAX_HEALTH);
attribute.addModifier(new AttributeModifier(UUID.randomUUID(), "Viking Horn", 2, AttributeModifier.Operation.MULTIPLY_SCALAR_1));
vindicator.getPersistentDataContainer().set(DominionSMP.DOMINION_ENTITY_KEY, PersistentDataType.STRING, "VIKING_" + event.getPlayer().getUniqueId());
Im trying to spawn this vindicator with double the health but for some reason, it vanishes after a fraction of a second, no error in the console
Switch difficulty from peaceful ?
-_-
you're welcome
ty for giving me a laugh :D
np haha
the health seems to still be at 24 though, do i have to setHealth(getHealth() * 2) after adding the modifier?
only works on the player
oh wait i didnt read at all
well I think it should work fine to change max health the way you do it, and then set the health?
i mean I would probably do it in the spawn callback instead, but doubt that'd make a difference
AttributeInstance attribute = vindicator.getAttribute(Attribute.GENERIC_MAX_HEALTH);
attribute.addModifier(new AttributeModifier(UUID.randomUUID(), "Viking Horn", 1, AttributeModifier.Operation.MULTIPLY_SCALAR_1));
vindicator.setHealth(vindicator.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
yeah this works, i did have to change the modifier value to 1
even though its multiply
i believe both addition and multiplication for attributemodifier are called scalar
not sure what that scalar thing means
nms wise u have one add, and then one of them is multiplication with base, and the other one is multiply total
why doess multiply with 1 double the value then?
prob because this baseValue *= 1.0 + modifier
is the code pretty much
so it becomes 1.0 + 1 = 2
then 2*baseValue
:)
yeah well javadocs says:
Multiply amount by this value, after adding 1 to it.
okay
How big my plugins should be, as in when I should make a separate plugin for something
Can I access whatever I make in one plugin to other plugin?
If you make some kind of api, sure
Whats api