Thread: Commands.java help

Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1 Commands.java help 
    Registered Member Bad Havoc's Avatar
    Join Date
    Nov 2010
    Age
    26
    Posts
    33
    Thanks given
    6
    Thanks received
    1
    Rep Power
    1
    hi i was wondering if anyone could help me, i'm trying to make it so on my commands, i can do something like this,
    "public void Owner && c.playerRights = 3 {
    }" i know that would probably never work, but its just an example to show you what i mean, now what i'm wanting is now i can put in all the commands i want to be owner only to be inside those brackets after playerRights = 3, so i don't have to continuously type c.playerRights= whatever, after each code, also it will help organize it so its not all mombo jumbo, so can anyone help me format this or show me how to do this?

    P.S. also can anyone tell me how i can make that text box where u can enter code? i never found out how to do that.. like the place you put stuff like "public void" yada yada, thanks
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Jul 2014
    Posts
    305
    Thanks given
    62
    Thanks received
    40
    Rep Power
    0
    I think you don't understand PI yet.
    It already does that.
    Reply With Quote  
     

  3. #3  
    Registered Member Bad Havoc's Avatar
    Join Date
    Nov 2010
    Age
    26
    Posts
    33
    Thanks given
    6
    Thanks received
    1
    Rep Power
    1
    Quote Originally Posted by inkk View Post
    I think you don't understand PI yet.
    It already does that.
    well tbh i'm completely new so obvious i wouldn't understand that's why i asked for help, and my commands.java doesn't do that....its a cleaned pi source so it has nothing.. just this-
    "package server.model.player.packets;

    import server.Settings;
    import server.GameEngine;
    import server.model.player.Client;
    import server.model.player.PacketType;
    import server.util.Misc;

    /**
    * Commands
    **/
    public class Commands implements PacketType {

    @Override
    public void processPacket(Client c, int packetType, int packetSize) {
    String playerCommand = c.getInStream().readString();
    Misc.println(c.playerName + " playerCommand: " + playerCommand);
    if (Settings.SERVER_DEBUG)
    if (playerCommand.startsWith("/") && playerCommand.length() > 1) {
    if (c.clanId >= 0) {
    System.out.println(playerCommand);
    playerCommand = playerCommand.substring(1);
    GameEngine.clanChat.playerMessageToClan(c.playerId ,
    playerCommand, c.clanId);
    } else {
    if (c.clanId != -1)
    c.clanId = -1;
    c.sendMessage("You are not in a clan.");
    }
    return;
    }
    // player commands
    {
    if (playerCommand.equals("home") && c.playerRights >= 0) {
    c.getPA().startTeleport(3087, 3502, 0, "modern");
    }
    // donator commands

    // moderator commands

    // admin commands
    if (playerCommand.startsWith("item") && c.playerRights >= 2) {
    try {
    String[] args = playerCommand.split(" ");
    if (args.length == 3) {
    int newItemID = Integer.parseInt(args[1]);
    int newItemAmount = Integer.parseInt(args[2]);
    if ((newItemID <= 20000) && (newItemID >= 0)) {
    c.getItems().addItem(newItemID, newItemAmount);
    } else {
    c.sendMessage("No such item.");
    }
    } else {
    c.sendMessage("Use as ::item id amount.");
    }
    } catch (Exception e) {

    }
    }

    // owner commands
    }
    }
    }
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Jul 2014
    Posts
    305
    Thanks given
    62
    Thanks received
    40
    Rep Power
    0
    If your new, don't use a clean PI then.
    Reply With Quote  
     

  5. #5  
    Registered Member Bad Havoc's Avatar
    Join Date
    Nov 2010
    Age
    26
    Posts
    33
    Thanks given
    6
    Thanks received
    1
    Rep Power
    1
    Quote Originally Posted by inkk View Post
    If your new, don't use a clean PI then.
    just go away talking to you is pointless, can someone please help me with the original problem please?
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Apr 2014
    Posts
    8
    Thanks given
    0
    Thanks received
    1
    Rep Power
    0
    The Java™ Tutorials

    That link will lead you to all of the information you need to know.
    Reply With Quote  
     

  7. #7  
    Registered Member Bad Havoc's Avatar
    Join Date
    Nov 2010
    Age
    26
    Posts
    33
    Thanks given
    6
    Thanks received
    1
    Rep Power
    1
    fml, i'm already in the process of watching java guides and learning the basic language and how to do things, but i still want to work on my private server as i go so i can apply what i'm learning, why post a reply if your not actually trying to help answer the question i asked? makes no sense at all don't understand why it's so hard just to help someone whos new out...
    Reply With Quote  
     

  8. #8  
    Extreme Donator

    Join Date
    Aug 2013
    Age
    29
    Posts
    708
    Thanks given
    192
    Thanks received
    234
    Rep Power
    106
    Replace your commands.java with that. But you will need to add in your own commands into the brackets itself.
    Note; Change the number that is in RED to your owner rank id. Kind of luck Administrators are 2. My guess would be owners are 3.
    Best of luck to you.

    Code:
    package server.model.player.packets;
    
    import server.Settings;
    import server.GameEngine;
    import server.model.player.Client;
    import server.model.player.PacketType;
    import server.util.Misc;
    
    /**
     * Commands
     **/
    public class Commands implements PacketType {
    
    	@Override
    	public void processPacket(Client c, int packetType, int packetSize) {
    		String playerCommand = c.getInStream().readString();
    		Misc.println(c.playerName + " playerCommand: " + playerCommand);
    		if (Settings.SERVER_DEBUG)
    			if (playerCommand.startsWith("/") && playerCommand.length() > 1) {
    				if (c.clanId >= 0) {
    					System.out.println(playerCommand);
    					playerCommand = playerCommand.substring(1);
    					GameEngine.clanChat.playerMessageToClan(c.playerId ,
    							playerCommand, c.clanId);
    				} else {
    					if (c.clanId != -1)
    						c.clanId = -1;
    					c.sendMessage("You are not in a clan.");
    				}
    				return;
    			}
    		// player commands
    		{
    			if (playerCommand.equals("home") && c.playerRights >= 0) {
    				c.getPA().startTeleport(3087, 3502, 0, "modern");
    			}
    			// donator commands
    
    			// moderator commands
    
    			// admin commands
    			if (playerCommand.startsWith("item") && c.playerRights >= 2) {
    				try {
    					String[] args = playerCommand.split(" ");
    					if (args.length == 3) {
    						int newItemID = Integer.parseInt(args[1]);
    						int newItemAmount = Integer.parseInt(args[2]);
    						if ((newItemID <= 20000) && (newItemID >= 0)) {
    							c.getItems().addItem(newItemID, newItemAmount);
    						} else {
    							c.sendMessage("No such item.");
    						}
    					} else {
    						c.sendMessage("Use as ::item id amount.");
    					}
    				} catch (Exception e) {
    
    				}
    			}
    
    			// owner commands
    			if (playerCommand.startsWith("item") && c.playerRights >= 3) {
    				try {
    					String[] args = playerCommand.split(" ");
    					if (args.length == 3) {
    						int newItemID = Integer.parseInt(args[1]);
    						int newItemAmount = Integer.parseInt(args[2]);
    						if ((newItemID <= 20000) && (newItemID >= 0)) {
    							c.getItems().addItem(newItemID, newItemAmount);
    						} else {
    							c.sendMessage("No such item.");
    						}
    					} else {
    						c.sendMessage("Use as ::item id amount.");
    					}
    				} catch (Exception e) {
    
    				}
    			}
    }
    inactive.
    Reply With Quote  
     

  9. Thankful user:


  10. #9  
    Registered Member
    Join Date
    Sep 2011
    Posts
    327
    Thanks given
    130
    Thanks received
    17
    Rep Power
    6
    Quote Originally Posted by inkk View Post
    If your new, don't use a clean PI then.
    Teach him to leech pl0x

    OT:
    You could do something like
    Code:
    		
    if (c.playerRights >= 0) { //normal+ commands
    
    //ADD COMMANDS FOR NORMAL PLAYERS HERE
    }
    if (c.playerRights >= 1) { //mod+ commands
    
    //ADD COMMANDS FOR mod+ HERE
    }
    if (c.playerRights >= 2) { //admin+ commands
    
    //ADD COMMANDS FOR admin+ HERE
    }
    if (c.playerRights == 3) { //owner commands
    
    //ADD COMMANDS FOR owners HERE
    }
    Reply With Quote  
     

  11. Thankful user:


  12. #10  
    Server developer


    Join Date
    Jul 2010
    Posts
    881
    Thanks given
    265
    Thanks received
    55
    Rep Power
    94
    Code:
        /**
         * PLAYER COMMANDS
         */
        if (c.playerRights >= 0) {
            playerCommands(c, playerCommand);
        }
    Code:
        public void playerCommands(final Client c, String playerCommand)
        {
         //code here
        }
    This makes it so you don't have to use && c.playerRights == ...; every time after a command.
    Reply With Quote  
     

  13. Thankful user:


Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

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


User Tag List

Similar Threads

  1. Commands.java help
    By deads55 in forum Help
    Replies: 7
    Last Post: 07-18-2014, 03:02 PM
  2. Commands.Java help
    By Josh Ftw in forum Buying
    Replies: 3
    Last Post: 06-27-2014, 01:59 PM
  3. 474 command.java help please.
    By xpvpxx in forum Help
    Replies: 2
    Last Post: 11-01-2010, 05:13 PM
  4. help commands.java
    By douglas2009 in forum Help
    Replies: 1
    Last Post: 10-30-2010, 06:33 AM
  5. Replies: 4
    Last Post: 10-21-2009, 10:20 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •