walrusone / SkyWarsReloaded

SkyWarsReloaded
GNU General Public License v3.0
22 stars 52 forks source link

Spectators can hit players under certain conditions #40

Closed PatoTheBest closed 6 years ago

PatoTheBest commented 9 years ago

https://github.com/walrusone/SkyWarsReloaded/blob/master/SkyWarsReloadedPlugin/src/main/java/com/walrusone/skywars/listeners/SpectatorListener.java#L164 https://github.com/walrusone/SkyWarsReloaded/blob/master/SkyWarsReloadedPlugin/src/main/java/com/walrusone/skywars/listeners/SpectatorListener.java#L243 Issue Description: When players leave the arena (by right clicking the leave-item), they will leave and get teleported to the spawn, which it's intended, but if they get hit by an arrow and they leave, when the 5 ticks of the scheduler passes, they'll get teleported back to the place they were with the ability to hit other players. Fix:

                    GamePlayer spec = SkyWarsReloaded.getPC().getPlayer(spectatorInvolved.getUniqueId());

                    // Fix for possible NPE
                    if(spec == null) {
                        return; //continue if the code is on the potion loop
                    }

                    // Don't teleport the player back if they aren't spectating
                    if(!spec.isSpectating()) {
                        return; //continue if the code is on the potion loop
                    }

                    spectatorInvolved.teleport(new Location(initialSpectatorLocation.getWorld(), initialSpectatorLocation.getX(), initialSpectatorLocation.getY(), initialSpectatorLocation.getZ(), spectatorInvolved.getLocation().getYaw(), spectatorInvolved.getLocation().getPitch()), TeleportCause.PLUGIN);
                    spectatorInvolved.setAllowFlight(true);
                    spectatorInvolved.setFlying(wasFlying);
LazoYoung commented 8 years ago

So.. A spectator hit by an arrow, then leave the game in 5 ticks, will make such an issue? I think it is quite a rare accurence.

PatoTheBest commented 8 years ago

Yes, but no, players find bugs like this and abuse them, this bug allows the player to hit the players, and its a simple fix

LazoYoung commented 8 years ago

You're right, this should be fixed though. However, the author gave up supporting this project recently. https://www.spigotmc.org/resources/skywarsreloaded.3796/

So I guess you should make a change and do a pull request yourself.