forked from MagicBane/Server
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							70 lines
						
					
					
						
							2.9 KiB
						
					
					
				
			
		
		
	
	
							70 lines
						
					
					
						
							2.9 KiB
						
					
					
				| // • ▌ ▄ ·.  ▄▄▄·  ▄▄ • ▪   ▄▄· ▄▄▄▄·  ▄▄▄·  ▐▄▄▄  ▄▄▄ . | |
| // ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· | |
| // ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ | |
| // ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ | |
| // ▀▀  █▪▀▀▀ ▀  ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀  ▀  ▀ ▀▀  █▪ ▀▀▀ | |
| //      Magicbane Emulator Project © 2013 - 2022 | |
| //                www.magicbane.com | |
|  | |
|  | |
| package engine.net.client.handlers; | |
|  | |
| import engine.Enum; | |
| import engine.exception.MsgSendException; | |
| import engine.gameManager.BuildingManager; | |
| import engine.gameManager.MovementManager; | |
| import engine.net.client.ClientConnection; | |
| import engine.net.client.msg.ClientNetMsg; | |
| import engine.net.client.msg.MoveToPointMsg; | |
| import engine.objects.*; | |
|  | |
| public class MoveToPointHandler extends AbstractClientMsgHandler { | |
|  | |
|     public MoveToPointHandler() { | |
|         super(MoveToPointMsg.class); | |
|     } | |
|  | |
|     @Override | |
|     protected boolean _handleNetMsg(ClientNetMsg baseMsg, | |
|                                     ClientConnection origin) throws MsgSendException { | |
|         MoveToPointMsg msg = (MoveToPointMsg) baseMsg; | |
|  | |
|         PlayerCharacter pc = (origin != null) ? (origin.getPlayerCharacter()) : null; | |
|         if (pc == null) | |
|             return false; | |
|  | |
|         if(pc.combatTarget == null){ | |
|             MovementManager.movement(msg, pc); | |
|             return true; | |
|         } else{ | |
|             Enum.GameObjectType combatTargetType = pc.combatTarget.getObjectType(); | |
|             if(combatTargetType.equals(Enum.GameObjectType.NPC)){ | |
|                 msg.clearTarget(); | |
|                 pc.setCombatTarget(null); | |
|                 origin.sendMsg(msg); | |
|             } | |
|  | |
|             if(combatTargetType.equals(Enum.GameObjectType.Mob) || combatTargetType.equals(Enum.GameObjectType.PlayerCharacter)){ | |
|                 MovementManager.movement(msg, pc); | |
|                 return true; | |
|             } else if(combatTargetType.equals(Enum.GameObjectType.Building)) { | |
|                 Building targetBuilding = BuildingManager.getBuilding(pc.combatTarget.getObjectUUID()); | |
|                 if (targetBuilding != null) { | |
|                     if (targetBuilding.isVulnerable() && targetBuilding.getRank() > -1) { | |
|                         MovementManager.movement(msg, pc); | |
|                         return true; | |
|                     } else{ | |
|                         msg.clearTarget(); | |
|                         pc.setCombatTarget(null); | |
|                         origin.sendMsg(msg); | |
|                     } | |
|                 } | |
|             } | |
|         } | |
|  | |
|         pc.teleport(pc.loc); | |
|         msg.setEndCoord(pc.loc); | |
|         origin.sendMsg(msg); | |
|         return true; | |
|     } | |
| }
 | |
| 
 |