#help-development
1 messages · Page 123 of 1
if you watch the code i already to that
but happens the same
when does it stop? when teh player relogs?
yes
currently im only testing
Player objects are transient. they are not reused between sessions
get the Player by uuid
yea i know
but rn i don't need to do that i only trying the particle if they works
and yes but stops immidiantly
yes you do
if you are finding the particles stop spawning when teh player relogs, its because you are hard referencing the Player object in your runnable
no when the player is online and the particle spawn then doesn't respawn and seem horrible like bugged
I do the command and then the particle spawn but then disappears and never spawns back there and seem a horrible mess of particle
Add a sysout. Im guessing that either you are shifting a location into oblivion or that the map is empty.
i already tried that and seem not there the problem on the player.sendMessage works fine
lmao i’m taking a software development class rn and the teacher is so adamant on writing pseudocode for an entire project before coding
probably the worst class ive ever taken
that is sad
in college I had to write pseudocode after writing the real code
quite useless
i get it if you make like a flowchart but pseudocode for an entire project is redundant
Pseudocode is good for scientific definitions. Thats it.
i mean she’s also teaching out of a book that’s 8 years old
Add a sysout. Im guessing that either you are shifting a location into oblivion or that the map is empty.
Did you get any infos in the sysout? Do that.
yes the coordinate of the postion
where the particle should be
And? Whats your result. More infos please.
inside the map color and position and they are fine
can i ask a question about my plugin ?
?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!
in this case
@EventHandler
public void onDeath(EntityDeathEvent event) {
if (event.getEntity() instanceof Zombie) {
Zombie zombie = (Zombie) event.getEntity();
if (zombie.getCustomName().equalsIgnoreCase("Ghost")) {
if(zombie.getEquipment().getItemInMainHand().getType() == Material.DIAMOND_SWORD){
event.getDrops().clear();
event.getDrops().add(new ItemStack(Material.DIAMOND_BLOCK , 10));
}
}
}
}
``` if we have a zombie named Ghost and if zombie had Diamond-sword , our zombie drop 10 diamond blocks . right? but it didnt work. how can i fix this ?
directly spawn them
on the floor
where the zombie died
Dont detect custom mobs by their name. Use the pdc.
Did you add a debug message after the drops where added? Do that to check if you conditions are met.
no
https://www.spigotmc.org/threads/image-to-particles.455677/ and btw im using this code for work
yes
Thats some bad code.
Add debug messages and then come back with your results.
ok
didn't find something more helpful
So you are saying that the location stays the same, the map actually contains values and spawnParticle is called with the right parameters?
yes but the particle is not maintain the location but change everytime
Thats what i was asking earlier... So the location is shifting into oblivion
yes
event.getDrops().add(new ItemStack(Material.DIAMOND_BLOCK , 10)); this change the loot not location
Even if you stay perfectly still and dont move?
Because currently your image will kind of follow the player
yes
Hm. What version are you using? Because this should not happen in newer versions.
1.19
lol
Ok send the whole method pls
Method:https://sourceb.in/4TBjrSMas3 Command: https://sourceb.in/j1cIf8Q5SQ
You are testing this with a single colored small image i hope
so 16x16 or something
Whats the size?
128x128
Hello, I would like make plugin, witch will show number of players in team in scoreboard and update it every tick (I will change update time later). I have made this so far, but every time I run updatePerLine() method, its showing errors in scoreboard like on picture
https://pastebin.com/SD868ffE
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.
ignore it
Here is your problem
it can be, but can you help with fix?
pro tip: don't use toString as if it would return any text contained within the score
Try not setting the anchor and increase the display ratio to 0.2
toString is sometimes useful for debug reasons but overall there's usually a getter
Yeah. Never call toString on stuff like this. In most cases it will just print out the jvm memory address and class like it did for you.
if i don't set that doens't work
or i can try making it the size of the image
The anchor is at 0, 0 on default
pretty sure it's the hashcode actually
oh ok
Never looked into that. Always thought it was some mem address
you speak about stuff like you're so sure of it, makes me question my own understanding of java sometimes
Im glad when i get corrected sometimes
Why is your pitch always at 25?
ok so what is my solution?
idk random number lol
Dont use toString on your scores
ok but if I use only score4, it will say error "its not string value"
Vector dist = player.getEyeLocation().getDirection();
dist.multiply(-0.5);
This will show the particles behind the player. Do you check with 3rd person view?
man's tryna make wings
Always thought that code would be hard but it's surprisingly easy
nah im using a ps4 controller for testing
Let's say I want a computer program that will add two numbers and output the result on screen with two numbers 18 and 8, add them and out the result.
What would be the two steps needed for a computer to solve the problem?
would it be getting the sum and outputing it?
oh...
can i replace toString() to getEntry()?
try it and see
ok
7smile7 you made the arithmetic logic part way more complicated than it needed to be
I can't tell if you're asking us or testing us at this point
man just said the answer in class and replied with the teacher's response
ok what happens its strange the particle spawn in order and make the image but they disappears fast enought to not be seeing
they fliker and teleport around
Ok try not setting the anchor, increase the ratio to 0.2 and let the image display in from of you. Make sure you are in the air.
We also clone the locations just to be sure.
Vector dist = player.getEyeLocation().getDirection();
dist.multiply(-0.5);
Location location=player.getEyeLocation().add(dist).subtract(0,0.5,0);
Map<Location, Color> particle = particles.getParticles(location,25,location.getYaw());
->
Vector dist = player.getEyeLocation().getDirection().multiply(2);
Location location=player.getEyeLocation().add(dist);
Map<Location, Color> particle = particles.getParticles(location.clone(),25,location.getYaw());
And then we enhance our loop
for(Location spot:particle.keySet()) {
player.sendMessage(spot.toString());
Color color=particle.get(spot);
//spawn particle at location "spot" with color "color"
player.getWorld().spawnParticle(Particle.REDSTONE,spot,1, new Particle.DustOptions(color, 1));
}
->
for(Entry<Location, Color> entry : particle.entrySet()) {
Color color = particle.get(entry.getValue());
//spawn particle at location "spot" with color "color"
player.getWorld().spawnParticle(Particle.REDSTONE,entry.getKey(), 1, 0, 0, 0, new Particle.DustOptions(color, 1));
}
I made some progress in my plugin, its now showing numbers, but its showing only 0 and if I join some of my teams, it dont change number in scoreboard. here is my new code: https://pastebin.com/HyQWUCSW
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.
is there anyway to like when someone subscribes to my youtube channel it does a command in my server
Well... not exactly. Thoes arent Strings but metadata.
if(Stream.of("A", "B", "C").anyMatch(player::hasMetadata)) {
}
One example. But i would rather use a field which contains the values.
No he's not
No he doesnt
...
hasMetadata is returning a boolean
hasMetadata(String)
Is not a String comparison
Yeah..? String is the argument for the method.
There's no String comparison, wheres the equalsIgnoreCase() 
or equals()
i'm not sure about realization but you can use regex in lots of cases in bukkit
not string matches only
How does that change the fact that the Strings aren't be compared but passed as arguments
Sometimes methods eat regex in string params
Following up
if(Stream.of("A", "B", "C").anyMatch(player::hasMetadata)) {
}
Or with a field
// Top of the class
private static final List<String> metas = List.of("A", "B", "C");
// Later in your method
if(metas.stream().anyMatch(player::hasMetadata)) {
}
[20:20:55 WARN]: [NextBot] Plugin NextBot v1.0-Beta generated an exception while executing task 19
java.lang.IllegalArgumentException: color
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:145) ~[guava-31.0.1-jre.jar:?]
at org.bukkit.Particle$DustOptions.<init>(Particle.java:184) ~[purpur-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at it.zerotwo.nextbot.commands.MainCommands$1.run(MainCommands.java:67) ~[NextBot-1.0-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.scheduler.CraftTask.run(CraftTask.java:101) ~[purpur-1.19.2.jar:git-Purpur-1775]
at org.bukkit.craftbukkit.v1_19_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:57) ~[purpur-1.19.2.jar:git-Purpur-1775]
at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[purpur-1.19.2.jar:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
well actually that's kinda faster
if you make it to 1 line
By not assigning variable
So? Doesnt mean its faster.
You need to add racing stripes to speed things up
And fire decals
Pretty sure the second one is faster because the static variable is on the stack at all times.
Ah i see
Turning a list into a stream and then using anyMatch is probably slower
than just three or
For sure
Cuz stream is not on the stack
We shouldnt think about those things. JIT carries our bad code anyways.
Sometimes even JIT compiler can't help ya know
Gotta outsource it to China
what
Yeah. Let child labour optimize our code.
true actualy
Child with Middle Java level at least
Learning java even before being born
Audio tapes in the womb
depends
for instance IntStream will have its values on the stack
I am trying to use protocol lib to listen for entity movement, and I'd like to figure out previous/current location, however I need the entity's current location, and to get that, I need the entity, how can I get the entity?
this.manager.addPacketListener(new PacketAdapter(
this.plugin,
ListenerPriority.MONITOR,
PacketType.Play.Server.REL_ENTITY_MOVE
) {
@Override
public void onPacketSending(PacketEvent event) {
PacketContainer container = event.getPacket();
short deltaX = container.getShorts().readSafely(0);
short deltaY = container.getShorts().readSafely(1);
short deltaZ = container.getShorts().readSafely(2);
}
});
for (var s : "A,B,C".split(",")) {
if (p.hasMetadata(s)) break;
}
Does someone have an idea how I could vanish a player so he isn’t even recognized in other plugins anymore? So e.g. you cannot /msg him? I was thinking about modifying the field underlying getOnlinePlayers(), but if that’s not only used for Plugin API it would have very bad side effects
split("|") you mean?
the getOnlinePlayers returns a copy anyways
there are different split methods as far as i know
That’s why I'd modify the underlying field via reflection
one with only int parameter splits by regex and has a limit
so nms
I guess you can
nope
The container contains the entitiy id
But the player won’t be able to play anymore if the server considers him as offline
Store player join leave and you'll never need to query online
yes but "A|B|C".split() wont work because there is no zero arg split method on String afaik
and if you use the regex one thatll ofc decrease performance rather drastically, altho streams probably do it even more
no?
well there are different types of laziness
gonna try shortest code now
shit there is one already
probably the smallest
Do I have to only read ints
How else would the client know which entity to update on his side
since there is no var ints on the packet container
I am not talking about the packet
talking about the protocollib api
int at index 0
I think plib has a util method for that
can't find
Are most of the guys here coding on java 8?
nvm
I think j11
no
My laziness is the biggest probably
16+
j8 is minimum
https://www.spigotmc.org/threads/getting-entity-from-entity-id-protocol-lib.528385/ EntityUtilities does not exist
J18 cause 20 can't come soon enough
Nobody uses var and Pattern matching
it moved
Ive seen the former a lot but not the latter
Always latest LTS. So 17
guess its gonna get more popular with switch expressions
Protocol lib might not be designed the best
look
ProtocolManager#getEntityFromId takes a world
well what if I don't have a fucking world
sorry for tagging
Java 8 instantly rises suspicion because its a first indicator that you are using the garbage minecraft version.
But haven't seen anybody using pattern matching
The player which receives the packet is always in the same world
Well I use it for convenience
but I haven't done any real bms on whether its performance is actually great
Idk i'm rly curious about applying to actual job
So i learned every freaking thing about new jdks
Pattern matching is amazing
this is gonna be awesome
Ah fair
I am bad
and will advocate people to use pattern matching a lot more
Interesting. But very specific
record looks kinda sussy
cus instead of actual getValue()
you recieve value()
maybe it's time to change but idk
seems to non-java for me
Just name your variables int getX, boolean isOnline 
I mean by traditional means a function does something hence the name of it should be a verb
but now there are "property functions" and "accessors", "mutators" who are not semantically different but we look upon them with a slightly different aspect
I made a plugin that should show the number of players in the team in the scoreboard. I made an update per line, so the line in which it is displayed int List0 = blue.getEntries().size();
and then String.valueOf(List0). The problem is that when I join the team, the value does not change. Does anyone know where the error is?
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.
https://paste.md-5.net/onarecaxas.java https://paste.md-5.net/vusuxazako.java https://paste.md-5.net/gusibanoca.java
Anyone know why this is happening?
No errors
Hello!
I use a plugin message to send data between a proxy and a spigot server. The problem is that the message contains UUIDs, and that they aren't formatted correctly by player.getUUID() method on Bungeecord. The Spigot server recieves the correct UUID, without the "-", so server send "Invalid UUID string" error while using it
Can you help?
Thanks
Both sides use UUID objects. Dont compare Strings.
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
ProtocolHook hook = new ProtocolHook(this);
hook.attach();
}
public ProtocolHook(Plugin plugin) {
this.plugin = plugin;
this.manager = ProtocolLibrary.getProtocolManager();
}
Manager is null when calling #attach, why?
You are shading in ProtocolLib
no?
bump
I don't do that
Do you use maven?
How do you compile?
Alright. Add <scope>provided</scope> to your dependency
Its always a good idea to have the maven shade plugin in your pom
Yeah but I just transform them into String then back into UUID as I can't simply send UUIDs. So what should I do?
Changing the scope is more explicit. Do that instead.
Well then there should be no issue because you are comparing UUIDs
does anyone know how would i spawn like smoke particle on player death
i know it was a thing in 1.8 where you could just do playEffect()
Listen to the EntityDeathEvent and spawn particles
yes yes i know that but i mean like an effect
get the world -> call spawnParticles
declaration: package: org.bukkit, enum: Particle
@lost matrix protocol is not really having a good time
then get the world and call playEffect
2nd bump ;-;
Wrong plib version
dangit smile beat me to it
Use 5.0.0-SNAPSHOT for 1.19
Oh I am categorally bad
what does the data parameter refer to ?
Not enough info. Do some debugging and ask a more specific question.
declaration: package: org.bukkit, interface: World
how do i know which particle needs this data
and can it be null
plugin.updateLastReceived(receiver.getName(), sender.getName()); is not doing anything on line 41 for the 2nd file
declaration: package: org.bukkit, enum: Effect
?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!
okay, ty
but development related questions only
If you need help setting up or finding a plugin go to #help-server
bump
We dont even have the method...
Yes. But you should probably use a map for that.
it just returns this with
You can have it still contain the uuid. Doesnt mean you cant use the uuid as a key suddenly.
plugin.updateLastReceived(receiver.getName(), sender.getName()); what is this method
Cursed, guaranteed
It's using names which is already a bad sign
I'm aware
Player receiver = Bukkit.getPlayer(plugin.getLastReceived(sender.getName()).getLastReceived());
Line 30: https://paste.md-5.net/gusibanoca.java
Again: We need the actual implementation
Links are here
Alright: Final answer. We have not enough code to solve this. Go add debug messages.
👍
Where does the obsession with equalsIgnoreCase coming from btw? Ive seen it so often for no reason.
And i havent used this in the last 10k lines i have written for sure.
It's one of those "better safe than sorry" kinda things I see people do
@lost matrix how about spawning particles to player as trails in 1.8.8 ?
?1.8
Too old! (Click the link to get the exact time)
How do I implement a uuid?
1.8 💀
?
p.uuid?
yes i know it is old but pvp minigame is not really making sense in 1.19.2
A UUID is a unique identifier. You dont implement it. You get it from objects or generate it.
Then deal with the drawbacks that come with using such an horribly outdated piece of software.
Forum posts from half a decade ago might help you.
Whats the identifier?
Depends on what player you want
You dont want the player to input a uuid...
You get the player via name then grab the UUID from the player object
You use uuids internally and let user interaction go through names.
/msg d6bdae2a-3d79-4830-857d-b0920016ff59 Hello very nice command
You probably want the username not the UUID in your command
Player receiversuuid = receiver.getUniqueId ();?
Yeah thats what i'm doing
Bukkit.getPlayer?
Did you skip learning Java before trying to make a plugin
No ;-;
It translates "e" to EthanGarey (Online player)
This looks about right
Bukkit.getPlayerExact
It's the same thing
When I send dataout.writeUTF(p.getUUID()); out.writeUTF(p2.getUUID());
When I receive it String p1 = in.readUTF(); String p2 = in.readUTF();
Then I get Invalid UUID string here AddPlayerInGame.addPlayerInGame(UUID.fromString(p1), UUID.fromString(p2), type);
It does both
and what is null
Operator '==' cannot be applied to 'java.util.UUID', 'org.bukkit.entity.Player'```
if (receiveruuid == p) {
mixed up with something, I get an Invalid UUID string
Yes ofc you do...
A Player will never be a UUID
o
A UUID is not a UTF String... Its a UUID.
I'll make a uuid string for player too
Call .toString() on it
^
I hate doing it that way
It would be nice if it had the option to give you a byte[16]
https://paste.md-5.net/egelalalak.java
Now what?
Yeah but I can't transmit it as an UUID as there's any .writeUUID function
Well, you need to refactor your stuff that takes names takes UUIDs
I'll pay someone nitro if they do some tasks for me (coding) DM me (Nitro classic)
Must be a 10 star coder
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
alr
The function would just write the 16 byte
see the UPDATE instruction
yeah I now I can't use it, but are there's any function that would match my needs?
Why can’t you use it?
public static byte[] getBytesFromUUID(UUID uuid) {
ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
bb.putLong(uuid.getMostSignificantBits());
bb.putLong(uuid.getLeastSignificantBits());
return bb.array();
}
public static UUID getUUIDFromBytes(byte[] bytes) {
ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
return new UUID(byteBuffer.getLong(), byteBuffer.getLong());
}
could be used for uuid in bytes
epic
update updates a row
what condition
yea ? What about that
I am confused as to what your question is here
it doesn't upsert
if that is your question
e.g. if no line matches the WHERE case it just does nothing
checkout UPSERT
Working on a plugin that will likely have a lot of holograms, *surely more than 500 (when some time has passed), up to 1000 (well I think it's a lot) * and I'm planning to use Holographic Displays. Do you guys think it can handle this well?
depends what you plan on having on them
very specific to the DB
UPSERT is not a standard SQL command
so each SQL server might have its own syntax for it
Well, on the SQL server
your mysql upsert syntax won't work for sqlite
or postgres
for example
tho like, mysql iirc does not really have a built in upsert
Well thoses "-" aren't transcripted. When they're received they aren't present
The hologram will be spawned on top of a mob spawner (modified, not like vanilla) that a player will place. It will displays info like what type of mob that is, and the amount of spawners there are on that 'stack', as well as the owner's name of it.
sorry, if it's too confusing, english is not my first language
personally in that case; to reduce the amount of holograms
id only create it if a person is within like 15 blocks
that should be fine but do what rack says
This is what I was thinking
just, google
Bing your question before asking it:
https://www.bing.com/
at least duckduckgo it then
"how to UPSERT in mysql"
I presume you are using mysql ?
yea I think you said that somewhere
I'd have to create a repeating task and iterate in all the spawners, get the location calculate if the player's in the radius, then change the hologram visibility setting for that player
should be something along the lines of INSERT ... ON DUPLICATE KEY UPDATE
if my mysql knowledge did not forsaken me
can't think of a better way to do this honestly
can you help me please?
hello, apparently this method only exists on 1.18 and newer servers. what is the method to get it on a 1.17 server?
Bukkit.getUnsafe().getTranslationKey(EntityType)```
If you just sent UUID toString and then build a UUID again, the "-" signs are still there.
I dont know where your problem is coming from
Probably nms
Or by doing some bootleg String assembling
🤷♂️
final String translationKey = "entity.minecraft." + livingEntity.getType().toString().toLowerCase();```
you're right, thanks
that doesn't exist at all in spigot
neither in UnsafeValues nor in CraftMagicNumbers
UnsafeValues appears to exist in 1.19
but not <= 1.18
oh well, I just changed my code to where I don't need that anymore
UnsafeValues exists in all versions. but getTrsnaltionKey is in no spigot version, you are using Paper API
oh right, yes that
yeah it was annoying to have everything working in paper 1.19 then finding all the broken stuff in spigot
that's what happens when you use paper specific features 😄
you can ofc use NMS to get the translation keys within one line
if I have the option to drive the Mercedes or the Hyundai I'm picking the Mercedes
that's how paper does it
that's an odd comparison
it's like building a road (a plugin) where only mercedes can drive on (only paper servers can run it)
instead of buying a mercedes for yourself
ah good, I am using nms so nice to know that's an option
It's a shame that the Hyundai is more reliable. 😛
public String getTranslationKey(org.bukkit.entity.EntityType type) {
return net.minecraft.world.entity.EntityType.byString(type.getName()).map(net.minecraft.world.entity.EntityType::getDescriptionId).orElse(null);
}
i wonder why they added this to Unsafe instead of adding it to EntityType directly o0
EntityType.ZOMBIE.getTranslationKey() would make kinda more sense
cough paper
you mean like someothersite/1.19/org/bukkit/entity/EntityType.html#getTranslationKey()
How do you guys manage your TODO's in your IDE? So far every time I have an idea I add a comment at the top of my main class :D On my current project I have like 8 todo's rn
I just use the TODO tab?
lol
IntelliJ also warns when committing TODO comments
and it also mentions those when using "Analyze code"
I also set it to show // debug comments
and yell at me when using System.out
or do you mean todos for features etc? I use a kanban for that
yes this
what's a kanban?
I just have one board per project or a "General" thing for projects that only have one or two TODOs
the general board is then just divided by project per swimlane
Looks pretty cool nice
yeah kanban is the general name for these kind of boards, e.g. trello is also a kanban board
I'm using selfhosted "wekan" which is free
it also supports a ton of things that I never use, like deadlines, images, time tracking, checklists, subtasks, attachments, labels, bla bla bla
or assigning certain members to each entry, having different organizations with different permissions, ... and installed with just one command lol snap install wekan
what database
if you're talking about a java.util.List, i doubt that ANY database has support for that lol
I think that's what they were getting at. They want to know how to store a list in a database.
you'll have to serialize that yourself into some datatype the database understands, then deserialize it later
e.g. if you have a List<String>, you could turn it into a json string
or even just comma-separated if your strings don't have commas, whatever, it depends on what you wanna store exactly
alternatively you could just use a new table, e.g.
your current table:
| key | listId |
|------------|--------|
| first list | 1 |
| second list| 2 |
your list table:
| listId | i | value |
|--------|---|------------------------------|
| 1 | 1 | first value in "first list" |
| 1 | 2 | second value in "first list" |
| 2 | 1 | first value in "second list" |
directly trying to store a list in a table sounds like the data isn't normalized properly, unless it's really basic stuff like a json or csv string though
so yeah I guess this would be a valid option
so e.g. imagine you have a class like this
public record Person(String name, int age, List<Person> friends) { }
You'd have a table like this to store name and age and the reference to the friends list
CREATE TABLE `Person` (
`id` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(32) NOT NULL,
`age` INT NOT NULL
);
and another table to store the friends, where "id" is the owner of the friends list, and "friend_id" is the id of the other person in that list
CREATE TABLE `Person_friends` (
`id` INT NOT NULL,
`friend_id` INT NOT NULL
);
can't think of any better way rn
what would be the best way to have an entity's name be different for certain players
i'm using invisible armorstands to make a hologram library for myself
and i was wondering if there is a way i could make it so the hologram's text is different for certain players
i believe it will require nms or something
yes, you need to change the NMS' entity's name, and then send a ClientboundSetEntityDataPacket. For example something like this (haven't tested):
public void changeNMSEntityName(Entity nmsEntity, String name) {
entity.setCustomName(CraftChatMessage.fromString(name)[0]);
for (final Player player : Bukkit.getOnlinePlayers()) {
sendPacket(player, new ClientboundSetEntityDataPacket(nmsEntity.getId(), nmsEntity.getEntityData(), true));
}
}
except that you wouldnt loop over all players ofc
np, but as said- havent tested
alright
oh yeah, what is the sendPacket method?
erm
that's just something like this
void sendPacket(Player bukkitPlayer, Packet<?> packet) {
((CraftPlayer)bukkitPlayer).getHandle().connection.send(packet);
okay thanks
lmao
Stop modifying event outcomes and breaking them 
I didn't modify an event lmao
How'd you do it
Was screwing around w/ having items execute commands @vocal cloud
ClientboundSetEntityDataPacket doesn't exist
Oh my
this happens when you have fucked up items, e.g. books with too long meta, or when you downgraded the server but still have some "newer" items in some chest or whatever
hey ClientboundSetEntityDataPacket doesn't exist
it does, you just gotta use the proper mojang mappings
hmmm, was PDC stuff on a 1.19.2 server & world 🤔
how?
are you using maven?
yes
time to check the NBT lmao
the "legacy" name of that packet is PacketPlayOutEntityMetadata btw
you can check it here, mojang mappings vs spigot mappings: https://nms.screamingsandals.org/1.19.2/net/minecraft/network/protocol/game/ClientboundSetEntityDataPacket.html
lol I wonder what in the PDC caused it to break 🤔
it can't find the dependency in central
i have the spigot repository in the pom.xml
@tender shard
it's the method (NMS)ItemStack#updateEmptyCacheFlag() that fails
This p.getScoreboardTags().contains("shadowsneak") would check to see if a player has the tag shadowsneak right
lmao I guess having it run the kill command on yourself breaks it somehow
I'll try again, see what happens lol
better yet, I'll record it. Gotta get some use out of my YT channel xD
I mean wtf is TRAP even supposed to mean lol
I thought more about sth else lol
all I can tell you is your exception was thrown because nms' ItemStack#setCount(int) called nms' ItemStack#updateEmptyCacheFlag() and then came to the conclusion that the emptyCacheFlag flag was set and that the new ItemStack equals ItemStack.EMPTY
but why, or what this means, no fucking clue
I'm not too sure the Mojang devs took this dumb shit into account @tender shard lol
hmm, maybe a different command. I'll try that
also, the Entity class doesn't have the methods you put here
@tender shard
If it's give Optic_Fusion diamond 10 it's fine.
kill @e[type=!player] it's also fine
but as soon as I kms it's like no lol
Maybe I need a blacklist 😂
Are you removing the item after the command is executed? Cause that could be the only reason #setAmount() would be called.
I kill myself, ofc it gets removed
I mean manually. It would drop otherwise.
No
as I said - nmsEntity
is the NMS Entity class
which method can't it find?
because you're not using mojang mappings
in spigot mappings, the methods are called a(), b(), c() etc
ig if anything I just blacklist certain functionality since server commits die
when you don't use mojang mappings, then e.g. it's not called nmsEntity.getId() but nmsEntity.ae()
i used your tutorial
it's using org.bukkit.entity.Entity;
whenever I call something "nmsEntity", you must use this import instead of the bukkit one
isn't it supposed to use net.minecraft.world.entity.Entity
yeah
ok it works, thanks
np
don't forget to use mvn package to compile, instead of intellij 😛
otherwise the remapping won't work
yeah i always use that
or well - clean package
yeah many people don't
and then they wonder why their pom adjustments dont change anything
Yea, might just put a blacklist on the plugin lmao
That's usually cause they don't know that they need to reload their poms.
what jar do i use
that often too, but I was talking about stuff like "remappings dont working" because they do File -> export .jar instead of "mvn package"
Wait, people do that?
depends, usually the "MyPlugin-1.0.0.jar"
ok cool
many people do that...
is there a way to turn off "This message has been modified by the server"?
Anyone?
I mean I cant blame them, how are they supposed to know? most people wathced a shitty youtubube tutorial
yes
but yea, literally anything else works @tender shard but as soon as it ends w/ the executor dying it crashes.
I'm guessing something about the death & holding the item that caused it creates issues
maybe show your code
It's literally just PDC handling @tender shard
set PDC, check PDC & run command
not enough leedles
are you maybe setting the pdc, then lowering the item count to 0, then trying to get the PDC or sth? idk
Nope lmao
hm idk
Literally just a has correct PDC? Yes? Cool, run command that's stored
no idea, what happens if you, just for fun, catch the AssertionError, then print the full stacktrace in the catch block?
There's a validation check, but that doesn't cause it since it makes it to right after the command
Ye
because then the item will be set to 0
since it was dropped
the itemstack is gone
There were a good 100 or so actually
why do you need to get the PDC value right after you set it anyway, I wonder?
item interact, can happen any time
PDC is just so I don't have to store non-global commands that way it's tied to a specific item instead of the material
there's surely an easy fix but it's hard to tell without seeing code and I gotta go to bed in... 2 hours ago lol
hmm, try-catch and it didn't break. Weird
for example why not just clone the itemstack before executing the commands?
``` Would this run if a player has either the shadowsneak or shadowhunt tag? meaning a player like the one in the screenshot would trigger the if statement?(sorry I just need a sanity check as this doesn't seem to be working)
tbf I didn't expect a server crash @tender shard
yeah that's because it throws an Error and not an Exception
lets try error
the eventhandler only catches Exception and not Throwable
Either way, it didn't crash lmao
Throwable
| - Exception
| - Error
so I might just try/catch it and leave it lmao
just check if the itemstack's new amount is 0 before getting the PDC again
It gets it exactly once
ItemMeta itemMeta = itemStack.getItemMeta();
PersistentDataContainer container = itemMeta.getPersistentDataContainer();
Player player = event.getPlayer();
if (container.has(key, PersistentDataType.STRING)) {
String command = container.get(key, PersistentDataType.STRING);
performCommand(player, command);
return;
}
what's performanCommand look like?
private void performCommand(Player player, String command) {
// TODO: Add a fake operator or something so this is still possible without needing to op the player
boolean wasOp = player.isOp();
player.setOp(true);
try {
player.performCommand(command);
} catch (Error e) {
System.out.println("SHIT BROKE, FIX IT");
}
player.setOp(wasOp);
}
generic thing, since I cba to make a fake op impl
instead of souting "SHIT BROKE", do e.printStackTrace()
then it should show your plugin in the stacktrace
I'll shout as much as I want
yeah but don't you wanna find a proper fix? 😄
Nothing related to the plugin
hm then let's go through the whole stacktrace again
Exact same stacktrace as the original
send it again please, as text please
then I can rund it through the remapping thing
and see the actual stacktrace, with mojang mappings
thx
If anything I just blacklist the ability to commit suicide lol
okay so
at ItemStack.doUpdateChacheThingy()
at ItemStack.setCount(int)
at PlayerInteractManager.a() which is either getGameModeForPlayer or setGameModeForPlayer or tick() (probably it's the tick() method, or are you changing gamemodes somewhere?
do you execute the command when the player tries to place a block?
It doesn't crash when in survival and yea, but non-suicidal commands don't break it 🤔
okay I got one step further
the third line of the stacktrace is ServerPlayerGameMode#useItem, this line:
and yeha, it only runs when in creative
so that matches what you said
huh, wonder if there's a proper fix for this 🤔
ig checking for null or something?
yeah I have to through the whole stack one by one, since the stacktrace doesn't tell me "which" a method they use >.< 😄
lmao
it definitely happens while placing blocks in creative mode when the itemstack was already invalidated because it got dropped since you killed the player before the interact manager finished everything. The easiest fix by far would be to run your command on next tick, I guess
unless md applied a fix to spigot directly, anyways
maybe cancelling the block place 🤔
this can't be fixed at this point without breaking tons of other things, I guess
the whole blockplace logic was always weird
when you place a block, it gets placed, but when some plugin cancels this event, then the block is basically removed again
I always call this schrödinger's blockplace
basically the whole logic for calling the blockplace event happens too late in craftbukkit but I doubt that someone will ever change this again
but isn't there any problem in delaying the performCommand by one tick?
that's definitely how I'd just do it
Gonna see if cancelling the block place does anything, if not then I'll try by one tick
oki
I doubt that cancelling the BlockPlaceEvent would change anything since it's called after the block was already set
huh
weird
oh wait
you cancelled the INTERACT event, right?
aaaah yes, now it also makes sense why the stacktrace didnt show your plugin
oh?
yeah sorry it was so obvious, I was a bit slow
lmao
it's such an easy problem
Let me explain
- InteractEvent happens. You kill the player
- Server thinks: "Interact wasnt cancelled, so let's go for BlockPlaceEvent now with the following item:"
- Item is gone, since you already dropped it
tldr; Check if itemstack is null, problem fixed in spigot
:p
so we got this fixed now? :3
Ye, now people can be as suicidal as they want 😂
great XD
but yeah, I loved this. most people here are like "how can I set lore, its not working". finally this was an interesting problem again
yeah especially if the stacktrace is only NMS stuff
Praise be shit QA doesn't expect
I mean I said at the beginning that the itemstack's amount must be zero but i totally overlooked that it was because BlockPlace inevidintly (correct word? idk) gets called after InteractEvent, no matter whether you change the itemstack or not
or me "No one would ever think to kill themselves using a command that's on an item"
Yes, tell that to the server crash
has a 10% chance of killing yourself, or 90% chance of tasting delicious
yea but that doesn't need commands, just setHealth or whatever
yeah but I mean you could do something like this
my-awesome-pufferfish:
commands:
10%: kill %p
90%: - sendmessage %p Wow, that was tasty!
heal %p
lol
I haven't signed the CLA
isnt the jira open to anyone, and only stash isnt open?
hmmm
I am not sure
not even sure I remember my creds lol
I mean it would really just need to check if the itemstack is equal to ItemStack.EMPTY before continueing
it's either only one line, or it's way more complex and unfixable lol
although I vaguely remember that a "similar" issue existed
I'm making an issue lol
would be worth checking if the same things happens if one doesnt kill the player, but just set the itemstack's amount to 0
in the interactevent, without cancelling it
because I think, it should also TRAP then
https://paste.md-5.net/kewojakugo.cs plot thickens @tender shard
yeah but that's because you get the PDC
I meant just a plain easy thing like this:
on interact:
if is rightclick on block
currentItem.setAMount(0)
and see if that causes this TRAP thing
okay good, then I'd suggest that you report it rn 😛
That's what I'm doing lmao
bump
why dont you try it?
Using PDC to commit die causes the server to crash
best summary
it doesnt even have anything to do with the PDC
Hm let's try this
on interact event:
if is about to place a block:
kill player but NOT cancel interact event
i think thats all it needs
Action action = event.getAction();
if (action != Action.RIGHT_CLICK_AIR && action != Action.RIGHT_CLICK_BLOCK) {
return;
}
event.getPlayer().setHealth(0);
yea?
That doesn't break the server
@EventHandler
public void on(PlayerInteractEvent event) {
Action action = event.getAction();
if (action != Action.RIGHT_CLICK_AIR && action != Action.RIGHT_CLICK_BLOCK) {
return;
}
Player player = event.getPlayer();
player.setOp(true);
player.performCommand("kill " + player.getName());
player.setOp(false);
}
this doesn't break the server either @tender shard
no no
you're doing it the wrong way around
don't check for the action at all
oh no wait
hmm weird
okay then report it as you wanted to earlier
including the PDC part
My guess is it's something related to the ItemStack & it affecting the player holding it
This is the same as when it crashes the server, only difference is it's no longer on an item stack's PDC
it only happened in creative anyway, right?
Correct, however this should be fixed nonetheless, since it can be exploited for malicious purposes
or non-malicious purposes, if you were doing something
e.g. creative server
some people really don't understand the help-dev forum
shit 4am, and I gotta go to a concert today. good night everyone lol
Idiot
He works for someone who needs plugins but has no time to learn how to code plugins
Asks other people to code it
i'd do it for... erm... 12 million €
how can i avoid this exception
you didnt post any exception?
idk lol
Help me
?help
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous names and nicknames of a member.
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
idfk know either lmao
@tender shard help me pls
?help
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous names and nicknames of a member.
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
here you go ^
I can't pickup all drop items in server
I'll create a plugin w/o the extra functionality & see if that causes a crash
yeah that's required for a valid jira report anyway
I also tried to reproduce it but couldnt
very weird 😄
I just tried some simple stuff like this
(while in creative, trying to place blocks)
worked fine :/
oh right
gimme a sec
still working fine with "/kill mfnalex"
it's so weird lol
Bump
?tas
You are missing braces. (x && (y || z))
Or else its interpreted as (x and y) or z
what even is PacketType.Player.Server.ENTITY_EQUIPMENT
what are you trying to do
what is supposed to happen
tf, bare minimum and it still doesn't crash the server
weird
well..... kind of hard to make an issue if I can't reproduce it reliably lmao
Whats broken?
Well, I managed to trigger a TRAP error @lost matrix
https://paste.md-5.net/eqaqupayeh.md
Trying to figure out why and make it reproduceable lmao
The heck?
Originally it was from me running /kill <my_own_username> on an ItemStack which had it as its PDC, but that same thing is no longer working
during the interactevent without cancelling it, while placing blocks in creative
(important info)
yea, that too lmao
I made a video as well
I do have braces. or are you saying I need more braces? In that it is (x && (y || z)) not (x && y || z)
@mighty aurora
The entire if statement is supposed to make a player's armor and held items disapear. it works but after adding the tag requirement it stopped working. I need it to only be active at specific times though.
but WHEN is it going to make it disappear? it looks like some kind of protocollib listener?
I use PacketEvents(an api) that without the tag check it will always make the armor and items disapear. after the check its supposed to make them disapear only on players that have the specific tag.
okay, yea. I still have it reproduceable @lost matrix lmao
need to see if I can limit how to cause said crash
do some debugging and see whether your if statement actually runs. something like this
boolean firstCondition = ...;
boolean secondCondition = ...;
boolean thirdCondition = ...;
System.out.println("first: " + firstCondition);
// same for second and third
if(firstCondition && (secondCondition || thirdCondition) {
System.out.println("my if runs");
// other stuff
}
then see what it prints
So, remember the diamond thing @tender shard ?
Works as expected when right clicking a block, but as soon as it's air.. server crashes
yes
oh yeah
hmm
might be because DIAMOND is an Item while AIR is a block
Possibly, gonna remove that Action return and see if that does anything lol
Pretty sure it's useless anyways unless it's left click lmao
still wokring fine for me with diamond
both with and without chaning the diamond's PDC before killing the player
Gimme a sec to re-double check w/ my plugin, then I'll send it if it works lol
So basically I need to make it if ((event.getPacketType() == PacketType.Play.Server.ENTITY_EQUIPMENT) && (p.getScoreboardTags().contains("shadowsneak") || p.getScoreboardTags().contains("shadowhunt"))) {
@tender shard
steps:
- Give yourself item
- /commanditem assign kill <your_username>
- Right click block, verify it works as expected
- Repeat 1 & 2, but rightclick air
yeah it crashes while clicking on air
What gameprofile field has the UUID?
"id"
why?
this is a weird question
I mean why don't you just look at the GameProfile class
np lol
upload this to github, I'll definitely find out the exact problem but not sure whether I can do this now, since it's 4:45am and I wanted to go to sleep almost 4 hours ago lmao
I wonder why 🤔
and I'll upload it to JIRA first and apply a temp-fix for the spigot release
yeah "why" is hard to tell without the full source code and decompiling it is annoying since I can't just throw it into intellij then
sure, send bug report link when you finished the jira report 🙂
The fun part is why, I doubt it's going far into the block place stuff @tender shard
when I narrow your code down to this, everything works
but again, it seems to break only if it's on the PDC @tender shard
Remember, we tested that lmao
player.setHealth(0) & player.performCommand("kill <own_player_name>") all work on their own, but once it's pulled from the PDC & executed that way the server commits die
Player player = (Player) sender;
Location spawnLocation = player.getLocation();
World myWorld = Bukkit.getWorld("world");
Zombie zombie = (Zombie) myWorld.spawn(spawnLocation, Zombie.class);
if(sender instanceof Player){
zombie.setAdult();
zombie.setCustomName(ChatColor.RED + "" + ChatColor.BOLD + "Ghost");
zombie.setCustomNameVisible(true);
((Attributable)zombie).getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(100.0);
zombie.setHealth(100);
NamespacedKey key = new NamespacedKey(pluginInstance, "our-custom-key");
PersistentDataContainer container = zombie.getPersistentDataContainer();
if(container.has(key , PersistentDataType.DOUBLE)) {
double foundValue = container.get(key, PersistentDataType.DOUBLE);
return true ;
}
```how can i use PDC .i want my zombie(ENTITY) have a data and i need that data to set it custom drop . pls help
so you want a custom drop pool?
no i made a command spawn a custom zombie and i want to change my zombie drop
still not signing the CLA though lmao
you'll have to strip everything from your plugin that's possible to strip without the bug NOT happening
e.g. I cannot just copy your listener part because it's missing so many other things then
so yeah upload it to github or sth
Yea, that's what I attempted before yet it worked as expected 🤔
what exactly is the problem? I don't really understand your question
Gimme a sec, I'll upload src lol
i have my zombie but i need a special thing (metadata ,pdd or somthing else) to call him in another class
@tender shard https://github.com/OpticFusion1/CommandItems
lets try
That's the above plugin, currently removing a bunch of stuff
huh
when I compile and run this, then nothing happens when I right click
and yes, I assigned the command
i gave myself a diamond, held it in mainhand, then did /commanditems assign kill mfnalex
then I rightclick and I dont die
also no errors
Gonna try a clean & build
this is sus
Smh
LMAO
okay, gonna remove that and try again lmao
time to make a forceop exploit with your plugin ✓
after removing the return part, it works perfectly again, without errors or crashes
can he use swich for that ?
I was gonna add a blacklist, but I got sidetracked lmao
@tender shard
bare minimum, just say ==test in chat
==test gives me a stone. right clicking air with that, in creative, kills me, no crash
breh
and trying to place it just prevents placement
hmmm
ig I'll like.. idk, try updating spigot lmao
but that's the exact jar I'm using 😂
your former .jars also crashed my spigot AND paper
but not this one
nor the github one
I lied, md5 2D058D1DB921B26B3F130B4C9B36E311
lmao would of been faster to just verify the md5 hash lol
Ye, see if I provided the right one lol
Fucking weird if it's the same one but has issues being reproduced
its the same md5
2d058d1db921b26b3f130b4c9b36e311 */c/mctest/plugins/Crash.jar
weird, go sleep I'll bug you about the issue report later lol
ill try once more, on spigot
last try was paper
but your ealier thing also crashed on paper
hmm, happen to remember which lol
So it seems like paper fixed it, while spigot still has said issue
I'm latest afaik and it crashes still
I'll build it again rn
lmao so much for sleep
😛
another 5 minutes "won't make the roast any fattier" as we say in germany lm ao
:3