Results 1 to 10 of 10
- 06-28-2010, 11:11 PM #1
Member
- Join Date
- Jun 2010
- Posts
- 4
- Rep Power
- 0
getIp Function finding wrong type
Java Code:public String getIP(int channel) { return channelServer.get(channel); }What is wrong? If you need any whole files, please post so.Java Code:C:\Users\Dan\Desktop\Source\src\net\login\LoginServer.java:81: incompatible types found : java.util.Map<java.lang.Integer,java.lang.String> required: java.lang.String return channelServer.get(channel); 1 error BUILD FAILED (total time: 3 seconds)Last edited by Dom; 06-28-2010 at 11:48 PM.
- 06-28-2010, 11:23 PM #2
Member
- Join Date
- Jan 2010
- Posts
- 14
- Rep Power
- 0
Most likely:
the function channelServer.get() returns a map of Integers to Strings instead of one single String. Because getIP wants to return a String and you are returning an map of Intgers to strings ( channelServer.get() ) it will complain about a mismatch.
- 06-28-2010, 11:45 PM #3
Member
- Join Date
- Jun 2010
- Posts
- 4
- Rep Power
- 0
I figured it out, I had it so instead of just channel, it needed to find the world as well.
Fixed Function:
But now I have another problem, this file is giving errors cause the 2 lines don't include world, only channel. Can you explain what I need to add to the lines?Java Code:public String getIP(int world, int channel) { return channelServer.get(world).get(channel); }
I bolded the 2 lines.Java Code:package net.login.handler; import java.net.InetAddress; import java.net.UnknownHostException; import client.MapleClient; import net.AbstractMaplePacketHandler; import net.login.LoginServer; import tools.MaplePacketCreator; import tools.data.input.SeekableLittleEndianAccessor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class CharSelectedWithPicHandler extends AbstractMaplePacketHandler { private static Logger log = LoggerFactory.getLogger(CharSelectedWithPicHandler.class); @Override public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) { String pic = slea.readMapleAsciiString(); int charId = slea.readInt(); String macs = slea.readMapleAsciiString(); c.updateMacs(macs); if (c.checkPic(pic)) { if (c.hasBannedMac()) { c.getSession().close(true); return; } try { if (c.getIdleTask() != null) { c.getIdleTask().cancel(true); } //c.getSession().write(MaplePacketCreator.getServerIP(InetAddress.getByName("127.0.0.1"), 7575, charId)); c.updateLoginState(MapleClient.LOGIN_SERVER_TRANSITION); String channelServerIP = MapleClient.getChannelServerIPFromSubnet(c.getSession().getRemoteAddress().toString().replace("/", "").split(":")[0], c.getChannel()); if(channelServerIP.equals("0.0.0.0")) { [B]String[] socket = LoginServer.getInstance().getIP(c.getChannel()).split(":");[/B] c.getSession().write(MaplePacketCreator.getServerIP(InetAddress.getByName(socket[0]), Integer.parseInt(socket[1]), charId)); } else { [B]String[] socket = LoginServer.getInstance().getIP(c.getChannel()).split(":");[/B] c.getSession().write(MaplePacketCreator.getServerIP(InetAddress.getByName(channelServerIP), Integer.parseInt(socket[1]), charId)); } } catch (UnknownHostException e) { log.error("Host not found", e); } } else { c.getSession().write(MaplePacketCreator.wrongPic()); } } }
I would think it would be something like this, but its not because it says "int can not be deferenced"
String[] socket = LoginServer.getInstance().getIP(c.getWorld().getCh annel()).split(":");Last edited by Dom; 06-28-2010 at 11:59 PM.
- 06-28-2010, 11:59 PM #4
Please copy and paste the FULL text of the error messages here.this file is giving errors
- 06-29-2010, 12:04 AM #5
Member
- Join Date
- Jun 2010
- Posts
- 4
- Rep Power
- 0
This Line:Java Code:init: deps-clean: Deleting directory C:\Users\Dan\Desktop\Source\build clean: init: deps-jar: Created dir: C:\Users\Dan\Desktop\Source\build\classes Compiling 433 source files to C:\Users\Dan\Desktop\Source\build\classes C:\Users\Dan\Desktop\Source\src\net\login\handler\CharSelectedWithPicHandler.java:42: int cannot be dereferenced String[] socket = LoginServer.getInstance().getIP(c.getWorld().getChannel()).split(":"); C:\Users\Dan\Desktop\Source\src\net\login\handler\CharSelectedWithPicHandler.java:45: int cannot be dereferenced String[] socket = LoginServer.getInstance().getIP(c.getWorld().getChannel()).split(":"); C:\Users\Dan\Desktop\Source\src\net\login\handler\RegisterPicHandler.java:39: int cannot be dereferenced String[] socket = LoginServer.getInstance().getIP(c.getWorld().getChannel()).split(":"); C:\Users\Dan\Desktop\Source\src\net\login\handler\RegisterPicHandler.java:42: int cannot be dereferenced String[] socket = LoginServer.getInstance().getIP(c.getWorld().getChannel()).split(":"); Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. 4 errors BUILD FAILED (total time: 2 seconds)needs to work for this function:Java Code:String[] socket = LoginServer.getInstance().getIP(c.getWorld().getChannel()).split(":");Java Code:public String getIP(int world, int channel) { return channelServer.get(world).get(channel); }
- 06-29-2010, 12:15 AM #6
The error message says you are using an int for a reference.int cannot be dereferenced
For example:
int notObject = 1;
notObject.toString(); // int can't be used here
Check what ALL the methods return in your long chain. One must return an int.
- 06-29-2010, 01:22 AM #7
Member
- Join Date
- Jun 2010
- Posts
- 4
- Rep Power
- 0
yea...
Java Code:public int channel = 1;
So how do i fix the fact I cant reference an int?Java Code:private int world;
Last edited by Dom; 06-29-2010 at 01:25 AM.
- 06-29-2010, 02:11 AM #8
An interesting question for a programmer!So how do i fix the fact I cant reference an int
Use the int to index an array of objects.
You can only reference objects. An int is an int. It has no members or methods. Only a value.
- 06-29-2010, 09:51 AM #9
Member
- Join Date
- Jun 2010
- Posts
- 26
- Rep Power
- 0
- 06-29-2010, 11:13 AM #10
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Similar Threads
-
Possible? Callback function passed as arguments to another function
By TreyAU21 in forum Advanced JavaReplies: 3Last Post: 12-04-2009, 03:08 PM -
Error if someone enters the wrong data type
By lithium002 in forum New To JavaReplies: 43Last Post: 11-16-2009, 04:41 PM -
Simple search-function: what am I doing wrong?
By Bas in forum New To JavaReplies: 4Last Post: 07-23-2009, 09:45 PM -
Hibernate mapping error Provided id of the wrong type with composite id
By zigzag in forum JDBCReplies: 1Last Post: 11-11-2008, 08:18 PM -
[SOLVED] Cast string type to int type
By GilaMonster in forum New To JavaReplies: 9Last Post: 09-17-2008, 10:43 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks