#help-development
1 messages Β· Page 902 of 1
Clear the caches
I see "common" as a popular module name, but should I do the same in my packages for a non modular project
How would that look in json
JsonArray
You are probably referring to JsonArray ^
No, set of objects inside of an object
JsonArray
I think
Congrats you've just described what a JsonArray does!
Yeah, that is JsonArray
ok thanks then
np
I thought JsonArray was a list of JsonObjects not JsonElements
it's an array of any json element
could be an object
could be another array
could be a mixture of many element kinds, it doesn't have to be of one type
It could be another list with an object
hi guys
worked thanks
im trying to create a server using the build tools but i keep getting a SocketExceptions message
can somebody help me?
Show the error in full please
?paste
Anyone have an opinion
Ok now how would I add the JsonArray I made to a json object
cant send ss
. Add
Does anyone know how to go to a new line after every line of lore when using a variable that isn't a fixed amount of lines? When using \n the next line just doesn't show
I tried finding the solution in this discord & with chatgpt, below is everything I tried but I don't think I understood it right so nothing worked.
List<String> loreList = new ArrayList<>();
//logic to add lines of lore
//what I tried
List<String> loreLines = Arrays.asList(loreList.toString().split("\n"));
meta.setLore(Arrays.asList(loreLines.toString()));
item.setItemMeta(meta);
//also tried this
StringBuilder stringBuilder = new StringBuilder();
for (String loreLine : loreList) {
stringBuilder.append(loreLine).append("\n");
}
meta.setLore(Arrays.asList(stringBuilder.toString()));
item.setItemMeta(meta);```
Read the parameter types
see those suggestions, doesnt allow JsonArray
chatgpt π
?paste
jsonarray extends jsonelement
Well it's OOP
Ok thx
ok
?paste
bruh press the save button then copy the link in your address bar
but aside from that, am i going the right way?
@zinc moat @zinc moat
Anyone got something about this
bro coded the whole plugin for me π
add ""
i've tested it and it works fine. some stuff isn't the prettiest, for example maybe you could define the namespacedkey only once globally. i've left it out for simplicity.
you're internet sucks seems to be the issue here
The hidden backdoor: π₯°
solution is to get better internet or go somewhere where there is good internet
was looking at oracles documentation for naming conventions to get how member variables are to be named and found a doc of 11 pages
I know a guy who once backdoored a server by injecting malicious code in the gradle-wrapper.jar
And it worked
i knew a guuuuuy who got his haaair cut shoooort
I dont think thats the problem, i dont have bad internet
@zinc moat
@bleak eagle how do i fix this again?
than minecraft.net is blocked in your country
repair ide
you can't just open my code
it's for reading
that's where the resources are from
i didn't include a pom.xml or anything
so your ide doesn;t even know it's supposed to be a spigot plugin
read the code and implement it inside your own plugin
we could've done some really fancy stuff with enumconverters and shit instead of defining the particle types you want by brute force but again i left it out for simplicity
once you understand the code you can implement it so that any particle type works without you having to have a huge switch statement
.valueOf(String)
alrigth
?jd-s
?
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html#addCustomChatCompletions(java.util.Collection)
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/server/TabCompleteEvent.html
declaration: package: org.bukkit.event.server, class: TabCompleteEvent
declaration: package: org.bukkit.entity, interface: Player
@inner mulch ^
is it possible to make another entity invisible? even on the forums some people are saying with nms its still impossible
okay, thank you but where is the tabcompletion part in the player interface?
Player#hideEntity()
according to the documentation yes
invisible for what purpose?
its a nametag
1.8.9 unforunately π’
where? I cannot find any methods in the interface
I assume like one of these, both doesn't work unfortunately π
stringBuilder.append(loreLine).append("");```
you are not on the latest version then
then setting the metadata isVisible should be sufficient then o.O
not sure why you would need nms for that
that can be done on enums? sure that's way better then
oh, well that is what you get with old software
if you like making it harder on yourself then so be it I guess
Ye
im getting paid to do it in 1.8
not our problem
I feel even less incentivised to help you
I want 10%
one day I won't have to worry about this
i want a cut too, for being a good listener
#1 thing to say to NOT get free help from people online
"yeah I'm getting paid tho"
π€·ββοΈ
getting paid to make something they don't know how to make on outdated software
sounds legit
i knew how to do it but i am following a diff way that 7smile7 suggested
meta.setLore(Arrays.asList(loreLines.toString())); that would set one line of lore
yeah but the problem is that I can't go to a new line cause \n doesn't work
dont use a stringbuilder, append to your list instead
listOf("line", "another one", "woo", "", "ooh")
yeah, i know how to get different lines of lore underneath eachother, but the problem is that my lore is within a variable that isn't of a fixed size, and I need to make splits within that variable, so I tried \n everytime I add something to that variable but that doesn't work
theres some form of a pageinator buit in somewhere
its like ChatPaginator or smth
hey guys, i'm trying to import the citizens api into my plugin, but i'm struggling. i've followed the tutorial on the citizens wiki, any idea what might go wrong?
It would be nice to see some code
or see anything actually
also, what exactly is going wrong
just create a list of it and add to your list?
yeah i was just waiting for a reply sorry bc i don't wanna spam chat. should i just paste the pom.xml into chat or is there a specific way i should do it?
It sounds like you're merging lists.
i'm using intellij and the dependency for citizensapi appears red and says "dependency not found".
yes
- did you reload maven?
- the scope of citizens should be "provided" not "compile"
ah ok, i'll reload maven and change that rq
thanks π
and what all are all these user.java.io ?
How can I add a dependency to a lib jar?
and why do you have com.github.nbbrd.java-io-util like 20 times in your pom?
what the heck is all that π
idk i've tried and failed at importing stuff ik i'll clean it up soon
yeah sorry it looks rly bad atm
When I append \n all the lore after that is just gone, and if I append "" it doesn't go to a new line
dont use a string builder
yeah i barely ever use dependencies bc i find them rly frustrating but now i have to so thanks for trynna help me guys π hope it works, just syncing now
oh my god i'm an idiot
wow im so stupid
ive been trying to add dependencies but i havent been reloading maven and syncing
ive literally spent like 10 or 20 hours overall trynna do this stuff
@tender shard @rough ibex thanks guys sorry i was being stupid but my code works now π tysm
np lol
Why not and what should I use instead?
your current lore looks like this
"line1",
"line2"
"line3\nline4"
"line5\nline6"
I had a list before but that didn't work so I changed it to a builder but I will change it back
oh
ItemStack stack = new ItemStack(Material.BARRIER);
ItemMeta meta = stack.getItemMeta();
List<String> lore = new ArrayList<>();
lore.add("Line 1");
lore.add("Line 2");
meta.setLore(lore);
stack.setItemMeta(meta);
``` and you send up with
Barrier
minecraft:barrier
Line 1
Line 2
A user of a plugin of mine tried to change the plugin's messages to cyryllic.
But it shows up like that
Does anyone know why?
is the file saved as UTF8? How do you load the file?
I don't do anything funny with it
BufferedReader
readLine
then you have to specify a charset
Is there a universal one?
And where do I specify it?
show your code to load the file
UTF8
import java.nio.charset.StandardCharsets;
//...
try (FileInputStream fis = new FileInputStream(file);
InputStreamReader isr = new InputStreamReader(fis, StandardCharsets.UTF_8);
BufferedReader reader = new BufferedReader(isr)
) {
String str;
while ((str = reader.readLine()) != null) {
System.out.println(str);
}
} catch (IOException e) {
e.printStackTrace();
}
for example like this ^
For all chars?
yeah
Thank you this worked π
Tis how I do it
but even better is utf8 aware system by default π€€
utf8 does not support all characters
you should be using try-with-resources or at least close the reader / etc properly
It's an old piece of code
Doesn't #close do it?
So
How do I make it read what's actually there?
in utf8, characters take 1,2,3,4 bytes(8,16,24,32 bits) to encode a character. With UTF-16 its either 2 or 4 bytes. (16, 32 bits) and utf32 always uses 32bits to encode a character
only if you know that the characters you are going to use will always take 32bits, IE chinese characters for example always do
and I think some emojis
it is standard, its part of UTF
the number after UTF is how many bits minimum it uses
I just want it to read the actual file contents
just use utf8
just use utf8
lmao


yeah what the two above said
And since it's for messages it could be any
But isn't that what java does for default when not specified
no
if (Bukkit.getServer().getPluginManager().getPlugin("CoreLib") == null) {
System.out.println(ChatColor.RED + "CoreLib dependency not found");
return;
}
So I what to add a dependency to my plugin with a jar, that code will able to check if the jar is in the plugins folder but, on the maven project how can I set the dependency on the pom.xml???
mvn install the other plugin and add the info
does any1 here know of good software to make a few hundred bots join my server?
for testing obviously
mine flayer
^^
I do
Well, technically yes
Mc bots
And mcstorm
specify it actively and be happy
You can use my AlixSystem antibot if you want
You mean the jar?
the project, im guessing both use maven
yes
just run the mvn install task and it will handle all the info
let me try
this?
top right it's like a little m
it adds it to maven local as well
you have to add that
I mean those a 3 separated maven projects but at the same folder
read the info at the top of the pom and add it to a dep
Each time I update the lib I need to change the dependency?
hmmm
it is interesting that suddenly recently people have issues with using maven
you would think by now there is plenty of info out there in using it
they are modules, and there is probably a parent pom for them
technically yes they are separate maven projects on their own
but if you use the parent pom, it should pull all of them up
or you can compile all of them using the parent pom
there is no parent pom
why block displays location isn't in it's center?
is it possible to cancel all the player events at once for one player or do i really neeed to go through every event and cacnel it for them?
is there any populair particle api?
there is no need for one
it exists in bukkit
but a guy got
i know
KISS, use as little external dependencies as you can
i'm sure there is some 'particle api' out there but there are many reasons as to why you shouldn't use dependencies for very simple things like that
you're counting on some random guy outside of your code maintaining it
you can cancel packets like I do https://github.com/ShadowOfHeaven-Me/AlixSystem/blob/master/src/shadow/utils/objects/packet/types/unverified/PacketBlocker.java
thank you :)
I setted it at dep but is not taking it
that's what java does
did you reload
and it ain't working
the ide?
maven
?paste the 2 poms
cuz it does this and then this
we love type erasure
whats that, and how do i get a capture of ?
epic ?
this can explain it better than i can https://www.reddit.com/r/learnjava/comments/8hsh6g/eli5_what_is_type_erasure/ for fixing it i have no clue thats above my knowledge atm
set the scope to provided and check that the install goal passed on the lib project
goal pass correctly
can i teleport a player on PlayerQuitEvent?
the event is triggered before the quit or after it?
now it works i fixed a thing
thanks
Called when a player leaves a server before or after? π€
No
only one way to find out
It only defaults to utf 8 if file.encoding isn't set
Which, your os might very well do
So if people run their shit with that set to anything but utf 8, Welp, explodr
i'll test it for you
thanks, i've a teleport code on my PlayerQuitEvent, it works sometimes
otherwise gives an error (i don't have any logs & erros rn)
it worked every single time for me
i'm pretty sure you can be certain it executes before
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event) {
Player player = event.getPlayer();
player.teleport(player.getWorld().getSpawnLocation());
}
this is the handler i used
thanks
hm is there a way to force a player to place a block
fuck it imma call bukkit events
im feeling angy
There is not a way to force this, no
Depends
I've considered it a few times but I think there was a reason why it wasn't possible
You can make it seem like the player tried to place a block
But you can't really physically force him
well
not necessarily force but call all the right events n stuff
or like get the block state, create a context n call the thing
but creatin a context is annoying as shit
You mean ChannelHandlerContext?
I think imma just call BlockPlaceEvent with a hacky injected block
BlockPlaceContext
Tf is that
Oh dear
I don't see why you would ever need to do that though?
A block is literally nothing more than a set of coordinates and a world
It's a glorified Location object
to call a BlockPlaceEvent and see if things worky
basically this idiot customer configured her "custom block" as a feather and feathers can't be placed
and they can't change it from a feather because stuff breaks idk im not an expert
so imma hack something in so they can place a feather
it's just hacking in a new block, calling the event for region checks n placing it
no big deal
just a pain in the ass
ez
I wonder if Location is final 
what if I extended the location class so location.getBlock returned the hacked block
it's not final let's go
And location is a glorified x y and z π¨
That means a block is just 3 numbers the truth is scary
Tmw you realize everything is just math.
I'm watching this series of a guy remaking a voxel game in an optimized way
It's very interesting
Is that the one by FinalForEach?
yeah
he's awesome can't wait to see what he does
hi, so I'm trying to make a task that runs basically every single living instant of a plugin, but anyways im trying to assign it to a variable known as scoreScheduler, now upon looking at the bukkit classfiles, it appears that this should work but it doesn't... can someone explain what im doing wrong?
https://imgur.com/a/XpWcJmK
the runTaskTimer variant that takes a Consumer yields void
as seen in your screenshot
replace task -> with () ->
β€οΈ
there is a way
it's fairly simple - find their address, pull up to their house and hold them at gunpoint telling them to place the block
Sadly no
Yeah thats pretty much it. Fire the BlockPlaceEvent and place a block according to the outcome.
for some reason working with remapped-mojang brings errors as soon as i try out commands and working without it makes my plugins work correctly
pom plox
Are you remapping your jar ^
wdym
?paste
PASTE YOUR POMMMMMMM 
Show your pom.xml
oh okay
in the link above please ^^^^^^^^^^^^
And tell us what steps you take in order to compile while you are at it
You are not using the special sources plugin which is needed to remap your jar
i just wanted server independent communication and ended up writing my whole ass own api... ```java
public class DataPackage implements Serializable
{
private static final long serialVersionUID = -5167300204896740582L;
protected PublicKey responseKey = null;
protected byte[] dataKey = null;
protected byte[] data = null;
<T> DataPackage(RSAEncrypter rsa, AESEncrypter aes, Serializer serializer, T data) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException
{
this.responseKey = rsa.getPublicKey();
this.dataKey = rsa.encrypt(serializer.serializeToBytes(aes.getSecretKey()));
this.data = aes.encrypt(serializer.serializeToBytes(data));
}
PublicKey getResponseKey()
{
return this.responseKey;
}
byte[] getDataKey()
{
return this.dataKey;
}
byte[] getData()
{
return this.data;
}
}
i feel like this is a crime
nvm, 2.0.2 works
didn't help much, i'm getting pretty much the same problem
How are you compiling?
with intellij i go to project structure, artifacts and there i put my jar output dir
then i build the project
you gotta compile with maven
if you compile with intellij it simply ignores your pom.xml configuration
OOOOOH
Alright, this will result in the pom to be completely ignored because you arent using maven.
When using maven you can only compile through the maven goals.
And never manually add any jars to your project when using maven. If you did -> remove them again.
After that: Click on your maven pannel and run package
You can sporadically run clean before package
does snake yaml support comments above objects
like this works, but it's because the comments are attached to the value node
not the actual key node "hi"
Pretty sure the updated one for recent versions does but for versions below 1.17 which uses the old snakeyaml version does not
im getting 4 jar outputs, which one should i use
the one without any suffixes*
Bukkit will attempt to fix it this time for you, but may not be able to do this every time.
If you see this message after typing a command from a plugin, please report this to the plugin developer, they should use the api instead of relying on reflection (and doing it the wrong way).```anyone know why im getting this
use the PlayerProfile API
public static ItemStack getSkull(String url) {
ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1, (short) 3);
if (url.isEmpty()) {
return head;
}
SkullMeta headMeta = (SkullMeta) head.getItemMeta();
GameProfile profile = new GameProfile(UUID.randomUUID(), "");
profile.getProperties().put("textures", new Property("textures", url));
Field profileField;
try {
profileField = headMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(headMeta, profile);
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException ignored) {
}
head.setItemMeta(headMeta);
return head;
}
}```thats what i use
yeah so, not that
check the methods in SkullMeta for working with PlayerProfile, Bukkit.creatrProfile etc
textures in the profile, properties and such
i didnt even make this system so
okay so after working it out abit more, im aware that serializing class instances and transmitting them via the internet is generally considered a vulnerability for arbitrary code execution, is this still a major concern when the serialized object is transmitted encrypted like this: ```java
public class DataPackage implements Serializable
{
private static final long serialVersionUID = -6766450200075478944L;
protected PublicKey responseKey = null;
protected byte[] dataKey = null;
protected byte[] data = null;
protected byte[] hash = null;
<T> DataPackage(RSAEncrypter rsa, AESEncrypter aes, Serializer serializer, T data) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException
{
this.responseKey = rsa.getPublicKey();
this.dataKey = rsa.encrypt(serializer.serializeToBytes(aes.getSecretKey()));
this.data = aes.encrypt(serializer.serializeToBytes(data));
this.hash = MessageDigest.getInstance("SHA-512").digest(serializer.serializeToBytes(data));
}
PublicKey getResponseKey()
{
return this.responseKey;
}
byte[] getDataKey()
{
return this.dataKey;
}
byte[] getData()
{
return this.data;
}
byte[] getHash()
{
return this.hash;
}
}
altough the package itself is not encrypted?
thank you guys very much btw @lost matrix @river oracle
Can I replace all villager pathfinders with my own in NMS or no?
is there a reason you need to use PLib?
i'm sorry?
by its UUID?
Why are you using Plib?
are we having an XY problem
is it just a packet entity?
if so you can't
you have to keep track of it on the server
then you will need to keep track of it
Late response but I'm working with snakeyml's objects
and I can't seem to attach a comment to a key
How does one implement vanilla-like enchants in 1.20+ ? I've seen other plugins are able to add vanilla-like enchants to minecraft and have them appear in the enchant table and work fine with the anvil.
have them appear in the anvil??
that's not even possible
@young knoll the lang files for enchantments are hard coded right I'm not going insane here?
declaration: package: org.bukkit.configuration, interface: ConfigurationSection
I said appear in the enchant table and work in the anvil
as if they were just another enchantment
work in the anvil would include displaying the lang files in my mind
I want to do something like this :l
There is a method for inline comments too
is there any existed way for it
either way you need to inject into the vanilla registry with NMS
The lang files are not hard coded
But enchantments are sent over the network by numeric id
I'm pretty sure they are you can't send the client new enchantment data
Sure but you can still change the names of enchantments
since the registries aren't synced it has no clue what your enchantment even is on the client regardless of the numeric ID system
what would be the class name for a strength or like health tipped arrow?
mmm that's what I meant i worded it poorly
Can I just intercept the packet then? and change the name of the enchant?
no
the client doesn't even know your enchantments exist
it can't interpret them in any capacity
can someone help me?
still the only way to add them is to use the vanilla registry, unfeeze it and register your enchantment
be patient
Or use PDC and events for the table and anvil
ok
Registry πͺ
doesn't that lead to a blank named enchant when the client attempts to see it?
Yes
yes, but that's something that is impossible to overcome
already been trying that, tis a pain
You can just manually add it to lore
But if it gets picked as the hint in an enchantment table itβll just appear blank
Just add it to the start of the list
the small price to pay for salvation
So in otherwords, adding an enchant to the registry is only good as a method for identifying the enchant on it
it's basically useless at displaying itself?
oh and adding the glow effect
yeppers π
christ on a stick, alright. Guess I'll have to get gud with the manual handling of anvil logic.
Thanks for the help o/
Guys, could you tell me how to make a lobby teleporting system in gui?
With spigot world loading api?
What?
likely they think every tipped arrow has its own class
when in reality its just a potioneffect lol
Yeah all tipped arrow items have PotionMeta and all the entities are just arrow
Wdym
Hello everyone! I am currently building a server with Mohist Bukkit and creating plugins.
When I modify the plugin, build it, and reload it, an error occurs. How should I resolve this?
where r the logs?
Furthermore, my plugin operates normally again after I turn off and restart the server.
Cannot find main class `org.server.silvergabi.Main'
well is that Main Class Path in plugin.yml correct?
yap
wait
https://www.youtube.com/watch?v=rgQBPDJVnD0
here is my issue video
# plugin.yml
name: SilverGabi
version: '${version}'
main: org.server.silvergabi.Main
api-version: '1.16'
commands:
νΈκ°λ:
description: "νΈκ°λ κ΄λ ¨ λͺ
λ Ήμ΄μ
λλ€." # sorry not english
depend:
- ItemsAdder
?fork
SpigotMC maintains the Spigot server. If you are using a fork of Spigot (such as Paper, Airplane, Purpur, or other derivative works), you should seek support in the appropriate Discord servers.
instead of reload the plugin by PlugMan
Mohist isn't support
Nor Is reloading
You can't expect stuff to work if you're using unsupported software and an unsupported feature
Oh, I See!
Reloading in general is just a stupid idea and not meant to be I'm sure if spigot could go back in time it wouldn't exist
Unfortunately time travel hasn't been invented yet
So we are stuck with /reload and whatever jank ass plugins people use to reload now adays
stop hiding the truth
I know you're a time traveller
"y2k" pft
π€£
Listen we can settle this one of two ways. Ima need you to delete this message or were gonna have big problems

watch out bro
lock your door this nightπ΅οΈββοΈ
message delete or Emily delete LOL
so thats how you put up with me
Nah I was gonna steal her sofa or something
I'd never hurt anyone
That's fucked up
you would definately beat me up
You think my scrawny ass could beat you up? Smh epic
I weigh less than a feather πͺΆ
ive been told im built like a paper clip
i ll steal your snacks, and all soda in the freezer...
you would try atleast
Itβs for anything with generics
Shhhh he is still pure
And has not been corrupted by the type erasure
yeah i didnt get a chance to do anything on it today so im still having some fun
does anyone know if it is possible to make beacons able to use other materials to activate them? Like quartz or something
I believe that's client-sided
Maybe you could packet spoof that in some way, idk
Is it? I would assume that a custom tile state works for this, as the server decides when to approve of the beacon being enabled.
does anyone happen to know which packet updates the armorstand head post rotation on a client?
isn't it supposed to be ClientboundSetEntityDataPacket?
Rotation is part of EntityData, yes
Its this hybrid pos+rot packet
hm
Since when
pos+rot is yaw/pitch
including the more specific armorstand rotations? because it's giving me a hard time
euler angles are in entity data
Ah he means specifically for the AS component
same for transformations on display entities
p sure you can use yaw+pitch on top of the quaternions
entity.setHeadPose(new Rotations((float) eulerAngle.getX(), (float) eulerAngle.getY(), (float) eulerAngle.getZ()));
sendPacket(createEntityDataPacket());
this snippet should be about right, right?
looks fine
hrm
bro just copied my code
nah man I added some sick methods
I changed the homework
light theme 
ok so why is this not updating hten
yep
Did you send the packet π
Then send some coderino
nope
Maybe some kind of entity update packet needs sent or chunk update? Pretty sure some update packet needs sent.
uHh
no
just like
debug stuff idk
There are a ton of things that could go wrong. For example: Is the entity ID correct
was just making sure I was addressing the right packet in the first place
I'm crashing from a 60 hour work week I really can't bother staring at code
I believe the client just refuses to send this packet if it's not one of the hardcoded items
Maybe with the new registry stuff we'll be able to change beacon items
Isnt that packet sent when the UI is clicked? Not sure if it even checks the underlying block state.
Doubt
but feel free to prove me wrong
We would first have to postulate a thesis before anyone can prove anything wrong...
Currently we are just guessing
fuck it time to hook protocollib
that's not officially updated to 1.20
Use display entities instead
I am going to
cool I don't have a test server with protocollib
am I tripping or something
No, bad illusion. Dont use prod for testing your stuff

I have a minigame network
where the prod servers are running plib
what if I spammed the console for a bit
wtf was I testing
This should be sent when messing with the beacon inventory. The underlying blocks below the beacon only control the strength and how many differing powers are available.
Watch it be some plugin swatting the packets away
not on this setup
they're all mine and this is the first time I'm doing stuff with packets
it looks like the packet is getting sent
I actually crashed my client exactly 3 times today
Send it 3 times, just to be sure 
the answer is no, I can't place and the packet doesn't get sent unless the button is actually clickable
Now, let's see if any inventory events fire
cool the inv click event fires
not going to lie this is the least fun way of developing this
now let's do a pro gamer move
all nms and packets are doing in a library that gets shaded in
so I have to clean and restart everything every time
hmm
wait... radian to degrees maybe?
noob
ayo boys
it's full async
and packet-based
so stop asking me to add that
now just missing using display entities
cool so @delicate obsidian @lost matrix Done some testing. While the slot is restricted in vanilla, it still fires the InventoryClickEvent
Unfortunately, if the item's not in the list, the button won't be marked as available
And it won't fire any confirm packets
I might be an idiot and need a bunch of iron blocks though
Ok yeah with iron blocks this works
cool
You'll still need to emulate all the slot functionality with the inventory click event
This is really cursed but achieves your goal so whatever
I might make a plugin for this 
You didnt implement a custom tile state to check if this enables the buttons
bedrock has display entities right
y u do dis
Β―_(γ)_/Β―
imma open source it
flex quality on cmarco or sumn idk
im just bored
Illusion is bored, quick, give him Spigot PR ideas!
I would like uhhh
You know the Events vanilla added, for sound and stuff ?
Ye that plz kthx
I don't do spigot forks
I said PR to spigot
(am I not understanding something here actually ?)
Not signing the CLA, not doing the whole patch process
Basically go bother someone else for spigot stuff
Aaah okok
Gotcha, sry :D
Its like actually really easy, if you dont need to touch internals its just adding classes or methods or you modify nms you just modify a java class and it makes the patch for you
What do static interfaces even do?
I don't suppose you've ever done display entity rotations via nms?
done it
I already showed you
yeah
uh
rotations are on the transform
idiot
hey I'm a man of laser focus, I was doing armorstands
I'm trying to make it so that the system scans for bedrock player automatically and serves either display entities or armor stand entities depending on that
fuck I gotta handle item merging
oh that's blockdata? pretty sure I have to look at itemdisplay for horse leather armor right
never used these before
what's up with having a left and a right rotation anyway
No clue
iirc it allows for something called "shear?"
" left rotation is applied before scaling and right rotation after scaling" says reddit
https://paste.md-5.net/edevacezor.bash - will the CLOSE section be ignored if I do not fill in its value?
are display entities like armor stands in that it's a different packet to show items on the entity?
metadata yeah
well armorstands have equipment
metadata
that's this one right? ClientboundSetEntityDataPacket
probably
you're setting it on the nms entity right
with like a craft mirror
or whatever
noob
public void initializeModel(Location location, int modelID) {
Display.ItemDisplay itemDisplay = entity;
// itemDisplay.setInterpolationDelay(-1);
// itemDisplay.setInterpolationDuration(1);
org.bukkit.inventory.ItemStack itemStack = new org.bukkit.inventory.ItemStack(Material.LEATHER_HORSE_ARMOR);
LeatherArmorMeta itemMeta = (LeatherArmorMeta) itemStack.getItemMeta();
itemMeta.setCustomModelData(modelID);
itemMeta.setColor(Color.WHITE);
itemStack.setItemMeta(itemMeta);
leatherHorseArmor = CraftItemStack.asNMSCopy(itemStack);
itemDisplay.setItemStack( leatherHorseArmor);
Bukkit.getLogger().info("display item entity initialized");
//Actually useless, managed by the packet that sends equipment info
}
btw fun fact in 1.19.4 the methods commented out give a class missing error but exist in the decompiled code, don't even ask me
imports
or sumn
cool I need to do shift click logic now
this is a fucking pain in the ass
eh there's progress
there's something busted with this
you're prob just sending the wrong packet
basically the same thing runs for armorstands and that one works, all I did was remove the equipment packet
(and I tested it with that packet on too)
oh the plot thickens
I can see it on my test command
you're prob just doing something stupid
starting to think it might be the scaling adjustments I was doing for armorstands, going to have to retest that
one question: the formatting in spigot is all over the place
i've seen both
if ( condition )
{
System.out.println( condition );
}
and (in my opinion better and more standard)
if (condition) {
System.out.println(condition);
}
which one is actually preferred?
The first is primarily used if you have issues and just wanted to show that to everyone
For Java it is usually the second one
(Also, I've never seen if ( condition ) with the spaces)
I feel personally attacked
the entire builder class here, for example, has those weird spaces
i tried to follow it in my pr and work against my ide which prefers the second one
good
LOL
This one is commonly used https://google.github.io/styleguide/javaguide.html
I find it ugly, it wastes a lot of lines and thereby makes it more difficult to read
yeah same
i could do another pr to fix it though it might be deemed as unnecessary by md
That's likely, it could also break existing prs
Bungeecord is similarly formatted if i remember correctly
md himself probably writes that then
the funny thing is that Code Requirements in the craftbukkit readme propose sun/oracle coding standards, and those propose the second method without the weird spaces and line breaks
i'm assuming (at least that part of) the craftbukkit readme is kind of universal to all the other projects too
buildtools only has 3 active ones which will probably get merged or declined soon so i can snatch the chance to fix the formatting or at least part of it if no new ones pop up
is there any event that detects composter being filled?
I wanna create a plugin to increase the drop from composter
maybe there is one, but at the top of my head you could use a player interact event and get the target composted block to check if it's full or one stage from being full
1: C# style
2: Chad java style
ohh ye ok
though you must check if everything is okay before running any code since playerinteractevents will trigger even when clicking on it with an invalid item or empty hand
https://www.spigotmc.org/threads/player-compost-event.547470/ I found this forum post that could help you
to get the levels of a composter getBlockData() and cast it to Levelled and then getLevel() on that
ye alright thanks
second one definitely, Java official code conventions already says to use egyptian brackets
half the page is ripped, don't think thats a valid newline
feel bad for whatever teacher had to mark that chicken scratch
you forgot // Plugin shutdown logic
what kind of hieroglyphs did you use for the brackets there
β΄³β΅£β΅β΅β΅£β΅β΅β΅β΄΅β΅β΅β΅‘β΅β΄Άβ΅β΅β΅β΄Έβ΅β΅β΄΄β΅β΄Ίβ΅β΅β΄Ήβ΅β΅β΅β΅ β΅β΄³β΅§β΅β΅β΅β΄΄β΅β΅β΅β΄³β΄Όβ΅β΅β΄³β΅β΅β΅β΄·β΅β΅β΅β΄Ήβ΅ β΅β΄Ήβ΅£β΄²β΅β΄Άβ΅β΄Ύβ΅β΄°β΅β΄Ώβ΅β΅β΅β΅β΄Ώβ΅β΅β΅β΅β΅β΅β΄·β΅β΅β΅β΅β΅β΅β΅β΄±β΅β΅β΅β΅ β΅β΅β΅β΅β΅β΄±β΅β΅β΅β΅β΅β΅ β΅β΄½β΅β΅β΅β΄Ύβ΅β΄Έβ΅β΅β΄΅β΄²β΅β΄΅β΅β΅β΅β΄Ίβ΅β΅β΅β΅β΅β΅β΄΅β΅β΅β΅β΄»β΅β΅β΅β΅β΄Έβ΅β΅β΅β΄Έβ΅β΄³β΅β΅β΄Όβ΅β΅β΅β΄Ίβ΅ β΅β΅β΄Ώβ΅β΅β΅β΄½β΅β΅β΅β΅β΅β΄Ίβ΅β΄²β΅β΅
]
hm actually what do you guys think of isCompostable() api for Material
yay or nay / useful or useless
I could totally implement it in bukkit but I just don't know if it would ever get merged
yes but should be a double not boolean
it should return the "level up chance" i guess, where 0 is not compostable
why am i getting this error? https://pastebin.com/rZWpxwsJ
because you invoke "org.bukkit.inventory.ItemStack.getType()" although the return value of "org.bukkit.event.inventory.InventoryClickEvent.getCurrentItem()" is null
it what file
in line 27 of ReviveInventoryListener
those are on the wiki yah?
I think so - I'm using these values for my AutoComposter plugin but I don't remember where I got them from https://paste.md-5.net/efiwabaxul.makefile
Yes
well I already told you
you're calling getType() on the return value of event.getCurrentItem() even though event.getCurrentItem() returns null
how would i then do it?
check if event.getCurrentItem() returns null and if yes, do not call getType() on it
ItemStack currentItem = event.getCurrentItem();
if(currentItem != null) {
// Now check if currentItem.getType() is a player head
i have it so people cant take the items from the gui but i makes it so every gui i cant move stuff
even better, if you can do it in your case (didn't read the code), check if it IS null and then return early to keep it flatter
no he's also doing some else checks
kk
do you know why it does that?
this
because you call event.setCancelled(true)
but how can i make it so people dont take the items from the gui but can stille from crafting tables and their inv
by only calling event.setCancelled(true) if the inventory is your GUI
how?
like this ?
if (event.getView().getTitle().equalsIgnoreCase(ChatColor.AQUA + "Revive A Player"))
event.setCancelled(true)
you should rather identify your inventories by storing them in a set or sth
but yeah if you insist on using the title, then move the setCancelled into the if
how would i make the set
btw isnt that exactly the same?
new HashSet<>()
yeah it is
private Set<Inventory> myGuiInventories = new HashSet<>();
then when you create a GUI inventory, add it to the set. In InventoryCloseEvent, remove the inventories from the set again
then in InventoryClickEvent you can just check if the set contains the current inventory
if yes, it's your GUI
do i do that when creating the inventories?
you create the set only once and store it in a field
@tender shard I can only make a PR in bukkit with a new method on Material, no need for anything craftbukkit, right?
Mega buster I'd recommned 7smile7's midern approach to gui's
you also need to add the implementation to craftbukkit
what do you mean?
wouldn't something like that not need any implementation code?
Its a guide by 7smile7 which shows you how to make proper guis
where would bukkit get the values from then?
and where is that guide?
bukkit
a big switch statement
just like for isBlock() and similar
that stuff is auto-generated iirc
Spigot forums, im on my phone rn therefore dont habe the lini
don't habe the lini either
it is?
I can't find any CraftMaterial class or anything in craftbukkit
although that might just be because I'm being dumb
found it
Okay, good
usually CraftMagicNumbers -> getItem/getBlock (returns the NMS version) -> ...
Thats a basic approach that you can build on top of, it also teaches you some nice principles
this is usually how a Material returns a value from NMS, by moving that method to UnsafeValues / CraftMagicNumbers
but for my use I wouldn't need that, unless I were to retrieve the composter chance values from some nms class?
i doubt it'd get merged if you just hardcode it into bukkit
let's assume I was making a simpler isCompostable method similar to something like isEdible instead of something like getComposterLevelUpChance
what would that need to be merged?
just for examples sake I might make both
well I'm not md5, i dont know if he'd accept a hardcoded thingy in Material, but I highly doubt it. IIRC all the values in Material are auto-generated and you should get any values like that from NMS. otherwise imagine the pain if MC gets updated
yeah gotchu
do you have any clue on how it's generated? because if I just search the entire craftbukkit repo for isEdible which is similar to what I'm trying to do, the only thing returned is some test. so clearly there isn't a craftbukkit implementation for it, rather it's generated within bukkit (which it is, there is a big switch statement that returns true in case of edible materials and false otherwise)
I should maybe just look thru commits myself instead of asking you to do my homework but pointers are appreciated anyways
I bet md has some secret scripts lol. I bet choco knows more about it, and he also knows whether your suggestion would get merged or not
@worldly ingot are all the values in Material autogenerated? Eg the huge switch/cases etc?
in the forum he wrote Inventory.Handler but i can only find Holder
that's his own class / interface
This means we will create an inventory handler object

have you fully read his post?
in a seperate file?
nearly
it actually explains everything
in either case I was thinking of having an isCompostable AND getComposterLevelUpChance and then put a precondition into getComposterLevelUpChance to check whether the Material isCompostable. basically making it the programmer's duty to check if a Material is compostable before trying to get its level up chance. getComposterLevelUpChance returning 0 for non-compostable Materials implies that those materials are indeed compostable but don't level the composter up at all, and AFAIK there isn't an item like that in the game
btw the compostable chances are part of BlockComposter in net.minecraft.world.level.block, Object2FloatMap "COMPOSTABLES"
so you could add sth like getCOmpostChance(Material) in CraftMagicNumbers that calls getItem on the material to turn it into an IMaterial and then just throw that into the static COMPOSTABLES map
but then I'm being counted on to maintain those and what if I get a heart attack one day or something
sounds good
how do i use the getLevel() method?
you call it
wait i cant send ss
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
alright
(750) 471-0936 is its phone number
just say you're a plugin developer and want to know the level
*But do it async because this is considered IO
xD
this is all you'd need to PR @bleak eagle
oh wait that was suposed to be 3 screenshots
is my discord broken?
ok good
too bad
Bukkit Material:
public float getCompostChance() {
return Bukkit.getUnsafe().getCompostChance(this);
}
Bukkit UnsafeValues:
// In UnsafeValues
float getCompostChance(Material material);
CraftBukkit CraftMagicNUmbers
@Override
public float getCompostChance(Material material) {
IMaterial nmsMaterial = getItem(material);
return BlockComposter.COMPOSTABLES.getOrDefault(nmsMaterial, -1.0F);
}
that's it
why is UnsafeValues deprecated?
because plugins are not supposed to use it
public Map visible disgust
ahh okay
internally it's fine to use
Oh no
accessing it will violate ocp
sigh
neatneatneat I think I got it
can this be done for isCompostable too? like checking in the COMPOSTABLES enum
how do I use getLevel() here?
you need to cast the block data to Levellable
did you make this just now lmao
y
every day we reach peak #help-development
we strive to get more #help-development per #help-development every day
also you must check if stuff is null
let me write up an example one sec
dont really know how to do that sorry
sure thanks
COMPOSTABLES is a map and you would just check contains(...) on it
yeah sorry misphrased
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Block clickedBlock = event.getClickedBlock();
// not every playerinteractevent has to be about clicked blocks. if no block was clicked, return early
if (clickedBlock == null) {
return;
}
// we've made sure clickedBlock is not null, so this won't throw errors at us
BlockData blockData = clickedBlock.getBlockData();
// we've made sure clickedBlock is not null, but we'll also return early if it's not a composter to keep the code flat
if (!blockData.getMaterial().equals(Material.COMPOSTER) {
return;
}
Levelled levelledBlockData = (Levelled) blockData;
int composterLevel = levelledBlockData.getLevel();
event.getPlayer().sendMessage("the level of the composter you interacted with is " + composterLevel);
}
obligatory "this is untested"
ohh I see thanks
@bleak eagle are you going to PR the composter stuff?
whats up with everyone talking about composters today
you started this lol
lol
well i dont care who does it, as long as somebody does it lol
i was talking about implementing an api inside bukkit for checking whether an item is compostable
cuz that's not really possible right now
https://pastebin.com/gmziK4wZ why cant i use this
rn you need a big list of compostable items in your own code to check if an item is compostable
ye u hv to add an array or what not
Hello good, I hope you are all well and are having a nice day, I wanted to ask if you know of any spigot plugin which connects to Twitch, which serves to someone to donate me a X amount of bits can run a command on my server, so is the command of another plugin, I've been looking and have not found, and the few I've found do not have a good wiki or references, if you can help me I would appreciate it very much
You can use this
no it gives me an error
Show the error then :=
"it gives me an error"
"which error?"
"the error"
lmao
If you have any code to create this that I can use as a reference I could also use, I am currently making plugins with Maven and javascript, suddenly do not know of a plugin but if the how to do it, I would also appreciate it.
javascript?
donating 10β¬ to give myself op
but #help-server
just use the twitch developer api and listen to the web hooks on your server
casting in java is like converting one type to another. only Levelled types have the getLevel method we need. not all blockdatas are Levelled, so if we've made sure the block is levelled (only some are like crops and a composter, and we've already checked if it's a composter) we can safely cast ("convert") it to Levelled block data with the cast syntax (Levelled) boringNonLevelledBlockData
understood thanks
make sure you don't cast if you aren't already 100% sure the BlockData is of a levelled block
it will just chuck errors at you
ok ill hv to filter out what block is being taken first then
it's already done in the example
ye
you just have to check if it's not a levelled block and then return early to stop your code from ever reaching the cast
For casting you should check with instanceof in >90% of cases
in this case we only care about composters though
so we're checking material
not if it's a levelled block in general
Sure, but thats still a weak correlation
we can be sure composters are levelled
how would i check if a block is levelled block without doing it manually like the example
it's unnecessary adding the instanceof but you can if you'd like to additionally
as 7smile7 said
if (blockData instanceof Levelled)
just go the right way directly and check with instanceof
Well if you make me a good plugin and give me the source code for Maven and javascript I could pay you for that
ohh i see
but remember that composters aren't the only levelled blocks in the game
very bad practice to go against the impl
ye ik
too lazy, @echo basalt does everything for money
it only makes the code less readable by not having a strong correlation/instanceof check before/after checking if it's a composter
it shouldn't ever lead to any weird behavior in my example, unless mojang randomly decides to make composters non levelled
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Block clickedBlock = event.getClickedBlock();
// not every playerinteractevent has to be about clicked blocks. if no block was clicked, return early
if (clickedBlock == null) {
return;
}
// we've made sure clickedBlock is not null, so this won't throw errors at us
BlockData blockData = clickedBlock.getBlockData();
// we've made sure clickedBlock is not null, but we'll also return early if it's not levelled
if (!(blockData instaceof Levelled levelled)) {
return;
}
if(blockData.getType() != Material.COMPOSTER) {
return;
}
int composterLevel = levelled.getLevel();
event.getPlayer().sendMessage("the level of the composter you interacted with is " + composterLevel);
}
Its one more check but i think its worth it