I don't even?
Your logger is trying to log something that is null?
Post the code blocks surrounding Logger.java line 26 and NPCDrops.java line 85, indicate each relevant line number if you could as well
|
So basically i get this small error when i run my server and i feel like its effecting my npc drops... but i have no idea what it means...
Can someone explain to me what it means and how to fix it?
I don't even?
Your logger is trying to log something that is null?
Post the code blocks surrounding Logger.java line 26 and NPCDrops.java line 85, indicate each relevant line number if you could as well
Logger.java:
Code:package server.util.log; import java.io.PrintStream; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import server.util.SimpleTimer; /** * * @author nick */ public class Logger extends PrintStream { private DateFormat dateFormat = new SimpleDateFormat(); private Date cachedDate = new Date(); private SimpleTimer refreshTimer = new SimpleTimer(); public Logger(PrintStream out) { super(out); } @Override public void print(String str) { if (str.startsWith("debug:")) super.print("[" + getPrefix() + "] DEBUG: " + str.substring(6)); else super.print("[" + getPrefix() + "]: " + str); } private String getPrefix() { if (refreshTimer.elapsed() > 1000) { refreshTimer.reset(); cachedDate = new Date(); } return dateFormat.format(cachedDate); } }
NPCDROPS.java:
Code:package server.model.npcs; import java.io.*; import java.util.HashMap; import java.util.Scanner; import java.util.StringTokenizer; import server.world.ItemHandler; import server.Server; import server.model.npcs.NPCHandler; /** * @author Sanity * @author Aintaro */ /** * Made by Aintaro BufferedWriter out = new BufferedWriter(new FileWriter("./Data/npcType/npcRare.txt", true)); BufferedWriter out2 = new BufferedWriter(new FileWriter("./Data/npcType/npcNormal.txt", true)); try { out.newLine(); out.write(ItemHandler.itemNames.get(rareDrops2[npcId][count][0]) + " npcName : " + NPCHandler.getSingleton().getNpcName(npcId)); } finally { //out.close(); } out2.newLine(); out2.write(ItemHandler.itemNames.get(npcDrops[npcId][count][0]) + " npcName : " + NPCHandler.getSingleton().getNpcName(npcId)); * */ public class NPCDrops { public NPCDrops() { //loadDrops(); } public static HashMap<Integer, int[][]> normalDrops = new HashMap<Integer, int[][]>(); public static HashMap<Integer, int[][]> rareDrops = new HashMap<Integer, int[][]>(); public static HashMap<Integer, int[]> constantDrops = new HashMap<Integer, int[]>(); public static HashMap<Integer, Integer> dropRarity = new HashMap<Integer,Integer>(); public static void loadDrops() { try { int[][][] npcDrops = new int [62585][][]; int[][][] rareDrops2 = new int [62585][][]; int[] itemRarity = new int [62585]; File f = new File("./Data/cfg/NPCDrops.TSM"); BufferedWriter out = new BufferedWriter(new FileWriter("./Data/npcType/npcRare.txt", true)); //BufferedWriter out2 = new BufferedWriter(new FileWriter("./Data/npcType/npcNormal.txt", true)); Scanner s = new Scanner(f); while (s.hasNextLine()) { String line = s.nextLine(); if (line.startsWith("#")) continue; StringTokenizer normalTok = new StringTokenizer(line, "\t"); line = s.nextLine(); if (line.startsWith("#")) continue; StringTokenizer rareTok = new StringTokenizer(line, "\t"); String[] information = normalTok.nextToken().split(":"); int npcId = Integer.parseInt(information[0]); itemRarity[npcId] = Integer.parseInt(information[1])-1; npcDrops[npcId] = new int[normalTok.countTokens()][2]; rareDrops2[npcId] = new int[rareTok.countTokens()][2]; int count = 0; while (normalTok.hasMoreTokens()) { String[] temp = normalTok.nextToken().split(":"); npcDrops[npcId][count][0] = Integer.parseInt(temp[0]); npcDrops[npcId][count][1] = Integer.parseInt(temp[1]); //out2.newLine(); //out2.write(ItemHandler.itemNames.get(npcDrops[npcId][count][0]) + " npcName : " + NPCHandler.getSingleton().getNpcName(npcId)); count++; } count = 0; while (rareTok.hasMoreTokens()) { String[] temp = rareTok.nextToken().split(":"); rareDrops2[npcId][count][0] = Integer.parseInt(temp[0]); //System.out.println("npc : " + NPCHandler.getSingleton().getNpcName(npcId)); rareDrops2[npcId][count][1] = Integer.parseInt(temp[1]); //System.out.println("Raredrop: " + count + " " + rareDrops2[npcId][count][1]); System.out.println(ItemHandler.itemNames.get(rareDrops2[npcId][count][0])); out.newLine(); out.write(ItemHandler.itemNames.get(rareDrops2[npcId][count][0]) + " npcName : " + NPCHandler.getSingleton().getNpcName(npcId)); count ++; } normalDrops.put(npcId, npcDrops[npcId]); rareDrops.put(npcId, rareDrops2[npcId]); dropRarity.put(npcId, itemRarity[npcId]); } loadConstants(); } catch (Exception e) { e.printStackTrace(); } } public static void loadConstants() { try { File f = new File("./Data/cfg/NpcConstants.TSM"); Scanner s = new Scanner(f); while (s.hasNextLine()) { String line = s.nextLine(); if (line.startsWith("#")) continue; StringTokenizer constantTok = new StringTokenizer(line, "\t"); int npcId = Integer.parseInt(constantTok.nextToken()); int count = 0; int[] temp = new int[constantTok.countTokens()]; while (constantTok.hasMoreTokens()) { temp[count] = Integer.parseInt(constantTok.nextToken()); count++; } constantDrops.put(npcId,temp); } } catch (Exception e) { e.printStackTrace(); } } }
Can you find those lines of code and give them to let us know what the problem is? Mainly the NpcDrops and Logger
Logger.java line 26:
Code:if (str.startsWith("debug:"))
NPCDrops.java line 85:
Code:System.out.println(ItemHandler.itemNames.get(rareDrops2[npcId][count][0]));
First off, you are printing a null. This may or may not be a bad thing, I don't know the line numbers. It depends on the context or your code.
Secondly, your print method does not ensure the argument is not null before using it as a string, this is the fix:
Code:public void print(String str) { if(str != null){ if (str.startsWith("debug:")) super.print("[" + getPrefix() + "] DEBUG: " + str.substring(6)); else super.print("[" + getPrefix() + "]: " + str); } }
Easy fix
change it to this:
Why do you need it to tell you that there was a rare drop? It's pointless tbhCode://System.out.println(ItemHandler.itemNames.get(rareDrops2[npcId][count][0]));
k thanks guys idk if it was actually hurting anything on my server but im glad its gone it just looked trashy but yeah thanks!!
Also you're fixing it a way to not load drops...
If drops arent loading, try this:
Code:package server.model.npcs; import java.io.*; import java.util.HashMap; import java.util.Scanner; import java.util.StringTokenizer; import server.world.ItemHandler; import server.Server; import server.model.npcs.NPCHandler; /** * @author Sanity * @author Aintaro */ /** * Made by Aintaro BufferedWriter out = new BufferedWriter(new FileWriter("./Data/npcType/npcRare.txt", true)); BufferedWriter out2 = new BufferedWriter(new FileWriter("./Data/npcType/npcNormal.txt", true)); try { out.newLine(); out.write(ItemHandler.itemNames.get(rareDrops2[npcId][count][0]) + " npcName : " + NPCHandler.getSingleton().getNpcName(npcId)); } finally { //out.close(); } out2.newLine(); out2.write(ItemHandler.itemNames.get(npcDrops[npcId][count][0]) + " npcName : " + NPCHandler.getSingleton().getNpcName(npcId)); * */ public class NPCDrops { public NPCDrops() { loadDrops(); } public static HashMap<Integer, int[][]> normalDrops = new HashMap<Integer, int[][]>(); public static HashMap<Integer, int[][]> rareDrops = new HashMap<Integer, int[][]>(); public static HashMap<Integer, int[]> constantDrops = new HashMap<Integer, int[]>(); public static HashMap<Integer, Integer> dropRarity = new HashMap<Integer,Integer>(); public static void loadDrops() { try { int[][][] npcDrops = new int [62585][][]; int[][][] rareDrops2 = new int [62585][][]; int[] itemRarity = new int [62585]; File f = new File("./Data/cfg/NPCDrops.TSM"); BufferedWriter out = new BufferedWriter(new FileWriter("./Data/npcType/npcRare.txt", true)); //BufferedWriter out2 = new BufferedWriter(new FileWriter("./Data/npcType/npcNormal.txt", true)); Scanner s = new Scanner(f); while (s.hasNextLine()) { String line = s.nextLine(); if (line.startsWith("#")) continue; StringTokenizer normalTok = new StringTokenizer(line, "\t"); line = s.nextLine(); if (line.startsWith("#")) continue; StringTokenizer rareTok = new StringTokenizer(line, "\t"); String[] information = normalTok.nextToken().split(":"); int npcId = Integer.parseInt(information[0]); itemRarity[npcId] = Integer.parseInt(information[1])-1; npcDrops[npcId] = new int[normalTok.countTokens()][2]; rareDrops2[npcId] = new int[rareTok.countTokens()][2]; int count = 0; while (normalTok.hasMoreTokens()) { String[] temp = normalTok.nextToken().split(":"); npcDrops[npcId][count][0] = Integer.parseInt(temp[0]); npcDrops[npcId][count][1] = Integer.parseInt(temp[1]); //out2.newLine(); //out2.write(ItemHandler.itemNames.get(npcDrops[npcId][count][0]) + " npcName : " + NPCHandler.getSingleton().getNpcName(npcId)); count++; } count = 0; while (rareTok.hasMoreTokens()) { String[] temp = rareTok.nextToken().split(":"); rareDrops2[npcId][count][0] = Integer.parseInt(temp[0]); //System.out.println("npc : " + NPCHandler.getSingleton().getNpcName(npcId)); rareDrops2[npcId][count][1] = Integer.parseInt(temp[1]); //System.out.println("Raredrop: " + count + " " + rareDrops2[npcId][count][1]); System.out.println(ItemHandler.itemNames.get(rareDrops2[npcId][count][0])); out.newLine(); out.write(ItemHandler.itemNames.get(rareDrops2[npcId][count][0]) + " npcName : " + NPCHandler.getSingleton().getNpcName(npcId)); count ++; } normalDrops.put(npcId, npcDrops[npcId]); rareDrops.put(npcId, rareDrops2[npcId]); dropRarity.put(npcId, itemRarity[npcId]); } loadConstants(); } catch (Exception e) { e.printStackTrace(); } } public static void loadConstants() { try { File f = new File("./Data/cfg/NpcConstants.TSM"); Scanner s = new Scanner(f); while (s.hasNextLine()) { String line = s.nextLine(); if (line.startsWith("#")) continue; StringTokenizer constantTok = new StringTokenizer(line, "\t"); int npcId = Integer.parseInt(constantTok.nextToken()); int count = 0; int[] temp = new int[constantTok.countTokens()]; while (constantTok.hasMoreTokens()) { temp[count] = Integer.parseInt(constantTok.nextToken()); count++; } constantDrops.put(npcId,temp); } } catch (Exception e) { e.printStackTrace(); } } }
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |