Fixes some nullpointerexceptions in PlayerEventsListener's onPlayerMove
This commit is contained in:
parent
d26196b8aa
commit
279ea9d8f0
@ -100,19 +100,23 @@ public class PlayerEventsListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled() || event.getTo() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check to see if the player moved to another block
|
//Check to see if the player moved to another block
|
||||||
BlockLocation fromLocation = (BlockLocation) event.getFrom();
|
BlockLocation fromLocation = new BlockLocation(event.getFrom().getBlock());
|
||||||
BlockLocation toLocation = (BlockLocation) event.getTo();
|
BlockLocation toLocation = new BlockLocation(event.getTo().getBlock());
|
||||||
if (toLocation == null || fromLocation.equals(toLocation)) {
|
if (fromLocation.equals(toLocation)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Portal entrancePortal = PortalHandler.getByEntrance(toLocation);
|
Portal entrancePortal = PortalHandler.getByEntrance(toLocation);
|
||||||
|
if (entrancePortal == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Portal destination = entrancePortal.getDestination(player);
|
Portal destination = entrancePortal.getDestination(player);
|
||||||
|
|
||||||
//Decide if the anything stops the player from teleport
|
//Decide if the anything stops the player from teleport
|
||||||
|
Loading…
x
Reference in New Issue
Block a user