Thread: Project Insanity Teleport handler

Page 1 of 2 12 LastLast
Results 1 to 10 of 18
  1. #1 Project Insanity Teleport handler 
    Registered Member
    Optimum's Avatar
    Join Date
    Apr 2012
    Posts
    3,517
    Thanks given
    830
    Thanks received
    1,580
    Discord
    View profile
    Rep Power
    5000
    Awhile ago i made a teleport handler that wasn't the best. But im back with a better teleport handler.

    First off add this class Fix the imports and the packaging
    Code:
    package org.rs2server.entity.players.teleport;
    
    import org.rs2server.Config;
    import org.rs2server.entity.players.Client;
    import org.rs2server.entity.players.PlayerHandler;
    import org.rs2server.event.CycleEvent;
    import org.rs2server.event.CycleEventContainer;
    import org.rs2server.event.CycleEventHandler;
    
    /**
     * This class will handle all everything to do with the teleporting
     * it will check if the player is eligible to teleport and
     * handle all the animations and gfxs.
     * @author Zack/Optimum
     *
     */
    public class Teleport {
    	
    	/**
    	 * The player teleporting
    	 */
    	private Client player;
    	
    	/**
    	 * The targeted x, y and h coordinates
    	 */
    	private int targetX, targetY, targetH;
    	
    	/**
    	 * Constructor for teleporting
    	 * @param player - the player
    	 */
    	public Teleport(Client player){
    		this.player = player;
    	}
    	
    	/**
    	 * Submits a new teleport tab type
    	 * @param tarX - the new x coordinates
    	 * @param tarY - the new y coordinates
    	 */
    	public void submitTab(final int tarX, final int tarY){
    		this.targetX = tarX;
    		this.targetY = tarY;
    		startTeleport(TeleportType.TELETAB_TELEPORT);
    	}
    	
    	/**
    	 * Submits a new ancient teleport type
    	 * @param tarX - the new x coordinates
    	 * @param tarY - the new y coordinates
    	 */
    	public void submitAncient(final int tarX, final int tarY){
    		this.targetX = tarX;
    		this.targetY = tarY;
    		startTeleport(TeleportType.ANICENT_TELEPORT);
    	}
    	
    	/**
    	 * Submits a new ancient teleport type
    	 * @param tarX - the new x coordinates
    	 * @param tarY - the new y coordinates
    	 * @param tarH - the new height
    	 */
    	public void submitAncient(final int tarX, final int tarY, final int tarH){
    		this.targetX = tarX;
    		this.targetY = tarY;
    		this.targetH = tarH;
    		startTeleport(TeleportType.ANICENT_TELEPORT);
    	}
    	
    	/**
    	 * Submits a new modern teleport
    	 * @param tarX - the new x coordinates
    	 * @param tarY - the new y coordinates
    	 */
    	public void submitModern(final int tarX, final int tarY){
    		this.targetX = tarX;
    		this.targetY = tarY;
    		startTeleport(TeleportType.MODERN_TELEPORT);
    	}
    	
    	/**
    	 * Submits a new modern teleport
    	 * @param tarX - the new x coordinates
    	 * @param tarY - the new y coordinates
    	 * @param tarH - the new height
    	 */
    	public void submitModern(final int tarX, final int tarY, final int tarH){
    		this.targetX = tarX;
    		this.targetY = tarY;
    		this.targetH = tarH;
    		startTeleport(TeleportType.MODERN_TELEPORT);
    	}
    	
    	
    	/**
    	 * Handles the teleport event in 3 stages
    	 */
    	public void startTeleport(final TeleportType teleType){
    		if(!canTeleport(player))
    			return;
    		final int startStage = teleType.getTickTimer1Start();
    		final int middleStage = teleType.getTickTimer2Start();
    		final int stopStage = teleType.getStopTimer();
    		cancelTradeAndDuel(player);
    		player.stopMovement();
    		player.isTeleporting = true;
    		player.startAnimation(teleType.getStartGfxAnim()[0]);
    		if(teleType.getStartGfxAnim()[2] == 100)
    			player.gfx100(teleType.getStartGfxAnim()[1]);
    		else
    			player.gfx0(teleType.getStartGfxAnim()[1]);
    		CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() {
    			int stage = 0;
    			@Override
    			public void execute(CycleEventContainer container) {
    				if (stage == startStage) {
    					player.startAnimation(teleType.getTimer1GfxAnim()[0]);
    					if(teleType.getTimer1GfxAnim()[2] == 100)
    						player.gfx100(teleType.getTimer1GfxAnim()[1]);
    					else
    						player.gfx0(teleType.getTimer1GfxAnim()[1]);
    				}
    				if (stage == middleStage){
    					player.startAnimation(teleType.getTimer2GfxAnim()[0]);
    					if(teleType.getTimer2GfxAnim()[2] == 100)
    						player.gfx100(teleType.getTimer2GfxAnim()[1]);
    					else
    						player.gfx0(teleType.getTimer2GfxAnim()[1]);
    					player.getPA().movePlayer(targetX, targetY, targetH);
    				}
    				if(stage == stopStage){
    					player.startAnimation(65535);
    					player.resetWalkingQueue();
    					container.stop();
    				}
    				stage++;
    				System.out.println("Teleport Stage: " + stage);
    			}
    			@Override
    			public void stop() { 
    				player.isTeleporting = false;
    			}
    		}, 1);
    	}
    	
    	/**
    	 * Checks to see if the player is eligible for teleporting
    	 * @param player - The target player
    	 * @return true if the player can teleport
    	 */
    	public boolean canTeleport(Client player){
    		if(player == null)
    			return false;
    		if(player.isDead)
    			return false;
    		if (isDueling(player))
    			return false;
    		if(isTeleBlocked(player))
    			return false;
    		if(player.isTeleporting)
    			return false;
    		if(wildyLevelCheck(player))
    			return false;
    		return true;
    	}
    
    	/**
    	 * Checks to see if the player is in a duel
    	 * @param player - The target player
    	 * @return true if the player is in a duel
    	 */
    	public boolean isDueling(Client player){
    		if (player.duelStatus == 5) {
    			player.sendMessage("You can't teleport during a duel!");
    			return true;
    		} else
    			return false;
    	}
    	
    	/**
    	 * Checks if the player is teleblocked
    	 * @param player - The target player
    	 * @return true if player is teleblocked
    	 */
    	public boolean isTeleBlocked(Client player){
    		if (System.currentTimeMillis() - player.teleBlockDelay < player.teleBlockLength) {
    			player.sendMessage("You are teleblocked and can't teleport.");
    			return true;
    		} else
    			return false;
    	}
    
    	/**
    	 * Cancels the trade and duel for {@link player} and
    	 * the opponent he is dueling / trading with
    	 * @param player - the target player
    	 */
    	public void cancelTradeAndDuel(Client player){
    		if (player.duelStatus >= 1 && player.duelStatus <= 4) {
    			Client o = (Client) PlayerHandler.players[player.duelingWith];
    			player.duelStatus = 0;
    			o.duelStatus = 0;
    			o.getTradeAndDuel().declineDuel();
    			player.getTradeAndDuel().declineDuel();
    		}
    	}
    	
    	/**
    	 * Checks the current player wilderness level and returns true
    	 * if the player is above the max teleport wilderness level
    	 * @param player - The target player
    	 * @return if player is in wildy > 20
    	 */
    	public boolean wildyLevelCheck(Client player){
    		if (player.inWild() && player.wildLevel > Config.NO_TELEPORT_WILD_LEVEL) {
    			player.sendMessage("You can't teleport above level "
    					+ Config.NO_TELEPORT_WILD_LEVEL + " in the wilderness.");
    			return true;
    		} else
    			return false;
    	}
    
    }
    Now add this class inside the same package
    Code:
    package org.rs2server.entity.players.teleport;
    
    /**
     * Contains all the teleport types and all their data
     * @author Zack/Optimum
     *
     */
    
    public enum TeleportType {
    
    	MODERN_TELEPORT(
    			new int[] {714, -1, 0}, 1, new int[] {-1, 308, 100},
    			3, new int[] {715, -1, 0}, 6),
    	ANICENT_TELEPORT(
    			new int[] {9599, 1681, 0}, 5, new int[] {-1, -1, 0},
    			5, new int[] {-1, -1, 0}, 5),
    	TELETAB_TELEPORT(
    			new int[] {9597, 1680, 0}, 2, new int[] {4731, -1, 0},
    			3, new int[] {9598, -1, 0}, 4);
    	
    	
    	int[] startGfxAnim;
    	int tickTimer1Start;
    	int[] timer1GfxAnim;
    	int tickTimer2Start;
    	int[] timer2GfxAnim;
    	int stopTimer;
    	
    	TeleportType(int[] startGfxAnim, int tickTimer1Start, int[] timer1GfxAnim, int tickTimer2Start, int[] timer2GfxAnim, int stopTimer){
    		this.startGfxAnim = startGfxAnim;
    		this.tickTimer1Start = tickTimer1Start;
    		this.timer1GfxAnim = timer1GfxAnim;
    		this.tickTimer2Start = tickTimer2Start;
    		this.timer2GfxAnim = timer2GfxAnim;
    		this.stopTimer = stopTimer;
    	}
    	
    	public int[] getStartGfxAnim(){
    		return startGfxAnim;
    	}
    	
    	public int getTickTimer1Start(){
    		return tickTimer1Start;
    	}
    	
    	public int[] getTimer1GfxAnim(){
    		return timer1GfxAnim;
    	}
    	
    	public int getTickTimer2Start(){
    		return tickTimer2Start;
    	}
    	
    	public int[] getTimer2GfxAnim(){
    		return timer2GfxAnim;
    	}
    	
    	public int getStopTimer(){
    		return stopTimer;
    	}
    }
    now go to Client.java and add these:
    Code:
    	private Teleport teleport = new Teleport(this);
    	public Teleport getTeleportHandler(){
    		return teleport;
    	}
    this is an example of how to use this:
    Code:
    		case 4171:
    		case 117048:
    		case 75010:
    		case 50056:
    		case 84237:
    				if(c.playerMagicBook != 1) {
    					c.getTeleportHandler().submitModern(Config.RESPAWN_X, Config.RESPAWN_Y);
    				} else {
    					c.getTeleportHandler().submitAncient(Config.RESPAWN_X, Config.RESPAWN_Y);
    				}
    				break;

    If i have missed anything please tell me.

    Quote Originally Posted by DownGrade View Post
    Don't let these no life creeps get to you, its always the same on here. They'd rather spend hours upon hours in the rune-server spam section then getting laid! ha ha!Its honestly pathetic i haven't seen so many lowlifes in my life its actually insane i wish that this section would just vanish its probably the only way to get these people out of the community...
    PLEASE BE AWARE OF IMPOSTERS MY DISCORD ID: 362240000760348683
    Reply With Quote  
     

  2. #2  
    Banned
    Join Date
    Feb 2013
    Posts
    1,067
    Thanks given
    72
    Thanks received
    28
    Rep Power
    0
    nice bro
    Reply With Quote  
     

  3. #3  
    Registered Member
    Optimum's Avatar
    Join Date
    Apr 2012
    Posts
    3,517
    Thanks given
    830
    Thanks received
    1,580
    Discord
    View profile
    Rep Power
    5000
    Quote Originally Posted by bhans12 View Post
    nice bro
    Thanks

    Quote Originally Posted by DownGrade View Post
    Don't let these no life creeps get to you, its always the same on here. They'd rather spend hours upon hours in the rune-server spam section then getting laid! ha ha!Its honestly pathetic i haven't seen so many lowlifes in my life its actually insane i wish that this section would just vanish its probably the only way to get these people out of the community...
    PLEASE BE AWARE OF IMPOSTERS MY DISCORD ID: 362240000760348683
    Reply With Quote  
     

  4. #4  
    Extreme Donator Market Banned Market Banned



    Join Date
    Aug 2011
    Age
    25
    Posts
    3,596
    Thanks given
    1,403
    Thanks received
    1,619
    Rep Power
    5000
    Nice work, gonna test it out

    [Only registered and activated users can see links. ]

    Discord: Roy#2382

    Reply With Quote  
     

  5. #5  
    Developer Of Life

    Join Date
    Nov 2014
    Posts
    290
    Thanks given
    8
    Thanks received
    36
    Rep Power
    9
    Damn bro this is really good, great contribution.
    Reply With Quote  
     

  6. #6  
    Registered Member
    Optimum's Avatar
    Join Date
    Apr 2012
    Posts
    3,517
    Thanks given
    830
    Thanks received
    1,580
    Discord
    View profile
    Rep Power
    5000
    Quote Originally Posted by Intensity View Post
    Nice work, gonna test it out
    Thanks

    Quote Originally Posted by SystemRsPs View Post
    Damn bro this is really good, great contribution.
    Thanks

    Quote Originally Posted by DownGrade View Post
    Don't let these no life creeps get to you, its always the same on here. They'd rather spend hours upon hours in the rune-server spam section then getting laid! ha ha!Its honestly pathetic i haven't seen so many lowlifes in my life its actually insane i wish that this section would just vanish its probably the only way to get these people out of the community...
    PLEASE BE AWARE OF IMPOSTERS MY DISCORD ID: 362240000760348683
    Reply With Quote  
     

  7. #7  
    ̿ ̿̿ ̿̿ ̿̿̿'̿'\̵͇̿̿\=(•̪

    Dragonking's Avatar
    Join Date
    May 2008
    Posts
    2,011
    Thanks given
    16
    Thanks received
    31
    Rep Power
    567
    Great Job, If it wasnt a pain to go through and change everything id use this.


    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  8. #8  
    Registered Member
    Optimum's Avatar
    Join Date
    Apr 2012
    Posts
    3,517
    Thanks given
    830
    Thanks received
    1,580
    Discord
    View profile
    Rep Power
    5000
    Quote Originally Posted by Dragonking View Post
    Great Job, If it wasnt a pain to go through and change everything id use this.
    Its honestly not that bad. Takes 10 minutes or so depending on how much teleports you've got

    Quote Originally Posted by DownGrade View Post
    Don't let these no life creeps get to you, its always the same on here. They'd rather spend hours upon hours in the rune-server spam section then getting laid! ha ha!Its honestly pathetic i haven't seen so many lowlifes in my life its actually insane i wish that this section would just vanish its probably the only way to get these people out of the community...
    PLEASE BE AWARE OF IMPOSTERS MY DISCORD ID: 362240000760348683
    Reply With Quote  
     

  9. #9  
    Registered Member
    Optimum's Avatar
    Join Date
    Apr 2012
    Posts
    3,517
    Thanks given
    830
    Thanks received
    1,580
    Discord
    View profile
    Rep Power
    5000
    updated

    Quote Originally Posted by DownGrade View Post
    Don't let these no life creeps get to you, its always the same on here. They'd rather spend hours upon hours in the rune-server spam section then getting laid! ha ha!Its honestly pathetic i haven't seen so many lowlifes in my life its actually insane i wish that this section would just vanish its probably the only way to get these people out of the community...
    PLEASE BE AWARE OF IMPOSTERS MY DISCORD ID: 362240000760348683
    Reply With Quote  
     

  10. #10  
    Registered Member Pseudo's Avatar
    Join Date
    Jan 2014
    Posts
    228
    Thanks given
    31
    Thanks received
    43
    Rep Power
    37
    This is still bad, hate how only a handful of people tell it as it is these days.
    Reply With Quote  
     

  11. Thankful user:


Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. project insanity - global drops handler
    By Spooky in forum Snippets
    Replies: 22
    Last Post: 11-10-2016, 06:15 PM
  2. Teleporting Interfaces [Project Insanity]
    By thim slug in forum Snippets
    Replies: 95
    Last Post: 04-16-2013, 03:18 AM
  3. Replies: 6
    Last Post: 05-31-2011, 05:28 PM
  4. Project Insanity Teleporting
    By Throat in forum Help
    Replies: 4
    Last Post: 10-23-2010, 02:22 PM
  5. Project Insanity Teleports
    By Juggalo Family in forum Requests
    Replies: 1
    Last Post: 09-17-2010, 10:41 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •