Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-19 13:00:06 +01:00
Fix teleporting entities with vehicles/passengers teleporting you illegally. Fixes BUKKIT-2821
Also some formatting...
Dieser Commit ist enthalten in:
Ursprung
fed863049d
Commit
71b0510f88
@ -346,7 +346,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
@Override
|
@Override
|
||||||
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
|
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
|
||||||
EntityPlayer entity = getHandle();
|
EntityPlayer entity = getHandle();
|
||||||
if (entity.netServerHandler == null || entity.netServerHandler.disconnected) return false;
|
|
||||||
|
if (entity.netServerHandler == null || entity.netServerHandler.disconnected) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity.vehicle != null || entity.passenger != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// From = Players current Location
|
// From = Players current Location
|
||||||
Location from = this.getLocation();
|
Location from = this.getLocation();
|
||||||
@ -355,10 +362,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
// Create & Call the Teleport Event.
|
// Create & Call the Teleport Event.
|
||||||
PlayerTeleportEvent event = new PlayerTeleportEvent((Player) this, from, to, cause);
|
PlayerTeleportEvent event = new PlayerTeleportEvent((Player) this, from, to, cause);
|
||||||
server.getPluginManager().callEvent(event);
|
server.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
// Return False to inform the Plugin that the Teleport was unsuccessful/cancelled.
|
// Return False to inform the Plugin that the Teleport was unsuccessful/cancelled.
|
||||||
if (event.isCancelled() == true) {
|
if (event.isCancelled()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the From Location
|
// Update the From Location
|
||||||
from = event.getFrom();
|
from = event.getFrom();
|
||||||
// Grab the new To Location dependent on whether the event was cancelled.
|
// Grab the new To Location dependent on whether the event was cancelled.
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren