Thread: What is wrong with this?

Results 1 to 4 of 4
  1. #1 What is wrong with this? 
    Banned

    Join Date
    Dec 2008
    Posts
    2,097
    Thanks given
    1,419
    Thanks received
    732
    Rep Power
    0
    Well i been having problems with the Fletching i wrote.. at first i was using Project insanity and the fletching class was shutting down the listener for some reason i have no clue well i said fk it and just switched bases i chose RuneFusion by blake and spent all day repackaging and renaming shit to make it easier for me to use then when it came time to start writing content i added my fletching and tryed logging in and i couldnt then i commented out the whole fletching class and it let me login

    Code:
    package server.model.player.skills;
    
    import server.model.player.Player;
    import server.Constants;
    
    public class Fletching {
    
    	Player p;
    
    	public Fletching(Player p) {
    		this.p = p;
    	}
    
    	private int skillId = Constants.FLETCHING;
    	
    	public int fSlot(int itemId){
    		return p.getItems().getItemSlot(itemId);
    	}
    
    	public boolean fletching = false;
    
    	int fletchType = 0, amount = 0, log = 0;
    
    	public void handleFletchingClick(int clickId) {
    		for (int j = 0; j < buttons.length; j++) {
    			if (buttons[j][0] == clickId) {
    				fletchType = buttons[j][1];
    				amount = buttons[j][2];
    				for (int i = 0; i < logType.length; i++)
    					if (log == logType[i]) {
    						fletchBow(i);
    						break;
    					}
    				break;
    			}
    		}	
    	}
    
    	public void fletchBow(int index) {
    		int toAdd = getItemToAdd(index);
    		int amountToAdd = getAmountToAdd(toAdd);
    		int levelReq = getLevel(index);
    		for (int j = 0; j < amount; j++) {
    			if (p.getItems().hasItem(logType[index])) {
    				if (p.playerLevel[skillId] >= levelReq) {
    					p.getItems().deleteItem(logType[index], p.getItems().getItemSlot(logType[index]), 1);
    					p.getItems().addItem(toAdd, amountToAdd);
    					p.addSkillXP(getExp(index), skillId);
    				} else {
    					p.sendMessage("You need a fletching level of " + levelReq + " to fletch this item.");
    					break;
    				}
    			} else {
    				break;
    			}
    		}	
    	}
    
    	public int getLevel(int index) {
    		if (fletchType == 3)
    			return 1;
    		else if (fletchType == 1)
    			return sbReq[index];
    		else
    			return lbReq[index];
    	}
    
    	public double getExp(int index) {
    		if (fletchType == 3)
    			return 5;
    		else if (fletchType == 1)
    			return sbExp[index];
    		else
    			return lbExp[index];
    	}
    
    	public int getItemToAdd(int index) {
    		if (fletchType == 3)
    			return shaft;
    		else if (fletchType == 1)
    			return shortbows[index];
    		else if (fletchType == 2)
    			return longbows[index];
    		return 0;
    	}
    
    	public int getAmountToAdd(int id) {
    		if (id == 52)
    			return 15;
    		else
    			return 1;	
    	}
    
    	public int shaft = 52;
    	public int[] logType = {1511, 1521, 1519, 1517, 1515, 1513};
    	public int[] shortbows = {841, 843, 849, 853, 857, 861};
    	public int[] longbows = {839, 845, 847, 851, 855, 859};
    	public double[] sbExp = {5, 16.5, 33.25, 50, 67.5, 88.25};
    	public double[] lbExp = {10, 25, 41.5, 58.25, 75,  91.5};
    	public int[] sbReq = {5, 20, 35, 50, 65, 80};
    	public int[] lbReq = {10, 25, 40, 55, 70, 85};
    
    	public int amt = p.getItems().getItemCount(log);
    
    
    	public int[][] buttons = {
    			{34185, 1, 1},
    			{34189,2,1},
    			{34170, 1, 1},
    			{34174, 2, 1},
    			{34193,3,1},
    			{34173, 2, amt > 5 ? 5 : amt},
    			{34169, 1, amt > 5 ? 5 : amt},
    			{34184,1,amt > 5 ? 5 : amt},
    			{34188,2,amt > 5 ? 5 : amt},
    			{34193,3,amt > 5 ? 5 : amt}, 
    			{34172, 2, amt > 10 ? 10 : amt},
    			{34168, 1, amt > 10 ? 10 : amt},
    			{34183, 1, amt > 10 ? 10 : amt},
    			{34187,2,amt > 10 ? 10 : amt},
    			{34193,3,amt > 10 ? 10 : amt},
    			{34182,1,amt > 27 ? 27 : amt},
    			{34186,2,amt > 27 ? 27 : amt},
    			{34193,3,amt > 27 ? 27 : amt}, 
    			{34167, 1, amt > 27 ? 27 : amt},
    			{34171, 2, amt > 27 ? 27 : amt}};
    
    
    	public void openFletching(int item) {
    
    		switch(item){
    
    		case 1511:
    			p.sendFrame164(8880);
    			p.sendFrame126("What would you like to make?", 8879);
    			p.sendFrame246(8884, 250, 839); // middle
    			p.sendFrame246(8883, 250, 841); // left picture
    			p.sendFrame246(8885, 250, 52); // right pic
    			p.sendFrame126("Shortbow", 8889);
    			p.sendFrame126("Longbow", 8893);
    			p.sendFrame126("Arrow Shafts", 8897);
    			log = item;
    			fletching = true;
    			break;
    
    		case 1521:
    			p.sendFrame164(8866);
    			p.sendFrame126("What would you like to make?", 8879);
    			p.sendFrame246(8870, 250, 845); // middle
    			p.sendFrame246(8869, 250, 843); // left picture
    			p.sendFrame126("Oak Shortbow", 8871);
    			p.sendFrame126("Oak Longbow", 8878);
    			log = item;
    			fletching = true;
    			break;
    
    		case 1519:
    			p.sendFrame164(8866);
    			p.sendFrame126("What would you like to make?", 8879);
    			p.sendFrame246(8870, 250, 845); // middle
    			p.sendFrame246(8869, 250, 843); // left picture
    			p.sendFrame126("Willow Shortbow", 8871);
    			p.sendFrame126("Willow Longbow", 8878);
    			log = item;
    			fletching = true;
    			break;
    
    		case 1517:
    			p.sendFrame164(8866);
    			p.sendFrame126("What would you like to make?", 8879);
    			p.sendFrame246(8870, 250, 845); // middle
    			p.sendFrame246(8869, 250, 843); // left picture
    			p.sendFrame126("Maple Shortbow", 8871);
    			p.sendFrame126("Maple Longbow", 8878);
    			log = item;
    			fletching = true;
    			break;
    
    		case 1515:
    			p.sendFrame164(8866);
    			p.sendFrame126("What would you like to make?", 8879);
    			p.sendFrame246(8870, 250, 845); // middle
    			p.sendFrame246(8869, 250, 843); // left picture
    			p.sendFrame126("Yew Shortbow", 8871);
    			p.sendFrame126("Yew Longbow", 8878);
    			log = item;
    			fletching = true;
    			break;
    
    		case 1513:
    			p.sendFrame164(8866);
    			p.sendFrame126("What would you like to make?", 8879);
    			p.sendFrame246(8870, 250, 845); // middle
    			p.sendFrame246(8869, 250, 843); // left picture
    			p.sendFrame126("Magic Shortbow", 8871);
    			p.sendFrame126("Magic Longbow", 8878);
    			log = item;
    			fletching = true;
    			break;	
    		}
    
    	}
    
    	public boolean isLog(int log) {
    		for(int i = 0; i < logType.length; i++) {
    			if(logType[i] == log)
    				return true;
    		}
    		return false;
    	}
    
    
    	private int[][] stringArray = {
    			{50, 841, 5, 5}, {48, 839, 10, 10},
    			{54, 843, 20, 1605}, {56 ,845, 25, 25},
    			{60, 849, 35, 3305}, {58, 847, 40, 4105},
    			{64, 853, 50, 50}, {62, 851, 55, 58025},
    			{68, 857, 65, 6705}, {66, 855, 70, 75},
    			{72, 861, 80, 83025}, {70, 859, 85, 19105}
    
    	};
    
    	public void finishBow(int unstrungBow){
    		for (int j = 0; j < stringArray.length; j++) {
    			if(stringArray[j][0] == unstrungBow){
    				if(p.playerLevel[2] == stringArray[j][2]){
    					p.getItems().deleteItem(unstrungBow, fSlot(unstrungBow), 1);
    					p.getItems().deleteItem(1777, fSlot(1777), 1);
    					p.getItems().addItem(stringArray[j][1], 1);
    					p.sendMessage("s");
    					p.addSkillXP(stringArray[j][3], skillId);
    
    				}
    			}
    		}
    	}
    	
    
    	public boolean isUnstrung(int unstrung) {
    		for(int i = 0; i < stringArray.length; i++) {
    			if(stringArray[i][0] == unstrung)
    				return true;
    		}
    		return false;
    	}
    
    	private int[][] dartArray = {
    			{819, 806, 1, 108}, {820, 807, 22, 308},
    			{821, 808, 37, 705}, {822, 809, 52, 1102}, 
    			{823, 810, 67, 15}, {824, 811, 81, 1808}
    
    	};
    
    	public int dartAmount(int index) {
    
    		int tip = p.getItems().getItemCount(dartArray[index][0]);
    		int feather = p.getItems().getItemCount(314);
    
    		if (tip > feather && feather < 15)
    			return feather;
    		else if (feather > tip && tip < 15)
    			return tip;
    		return 15;
    	}
    
    	public void makeDart(int dartTip) {
    
    		for (int j = 0; j < dartArray.length; j++) {
    			if (dartArray[j][0] == dartTip) {
    				if(p.playerLevel[2] == dartArray[j][2]){
    					p.getItems().deleteItem(dartTip, fSlot(dartTip), dartAmount(j));
    					p.getItems().deleteItem(314, fSlot(314), dartAmount(j));
    					p.getItems().addItem(dartArray[j][1], dartAmount(j));
    					p.sendMessage("s");
    					p.addSkillXP(dartArray[j][3] * dartAmount(j), skillId);
    
    				} else {
    					p.sendMessage("s");
    				}
    			}
    		}
    
    	}
    
    	public boolean isDartTip(int dartTip) {
    		for(int i = 0; i < dartArray.length; i++) {
    			if(dartArray[i][0] == dartTip)
    				return true;
    		}
    		return false;
    	}
    
    	private int[][] arrowData = {
    			{39, 882, 1, 206}, {40, 884, 15, 308},
    			{41, 886, 30, 603}, {42, 888, 45, 808}, 
    			{43, 890, 60, 1103}, {44, 892, 75, 1308}
    
    	};
    
    	private int arrowAmount(int index) {
    
    		int shaft = p.getItems().getItemCount(53);
    		int head = p.getItems().getItemCount(arrowData[index][1]);
    
    		if (shaft > head && head < 15)
    			return head;
    		else if (head > shaft && shaft < 15)
    			return shaft;
    		return 15;
    	}
    
    	public void makeArrow(int head) {
    
    		for (int j = 0; j < arrowData.length; j++) {
    			if (arrowData[j][0] == head) {
    				if(p.playerLevel[2] == arrowData[j][2]){
    					p.getItems().deleteItem(head, fSlot(head), arrowAmount(j));
    					p.getItems().deleteItem(53, fSlot(53), arrowAmount(j));
    					p.getItems().addItem(arrowData[j][1], arrowAmount(j));
    					p.sendMessage("s");
    					p.addSkillXP(arrowData[j][3] * arrowAmount(j), skillId);
    
    				}
    				else {
    					p.sendMessage("s");
    				}
    			}
    		}
    
    	}
    
    	public boolean isArrowHead(int arrowHead) {
    		for(int i = 0; i < arrowData.length; i++) {
    			if(arrowData[i][0] == arrowHead)
    				return true;
    		}
    		return false;
    	}
    
    	public int headlessAmount() {
    
    		int shaft = p.getItems().getItemCount(52);
    		int feather = p.getItems().getItemCount(314);
    
    		if (shaft > feather && feather < 15)
    			return feather;
    		else if (feather > shaft && shaft < 15)
    			return shaft;
    		return 15;
    	}
    
    	public void makeHeadlessArrow() {
    		p.getItems().deleteItem(52, fSlot(52), headlessAmount());
    		p.getItems().deleteItem(314, fSlot(52), headlessAmount());
    		p.getItems().addItem(53, headlessAmount());
    		p.sendMessage("s");
    		p.addSkillXP(headlessAmount(), skillId);	
    	}
    
    
    
    }
    I've read through this class several times looking for something that could be causing it but i have no idea ANY help would be GREATLY appreciated! thx
    Reply With Quote  
     

  2. #2  
    Registered Member
    Pilldom's Avatar
    Join Date
    Sep 2007
    Posts
    1,298
    Thanks given
    24
    Thanks received
    221
    Rep Power
    164
    What exactly is the problem you are having with it? Can you give us the error it gives when it shuts down the listener?
    Attached image
    Reply With Quote  
     

  3. #3  
    Banned

    Join Date
    May 2008
    Posts
    2,327
    Thanks given
    55
    Thanks received
    67
    Rep Power
    0
    Quote Originally Posted by Pilldom View Post
    What exactly is the problem you are having with it? Can you give us the error it gives when it shuts down the listener?
    this is the error
    Code:
    Exception in thread "Thread-4" java.lang.ExceptionInInitializerError
            at client.parseIncomingPackets(client.java:16787)
            at client.packetProcess(client.java:22003)
            at PlayerHandler.process(PlayerHandler.java:415)
            at process.run(process.java:14)
            at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.NullPointerException
            at Fletching.<clinit>(Fletching.java:101)
            ... 5 more
    Reply With Quote  
     

  4. #4  
    Banned

    Join Date
    Dec 2008
    Posts
    2,097
    Thanks given
    1,419
    Thanks received
    732
    Rep Power
    0
    Quote Originally Posted by silabgarza View Post
    this is the error
    Code:
    Exception in thread "Thread-4" java.lang.ExceptionInInitializerError
            at client.parseIncomingPackets(client.java:16787)
            at client.packetProcess(client.java:22003)
            at PlayerHandler.process(PlayerHandler.java:415)
            at process.run(process.java:14)
            at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.NullPointerException
            at Fletching.<clinit>(Fletching.java:101)
            ... 5 more
    ... no thats not it yours is completley different cuz your using a different base

    i'm not given any error at ALL it just simply wont login and it has nothing to do with an ip because i can just comment out the fletching class and it works just fine
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

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


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •