Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Glow effect limited for one player still show for others #22

Closed
Supre-le-sucre opened this issue Jul 30, 2022 · 4 comments
Closed

Glow effect limited for one player still show for others #22

Supre-le-sucre opened this issue Jul 30, 2022 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@Supre-le-sucre
Copy link

XGlow Version: 1.0.8 (latest)
ProtocolLib Version: 4.8.0 (latest)
Minecraft Server Version: Paper 1.18.1-160
JDK Version: 16.0.2

Description
While applying the glow effect on multiple entities (one glow effect per entities) with different colors and then restrict the viewer to only one player, other players can sometimes see the glowing effect on those entities, without the colors applied (The glow effect shows in white)

How to reproduce
Here is a pseudo code of what I did if it can help:

for(Object obj: ObjectList)) {

LivingEntity entity = (LivingEntity) someWorld.spawnEntity(someLocation, Entity.someEntity); 
entity.setAI(false); entity.setSilent(true); entity.setPersistent(true); entity.setInvulnerable(true); entity.setInvisible(true);

Glow glow = null; //I also tried creating a placeholder Glow object with the builder or by creating a new Glow Instance (the result remains the same)
if(stuff) glow = Glow.builder().color(Color).name(String.valueOf(entity.getEnitityId()).build(); 
else if(stuff) glow = Glow.builder().color(Color).name(String.valueOf(entity.getEnitityId()).build();
//I also tried creating a new Glow instance instead of using the builder (the result remains the same)
else if(stuff) [...]
//at the end of all those conditions, there is no way that the glow variable should be null anyway

glow.addHolders(entity);
glow.hideFromEveryone()
glow.display(theIntendedPlayer)

}

What is happening
With this code, what is intended to happen works perfectly: theIntendedPlayer can see the glow effect on entity with the right color applied on it.
However, other players that are unintended viewers can see the glow effect on some spawned entities but the effect only appears white.

Hope you'll see what's wrong, thank you for your time and support ! :)

@Xezard Xezard added the bug Something isn't working label Jul 30, 2022
@Xezard Xezard self-assigned this Jul 30, 2022
@Xezard
Copy link
Owner

Xezard commented Jul 31, 2022

I think it's all about the glow.hideFromEveryone() call. Haven't tested your case yet, but this is the only place where this effect can appear. Please, try testing your plugin without calling this method and post the results here.

for(Object obj: ObjectList)) {

LivingEntity entity = (LivingEntity) someWorld.spawnEntity(someLocation, Entity.someEntity); 
entity.setAI(false); entity.setSilent(true); entity.setPersistent(true); entity.setInvulnerable(true); entity.setInvisible(true);

Glow glow = null; //I also tried creating a placeholder Glow object with the builder or by creating a new Glow Instance (the result remains the same)
if(stuff) glow = Glow.builder().color(Color).name(String.valueOf(entity.getEnitityId()).build(); 
else if(stuff) glow = Glow.builder().color(Color).name(String.valueOf(entity.getEnitityId()).build();
//I also tried creating a new Glow instance instead of using the builder (the result remains the same)
else if(stuff) [...]
//at the end of all those conditions, there is no way that the glow variable should be null anyway

glow.addHolders(entity);
glow.display(theIntendedPlayer)

}

@Supre-le-sucre
Copy link
Author

I've tried it and unfortunately no, the glow effect is still visible for other players without colors even if I remove this call.
However, it seems that now the glow effect is visible for other players on all the holder entities instead of just showing on some entities.

What I've also observed is that the glowing effect will only be visible for other players at the end of the for loop and will fully show on all entities, on the other hand theIntendedPlayer will see the glow effect appear step by step on the different entities while the loop is running.
Because this loop is quite big and take some time to complete, I was wondering that maybe lag was the issue, but I've tried with a loop that repeats 1 time and it does not solve the issue either.
I've added nothing after the for loop that could have made this behavior to happen: I've tested it without the code after the loop and this issue still remains.

@Supre-le-sucre
Copy link
Author

I've been investigating the issue, to try to be helpful and tell you some other particularities...
We can move out of the way any conflicting plugins: I've tried with running the server with only my plugin, XGlow and ProtocolLib and the issue is still here. Also my plugin currently does not manipulate packets

What I've done so far is create a command that summon an entity cast into a LivingEntity with a red glowing effect on it visible for the one who summoned it. With this command, the issue still appear so here is the code:

if(BlaBlaBla) {
                LivingEntity entityL = (LivingEntity) p.getWorld().spawnEntity(p.getLocation(), EntityType.CREEPER);
                entityL.setAI(false);
                Glow glow = new Glow(ChatColor.RED,"test");
                glow.display(p);
                glow.addHolders(entityL);
                BukkitTask task = new BukkitRunnable() {

                    @Override
                    public void run() {
                        entityL.remove();
                    }

                }.runTaskLater(JavaPlugin.getPlugin(Main.class), 100L);
            }

What I discovered is that one account can see the glowing effect correctly applied:

The creeper that is summoned by this account is glowing red
The creeper summoned by the other account is not glowing

On the other hand, the second account can see the glowing effect applied wrongly:

The creeper that is summoned by this account is glowing red
The creeper summoned by the other one is glowing in white

I don't know if this can be useful for you, let me know how things goes ;)
(Sorry I will be pretty busy for the next few days, but I will try my best to help you solve this issue and answer as fast as possible)

@Xezard
Copy link
Owner

Xezard commented Aug 1, 2022

Hey, thank you so much for a job well done. Yesterday I tried to reproduce the bug and find out what might be causing it. Unfortunately, the main part of the day is taken away from me by the main work. I'll try to release a fix as soon as possible.

Xezard added a commit that referenced this issue Aug 14, 2022
@Xezard Xezard closed this as completed Aug 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants