#help-development
1 messages · Page 1155 of 1
yes, and i want to get the value of that state in other class
what should i write then to get it from other classes?
?learnjava
For Beginners:
Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/
For Intermediate to Advanced Learners:
Oracle Java Tutorials: The official guides by Oracle for Java programming—great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/
Practice and Hands-on Learning:
Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/
Free Resources and Documentation:
Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/
Community and Support:
Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/
Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! 🎉
i thought that by gameManager i would get access to the class and then by .getState() getting the state
JavaScript 🔫
This is Java
Not JavaScript
They are two quite different languages
and before you run in to problems with your string comparisons use .equals instead of ==
🤦♂️
that's funny, yeah i know, all the time i've mistaken those two languages
well thanks for reminding
why the head dont appear?
This looks like you should use a BlockDisplay or ItemDisplay instead.
it's 1.8
?1.8
Too old! (Click the link to get the exact time)
how can i initialize it then?
here
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.
https://media.discordapp.net/attachments/694661573125472256/998143126373941248/6n0v4g.gif
I love the fact that there's two of em
Initialize it in the constructor of your GameManager
private final Main plugin;
private GameState state;
public GameManager(Main plugin){
this.plugin = plugin;
this.state = GameState.WAITING;
Bukkit.getPluginManager().registerEvents(this, plugin);
}
And pls auto format your code, its messed up
That's not the entire issue here
The problem is they're trying to call getState on their gameManager variable
Which is never initialized anywhere
and there for is null
The game state is being set in other methods (which they've said are being called... I do agree that initializing state in the constructor is a good idea)
Ah in the ProtectionListeners. Yeah that as well.
they used to be the same thing just 1 had the gif one didnt
then alex showed up and made the normal one long
smh
this?

Im going off for today
Im judging you for this code
what 😭😭😭
the states themselves are already initiated
I think the main problem is that the lines of text you are writing, make no logical sense to you.
You need to stop what you are doing and start with something extremely basic, to understand how a computer actually runs code.
well, i guess i'll go sleep now and tomorrow start with basics...
Also a game manager is probably not the class you wanna store your state
A game manager is supposed to handle your games
A game is what I'd say would hold a state
game manager is supposed to manage game generally - states, etc...
oh boy after watching 6 hour course of kotlin
i feel like i've unlocked new level of syntax sugar in JVM
!!!!
facts!!!
I feel like lambdas should be kept to a minimum anyways. So one liners, otherwise create an actual method and reference it. 🙂
i like how lambda expressions that are present in kotlin std are mostly inline
so they cost nothing when compiled
For me it took a while to accept it as a keyword
I really don't like it for semi-large stuff
For a tiny expression like it.toMap().entries or something it's fine ig
the only thing is weird is the destructuring objects
But stuff like command contexts
my beloved
i mean why not destructure by property name
why by order
_ is ugly
my precious clean syntax sugar
Because then you can't rename your variables
use _epicUnused instead, please don't just have a bunch of _s
add TS like destructuring propertyName: newPropertyName which compiles to smth like val newPropertyName = propertyName
no
What i dont like is returning values from lambdas. It makes their scope ambigous. Something like
ints.filter {
val shouldFilter = it > 0
return@filter shouldFilter
}
yea also that
but you can use anonymous functions
which works the same as lambdas but use proper return functionality
You could also just .filter { it > 0 } here but sure
and you can label your lambda
ints.filter filterNotZero@ {
val shouldFilter = it > 0
return @filterNotZero shouldFilter
}
This is very useful when you're iterating over multiple lists
real
did someone say my name
Did you learn about inline and reified too
haii
what about tailrec
havent touched reified yet but i've touched inline
reified is good
never actually needed it
well you don't actually need it
it just makes the compiler go beep boop
instead of you the programmer
don't remember
I think I have seen you somewhere.
okay
wow that's crazy
Is this kotlin?
yup
No idea why you wanna label lambdas probably makes sense it kotlin tho
?? lol
not an annotation
it's for returning on a different level if you have multiple nested lambdas
Oh
This is not possible in Java as far as I know
So similar to label: for loops in Java
also for referencing the lambda receiver of a different level
But I don't see myself nesting
there are some places where I've used it but not very often
buildThingA { // this: ThingA
value = this.calculateMyCoolValue()
buildThingB bBuilder@ {
value = this@buildThingA.value
buildThingC {
value = this@bBuilder.value
coolFunction = {
val definitelyNotNull = calculateNullableResult() ?: return@buildThingC
return 5
}
}
}
}
Terrible example I just wrote up on my phone but ig
wait till you have to write FIR trees
I mean yeah there isn't really another good way to do trees in code without nesting
This is my function for serializing PlayerCourse class.
https://paste.md-5.net/exinefeyaf.js
I'm putting courseFeatures in the map, which is List<CourseFeature>, note that CourseFeature is my custom class. Since its my custom class, it implements ConfigurationSerializable and also it's own serialization method.
https://paste.md-5.net/bacijemihu.js
The thing is I'm somehow serializing the CourseFeature incorrectly. It failes to serialize and throws an error in the console telling me that object serialization failed.
Course status must be also serializable
Its an enum
And it doesnt have to be, I already tested by setting it and updating the pdc after that
no errors
Well the error might help you out
Worked perfectly, I've only gotten errors when adding coursefeatures to the list, it fails to serialize them
Yes
it is
This is the error
@Override
public @NotNull PlayerCourse fromPrimitive(@NotNull byte[] primitive, @NotNull PersistentDataAdapterContext context) {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(primitive);
try {
/*
private UUID owner;
private String name;
private CourseStatus courseStatus;
private int size;
private List<CourseFeature> courseFeatures;
*/
BukkitObjectInputStream bukkitObjectInputStream = new BukkitObjectInputStream(byteArrayInputStream);
Map<String, Object> playerCourseMap = (Map<String, Object>) bukkitObjectInputStream.readObject();
UUID owner = UUID.fromString(String.valueOf(playerCourseMap.get("owner")));
String name = String.valueOf(playerCourseMap.get("name"));
CourseStatus courseStatus = CourseStatus.valueOf(String.valueOf(playerCourseMap.get("courseStatus")));
int size = (int) playerCourseMap.get("size");
List<CourseFeature> courseFeatures = (List<CourseFeature>) playerCourseMap.get("courseFeatures");
return new PlayerCourse(owner, name, courseStatus, size, courseFeatures);
} catch (IOException e) {
throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
Map<String, Object> playerCourseMap = (Map<String, Object>) bukkitObjectInputStream.readObject(); this returns null
BukkitObjectInputStream 💀
The class is not bad ^
also, use a try-with-resources
@Override
public @NotNull Map<String, Object> serialize() {
Map<String, Object> serializedMap = new HashMap<>();
String type = "";
if (this instanceof CheckPoint)
type = "checkpoint";
else if (this instanceof SpawnPoint)
type = "spawnpoint";
serializedMap.put("location", location);
serializedMap.put("type", type);
return serializedMap;
}
so this method needs to be a constructor?
In CourseFeature class?
No waitr
you said
The reverse of it actuwlly
deserialize
At that point its time to shove spigots serialization system in the bin and use an actual serialization library like Gson or Jackson.
Storing ConfigurationSerializables in a PDC is def not the way to go.
my bad
Configurate 
Isn't all memory in bytes?
my memory is in bits
So ill just transfer my deserialization method to a constructor?
How would I return the deserialized obj?
Nah mine is terrabytes 💪
The deserialization is to give you back the object
Serialized is to pack up your object
You need both
Your memory needs more training, mine is in peta
I have ADHD I cannot remember anything 😔
Memory too 💀
I see but in order to give back the object ill need to return the object
RAM has ADHD
I cant return anything from the constructor
That’s why we need SSDs/harddrives
trueee
the constructor returns the object
whatever you set in the deserialize method you would set in the constructor
you dont need a constructor either
pick 1 and use it
is it static
Yes
?paste ur full class and any errors
on seperate pastes
that is just a lot of jank
you cant return an instance of the abstract course feature
its expecting a course feature not a subclass
Oh shit frl?
Cant i just return a subclass anywas
anyways*
Since its pretty much the same as coursefeature
Okay sht I think im fking up the basics of java now
Maybe I'm missing it but I haven't seen you register the actual serialization anywhere
I did register it in my main method
Okay just making sure :p
Generally we do it in static blocks in the plugin's init, if I'm remembering correctly
I did it under onEnable()
Yeah that's probably fine
But like I assume spigot just user reflection to run my method
public static CourseFeature deserialize(Map<String, Object> serializedMap) {
ConsoleManager.message(ChatColor.RED + "USING THIS METHOD!!!!!");
String type = String.valueOf(serializedMap.get("type"));
Location loc = (Location) serializedMap.get("location");
if (type.equals("checkpoint"))
return new CheckPoint(loc);
else if (type.equals("spawnpoint"))
return new SpawnPoint(loc);
return null;
}
my debug message here never was ran
I cant find it in console
yeah
this just seems like a
?learnjava moment
For Beginners:
Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/
For Intermediate to Advanced Learners:
Oracle Java Tutorials: The official guides by Oracle for Java programming—great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/
Practice and Hands-on Learning:
Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/
Free Resources and Documentation:
Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/
Community and Support:
Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/
Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! 🎉
Fixed it
added deserialization constructors for the child classes
Does anyone know how to send a hotbar text? I don't mean actionbar, i mean hot bar
It is possible
you know it is possible because...?
it isn't possible to show that without setting an item name
the other thing you can do is send a title/subtitle with a custom font that offsets it by just the right amount
yeah im not gonna make client download a resourcepack
👍🏻
it is annoying when you join a server you have to download smth
most, not all
you can just send it in the configuration phase so they won't even notice it
well, it will prompt the yes or no but that's it
no external things
you can host the resourcepack on the server through your plugin
I don’t see this issue with server resource packs anymore
A few versions back sure, but they are pretty great now
just sent info above the item name
i know i just don't want to make ppl need to download something to play my server
there are heaps of servers that do resource packs and tens of thousands of people play with no issue
I have a development question
players are far more willing to download a resource pack to have a better playing experience
who do I have to pay to assassinate the person who came up with the idea that vector.add modifies the vector instead of returning a new vector
and how much
and who wants in on the crowdfunding
actually this time it was joml that did it to me
I'm about to make someone's face mutable
there are immutable interfaces and mutable impls
then there is SpongePowered's math library which is immutable
it's alright
Ah right the immutable one is just an interface
I'll fund this
anyone experienced that essentials nick do not change in TAB or in chat? Im using LuckPerms aswell
is using a library like fastuuid actually worth it?
you want it fast but wonder if it's worth it?
It's more of a "Do you need it?"
If you work with large quantities of uuids, ig give it a shot, otherwise you probably won't need it or can expect next to none real performance benefits
would there be a way to inject into this class to change the return value of the last method
runTask is run one tick later
I dont think so
doesn't simply calling runTask run it without delay
Nope
On the next tick
because im running from void write from a class that extends ChannelDuplexHandler, aparently, that makes it async, so i have to do that
damn i think im stupid
Include the ifCancelled thingy inside the lambda then? Maybe
i have to run all async
yeah i didn't think about that 😭
keep in mind this code will not be executed immediately but will be scheduled to be executed on the next tick
So if youre writing to some stream it might become out of sync
Idk
Okay
holy fuck finally
I got health in tablist as numbers by literally modifying the packet before it was sent to the client
damn im doing the same here
wait like literally the exact same
you can do header and footer with this method here
private static void sendHeaderAndFooter(Player player, String header, String footer) {
PlayerConnection con = ((CraftPlayer) player).getHandle().playerConnection;
String headerJson = ComponentSerializer.toString(new ComponentBuilder(header).create());
String footerJson = ComponentSerializer.toString(new ComponentBuilder(footer).create());
IChatBaseComponent tabHeader = IChatBaseComponent.ChatSerializer.a(headerJson);
IChatBaseComponent tabFooter = IChatBaseComponent.ChatSerializer.a(footerJson);
PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter(tabHeader);
Field f;
try {
f = packet.getClass().getDeclaredField("b");
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
}
f.setAccessible(true);
try {
f.set(packet, tabFooter);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
con.sendPacket(packet);
}```
i did
did you do it a better way than I did?
im using this
serverPlayer.connection.connection.send(
new ClientboundTabListPacket(
net.minecraft.network.chat.Component.literal(
SkyblockServer.getTabHeader()
),
net.minecraft.network.chat.Component.literal(
SkyblockServer.getTabFooter()
)
)
);
getTabHeader and getTabFooter methos js return strings
im using nms mappings btw
final ServerPlayer serverPlayer = ((CraftPlayer) e.getPlayer()).getHandle();
serverPlayer.connection.connection.send(
new ClientboundTabListPacket(
net.minecraft.network.chat.Component.literal(
SkyblockServer.getTabHeader()
),
net.minecraft.network.chat.Component.literal(
SkyblockServer.getTabFooter()
)
)
);
what is ClientboundTabListPacket
The NMS mapping for PacketPlayOutPlayerListHeaderFooter
You are using spigot mappings
I'm using NMS
I see
ah weird my PacketPlayOutPlayerListHeaderFooter only accepts a header argument so I have to use reflection to set the footer
but I'm on 1.8.8 so could of changed
Lol
?1.8
Too old! (Click the link to get the exact time)
womp womp
How do I do Player#chat but visible to one player only?
I’m confused, why not just use Player#sendMessage
And then format it like chat
Because I don't know what the chat format is
guys, how do i get last damager in PlayerMoveEvent?
i do not want to combine 2 EventHandlers.. i only need to get the last damager, store him in the hashmap and then after teleport remove him.. i am struggling to get the last damager (Players name)
or will it be better just make new listener that is checking the lastdamager (EntityDamageEntity Event)
#1 this code will crash if the entity is not a player (ClassCastException)
#2 what exactly are you trying to achieve, as in what is all this supposed to do ?
Not "get damager, store in hashmap, teleport"
getLastDamageCause?
simple combat log i think that's what he want to make if iam not mistaken ..
Basically… yes
I forgot there was a way to hide the armor stand on the player's screen. Can you remind me guys
Set it to be invisible?
Only on that player's screen, other players will see it
When the player goes into spectate mode, I need to make armor stands invisible from his screen
player#hideEntity
how can i check if a block was placed by a player or naturally generated?
save the location of every block placed? how do i go about saving it?
How often do you plan on accesing it
And what do you want to do with the information
not that often just when ancient debris gets placed (add) and when broken (check and remove if on it)
I assume it's not going to be that many of them then
yea pretty rarely i imagine
Learn about CustomBlockData here:
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
?pdc
i tried persistent data container
is this the same?
Yes
refer to this one
^^
so youse customBlockData?
CustomBlockData is a library that helps you store pdc on blocks that don't support it
It works by storing it in the chunk instead
Are you using maven?
Then the guide link tells you the dependency information
And how to shade/relocate
whats that
Shading means including in your jar
Relocating is changing where in your jar it's included
im still really confused
What part?
Maybe he isn’t talking about a maven package
do i just add this to pom.xml
<groupId>com.jeff-media</groupId>
<artifactId>custom-block-data</artifactId>
<version>2.2.3</version>
<scope>compile</scope>```
You need to keep the dependency tag surrounding that
and just add it at the end or smth?
Oh he is, yeah you have to add the dependency tag and put the dependency in the dependencies project section
Oops*
it is
it's critical that you shade and relocate it though, or you can interfere with other plugins
how do i go about shading it?
Shading and relocating
If you've never shaded anything before though, you may not have the section that alex is referring to
i dont
theres nothing under the dependencies other than </project>
guys
have a quick look at https://maven.apache.org/plugins/maven-shade-plugin/examples/class-relocation.html it shoulds how to add the maven shade plugin as a build plugin
any utils for hex color handling?
(would love it if it has gradient as well as rgb & legacy support)
i've been trying to find a good one for the past hour and i cant find a single one
(legacy2component) (i wanted to use minimessage but stuff happened)
so add this bellow the dependencies in pom.xml
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>org.codehaus.plexus.util</pattern>
<shadedPattern>org.shaded.plexus.util</shadedPattern>
<excludes>
<exclude>org.codehaus.plexus.util.xml.Xpp3Dom</exclude>
<exclude>org.codehaus.plexus.util.xml.pull.*</exclude>
</excludes>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
after you've finished adding shading and relocating for the first time, you should double check the jar that you made, in an archive tool that can open it, I use winrar myself, but there's a few options like 7zip i think can do it too.
it will let you see the directory structure inside.
my group name for my plugin is au.id.rleach
and see how there's a shaded directory, that's where I relocated my stuff to
you are just copying and pasting the whole thing, you should really try to understand the structure of your build xml configuration
ill gladly leave that for future me im sure ill be just fineeeee :)
Like you don't want to have 2 <build>'s you need to merge the example into your file
Yes and then edit it to include the relocation that thr guide tells you to use
Yeah but you can't just append it
e.g. the plugin that's in that example, should go in your plugins section
and rip out this
<relocation>
<pattern>org.codehaus.plexus.util</pattern>
<shadedPattern>org.shaded.plexus.util</shadedPattern>
<excludes>
<exclude>org.codehaus.plexus.util.xml.Xpp3Dom</exclude>
<exclude>org.codehaus.plexus.util.xml.pull.*</exclude>
</excludes>
</relocation>
because that's just the example
alex provides you with a <relocation> for you to use in the guide
Do you kinda understand how the xml document is like a tree? (if you've done HTML before it's very similar)
Yeah, so xml is similar, except it's data
gotcha
so instead of ripping out the "section" tag that has an article, you need to merge the structure, and replace it with the "section" that you need
in this case you are subsituting the relocation for the one provided in the guide
and adding a plugin to your plugins section
"phase" package, is the part of the build that bundles up all the classes
i didnt understand any of that
and the goal 'shade' is the step of that, which is copying classes from one classpath to another, and is provided by the plugin you just added
sorry was trying to use html as an analogy when I was talking about 'section' tags
ive done html (i made snake in it) i dont know much about it
Yeah it's all good
hey guys im trying to make a server where armor trims give effects, like silence would give strenght 2 or rib would give fire rezistance, and when you take the armor off the effects go away.
but like so that i can have 4 effects at once by wearing armor
can anyone help me pls
anyway, relocating is basically scanning your classes and renaming the packages
<pattern>org.codehaus.plexus.util</pattern>
<shadedPattern>org.shaded.plexus.util</shadedPattern>
means that it turns org.codehaus.plexus.util into org.shaded.plexus.util in your code. so by renaming the package, you 'adopt' the code into your codebase, so other plugins can't accidentally use it unintentionally. which means you don't need to worry about version conflicts etc.
<excludes>
<exclude>org.codehaus.plexus.util.xml.Xpp3Dom</exclude>
<exclude>org.codehaus.plexus.util.xml.pull.*</exclude>
</excludes>
in the example is showing how to exclude a package of classes from being scanned, presumably because if you changed them, stuff would break
Get the armor trim data from the item
post a paste to your pom afterwards, and I can double check it
i dont have org.codehaus.plexus.util in my pom.xml
I was using the example
wdym
Are you trying to code a custom plugin?
i dont know how to code.. im trying though
?learnjava
For Beginners:
Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/
For Intermediate to Advanced Learners:
Oracle Java Tutorials: The official guides by Oracle for Java programming—great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/
Practice and Hands-on Learning:
Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/
Free Resources and Documentation:
Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/
Community and Support:
Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/
Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! 🎉
i remember learning how to code it was rough and hell and i didnt understand anything and it was so frustrating i was just copying code and i felt overwhelmed 24/7 but then i just kinda stopped using tutorials less and less untill i noticed i was using a lot less tutorials, hindsight i definitly should have asked for help other than just googling and youtube
so youre already doing better than i did
Unironically for the dead basics I'd reccomend just using Google and chatgpt. Now when I say dead basics with chatgpt I mean it your questions should be like how do I take user input or how do I loop over a list vs how do I write my entire project
If you stay dedicated you'll beable to write pretty much anything you want within a few months
It won't be easy but totally worth
Stuff that you know has been done 100 times, and doesn't rely on niche libraries. the second you start using niche libraries, chatGPT hallucinates like crazy
AI 🔫
I found it useful for the start of my C journey tbh I know it won't fuck up how struct syntax or null ptr checks work
stupidly, chatgpt could probably pass a lot of the simple uni assignments I had in uni, because people keep publishing them publically on github to cheat off of and resume build
Not to mention I force it to give a short summary
also play bitburner https://store.steampowered.com/app/1812820/Bitburner/ its very fun and simple and gets slowly harder and harder (its an idle game where you automise stuff with code in a hacking setting, and the discord is helpful for general coding help i still come there for non bitburner related stuff)
Syntax is something I consider dead basic theirs millions if examples
ChatGPT basically would have to be persuaded into fucking it up
it likes inventing methods that don't exist
still variables and loops and if statments are very simple and should be plenty of examples for it to not be drunk and high
Also, it merges all versions that ever got published together
Yeah swhy you only use it for stdlib as soon as you get above base level competency you gotta use SE again
like it has a LOT of trouble with groovy vs kotlin gradle builds
granted, human's struggle with old examples too
I'm an avid AI hater I'm just pointing out where I've found it useful as an experienced programmer
I think it's gradle's secret plot to get people to actually learn the tooling to change and break it constantly
otherwise if it worked forever, and was backwards compatible, you'd deskill and get frustrated every time you touched it
And honestly using it with basic C alongside a search engine has been nice it requires less optimized search terms for very basic stuff for how to make a struct or do string concatonation has been nice asf
I've never had issues with gradle deprecating something I use
I always stay latest pretty much too
as someone that programs in a few languages, it REALLY shines for going, I have this java code, and I'm trying to learn, lets say, GO, how would you turn this into GO code, and can you explain and link me the language features used
if the ai overtake will become real im gonna make an 'abfuscator' that scrapes github and makes shitty buggy ugly code of the stuff already there
AI is useful as a search engine for books etc
works pretty well for learning names of stuff
So like, it already is?
I found it can't do that for me well tbh it failed with helping me with that during my English class
It's because of the context windows
Half the books it said didn't exist or were named differently
they are way too small for it to process a whole book
nuh uh
Im talking about finding books not reading them
The context window is too small for an entire 800 page book
I can read I don't need an AI with shit ass memory for that
Hi there, I am having some issues with my NPCs I am creating. Whenever I spawn the npcs they are located exactly on top of the player, not at their set positions, their heads are rotated correctly.
This is my code:
public void spawn(Player player) {
CraftPlayer craftPlayer = (CraftPlayer) player;
ServerPlayer serverPlayer = craftPlayer.getHandle();
ServerGamePacketListenerImpl ps = serverPlayer.connection;
MinecraftServer server = serverPlayer.getServer();
ServerLevel level = ((CraftWorld) player.getWorld()).getHandle();
GameProfile profile = new GameProfile(UUID.randomUUID(), "npc");
profile.getProperties().put("textures", new Property("textures",
texture, signature));
ServerPlayer npc = new ServerPlayer(server, level, profile, serverPlayer.clientInformation());
npc.connection = new NetworkHandler(server, npc, CommonListenerCookie.createInitial(profile, true));
npc.setPos(location.getX(), location.getY(), location.getZ());
npc.setCustomNameVisible(false);
ServerEntity npcServerEntity = new ServerEntity(serverPlayer.serverLevel(), serverPlayer, 0, false, packet -> {
}, Set.of());
SynchedEntityData synchedEntityData = npc.getEntityData();
synchedEntityData.set(new EntityDataAccessor<>(17, EntityDataSerializers.BYTE),
(byte) (0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40));
ps.send(new ClientboundPlayerInfoUpdatePacket(Action.ADD_PLAYER, npc));
ps.send(serverPlayer.getAddEntityPacket(npcServerEntity));
ps.send(new ClientboundAddEntityPacket(npc, npcServerEntity));
ps.send(new ClientboundSetEntityDataPacket(npc.getId(),
synchedEntityData.getNonDefaultValues()));
ps.send(new ClientboundRotateHeadPacket(npc, (byte) ((location.getYaw() %
360) * 256 / 360)));
ps.send(new ClientboundMoveEntityPacket.Rot(npc.getBukkitEntity().getEntityId(),
(byte) ((location.getYaw() + bodyOffset % 360) * 256 / 360),
(byte) ((location.getPitch() % 360) * 256 / 360),
false));
}
The location is filled btw with the correct values
If I am at the wrong section, I am sorry, please let me know where to be
no comments 😔
I am sorry, I'll add some comments
that's a heck of a lot of NMS and packet hacking going on
Is there a way to combine things then? :o
What it comes down to, I make a ServerPlayer and use .setPos, but somehow even tho all the values are filled, they don't go to that spot but instead will spawn on top of the player
npc.setPos(location.getX(), location.getY(), location.getZ());
where is location defined?
In itself, it's an entire class, perhaps a way I could share the entire class without spamming the discord? A pastebin or anything?
Also, I'd set a breakpoint right after that, and double check npc.getPos is right
I'd then scan through the packets you are sending right after that, and compare them to https://wiki.vg/Entity_metadata#Entity:~:text=minecraft%3Afishing_bobber-,Entity Metadata Format,-Note that entity to make sure your getNonDefaultValues isn't stealing the position off the player
Yeah location isn't get set anywhere there, so it's whatever is extending it, or maybe the getNonDefaultValues
if EVERY investigation fails, I'd try changing the timing up, or comparing it to normal entities
he is using Lombok
so he sets it in the all args constructor
show your code to spawn this npc
Yea the location is set in an class which extends the base
ServerPlayer npc = new ServerPlayer(server, level, profile, serverPlayer.clientInformation());
This looks like it's cloning a player here, so it's probably cloning the location right in the constructor
no
he uses setpos so he is using teh location field
his fault is in calling his class
nm, didn't realize the snippet above was the same class in the paste
public static void addNpcsToPlayer(Player player) {
npcPlayerActions.put(player, new ArrayList<>());
for (BaseNpc npc : NpcData.npcs) {
NpcPlayerAction hubPlayerAction = npc.spawn(player);
npcPlayerActions.get(player).add(hubPlayerAction);
}
}
I mean this is where I execute the spawn() function
where do you create the npc instances?
It's being done on server start up, just has a list of classes that are extending by the base. Like https://pastes.dev/dg1Vyq0NNh
so all spawn at new Location(Bukkit.getWorlds().get(0), -16.01, 64.06, -21.5, 13, 20),
So does Timmy also spawn on the player?
oh I see
your npcServerEntity uses the serverPlayer and not npc in its constructor. Ryan was correct
you setPos on npc, then use serverPlayer instead
not really the constructor, but I was in the ball-park
I was just trying to trace where the players location could have been poisoning stuff
Thank you guys, it works!
Yea the code is a bit messy too, got some good improving to do
if it makes you feel better Mau, I was stuck for 3 days on the following.
I felt REAL silly afterwards
also came down to how messy the code was, simplifying it for a friend who was new at coding, it becomes very obvious
You start to understand how important it is after getting stuck on it like that haha
I'd started debugging both Spigot and Paper, but I should have stepped through my own code more carefully
what is the low complexity plugin
I don't know if I like it. https://plugins.jetbrains.com/plugin/12895-better-highlights
I was trialiing it in it's free period, because I was trying to see if I got value from changing some theme's that wern't possible otherwise
but if you like the complexity analysis that bits free
get urself some rainbow brackets
Themeing wise, I'd love to experiment with something that exposes public method usage (within your project and classes only) with different fonts, https://monaspace.githubnext.com/#learn-more
But I think I'd need to swap to VSCode, as intellij's themeing is surprisingly limited.
having Comic Sans ish font, for anything I expose as API, would be a good reminder to not expose it by accident
and when I was doing C# dev, being able to highlight methods that were considered internal, would have helped to tell at-a-glance where user input validation was leaking
think we have a lot of room for Human Computer Interface design in editors yet
Okay but Zed Mono
okay but why Zed of all editors
no u
using Firacode with ligatures atm, but not in love with it
https://www.nerdfonts.com/font-downloads ngl I hate all of these except Iosevka and Zed Mono
https://github.com/raexera/Iosevka-Matsuri Iosevka Matsuri is also good
hey, going for another help...
why the hell i get this error:
it should put the damager inside the map, when he hit the victim right?
like the victim will containkey damager?
How did you initiate your PlayerDamageListener? The error is about damageMap being null, not anything related to the behaviour of th emap
Your class PlayerDamageListener, where do you create an instance of it
nowhere
Making a class implement Listener doesn't immediately make it a listener, where do you register your listener
in main class
Can you show the code
Yea the whole code
give me a minute
timer started
I mean given you're using a singleton for you damagerMap, you probably don't need to pass it through your entire code, you could just do inside you PlayerDamageListener a DamagerMap.getInstance() inside the constructor and remove the parameter
But whatever you're passing onwards into the function is null
yeah well
you never call getInstance
so damagerMap is always null
since you only instantiate it there
u can have a look
But this
i dont quite get why you wrapped a map in a map object but anyways
you never call getInstance anywhere
so your instance in DamagerMap will remain null
well i am not that good, still learning and its mostly first time using something like instances, trying to learn them
i mean, you have everything. you just need to call DamagerMap.getInstance() somewhere and use the returned instance
can i call it inside the PlayerDamageListener like this:
yes but that wont fix your problem since you dont use that instance but a field of your main class instead
private DamagerMap damagerMap; to private final DamagerMap damagerMap = DamagerMap.getInstance();
in main?
where i linked it
okey
Where you do this.damagerMap = damagerMap you could do this.damagerMap = DamagerMap.getInstance() and you can remove the parameter from the constructor
but that being said you dont need the getInstance method in DamagerMap. you can just instantiate it right away.
private final DamagerMap damagerMap = new DamagerMap();
that would be the better approach
and then you pass it to where you need it, a la PlayerDamageListener
no
thats what DI is for
best to lead them away from static abuse before they even get to it
when i remove the getInstance method in DamagerMap i get this error:
i guess i need it in DamagerMap class
the singleton pattern is a bad pattern with only little of justified usecases
yes, now you need to instantiate the object
create a new one
^
sorry, but where?
here
?learnjava may help you as well
For Beginners:
Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/
For Intermediate to Advanced Learners:
Oracle Java Tutorials: The official guides by Oracle for Java programming—great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/
Practice and Hands-on Learning:
Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/
Free Resources and Documentation:
Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/
Community and Support:
Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/
Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! 🎉
Wowaawww
bless you
🌹
I did the job that I should have done with 6 lines of code, with 7 lines of code.
Actually, it is not 7 lines, its 7 classes
what happened
we need to know lol
oh, you're refering classes
i thought you went from 6 lines of code to 7 classes
😃
I implemented a fake death mechanism and needed to add a bit system, I created 8 classes while I needed to handle it with 7-8 lines with the worldguard API
Luckily I fixed it
Xd
just fake death?
it shouldn't take more than 2 classes
i have that in all my plugins
What's wrong?
System.out.println(NamespacedKey.fromString("wblockhandler:breakingTime"));
System.out.println("Why?");
i think you need to register the key first
I have set up all the statistics and lastdamager addition in the fake death mechanism, when the player is hit in a closed area in pvp, it adds a damager like 0.00003, which is when the player dies. It was causing the kill to be added
:d
wdym?
why do you want to do that
I also disabled lastdamager in certain regions with worldguard
new NamespacedKey()
you can;t have a space in the plugin name
well, I dont have it
Ok, it has sense
I guess it just looks like a space in discord
yes
?
no
identifiers need to be all lowercase
use snake_case
So, I should firstly use new NamespacedKey(...) and after that I can use NamespacedKey.fromString(...)?
ohh
it should be all lowercase?
yes
identifiers/resource locations/namespaced keys need to be [a-z0-9/._-]
ty
I just use NamespacedKey.fromString in order to use this plugin as a library for other my plugin, that's why I can't use new NamespacedKey(plugin,String)
A player switched to Spectate mode, I hid armor stands in his screen with Packet, and I also made him fly and invisible. But I forgot to hide the items and armor in your hand. Remind me
Ops I remember
I did
Ty
How might I orient an item display to conform to the players line of sight
I want to make an item display essentially face the way the player is looking
Constant tp
R u making nametags
What do you mean and no
Like make an item dispplay always face the player?
kotlin's object and companion objects are so weird
I want to face an initial direction of the player and then do some other actions
it eliminates the need of static
but at the same time introduces singletons
i guess its easier to unit test non static fields and properties
object fields are static anything else is a singleton
Then set display's direction to players direction
You can do that?
Wait how?
I thought I had to do shit with rotation
you want it to always face the player? just set billboard
yea you're right, i thought that that it would create singleton like structure, but it just uses static under the hood for declaring properties and methods inside it
methods are under a singleton structure
No I don’t it’s a particle model, meaning I want it to face an initial direction for the player and make it go forward
class variables are not
ok
So how would I do that
as pumpkin said, set the direction
How do I do that
I didn’t know there was a function for the items direction
its so hard to adapt from java to kotlin
i would need at least couple weeks to get into the workflow
if not months
its not that its hard i tend to google things of how would it look in java
https://github.com/mcbrawls/inject/blob/master/src%2Fmain%2Fjava%2Fnet%2Fmcbrawls%2Finject%2Fmixin%2FClientConnectionMixin.java#L19 an example of how an object field looks like in java
How do I set a direction to a display?
for an ItemDisplay you rotateY of the right rotation (transformation)
Transformation transformation = entity.getTransformation();
transformation.getRightRotation().rotateY(rotation);
entity.setTransformation(transformation);```
rotation being in Radians
Gotcha, and I set this angle in radians to the players eye angle?
yaw
I set it to the yaw?
Time to open up block bench and make some discs
if you want it to face teh same direction as the player
Yes!!!
lmk if you need any help with resource packs
I’m tired of seeing “driver disc” kek
Omg please help with the resource packs
Yes gimme like 30mins!
Ok I’ll check it out
I’m at work, give me like 2 hours lol
Ah lmao
Not gonna be able to vc but I'll try to help anyway
Maybe tomorrow just better then
Yeah I have lotta time tmrw
Ok cool I will dm you
or you can just manipulate it as an entity and entity.setRotation(...
kotlin keeps surprising me
.
japanese guy yell yelling screaming shouting casino jackpot bell ring
I can already see "Parse, dont validate" approach with this
how are you liking it
anyone else had issues with any issues with inventories recently, somehow im unable to set slot 0 in an inv, other items get set and the item exists in the contents but the client isnt being sent the item
Gotcha
just spam miles about it
this is something I'd have to open CraftBukkit and NMS packets and source to figure out in all likelyhood
I'm on my laptop rn which makes that a no go
miles was in a silly goofy mood when writing our menu apis and hes setting slot 0 to a dummy slot instead of the right index so blame him
wtf @river oracle !
my bad gang
this wouldn't have happened if rad gifted me discord nitro though
my fault
when did rad join pineapple
he's official Nitro Gifter
he has no other role or purpose
he's doing a shit job I ain't got no nitro from him yet 🤷♂️
I WILL make everything kotlin
And, good kotlin
100% will be builder DSLs

oh please do
ty
cant use ij convert to kotlin either
and cant dmca us later
It sucks
thats why i said you cant useit
when you realise how much there is to convert you'll say no
hm
pineapple
Trying to use buildtools but whenever I select version 1.21 it builds 1.21.1, am I doing something wrong?
Version says 1.21 at the top of the gui but in the console output it says
Building Bukkit 1.21.1-R0.1-SNAPSHOT
NMS version changed
All plugins compatible with 1.21 are compatible with 1.21.1
It did not
For reference 1.21.1 just patches two bugs and added two languages
Ye it was a server crash bug or something wasn't it
!paste
sorry about the reply lol
?paste
Is spigot forum trustable for devs?
sure
so I got my item display to work but:
I want it like this regardless of the angle
how might I dotaht
https://paste.md-5.net/oworaxovub.cs
here is what I have currently
do you know if this still the case
it seems that previously default impls on interfaces produced static class inside an interface, instead of utilizing default keyword inside jvm
I've made a plugin that uses custom heads for some of the items. when testing this on a test server of the same version (1.21.1) I get no errors. when we have moved it over to our main server I am getting this error. does anyone have an idea as to what this could be caused by ? \https://pastebin.com/5XP1KQJd
?whereami
🚫 no kotlin
I'd you're gonna diss kotlin please atleast follow java naming conventions
To see who you are saying weird stuff
alr sir y2k_
I am y2k_ yes
frsvn — today at 20:21
alr sir y2k_
good ol' kotlin
whats that

can someone help me figure out which packet contains the visual lines of text for the scoreboard and not the title
how do i load in a json that im using for some precalculated data that i need loaded? ive heard you use the resources folder but im new to spigot dev but i already know java to some extent (im in cs class in college rn)
?
why do you want that
it's the objectives
Don't know the packets name rn but should be along the lines of that
I want to get into plugin development and I know you probably get a lot of new people who just beg for help and I may seem like one of them but I am making a mistake during just setting up a basic plugin somewhere and cannot for the life of me find what I am doing wrong. If someone could join me in general-1 vc to help me out that would be great.
Cheers,
Acevatex
trying to fix a bug in viaversion
open a issue on viaversion github
its known
what's the error
.
yeah you are using 1.16+ colors right?
lol chill
no
then
then what
Like rgb converts to minecraft's default colors?
no, it continues to the next line
empty line of one color "&b" (no visible text), next line inherits color when it shouldn't
just search for objective lol I don't get this guys issue (not you)
&r
lmao
lol
version: 1.21.1, hash: b05a96caf9
you should be using custom objective names anyway
yes but this is a pre 1.13 server
Breh ok
bro why is he modifying smth with nms instead of fixing it normally
??
version: 1.12.2, hash: b05a96caf9
viaversion
I think they meant me with custom obj names
ta-da
now what if you wanna actually fix the issue? lol
.
-# *💀 *
I genuinely don't get what your problem is
alr 👍🏻
I’m going to probably upload my murder run plugin sometime soon
I think people would like it
Don’t you think
let's goooooo
nvm I found a fix (im dumb and didn't realise name for the plugin.yml auto set to paper-plugin.yml which was causing it to not get included in the plugin so I renamed it)
I found the packet just for it to be spitting nonsense/garbage, fun
why must it be a string of only the color codes? wtf wheres the actual text
theoretically you could maybe find a solution in newer versions of viaversion's code
maybe it works for your version, maybe not
its in the 1.12->1.13 conversion
i tested 1.8-1.12 and 1.13 is when the issue appears and lasts till 1.21 (latest)
packet id 0x45 in the 1.12.2 protocol, Update Score
which creates the lines and sets the text
I print out the data from that packet
and the text is just color codes
i've also printed out the data from the objective ones too
none it matches what i see ingame
theres 10 prints of SET_SCORE display name which is the same amount of lines there is on the scoreboard but the data it prints is just wrong
i give up for tonight
is there a way to stop a block placing using PlayerInteractEvent?
just cancel the event
I'm trying to get the players current World id that way I can use it to save their Location
Should I really just loop through each getWorlds() and check the name until it matches to get the id of the current world in the array? Or is there a better way? (almost like toName, but I want toInt)
player.getWorld should exist
Doesn't that return a World?
oh world ID
That is.. not a thing ?
So I later can do Location (getWorld(here will be the id), -, -, -)
you mean UUID ?
Because right now I have it default to getWorld(0)
And that works but that will always teleport to the overworld, not nether or end
And if I change it to getWorld(1), then it'll work
So I'm trying to convert the players current world to a int
Ye I don't think that is how you should manage the worlds
Give me a minute
I'm in a meeting at work lol, I'll have to re-read this so I can give proper answer lul
(or get sniped by the big man)
List.indexOf, but this doesn't seem like a good idea
You want to save the world name or uuid
Not int
Location is already serializable
I would do UUID
World.getUID
(Why is this the name md, why)
You can .get and .set it from a config
Okay I think needed context
I'm making a home plugin, and when the player runs a command it saves their location
And if they go to a different world, they need to be able to /home back to their saved world
The UUID method would work well but I save all the player home data in PersistentData
You can create custom persistent data types on your own, or use one of the many libraries available which have implemented those which match your needs. Learn about more persistent data types here: https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/
I will try to UUID
Idk which resource gave PDC for UUID only
if (p.getInventory().contains(new ItemStack(Material.GRAVEL))) {
p.getInventory().removeItem(new ItemStack(Material.GRAVEL));
p.getInventory().addItem(new ItemStack(Material.FLINT));
}
This only allows it if its a stack of one item and if I add an amount it sets it to only that amount
how can I allow it to be an ItemStack of any amount
Look at the other contains overrides and/or the docs for removeItem
This code doesn't exist
World world = [retrieve the world using the uuid]
Bukkit.getWorld(UUID) does exist
And the docs say this exists as well
They're probably on 1.8 or smthing
not if they are using PDC
I don't know why it wasn't popping up when typing getWorld. I had to specifically do Bukkit first but alright
Do you know java?
welll- ye
Are you new to Java ?
I don't consider myself new?
I mostly do C# I don't know if that changes anything though
Anyway, testing right now
.GetWord ahh
How do you force getWorld to take in a UUID instead of a String?
A UUID is a String right?
No
UUID.fromString(yourstringuuid)
😂
did you know c# code is offloaded to microsoft datacenters to be ran? the memory usage you see is for the Telemetry and Spyware
How do things work when I am without internet connection tho 🤔
Microsoft do some telemetry on .NET
I got my first plugin completed 😄
probably the wrong channel to say this tho
Home plugin?
nothing too advanced just a basic if you right click stone with gravel it removes the gravel and gives you flint
very very simple stuff
not bad for 4 hours
and for a first attempt while learning java im pretty happy
package me.acevatex.gravelBreak;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.Objects;
public final class GravelBreak extends JavaPlugin implements Listener {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
JavaPlugin.getPlugin(GravelBreak.class).getLogger().info("[GravelBreak] - Plugin Enabled");
}
@Override
public void onDisable() {
JavaPlugin.getPlugin(GravelBreak.class).getLogger().info("[GravelBreak] - Plugin Disabled");
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Player p = event.getPlayer();
if (!event.hasItem()) {
return;
}
if (event.getMaterial() == Material.GRAVEL && Objects.requireNonNull(event.getClickedBlock()).getType() == Material.STONE) {
ItemStack handItem = event.getItem();
if (handItem == null) {
return;
}
if (handItem.getType() == Material.GRAVEL) {
p.getInventory().removeItem(new ItemStack(handItem.getType(),handItem.getAmount()));
p.getInventory().addItem(new ItemStack(Material.FLINT,handItem.getAmount()));
}
p.spawnParticle(Particle.BLOCK_DUST, Objects.requireNonNull(event.getInteractionPoint()),10, Material.GRAVEL.createBlockData());
}
}
@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
if (event.getBlockPlaced().getType() == Material.GRAVEL && event.getBlockAgainst().getType() == Material.STONE) {
event.setCancelled(true);
}
}
}
the entirety of the code ^
most of the 4 hours was scouring docs / forums and learning about common practises
can you put java behind the ``` ?
```java
code```
It makes stuff colorful
ah yea I forgot lol
tyy <3