View Poll Results: Is this hard?

Voters
2. You may not vote on this poll
  • Yes

    0 0%
  • No

    2 100.00%

Thread: Make a new Commands.java

Results 1 to 8 of 8
  1. #1 Commands 
    Registered Member
    Join Date
    Mar 2009
    Age
    28
    Posts
    155
    Thanks given
    3
    Thanks received
    0
    Rep Power
    27
    Ok i have just come from 508 coding and now i am doing 317. I like it how things like commands and stuff are in their own file. Now i want to make a separate file for the Commands.java i put it into the file with all the others. I wanted to use the voids from client cause i don't want to have to repeat them. What do i have to do i know i have to add c. but do i have to add certain imports or something to make it link to client.java
    Reply With Quote  
     

  2. #2  
    Registered Member
    Hunter's Avatar
    Join Date
    Jun 2009
    Age
    33
    Posts
    857
    Thanks given
    3
    Thanks received
    23
    Rep Power
    216
    The best thing you can do is:

    1.) Make a new package within your source called "Commands"
    2.) Create a CommandManager.java (I think there is a tutorial around somewhere, I dunno)
    3.) Put all commands in their own files and execute the commands using the manager.
    4.) Execute the CommandManager in the client.java.

    Example:

    client.java - case 103: (commands packet)
    Code:
    Command().handlePacket(this, packetType, packetSize);
    If you can't find a tutorial, PM me and I'll set you up with a CommandManager my source has.
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Mar 2009
    Age
    28
    Posts
    155
    Thanks given
    3
    Thanks received
    0
    Rep Power
    27
    No but that is the thing i dont want to clog up Client.java and this is the reason why i wanted to add a seperate file for the commands. I just wanted to use some of the public voids so i didn't have to repeate them so how do i use the voids from client to it do i have to add c. or is there more to it
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Mar 2009
    Age
    28
    Posts
    155
    Thanks given
    3
    Thanks received
    0
    Rep Power
    27
    see this is what is get
    Commands.java:165: cannot find symbol
    symbol : variable c
    location: class Commands
    else if (command.startsWith("az") && c.playerRights >= 1)

    when i try to use some thing from client is just added c. in front do i have to add more
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Mar 2009
    Age
    28
    Posts
    155
    Thanks given
    3
    Thanks received
    0
    Rep Power
    27
    can anyone help
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Mar 2009
    Age
    28
    Posts
    155
    Thanks given
    3
    Thanks received
    0
    Rep Power
    27
    Quote Originally Posted by Hunter View Post
    The best thing you can do is:

    1.) Make a new package within your source called "Commands"
    2.) Create a CommandManager.java (I think there is a tutorial around somewhere, I dunno)
    3.) Put all commands in their own files and execute the commands using the manager.
    4.) Execute the CommandManager in the client.java.

    Example:

    client.java - case 103: (commands packet)
    Code:
    Command().handlePacket(this, packetType, packetSize);
    If you can't find a tutorial, PM me and I'll set you up with a CommandManager my source has.
    I sort of understand
    Reply With Quote  
     

  7. #7  
    Registered Member

    Join Date
    Sep 2008
    Posts
    227
    Thanks given
    6
    Thanks received
    15
    Rep Power
    91
    I created a basic way to do this, look through my threads.
    Quote Originally Posted by d0uwontawank View Post
    What about the botnets crossing the atlantic
    Reply With Quote  
     

  8. #8  
    Registered Member
    Hunter's Avatar
    Join Date
    Jun 2009
    Age
    33
    Posts
    857
    Thanks given
    3
    Thanks received
    23
    Rep Power
    216
    Well for the "c." problem..just create a new file called "Commands.java", add your commands void into it ..of course after creating the proper class layout.

    Then modify the void to look similar to this:
    Code:
    public void commands(client c) {
    Then find the commands packet (103) and execute the command.java like so:
    Code:
    Commands.commands(playerId);
    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
  •