#help-development
1 messages · Page 484 of 1
Your written explanation hurts my brain
see, it works
No Man I'm being serious trying to explain but the english is really bad. Inwill translate what i mean
nice cooking skills. "Today we'll cook a tasty porkchop. All you need is 2 cubic meters of cactus"
I don't mean using the recipe system, but the interface.
Hello, someone know why i've got an error when i try to compare two chunks like that : if(e.getChunk().equals(cs.getLocation().getChunk())) { ?
I believe what they're trying to say is that with a User it's a little awkward to sneak in an instance of your main class, which I kind of sympathize with. It's a strange instance to have to pass into the constructor of your User object because imo they're really not (or at least shouldn't be) tightly coupled
nobody knows it because you're not showing us the error message
At least that's how I'm interpreting their messages lol
yeah but if the alternative is a static getter, there's no difference
man i hate cmake sometimes
i left a comma
inside function arguments
and i wondered why it wouldnt work
I think the alternative isn't a static getter, it's a sign that your architecture doesn't abide by the single responsibility principle. Classes need to be broken up into more classes that make more sense to pass in. Or passing in values via methods that makes more sense
yeah agreed
smth is bad at WorldListener.java at line 16
i just have this 9999 times
Why do you need to access the main class in the first place?
then you're causing chunks to get loaded in the ChunkLoadEvent
It all starts with passing instances of your main class to different objects. In my case I use DI for this process. It is very like using it and its advantages.
But at least from my point of view it has flaws when working with objects which are not initialized. Like utility classes, model objects to store property with results (for example an entity User, Group, etc).
Copy the full error log, paste it somewhere
getChunk() loads the chunk
If you have a utility class that requires an instance of something, then it can't be a utility class
if your utility class requires your main instance, it's not a utility class
(assuming it's an instance that isn't passed as a method parameter)
Can you elaborate it More?
Arent static method utilities ? Or I'm confusing things
Yes i use ChunkLoadEvent
Does anybody know if it is possible to make a value in LoadingCache (Guava) immutable? That is, when I get a value from the cache and edit it, it is updated in the cache. Maybe I should just use copy constructor/Cloneable or something else?
https://pastebin.com/dsK0uDc9 it's just a little part
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
stop loading chunks in your ChunkLoadEvent
All utility methods are static, not all static methods are utilities
static just means a method has no state
A utility method that requires some instance of something that isn't directly passed to the constructor cannot be labeled a utility method
It should probably be an instance method and your current design is flawed
How can i compare chunk with ChunkLoadEvent ?
wdym?
compare the coordinates, not the chunk itself?
I'm assuming you just wanna check if the location is inside a specific chunk
I want to check if the chunk who is loading is a certain chunk for start my mob spawning
just mark the chunk with a PDC key
event.getChunk.getZ/X?
the in chunkload event, check if the chunk has that pdc key
And store X and Z values?
Or just ^^
Oh right, going back to my question what would be this clasified as?
public class Example {
Static oolean hasProperty() {
MainClass plugin = ?
If (bla.something()) return plugin.getBla().getProperty();
return bla;
}
}
Probably a method that should be in your main class
yes
But what if it's satic?
If the entire body of that method relies on the existence of an instance of an object, it should be an instance method of that object
Apply the same?
making this static is stupid
Why there's so many coding rules, holy crap, just write the code bro
I just see no reason to make it static
obviously it needs your main instance
it does not belong to be static
making this static would be "wrong" because it requires an instance
I think I'm not really explaning what i mean
you didn't really understand when to use static and when not to
Not rules, just guidelines that people have experienced over the decades of the language existing as a result of their faults
that method should be in your main class, not-static, or in a PropertyManager or sth, that your main instance returns with getPropertyManager() or whatever
People have failed to write good code to get to a point where others can learn from it
Hmm yes, pretty much the reason of why reading 1.8 bukkit codes are criminal
Hmn Let me find some Berger example
problem is that people have learned the habits, but not the reasons. Most people just do because they're told to do, imo.
I know, that's why concepts should be explained, not told lol
// Plugin disable logic
How ?
That's not a quick solution tho, so why would someone want a real explanation?
PacketContainer packet = manager.createPacket(PacketType.Play.Server.BLOCK_BREAK_ANIMATION);
if (Utils.getPickaxeFromItemStack(player.getInventory().getItemInMainHand()) != null) {
System.out.println("Pickaxe");
Pickaxe pickaxe = Utils.getPickaxeFromItemStack(player.getInventory().getItemInMainHand());
if (pickaxe.getPickaxeTier() >= ore.getPickaxeTierRequired()) {
Long delay = (long) (pickaxe.getMiningSpeed() * ore.getHardness());
for (int i = 0; i <= 9; i++) {
final int finalI = i;
new BukkitRunnable() {
@Override
public void run() {
packet.getBytes().write(0, (byte) finalI);
}
}.runTaskTimer(main, 0L, delay);
}
}
}```
Chunk implements PersistentDataHolder
this is my code for handling sending the animation to the player
getPersistentDataContainer()
could that be due to this part here for (int i = 0; i <= 9; i++) { final int finalI = i;
i dont know if final can be used like that
since it can only be assigned onc
tru. People want that real-time dopamine hit 
it would always be 0?
why are you using packets for block damage? o0
No it's final in the local scope ;p
Not entirely sure why someone would make a finalI variable, but no, it's created locally and assigned to i
Why ru initializing a task like that, it's Hella mess
the only issue there is using protocol lib
Lets say you have a TeamColor enum, which you want be able to get the team name. And a display of the team, but that display must setted on a config file. Theere you a clarify example of what i mean and you need a config object from main class. How would that apply there?
ive never used packets before so
it's not supposed to be an enum
and why did you start doing it now?
because im changing vanilla mining speed
and why don't you use the API for the block damage?
What should be? Because if it's a class i would need config reference but also that class shouldnt he initialized
this is the only way ive seen it done before
declaration: package: org.bukkit.entity, interface: Player
somePlayer.sendBlockDamage(...)
just a normal class
Hey, I have a question, it's a little complicated but I need to ask so
anyone knows off the top of their head how does the output of Bukkit.getBukkitVersion() look like? i mean the format of the string, how it looks
But why you Will initialize a TeamColor ? Isn't uncommon or.i haven't seen it before?
Hi, im trying getting the .x() from nms to then use movePlayer but i can't find the class https://sourceb.in/pp6yIZK1RB
the version as in pom.xml
I've been using a slimeworld plugin to build a skyblock-like server, but somehow if I reload that world, then all plugins that calling block.getType() thing on chunkloadevent cause the server to freeze and mess everything up
thanks
1.19.4-R0.1-SNAPSHOT
PlayerMoveEvent?
Wouldn't it be absurd to initialize a TeamColor class for each color?
can't find which class?
Just because you need a config reference
event.getTo().getBlockX(); ?
.x() and the other ones
why would a TeamColor class need the main instance?
classes cannot be called x()
which classes is it unable to find?
you don't need to have class instance if you just need config
you can use static util class
movePlayer and im using reflection
locX?
To.get the config reference, so them the enum has a property called displayed, which returns they display vía config
are you getting an exception, or what's the issue? I dont get it
but which information would a TeamColor object hold besides r,g,b?
im trying getting that class but when i try get the class after getHandle and its x i can't get it because .getMethod doesn't work
i am the cafe cat
and how the hell does the constructor look that it doesnt just take those values?
looks like the grindr logo
?notworking
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.
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
Oh please save me 🙏🙏. I have been around 30m trying to explain what I'm referencing. But i dont self explain or I'm not getting response apropiate to my question
we are one and the same
would be more helpful if you'd show actual code, e.g. your TeamColor class
Right I'm Will type it and send it
?nocode
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
I'm on cellphone that why it's really diffxoult
stop

pls
its without stack trace, its directly in ide,
getEntityPlayer(player).x().getPlayerChunkMap().movePlayer(((CraftPlayer) player).getHandle());
but getting with .getMethod("x") is not possible and that's my question
What ?
x() is a function/method
so how can i get it, with reflection
the IDE will definitely have a more appropriate message instead of "is not possible"
Well the problem is How you are trying to use NMS first then?
idk it's very hard to talk to you as all you say is always "not working", "not possible", but never show any screenshot or actual error message @grizzled oasis
Since x() is an obfuscated name for a function
You are trying to call getMethod on something that isn't Class<T>, of course it wouldn't work
I'm not sure why it needs a config reference. Why can't it pass in the values that were fetched from the config?
If I understood right
He Is calling obfusxated code directly without remaps
TeamColor(String displayName)
If you are trying to use reflection, you also need to pass in the instance of that entity player so, to note that you are trying to get that function, and you need to get the class of it first, do: entityplayer.getClass().getMethod("x", entityplayer)
mona cat
why the heck would anyone use reflection for NMS in the first place?
it changes names on every version
In the days of yore, my friend
Well that's why I asked that first of all
https://sourceb.in/hzQVSJufGZ so should be in this way
1.8 plugins, not like they need to be updated.
or have people finally stopped playing that version?
Could you paste the small part of it here? I'm living in 2nd restricted country, I can't open that site
He Is coding in 1.8 to start, where remaps doesn't exists. So you have to calle.dirextly obfusxated method
people stopped playing 1.8 a long time ago, there's only like 5% of servers left using that version
hypixel is quite significant i might mention
Well I think hypixel is non-existent
they on 1.12 now?
hypixel doesnt even use 1.8
I mean dont point the versión iif Is he using he has reason. We are free to help. If not it better to rest
https://paste.md-5.net/qakosenigu.java with md5 paste is ok?
Oh right they are 1.7
I have a devious use of reflection by the way. There's a server host my work is using that doesn't allow changing the "command-blocks-enabled" option in server.properties, but we need them enabled for the map that's being used. So I made this. https://paste.md-5.net/fojeqejoyi.java
Realizing only now that I have no idea why the Field instance is a field
That also didn't work for me sorry 💀
what kind of host is that? lol
time to make a pr?
xD
Probably tbh
We'd just need a more general server properties API because we really do not have one
also true
I really get upset why people only point the versión if you code on 1.8, Is because people has reason. But if you wont help just rest Is better
why are you still trying to use reflection instead of just doing myPlayerObject.actualMethodName() ?
Because they are minecraft-server packets. Which dont have methods public if un not wrong
whut?
because i want make something work in multi version without making my jar 10x times bigger
you can't
you literally even say "method x()"
it's called y() in the next verison
or a2()
Yes you cant
Try using remapped jar
mojang maps exist so you can use the same code for all versions
And modules
instead you do the opposite and write a class that only works in one version and even needs reflection
ok where i can find them?
CraftServer specific if I'm not wrong. Some of them are not with public modifier. So you have no other way rather acess them vía reflection
?nms
Are there remapped jars for < 1.16?
?nms
no
There is
good reason to ditch those old versions
MCP ones
So if you Will code on < 1.16, up better way Is protocol library. Instead of plain NMS working
No
Never
protocol lib is the worst pain ever
Using NMS itself is way better than plib
^
Just force players into newer versions of the game, or is there an actual reason to stay in previous versions?
there is not a single reason
It seems I haven't checked mutuals with you lmao
I mean isn't More hard, you have to self reflect the craft server things, etc
Till now💀
No
I dicuss that some weeks algo with mfalex and son others
Just use Netty and NMS functions itself
what is protocol sranding
oh
wrong reply
stsnding?
Standard you mean
protocol standar?
What
But even that makes little sense. You mean protocol API?
Yes protocol has a standar which means that they must use Protobuf for better usage and.impl
erm whut
No, protocol is object oriented in Minecraft base itself
Main.reason why sucks woring over the protocol
today, I dont understand a single word verano tries to say
Buffers are such mess
The only thing is perhaps the LEB128 encoding but even those are relatively easy to encode/decode by your own
You have to self decode it, use shity var ints longs, etc. While with Protobuf you sor over the model.proto
Bruh
It's the way how Netty works
Then you understood more of him than i did in the past
actually you only need that if you use protocollib
Yes but by using such magic files the software becomes far harder to understand than normally
Same with services
Yes i mean that Geol, exactly that. Working with MC.protocol Is like repairing a 2023 car piece, just buy a new piece
sometimes I understand two to three words
yeah with protobuf you just "sor over the model.proto"
erm whut
fr verano can you pls at least try to create proper sentences lol
You then have Stacktraces that are a bazillion lines long and it becomes difficult to figure out what exactly is missing
So no, Protobuf's *.proto files are NOT the way forward
Honestly I didn't understood too
Ok but literally nobody works with the buffered bytes. Nobody.
You have plain, simple java classes to work with.
^^
well verano hasn't, he uses protocollib and so has to do getLongs(), setInt(...) etc lol
Even then, you rarely want to directly operate on the network (unless you use plugin messaging channels but there you are free to set your own encoding)
ProtocolLib also simply wraps the classes. They dont actually write bytes into the encoded packets.
You mean, cLEaNeR code?
That why most protocol sucks. Same to those people who dont make approach of AI as an example. Ifnew things are here should be used
LOL
I have the feeling you don't know what you are talking about
fun fact @sterile token , even if mojang would use protobuf or whatever you suggest, you would never be able to use it because they definitely won't add it to 1.8 lol
Something Mooore, mAnAGaeBle
Maybe i.mean i dont know ecerything
lmao
If you want to send data through TCP over IP then you need to create a higher level protocol
so that bytes can be encoded, sent and decoded again. There is no other way to transfer data.
Smh, just use UDP
Yes there is
Or use that Appletalk protocol
for real, protocollib is like 20 lines compared to one in NMS
Send them through netfilter kernel, you have to also specify the TCP header
My real time game is running on API calls 🙃
Oh right im really interested on the topic about data synchronization and protocols
Thats just TCP with extra steps. You still need a protocol > level 4
to define how the frames are interpreted
20 lines? Bro I wish if the pain is just in lines, you have to specify the indexes too
yes and then even count that per type
new NMSPacket(100, "something", 50)
now in protocllib
getIntegers().get(0).set(100)
getStrings().get(0).set("something")
getIntegers().get(1).set(50)
lol for real who the fuck invented this "system"
protocollib is just a huge joke
What would you recommend me for joining and startimg around the data synchronization and protocols área?
They actually went back to monke
Those are two completely differen topics
i didnt understand the sentence at all
there is no right answer, its situational. And you are not gonna find that answer here, its not specific to spigot.
\o Hello ppl
I have come here yet again to seek your guidance!
Is there any way to store data into PersistentDataStorage without namespace
So the key would not be namespace:key but only key ?
no
why would you want to do that?
Even tho best anticheat use that library, like intave
I mean i know that, but it's general programming.
well vanilla does not have every key in NBT start with "minecraft" does it
Yes it does
also vanilla is not a plugin
vanilla knows exactly which keys it uses. you, as a plugin dev, have no clue which other plugins an admin installs
and hence we have namespacedkeys
You need namespaces or else other plugins can simply overwrite your keys by accident
I only use my own plugins, so i don't have that problem :)
imagine another plugin also wants to use "key". now your data is gone, good bye
Talking about recipes for example. Everything that is registry backed has a minecraft namespace.
Right so far I'm not sure exactly what to choose. I'm mainly interested on networking área (creating protocols, dealing with data synchronization, communicatimg diferent langs, rest api, proxying, etc)
buy books
I understand why it was implemented but for example, trying to store a vector inside of a compound
The compound would use my plugin namespace but the key inside would be simple "x, y, z"
Cross application communication is usually done by a broker. Redis or RabbitMQ are two examples.
Providing data is often done with Rest or Apache Kafka.
Create a custom PDC type.
Then you can store a whole Vector as a value
Right, but to re check that clasifies as networking or not?
a compound? you mean a nested persistentdatacontainer?
why don't you just create a PDC type for the vector
yes, I am talking in NBT terms
just create a PersistentDataType<double[],Vector>
'cause that is pain
then you only need one key instead of 3
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/
Hello there is someone who would have tips for an import that is not found when I have the api? vice-president
This is the cleanest approach to serialization.
vice-president?
no sorry
are you using maven?
I have all the api but it has an import that I don't want
so dont use it?
"it has an import that I don't want" wdyn? o0
you can type out the package you want an object to be from before the type.
or can i post a screenshot?
I'm.not.the.omly.one.who.dont.explain.really.well
?img
Not verified? Upload screenshots here: https://prnt.sc/
It's hard to explain something well if you don't have a good understanding of it.
!verify
Usage: !verify <forums username>
Sorry mfalex, for pingimg cellphone app get bug and.doesnt allow uncheck the tagging thing
which is why new programmers have trouble asking questions
how can i get server tps?
!verify
Usage: !verify <forums username>
im in 1.19.2
!verifiy Julien0001
Newer Versions: Bukkit.getServerTPS()
If I'm not wrong
that does not exist
getServer().getTPS() ?
Or Server#getTPS
not in Spigot
that does not exist
oh
Oh my bad
I thoguht it was on spigot too
NMS 🔥🔥
Isn't with MinecraftServer ?
slughorn 
what?
that is fabric
MinecraftServer.getServer().recentTps
why do you keep suggesting non-existent methods
when I already sent the proper solution twice
yeah idk wouldnt it make sense to just check that whatever you suggest actually exists before just sending random non-existent methods lol
i mean you sent 3 different methods, none of those exist
:)
No need to be rude, I'm.not a machine whixy doesn't make errors
what's jnbt? is that a dependency you added?
didnt mean to be rude, I just wonder why you randomly spam things without checking whether it's actually correct lol
Do German accepts asylum for gay math students?
I always check stuff before sending, even if I'm sending my code because of some error I always check for typos and wrong stuff
jnbt-1.11.jar
if you have an asylum reason, sure lol
?
yeah obviously that import doesn't exist. just remove it?
'x()' has private access in 'net.minecraft.server.v1_16_R1.EntityLiving'
((org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer) player).getHandle().x().getPlayerChunkMap().movePlayer(((org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer) player).getHandle());
someone knows why? by the IDE
Maybe you need to change versions
Bro
Please
Use mappings
and I have to be the what?
it's private, you gotta make it public. what even is x()?
its pre moj maps so who knows
i know only x() has getPlayerChunkMap
whut
Get the declaredmethod first, then call setaccesible(true)
I have to replace with which version
what does movePlayer() actually do?
can you send me the link in private message please
what you mean?
move the player
What are you trying to do?
then why don't you just use spigot's teleport() method? o0
oh sorry moves the player smoother, its for an animation so this is why im using it
you need to get the class of entityplayer first
so do entityplayer.getClass() or net.minecraft.....EntityPlayer.class
then
check screaming sandles to figure out what x is and to see what the correct way to get itis
entity player is not a class? you mean Craft Player?
you need to get the private method, set it as accessible for the class that you are trying to call with, then call invoke()
ok lemme send code
reflection is pain to understand
im not using reflection rn, im using nms
i imported various nms
holy crap
dude
you see that getMethod?
or just the getClass thing?
that's called java's reflection
or check screaming sandles and check if you can do it without reflection
hm no, x() in 1.16.1 returns the ChatVisiblity
wtf?
how can i see what they do?
that's in ServerPlayer / 1.16.1
but they had a lower case x()
but that's for killing not for getting the Player Chunk
lower case x() on LivingEntity is a void and it's "updateSwimAmount()" lol
oh true
what you are going to do with PlayerChunkMap?
use movePlayer, thats smoother than doing teleport
its a complex class, used for tracking entities
bro
or
lemme check
for a sec
where?
you can most likely do that without nms but some complex-ish math
| Mojang | Obfuscated |
|------------------------------|-----------------------------------------|
| ChunkMap#move(ServerPlayer) | PlayerChunkMap#movePlayer(EntityPlayer) |
| ServerPlayer#getLevel() | EntityPlayer#getWorldServer() |
| ServerLevel#getChunkSource() | WorldServer#getChunkProvider() |
| ServerChunkCache#chunkMap | ChunkProviderServer#playerChunkMap |
these are the classes and methods names you need @grizzled oasis
Player -> get NMS player -> getLevel() -> getChunkSource() -> chunkMap -> move(...)
lol
i wonder what hat method even does though
I mean it only takes a player but no destination?
((CraftWorld) player.getWorld()).getHandle().getChunkSource().chunkMap.movePlayer
the player gets teleported, but then sends this that make look it smoother for some reason
more or less, you mixed mojang and obfuscated names
i don't think so, its the way to do it with mappings, or just nvm sry, its 1,16
it should either be getChunkProvider instead of getCHunkSource, or movePlayer should just be move
((CraftWorld) player.getWorld()).getHandle().getChunkProvider().playerChunkMap.move
Link for version ? please
just google jnbt
Hi, I have maybe some stupid question. Why I should use Maven or gradle? Im not using any of these just play java and everything is fine I guess? Sorry for stupid question new here.
imagine you put your project on github, now people have to manually add the spigot-api etc
if you use maven (or gradle), people just clone it from github and it's done
and it'll work with every IDE
easier to work in a team and manage dependencies.
and it can automatically shade dependencies, relocate them, etc etc
it also minimizes the effort other people need to put in for it to work
they can clone and go, maven/gradle handles getting the deps
if its an ide build system they need to go download all the jars then add it to the project
https://github.com/JEFF-Media-GbR/ChestSort/pull/7#issuecomment-477606546 this explains maven
not result
no UK
or iran?
Hmm thats sound like reason. Im using just plain java now because working on some private plugins for my server so its fine. Is better to start with maven or gradle? I know is mostly personal but I dont know any of these, so what is better for baginer?
Morlok8k/JNBT: JNBT: The Java NBT Library
imho maven is the easiest and most comfortable. here's a tiny guide on how to setup maven for a basic spigot project: https://blog.jeff-media.com/how-to-create-your-first-minecraft-plugin-using-the-spigot-api-and-maven/
i perfer using gradle 🔥
i need help solving a problem with my code, the custom items are supposed to get consumed 1 each click but instead 5 get consumed https://paste.md-5.net/ehexowanal.java
imo, not using maven is more comfortable for private projects
I thought so too, for a while
i would never NOT use maven again
Now I'd always use maven
Okey goanna take a look on that links thanks a lot!
np
once you realise all your dependencies get downloaded to your local repository you'll not worry about maven
You can probably easly move you project between divices and If u resintall your PC so.
depends on the project imo
build once and forever you will be offline
imho it's always easier
everyone is allowed to have their own opinions :)
please help, how to fix this
I need to set armor_stand y like player y
standloc.setY(player.getLocation().getY()) - doesn`t work
whats the issue
teleport the armorstand
that location object is just a cloned object of stand's position
why does this code make the armorstand explode when i right click while looking down?
https://paste.md-5.net/ilafowufak.cs
?arrowcode
because you call explode(a)
i call that many times in that code which explode are you talking about
add debugs to each and see
you are checking for entities on the y axis of the block you are looking at
Location standLoc = stand.getLocation();
standLoc.setY(player.getLocation().getY());
stand.teleport(standLoc)
try teleporting the armorstand
no shit alex. he is asking why the raytracing is triggered when facing down
so 0.4y is gonna be the block
not the block above
so there are no entities
so you call explode
what ?
they always call explode() if the raytrace is not null
and if they look down, it's obviously not null
I wonder why would anyone expect the raytrace result to NOT be not-null when looking at the ground
Cause of my filter duh
@tawny remnant read this (or this could be easier to understand: https://blog.jeff-media.com/avoiding-the-arrow-anti-pattern/)
yeah well you yourself that you call explode() all the time
i really don't get the question
you call explode() if rayTrace == null and if it's not null

then you wonder why it keeps exploding
https://paste.md-5.net/jivayefate.java this class looks unnecessarily long
The RayTraceResult is not null, so it explodes.
how is the raytrace triggered when there are not blocks around me
Yeah, all this logic needs to be transferred into another class
did you read the code
it's not
es
aqua = explode if raytrace is null
red = explode if raytrace is not null
bad naughty
btw what's the for loop for? you loop over a list, then add the elements to the same list, then you catch the ConcurrentModificationException that will arise from this, only to ignore it again then?
lol
or yea, nvm i watched that video, i think you need the eyeloc
that is the problem i didnt notice that
thank you
try player.getEyeLocation()
and i am not calling explode when raytracing is or isnt null
when it is null it checks for the entities around
and then explode
there will always be entities around
the armor stand that you just spawned will be there
Is the raytraceresult ever null tho?
yes
stop, but I have the same
then you need this?:
standLoc.setY(player.getLocation().getY() + player.getEyeHeight());
thanks. i made it
how can I detect it a player did a water mlg? there is no event for it
what is a water mlg?
you could track player's y-velocity per tick, if it's 0 but was negative before, then the player has landed, and if the player is standing in water, then they either fell in water or did the water bucket thing
if you want to be precise then track BlockPlaceEvent and see if it's water, then combine it with the velo check
where you're falling and you place a water bucket under yourself to cancel fall dmg
cause its not that easy to do
yeah anyway, just listen to PlayerBUcketEmptyEvent, check if the placed block is Y below player's Y and if the X and Z coords are the same as the player's, or close, and if the player has a negative Y velocity
and "mlg" is short for "not that easy to do"? lol i dont get it
is it okay to do this? java public void addAttacker(User user) { if (allAttackers.contains(user) || this == user) return; allAttackers.add(user); }
the this == user part
major league gaming?
since it's much faster and avoids having to look through the list everytime
other people will trigger it more than the user
MLG is short for Major League Gaming and in Minecraft it refers to a set of survival tactics that can be used while playing the game in survival mode. There are multiple MLG tactics that can be used to prevent the player from the impact of a fall while playing the game in survival mode.
^^what google says^^
wtf lol
ok
nbl is thing
oh
why on earth do so many people, including the weird "mc-dev" ij plugin, disable the dependency reduced pom
that's just stupid
we dont need it
"im new to plugin dev, wtf is tthis file? should i delete it do i need to change it 1111111111111"
I never understood those people lol
also people who always wanna remove the test directory
maybe they don't want the test dir?
adhd?
gradle probably too
I'd be more upset if it was gone and then think "wtf this project is messed up"
ofc it is but it hurts to see it being gone
Maven does not regenerates it afaik
nope
it doesnt
https://paste.md-5.net/qitapuqiso.php can't decide whether to return null or throw an exception at the end
i guess exception makes more sense since it's never supposed to happen
ok IllegalStateException it is
your code doesnt match the exception
there is nothing in line 69
click it again my bad sorry
This usually happens when your vectors length is 0 or sth. Im only on the phone rn so cant properly look at the code
hmm modifying generated code is fun
when you come to the conclusion that it dissappears when you rebuild the project
what is generated code
so I'm trying out ACF for the first time
and I'm really confused on how function parameters work
if the first parameter is commandsender or player is that always the player who ran the command
could be console
yes
what happens if I use player as the first parameter and then someone tries to use the command from the console
will they get an error saying that only players can use it?
you can decide that for yourself
i can?
if you are talking about ACF, can;t tell you
@Default
public void doSth(Player player) // This is a player-only command. player arg is the sender
@Default
public void doSth(CommandSender sender) // Works for console too
it also shows "This can only be ran by players" automatically
it can even use localized messages etc, or even per player locales
so in this case would it use the top one unless its the console or a command block
and then call the bottom one
omg this is super helpful
thank you so much
you use CommandSender if you wanna allow both players and console
right i was just talking about the example you sent above
or you were just trying to show both options
you can also use two separate methods, as above, if you want it to do different things based on whether it's a player or not that ran this
i understand
oh
that's so cool
okay thank you so much
yeah and that's just the beginning. ACF is indeed amazing :3
I've been using it for years now and never looked back lol
There is some easy way to do this: is the player looking at the mob?
List<Entity> nearbyE = plugin.player.getNearbyEntities(plugin.range,
plugin.range, plugin.range);
ArrayList<LivingEntity> livingE = new ArrayList<LivingEntity>();
for (Entity e : nearbyE) {
if (e instanceof LivingEntity) {
livingE.add((LivingEntity) e);
}
}
plugin.target = null;
BlockIterator bItr = new BlockIterator(plugin.player, plugin.range);
Block block;
Location loc;
int bx, by, bz;
double ex, ey, ez;
// loop through player's line of sight
while (bItr.hasNext()) {
block = bItr.next();
bx = block.getX();
by = block.getY();
bz = block.getZ();
// check for entities near this block in the line of sight
for (LivingEntity e : livingE) {
loc = e.getLocation();
ex = loc.getX();
ey = loc.getY();
ez = loc.getZ();
if ((bx-.75 <= ex && ex <= bx+1.75) && (bz-.75 <= ez && ez <= bz+1.75) && (by-1 <= ey && ey <= by+2.5)) {
// entity is close enough, set target and stop
plugin.target = e;
break;
}
}
}
}``` found this but it works weird
just raytrace
and how to use it on an entity?
public static boolean isPlayerLookingAtMob(Player player, Entity entity, double maxDistance, double raySize) {
RayTraceResult result = player.getWorld().rayTraceEntities(player.getEyeLocation(), player.getEyeLocation().getDirection(), maxDistance, raySize, e -> e.equals(entity));
return result != null;
}
haven't tried but should work
you want to write your own command API?
ACF can do basically anything, so I'd take a look at that
Ye
Oki, I'm just having a hard time looking for the look
Like annotation based probably
if I need to get Entity, i need to check it for null and result.getHitEntity()?
what exactly do you wanna do? get the entity the player is looking at? or check whether the player looks at a specific entity?
is the player looking at the entity, if so, you will recognize it.
public static Entity getEntityPlayerIsLookingAt(Player player, double maxDistance, double raySize) {
RayTraceResult result = player.getWorld().rayTraceEntities(player.getEyeLocation(), player.getEyeLocation().getDirection(), maxDistance, raySize, e -> !e.equals(player));
return result == null ? null : result.getHitEntity();
}
this gets the entity a player is looking at. If you want to filter it more (e.g. only specific entities), change the Predicate<Entity> part (the lambda in the raytraceEntities)
error and class don't match up
there's an NPE in line 63 but your line 63 is empty
compile it again, restart server, then again send code and the new error msg
Do you know if Multiverse interfere with code for tp or something like that. cuz i try to create a plugin for play with friend i have 3 world : 1 hub and 2 arena. and when i try to tp to arena there is a erreur like : can’t tp in the world / world does not exist.
KoTHPlugin.java:63
exactly
your error does not match your code
you have either given us old code or an old error
we can't help if your error does not match your code
Show us the code that made the errror
Not a different code
Show us KothPlugin.java
@scenic sand
Show me your config.yml
@scenic sand
Sorry i meant plugin.yml*
Objects.requireNonNull(getCommand("me")).setExecutor(new KothCommand());
Yes
Ellar was correct
In your setupCommands you are trying to register “me” and not “kott”
The requireNonNull is redundant
Yes
public void setItem() {
ItemStack suggestionItem = new ItemStack(Material.valueOf(plugin.getConfig().getString("suggestion-item")));
ItemMeta suggestionMeta = suggestionItem.getItemMeta();
// setting status by color
setShowStatus();
// setup suggestion item
setItemName(suggestionItem);
setItemLore(suggestionItem);
// --- item data
suggestionMeta.getPersistentDataContainer().set(suggestionItemKey, PersistentDataType.STRING, String.valueOf(this.suggestionID));
suggestionItem.setItemMeta(suggestionMeta);
this.item = suggestionItem;
plugin.getLogger().info("Created suggestion item for suggestion #" + this.suggestionID);
plugin.getLogger().info("Item name: " + this.item.getItemMeta().getDisplayName());
}
public void setItemName(ItemStack item) {
OfflinePlayer ownerUser = Bukkit.getOfflinePlayer(UUID.fromString(this.owner));
ItemMeta itemMeta = item.getItemMeta();
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("suggestion-item-name")
.replace("{sender}", ownerUser.getName())
.replace("{id}", String.valueOf(this.suggestionID))
.replace("{status}", this.showStatus)
));
item.setItemMeta(itemMeta);
}
when I grab this.item and put it in a menu, its a plain item with no display name or lore
Don’t get the meta before running your set methods @misty ingot
This is unrelated to those two files.
either do what jantuck said or pass the meta about instead
im going to just get meta before setting the PDC instead
i didnt know that was a thing
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
ok it works now
why are you deleteing your messages
You’re doing a poor job at it. Write it in one message.
Situation: What are doing?
Expectation: What was expected?
Issue: What actually happened?
Debug before asking for help @scenic sand
jeez
?
@remote swallow i also added a system so admins can just straight up ban certain people from making suggestions (with reasons, time <optional> and unbans ofc)
you should do that
just because
i blame autism
no im autistic
all I need to make now is the system to view suggestions, their info, settings, actually use settings, do comments, votes, etc
ima do it after a brief hypixel skyblock session
it wont take long
i just need to grind dungeons first
another couple of hours and this is done
i dont write quickly
how do i see dat
wakatime
whats your WPM
like 110
accuracy?
give me 2 min
im slow
smh
most of the fuckups are the spacebar not working
this is better
well i have 120 with consistent 100% (on my good keyboard, not the laptop one)
there isnt a big difference
i can write quick enough to respond to people
my spelling dies sometimes
from how i type i think i dont rpess my space bar enough
holon actually i havent tried on my laptop in a while
then press it too early and fuck upo
ima do a couple runs
i cannot type on laptops
i have a non-butterfly keyboard on the lappy
im too used to mechanical keyboard
I also love my mechanical keyboard but sometimes you gotta use the lappy
also i dont have the space for my hands
like i need the drop from my fingers and the keyboard height
like if their the same level my speed is gone
how many fingers do you use
all but my pinkies
2 or 3 depending on the tightness
and sometimes my ring finger
ok nevermind i lied
my left pinky is for shit + control
thumbs handle space bar
right pinky for entry and right shift
ring finger for backspace
rest do the typing
left thumb is space bar, both indexes cover the entire keyboard and left pinky is for shift and control
i also use my palm for controlls
learn to use all fingers
it gets a bit easier
eh
i used to just use index fingers
bc i still looked down but was quick
then slowly i would remember where keys were
using 3 out of 5 fingers is pretty good for now
I never look down
ever
i have muscle memory of the position of every single key (except numpad cuz who even uses that)
yeah
numbers fuck my speed
puncuation fucks my speed
apostrophes are fine
sometimes
im good with numbers too as long as its from the top row and not the numpad
i cant do numbers on either
i went from <70 WPM and trash accuracy to 120+ with 100% in 2 years cuz i type so. fucking. much.
i dont have a numpad so cant do that either
make a claim plugin
you can make a simple administration plugin
add administration / utility commands for admins
make it easier for them to manage players
no
there are only about 10000 admin plugins so yeah
ban / unban / history / info / etc
they want to learn
want a maths challenge?
make a cosmetics plugin with multiple styles of moving particle cosmetics all on your own (for the math part)
98^3 + 853 - 12
john maths
it means 98x98x98 + 853 - 12
I mean I have yet to actually use them since for the plugin I am working with rn I already had made my own Item thingy
anyways, if you want to make a plugin to learn stuff, make some minigame thing
i think he meant my message @remote swallow
oh
copy some popular game or movie and make it into minecraft
oh morice do ur builds have component suport
or whatever
why
it doesnt sound fun
I am actually thinking of a custom armor / enchants / tools plugin as my first paid plugin
a very good one
i have a base idea planned out
nms is fine with remapped if you can find stuff
nbt is fucking painful
builders to what
ah
Hi , sorry how to fix the trouble ? because my health is not changes !
with no errors
Hello so basically I have special cases for smithing where there is no recipe registered to the game due to the fact i need the recipe to only only compare model id and item material so i use event.setResult but the issue is it does set the result but i can't grab it from the result box for some reason
did you even register that listener called "plugin"?
Was wondering if anyone knows why
- Your Listener should have a proper name, e.g. "RespawnListener"
- The method should have a proper name, e.g. "onRespawn(...)"
- You need a main class, do you even have one? Is that one actually called Untitled1? It should be called different, obviously
- In your main class, you need to register your listener. Did you do that?
in your onEnable() method (main class of your plugin):
getServer().getPluginManager().registerEvents(new plugin(), this);
Just starting using Maven and I have some warning here. Previously I was using java 17SE. If I change 1.8 java setting in maven to 1.17 I'm getting error.
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- The Java version used to compile the plugin. I suggest to use 1.8 because many servers are still using Java 8. -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>```
whats your ide?
if its idea then, try changing the jdk in project structure
Eclips xD
ok so
there might be an option for that
Its just better use that old java?
No I dont think so. But If I changed that number from 1.8 to 1.17 there is error during building .jar file so xD
maybe try searching the error?
I just already try google it but still cant get rid of warning. If I just leav as is it that works but that warning is annoying.
i know this
try just doing player.sendMessage in your event to make sure that you are listening on the right event
is right because when i respawn message is sended
so just try doing this after some kind of delay?
use bukkit scheduler
you also need to pass in your plugin's instance
How can i use autocraft(clicking recipe in craftbook) with custom items(with changed meta).
For example i have potion and i set it as ingredient with new RecipeChoice.ExactChoice(potion), but when i click recipe, only 'Material' items are placed
i think i can write custom ReceiptChoice, but maybe someone knows better solution?
Why isn't the corpse spawning?
CODE: https://pastebin.com/mgd1UMkj
CLIP: https://i.imgur.com/5WeIYBo.mp4
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
what would be the best approach to saving inventory layouts
im incredibly confused at how to add custom brewing recipes, i couldnt understand none of the information ive found online, if you could help me and explain how it works itd be much appreciated
What version is this for?
What do you mean by that?
For GUIs?
it is for 1.17
Then dont use obfuscated nms...
inventory loadouts, for my minigame lol
Is there a not obfuscated nms version for 1.17?
?nms
Mojangs mappings a public and spigot uses them
um what
reload maven or gradle
Then the layout shouldnt matter.
Just store the ItemStack[] which contains the content of you loadouts
And after i done it i should get all the methods like 1.16 right?
uh
didn't fix it? Here's my method
@Override
public <T, V extends Comparable<? super T>> TreeMap<T, V> sortValue(Map<T, V> map) {
if (map == null)
return null;
Comparator<Map.Entry<Object, V>> valueComparator = Map.Entry.comparingByValue().reversed();
TreeMap<T, V> sorted = map.entrySet().stream()
.sorted(valueComparator)
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
(e1, e2) -> e1, TreeMap::new));
return sorted;
}```
players can save their own loadouts for themselves
is that still gonna work with that solution
line 6
Yes. Dont save the whole inventory. Only the loadout items.
sortKey is fine?
the whole inventory is the loadout
at the start of every game they are given the inventory and i want them to be able to customize the order of the items
Why downcast to <Object, V> ??
You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
Becomes:
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
yeah
@Override
public <T, V extends Comparable<? super T>> TreeMap<T, V> sortValue(Map<T, V> map) {
if (map == null)
return null;
Comparator<Map.Entry<T, V>> valueComparator = Map.Entry.comparingByValue().reversed();
TreeMap<T, V> sorted = map.entrySet().stream()
.sorted(valueComparator)
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
(e1, e2) -> e1, TreeMap::new));
return sorted;
}```
How can i fix this error? Could not find artifact org.spigotmc:spigot:jar:remapped-mojang:1.17.1-R0.1-SNAPSHOT in spigotmc-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/)
Run buildtools with --rev 1.17.1 --remapped
Why is you value a comparable of your key??
because i wanna sort by value in this method
?nms
!paste
?paste
whole class: https://paste.md-5.net/ifuvewutov.java
public <T, V extends Comparable<V>> TreeMap<T, V> sortByValue(Map<T, V> map) {
if (map == null) {
return null;
}
Comparator<Map.Entry<T, V>> valueComparator = Map.Entry.<T, V>comparingByValue().reversed();
TreeMap<T, V> sorted = map.entrySet().stream()
.sorted(valueComparator)
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
(e1, e2) -> e1, TreeMap::new));
return sorted;
}
You need to explicitly define a type for comparingByValue()
ah i see
lines 266 to 282 arent working as expected (giving every effect and adding duration each time the item is used) after i added lines 266, 269, 270 (the item is now unusable) why can that be? https://paste.md-5.net/mazimuyeyi.java
uh how would i do the inventory thing
^
Hey what's the easiest way to change a player nametag to a string that I already have?
looking to do this basically
😭
I have protocollib added to my project but i don't know how to use it to change nametags :/
Hello there, somebody know what's my mistake? I created a file for an abstract command and then created a command, but when I check, it says that the command is null, what should I do?
AbstractCommand.java:
public AbstractCommand(String command){
System.out.println(command);
PluginCommand myCommand = Meditation.getInstance().getCommand(command);
if (myCommand != null) {
myCommand.setExecutor(this);
System.out.println("won");
}
System.out.println(myCommand);
}
public abstract void execute(CommandSender sender, String label, String[] args);
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
execute(sender, label, args);
return true;
}"
ReloadCommand.java:
public ReloadCommand() {
super("reload");
}
@Override
public void execute(CommandSender sender, String label, String[] args) {
}
Is it added inside of your plugin.yml?
Yeah
And that's what MainJavaClass looks like
private static Meditation instance;
@Override
public void onEnable() {
instance = this;
new ReloadCommand();
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
public static Meditation getInstance(){
return instance;
}
if getCommand returns null, it's definitely not in your plugin.yml
Would it be easier to use an API like NameTagEdit to change player name tags?
It feels like I have tried everything and I haven't found a way to get it working
you sould use this code on you ONENABLE
getCommand("TEST").setExecutor(new TESTCOMMANDCLASS());
public void ONENABLE()
Public static final void ONENABLE
public void onEnable() {
thats exactly what they have
well the original code had the formatting right
Executor is set inside of Reload Command constructor
are you saying to remove the @Override?
yes true
This is what I want to get rid of, I could use this method, but I want to create a separate abstract class for all the commands
and what's the advantage of removing the annotation?
that then breaks the entire startup
and Impliment : java.lang.Override
???
you have no idea what your talking about, dont give support if you have 0 idea what your talking about
very useful erm... "advices" lol
😂
Tbh I don't find it funny
Yk whats funny
My segue to the sponsor segment!
Trying to use NameTagEdit API but I'm getting this error, any ideas?
Do you have that plugin on your server?
yeah i do
Have you added it as depends in plugin yml
ah no, how do i do that?
It may be that nametag loads after your plugin
