Fix a null pointer exception if a certain world has no gates.
This commit is contained in:
		@@ -68,21 +68,23 @@ public class PluginPortalListener implements Listener
 | 
				
			|||||||
				Location eventLocation = event.getLocation();
 | 
									Location eventLocation = event.getLocation();
 | 
				
			||||||
				Gate closestGate = GateUtil.closestGate(eventLocation);
 | 
									Gate closestGate = GateUtil.closestGate(eventLocation);
 | 
				
			||||||
				
 | 
									
 | 
				
			||||||
				// Make sure gate and event locations are on the same height (y-value).
 | 
									if (closestGate != null) 
 | 
				
			||||||
				// Otherwise the distance will be messed up when players are flying.
 | 
									{
 | 
				
			||||||
				// FIX ME: this could potentially let a nearby nether portal fail!
 | 
										// Make sure gate and event locations are on the same height (y-value).
 | 
				
			||||||
				eventLocation.setY(closestGate.getLocation().getY());
 | 
										// Otherwise the distance will be messed up when players are flying.
 | 
				
			||||||
				
 | 
										// FIX ME: this could potentially let a nearby nether portal fail!
 | 
				
			||||||
				double distToClosestGate = closestGate.getLocation().distance(eventLocation);
 | 
										eventLocation.setY(closestGate.getLocation().getY());
 | 
				
			||||||
				
 | 
										
 | 
				
			||||||
				Plugin.log("closest gate: " + closestGate.getId());
 | 
										double distToClosestGate = closestGate.getLocation().distance(eventLocation);
 | 
				
			||||||
				Plugin.log("distance: " + distToClosestGate);
 | 
										
 | 
				
			||||||
				
 | 
										Plugin.log("closest gate: " + closestGate.getId());
 | 
				
			||||||
				if (distToClosestGate < 2.0) {
 | 
										Plugin.log("distance: " + distToClosestGate);
 | 
				
			||||||
					this.currentGateAtEvent.put(player, closestGate);
 | 
										
 | 
				
			||||||
					return;
 | 
										if (distToClosestGate < 2.0) {
 | 
				
			||||||
 | 
											this.currentGateAtEvent.put(player, closestGate);
 | 
				
			||||||
 | 
											return;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				
 | 
					 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
			this.currentGateAtEvent.put(player, null);
 | 
								this.currentGateAtEvent.put(player, null);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user