Thread: Is this jail system any good for delta?

Results 1 to 3 of 3
  1. #1 Is this jail system any good for delta? 
    Registered Member
    Join Date
    Nov 2011
    Posts
    44
    Thanks given
    21
    Thanks received
    11
    Rep Power
    22
    I don't know if this is the right section for this but,

    This is the code


    Spoiler for code for jail:
    Code:
    package org.model.content;
    
    import java.util.HashMap;
    import java.util.Iterator;
    
    import org.model.Client;
    import org.model.PlayerHandler;
    import org.model.commandmanager.Command;
    
    /**
     * Jail system
     * 
     * @author Innocence
     * 
     */
    
    public class JailHandler implements Command {
    
    	private static JailHandler instance = new JailHandler();
    
    	public static JailHandler getInstance() {
    		return instance;
    	}
    
    	private static HashMap<Client, Integer> playerInJail = new HashMap<>();
    
            /**
             * The Command
             */
    	@Override
    	public void execute(Client c, String playerCommand) {
    		try {
    			String[] args = playerCommand.split(" ");
    			if (args.length == 2) {
    				String otherPName = String.valueOf(args[1]);
    				int otherPIndex = PlayerHandler.getPlayerID(otherPName);
    				if (otherPIndex != -1) {
    					Client p = (Client) PlayerHandler.players[otherPIndex];
    					{
    						playerInJail.put(p, 1);
    						p.savegame(false);
    						jailed(c);
    						p.sM("You have been put in jail by " + c.playerName);
    					}
    				} else {
    					c.sM("That player doesn't seem to exist or isn't online");
    				}
    			}
    		} catch (Exception e) {
    			c.sM("Use as ::jail playername");
    		}
    	}
    
    	private void jailed(Client c) {
    		c.addItem(ITEMS[0][0], ITEMS[0][1]);
    		c.sM("Mine 50 tin ores to get out of here");
    		c.movePlayer(2936, 3282, 0);
    	}
    
    	private final int ITEMS[][] = { { 1265, 1 }, // items added
    			{ 439, 50 } // items required to get out of jail
    	};
    
    	public boolean action(Client player) {
    		if (isInJail(player)) {
    			player.sM("You cannot do this while in jail!");
    			return true;
    		} else
    			return false;
    	}
    
    	private void freePlayer() {
    		Iterator<Client> iterator = playerInJail.keySet().iterator();
    		while (iterator.hasNext()) {
    			Client player = iterator.next();
    			if (player == null) {
    				continue;
    			}
    			if (playerInJail.containsKey(player)) {
    				playerInJail.remove(player);
    			}
    			player.triggerTele(2657, 2639, 0);
    			player.sM("You are now free from jail");
    		}
    	}
    
    	public static boolean isInJail(Client player) {
    		return playerInJail.containsKey(player);
    	}
    
    	public void objects(int objectID, Client c, int x, int y) {
    		switch (objectID) {
    		case 6774:
    			if (c.playerHasItem(ITEMS[1][0], ITEMS[1][1]))
    				freePlayer();
    			break;
    		}
    	}
    
    	public int object[] = { 6774 };
    
    }


    I was just wondering if this is any good for delta. It works just fine but what improvements can be made?
    Reply With Quote  
     

  2. #2  
    Member Is this jail system any good for delta? Market Banned
    User Name's Avatar
    Join Date
    Oct 2007
    Posts
    66
    Thanks given
    2
    Thanks received
    3
    Rep Power
    19
    Jail systems are the mockery of your server stability.
    Reply With Quote  
     

  3. #3  
    Banned

    Join Date
    Jun 2009
    Posts
    2,916
    Thanks given
    169
    Thanks received
    806
    Rep Power
    0
    Just make sure you dont got any bugs and there is no reason to add
    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

Similar Threads

  1. [PI] jail system.
    By Harman in forum Help
    Replies: 5
    Last Post: 08-14-2011, 07:36 PM
  2. Quickly done Jail system [PI]
    By Linus in forum Snippets
    Replies: 19
    Last Post: 08-19-2010, 11:15 PM
  3. Replies: 1
    Last Post: 04-29-2010, 03:30 PM
  4. My jail system
    By Ninja assassin in forum Help
    Replies: 3
    Last Post: 11-02-2009, 07:45 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
  •