Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-11-2008, 06:06 AM   PM User | #1
Tonypker13
New to the CF scene

 
Join Date: Oct 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Tonypker13 is an unknown quantity at this point
Java help? Possibly easy.

So, I made this code for my server, I added it but a get a few errors. a guy told me how to fix but I dont really understand.

My code is-
Code:
                } else if (cmd[0].equals("banuser")) {
		    int id = Engine.getIdFromName(cmd[1]);
		    if (id == 0) {
			p.frames.sendMessage(p, "Player either does not exist or is not online!");
			return;
		    } 
		    Player p2 = Engine.players[id];
		    if (p2 == null) {
			return;
		    }
		    p2.disconnected[0] = true;
		    FileManager fm = new FileManager();
		    fm.appendData("banned/bannedusers.dat", cmd[1]);
		    fm = null;
		    Server.loadBannedUsers();
		    p.frames.sendMessage(p, "You have banned this user succesfuly!");
		} else if (cmd[0].equals("ipban")) {
		    int id = Engine.getIdFromName(cmd[1]);
		    if (id == 0) {
			p.frames.sendMessage(p, "Player either does not exist or is not online!");
			return;
		    } 
		    Player p2 = Engine.players[id];
		    if (p2 == null) {
			return;
		    }
		    p2.disconnected[0] = true;
		    FileManager fm = new FileManager();
		    fm.appendData("banned/bannedhosts.dat", p2.connectionIP);
		    fm = null;
		    Server.socketListener.loadBannedHosts();
		    p.frames.sendMessage(p, "You have ip banned this user succesfuly!");
		}
My error is-
Code:
.\palidino76\rs2\io\packets\Commands.java:331: non-static method getIdFromName(j
ava.lang.String) cannot be referenced from a static context
                    int id = Engine.getIdFromName(cmd[1]);
                                   ^
.\palidino76\rs2\io\packets\Commands.java:341: cannot find symbol
symbol  : class FileManager
location: class palidino76.rs2.io.packets.Commands
                    FileManager fm = new FileManager();
                    ^
.\palidino76\rs2\io\packets\Commands.java:341: cannot find symbol
symbol  : class FileManager
location: class palidino76.rs2.io.packets.Commands
                    FileManager fm = new FileManager();
                                         ^
.\palidino76\rs2\io\packets\Commands.java:344: loadBannedUsers() has private acc
ess in palidino76.rs2.Server
                    Server.loadBannedUsers();
                          ^
.\palidino76\rs2\io\packets\Commands.java:347: non-static method getIdFromName(j
ava.lang.String) cannot be referenced from a static context
                    int id = Engine.getIdFromName(cmd[1]);
                                   ^
.\palidino76\rs2\io\packets\Commands.java:357: cannot find symbol
symbol  : class FileManager
location: class palidino76.rs2.io.packets.Commands
                    FileManager fm = new FileManager();
                    ^
.\palidino76\rs2\io\packets\Commands.java:357: cannot find symbol
symbol  : class FileManager
location: class palidino76.rs2.io.packets.Commands
                    FileManager fm = new FileManager();
                                         ^
.\palidino76\rs2\io\packets\Commands.java:358: cannot find symbol
symbol  : variable connectionIP
location: class palidino76.rs2.players.Player
                    fm.appendData("banned/bannedhosts.dat", p2.connectionIP);
                                                              ^
.\palidino76\rs2\io\packets\Commands.java:360: loadBannedHosts() has private acc
ess in palidino76.rs2.net.SocketListener
                    Server.socketListener.loadBannedHosts();
                                         ^
9 errors
the reply was-
Code:
Public void getIdForName - Public static void

Add the import for the fileManager class

And make the method loadBannedHosts() public instead of private
can any1 help? Thanks!
~.Tony.~
Tonypker13 is offline   Reply With Quote
Old 10-11-2008, 07:08 AM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,678
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
This is "JavaScript programming" sub-forum, not for Java. Request a moderator to move this thread to the right forum.
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:50 AM.


Advertisement
Log in to turn off these ads.