Advertisement
cgrunwald

Untitled

Dec 21st, 2010
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 111.46 KB | None | 0 0
  1. import java.io.File;
  2. import java.io.FileInputStream;
  3. import java.io.FileNotFoundException;
  4. import java.io.FileOutputStream;
  5. import java.io.IOException;
  6. import java.io.ObjectInputStream;
  7. import java.io.ObjectOutputStream;
  8. import java.io.PrintWriter;
  9. import java.io.Serializable;
  10. import java.lang.reflect.Field;
  11. import java.util.ArrayList;
  12. import java.util.Collection;
  13. import java.util.Comparator;
  14. import java.util.HashMap;
  15. import java.util.HashSet;
  16. import java.util.Iterator;
  17. import java.util.List;
  18. import java.util.Map;
  19. import java.util.Map.Entry;
  20. import java.util.Set;
  21. import java.util.TreeMap;
  22. import java.util.logging.Level;
  23. import java.util.logging.Logger;
  24.  
  25. public class Economy extends Plugin
  26.   implements Serializable
  27. {
  28.   private static final long serialVersionUID = 0L;
  29.   private static final Logger logger;
  30.   private static final String PLUGIN_NAME = "Minecraft Economy Controller";
  31.   private static final String PLUGIN_VERSION = "1.2";
  32.   private static final String PROPERTIES_NAME = "economy.properties";
  33.   private static final File ECONOMY_FILE;
  34.   private static final File LOCATIONS_FILE;
  35.   private static final HashMap<String, String> COMMANDS;
  36.   private static Map<String, String> PROPERTIES;
  37.   private static int MAX_TRADE_AREA_LENGTH;
  38.   private static int MAX_TRADE_AREA_SIZE;
  39.   private static int MAX_BANK_AREA_LENGTH;
  40.   private static int MAX_BANK_AREA_SIZE;
  41.   private static double TRADE_AREA_COST;
  42.   private static double PERSONAL_AREA_COST;
  43.   private static double BANK_AREA_COST;
  44.   private static double TRANSFER_FEE;
  45.   private static double RENAME_FEE;
  46.   private static double STARTING_MONEY;
  47.   private static String TRADE_AREA_COLOR;
  48.   private static String PERSONAL_AREA_COLOR;
  49.   private static String BANK_AREA_COLOR;
  50.   private static String OFFER_COLOR;
  51.   private static String ONLINE;
  52.   private static String OFFLINE;
  53.   private static String ERROR;
  54.   private static String INFO;
  55.   private static String COMMAND;
  56.   private static String MONEY;
  57.   private static int MAX_OFFERS;
  58.   private static double VERTICAL_COST;
  59.   private static double LOTTERY_INTERVAL;
  60.   private static int PLAYERS_TO_HALF;
  61.   private static int MAX_AREAS;
  62.   private HashMap<String, Double> balances;
  63.   private HashMap<String, Double> paychecks;
  64.   private HashMap<String, ArrayList<Economy.Offer>> sellingOffers;
  65.   private HashMap<String, ArrayList<Block>> pendingTradeAreas;
  66.   private HashMap<String, ArrayList<Block>> pendingBankAreas;
  67.   private HashSet<Economy.Area> tradingAreas;
  68.   private HashMap<String, ArrayList<Block>> pendingPersonalAreas;
  69.   private HashSet<Economy.Area> personalAreas;
  70.   private HashSet<Economy.Area> bankingAreas;
  71.   private HashSet<Economy.Offer> allOffers;
  72.   private double publicFund;
  73.   private long lastLottery = System.currentTimeMillis() -
  74.     ()(LOTTERY_INTERVAL * 60.0D * 1000.0D);
  75.   private HashMap<Integer, HashSet<String>> offerListeners;
  76.   private static HashMap<Integer, Double> ITEM_VALUES;
  77.   private static int offerCount;
  78.   private static int areaCount;
  79.  
  80.   static
  81.   {
  82.     logger = Logger.getLogger("Minecraft");
  83.  
  84.     COMMANDS = new HashMap()
  85.     {
  86.     };
  87.     ECONOMY_FILE = new File("economy.dat");
  88.     LOCATIONS_FILE = new File("locations.dat");
  89.     try {
  90.       if (ECONOMY_FILE.createNewFile()) {
  91.         ObjectOutputStream outputStream = new ObjectOutputStream(
  92.           new FileOutputStream(ECONOMY_FILE));
  93.  
  94.         outputStream.writeObject(new HashMap());
  95.  
  96.         outputStream.writeObject(new HashMap());
  97.  
  98.         outputStream
  99.           .writeObject(new HashMap());
  100.  
  101.         outputStream.writeObject(new HashSet());
  102.  
  103.         outputStream.writeObject(new Integer(0));
  104.  
  105.         outputStream.writeObject(new Double(0.0D));
  106.  
  107.         outputStream
  108.           .writeObject(new HashMap());
  109.         outputStream.flush();
  110.         outputStream.close();
  111.         logger.log(Level.INFO, "Economy file successfully created.");
  112.       }
  113.     } catch (IOException exception) {
  114.       exception.printStackTrace();
  115.       logger.log(Level.SEVERE, "Exception while creating economy file.");
  116.     }
  117.     try {
  118.       if (LOCATIONS_FILE.createNewFile()) {
  119.         ObjectOutputStream outputStream = new ObjectOutputStream(
  120.           new FileOutputStream(LOCATIONS_FILE));
  121.  
  122.         outputStream.writeObject(new HashSet());
  123.  
  124.         outputStream.writeObject(new HashSet());
  125.  
  126.         outputStream.writeObject(new HashSet());
  127.  
  128.         outputStream
  129.           .writeObject(new HashMap());
  130.  
  131.         outputStream
  132.           .writeObject(new HashMap());
  133.  
  134.         outputStream
  135.           .writeObject(new HashMap());
  136.  
  137.         outputStream.writeObject(new Integer(0));
  138.         outputStream.flush();
  139.         outputStream.close();
  140.         logger.log(Level.INFO, "Locations file successfully created.");
  141.       }
  142.     } catch (IOException exception) {
  143.       exception.printStackTrace();
  144.       logger
  145.         .log(Level.SEVERE,
  146.         "Exception while creating locations file.");
  147.     }
  148.     try {
  149.       if (new File("economy.properties").createNewFile()) {
  150.         PrintWriter output = new PrintWriter(
  151.           new FileOutputStream(new File("economy.properties")));
  152.         output.println("maxTradeAreaLength=15");
  153.         output.println("maxTradeAreaSize=144");
  154.         output.println("maxBankAreaLength=25");
  155.         output.println("maxBankAreaSize=400");
  156.         output.println("tradeAreaCost=1.0");
  157.         output.println("personalAreaCost=3.0");
  158.         output.println("bankAreaCost=5.0");
  159.         output.println("transferFee=0.15");
  160.         output.println("renameFee=0.05");
  161.         output.println("startingMoney=10.0");
  162.         output.println("tradeAreaColor=Yellow");
  163.         output.println("personalAreaColor=LightBlue");
  164.         output.println("bankAreaColor=Green");
  165.         output.println("offerColor=LightGray");
  166.         output.println("errorColor=Red");
  167.         output.println("commandColor=Rose");
  168.         output.println("infoColor=Blue");
  169.         output.println("moneyColor=Green");
  170.         output.println("onlineColor=White");
  171.         output.println("offlineColor=Gray");
  172.         output.println("maxOffers=10");
  173.         output.println("verticalCost=0.02");
  174.         output.println("lotteryInterval=60");
  175.         output.println("playersToHalf=5");
  176.         output.println("maxAreas=20");
  177.         output
  178.           .println("exchange=265:1,42:9,266:10,41:90,264:100,57:900");
  179.         output.flush();
  180.         output.close();
  181.         logger.log(Level.INFO, "Properties file successfully created.");
  182.       }
  183.       PROPERTIES = new PropertiesFile("economy.properties").returnMap();
  184.     } catch (Exception e) {
  185.       e.printStackTrace();
  186.       logger.log(Level.SEVERE,
  187.         "Exception while creating properties file.");
  188.     }
  189.  
  190.     MAX_TRADE_AREA_LENGTH = 15;
  191.  
  192.     MAX_TRADE_AREA_SIZE = 144;
  193.  
  194.     MAX_BANK_AREA_LENGTH = 25;
  195.  
  196.     MAX_BANK_AREA_SIZE = 400;
  197.  
  198.     TRADE_AREA_COST = 1.0D;
  199.  
  200.     PERSONAL_AREA_COST = 3.0D;
  201.  
  202.     BANK_AREA_COST = 5.0D;
  203.  
  204.     TRANSFER_FEE = 0.15D;
  205.  
  206.     RENAME_FEE = 0.05D;
  207.  
  208.     STARTING_MONEY = 10.0D;
  209.  
  210.     TRADE_AREA_COLOR = "§e";
  211.  
  212.     PERSONAL_AREA_COLOR = "§b";
  213.  
  214.     BANK_AREA_COLOR = "§2";
  215.  
  216.     OFFER_COLOR = "§7";
  217.  
  218.     ONLINE = "§f";
  219.  
  220.     OFFLINE = "§8";
  221.  
  222.     ERROR = "§4";
  223.  
  224.     INFO = "§3";
  225.  
  226.     COMMAND = "§c";
  227.  
  228.     MONEY = "§2";
  229.  
  230.     MAX_OFFERS = 10;
  231.  
  232.     VERTICAL_COST = 0.01D;
  233.  
  234.     LOTTERY_INTERVAL = 60.0D;
  235.  
  236.     PLAYERS_TO_HALF = 5;
  237.  
  238.     MAX_AREAS = 20;
  239.  
  240.     ITEM_VALUES = new HashMap()
  241.     {
  242.     };
  243.     offerCount = 0;
  244.   }
  245.  
  246.   public void enable()
  247.   {
  248.     Iterator localIterator = COMMANDS
  249.       .entrySet().iterator();
  250.  
  251.     while (localIterator.hasNext()) {
  252.       Map.Entry currentCommand = (Map.Entry)localIterator.next();
  253.       etc.getInstance().addCommand((String)currentCommand.getKey(),
  254.         (String)currentCommand.getValue());
  255.     }
  256.     if (!isEnabled()) {
  257.       toggleEnabled();
  258.       logger.info(this + " enabled.");
  259.     }
  260.   }
  261.  
  262.   public void disable()
  263.   {
  264.     Iterator localIterator = COMMANDS
  265.       .entrySet().iterator();
  266.  
  267.     while (localIterator.hasNext()) {
  268.       Map.Entry currentCommand = (Map.Entry)localIterator.next();
  269.       etc.getInstance().removeCommand((String)currentCommand.getKey());
  270.     }
  271.     if (isEnabled()) {
  272.       toggleEnabled();
  273.       logger.info(this + " disabled.");
  274.       writeEconomy();
  275.       writeLocations();
  276.     }
  277.   }
  278.  
  279.   public void initialize()
  280.   {
  281.     readEconomy();
  282.     readLocations();
  283.     try {
  284.       readProperties();
  285.     } catch (FileNotFoundException exception) {
  286.       exception.printStackTrace();
  287.     }
  288.     PluginListener listener = new Economy.EconomyListener(null);
  289.     etc.getLoader().addListener(PluginLoader.Hook.COMMAND, listener, this,
  290.       PluginListener.Priority.MEDIUM);
  291.     etc.getLoader().addListener(PluginLoader.Hook.BLOCK_RIGHTCLICKED,
  292.       listener, this, PluginListener.Priority.MEDIUM);
  293.     etc.getLoader().addListener(PluginLoader.Hook.BLOCK_PLACE, listener,
  294.       this, PluginListener.Priority.MEDIUM);
  295.     etc.getLoader().addListener(PluginLoader.Hook.BLOCK_BROKEN, listener,
  296.       this, PluginListener.Priority.MEDIUM);
  297.     etc.getLoader().addListener(PluginLoader.Hook.MOB_SPAWN, listener,
  298.       this, PluginListener.Priority.MEDIUM);
  299.     etc.getLoader().addListener(PluginLoader.Hook.LOGIN, listener, this,
  300.       PluginListener.Priority.MEDIUM);
  301.     logger.info(this + " initialized.");
  302.   }
  303.  
  304.   public final String toString()
  305.   {
  306.     return "Minecraft Economy Controller version 1.2";
  307.   }
  308.  
  309.   private static final boolean online(String playerName) {
  310.     return etc.getServer().getPlayer(playerName) != null;
  311.   }
  312.  
  313.   private final void readEconomy()
  314.   {
  315.     try
  316.     {
  317.       ObjectInputStream inputStream = new ObjectInputStream(
  318.         new FileInputStream(ECONOMY_FILE));
  319.       this.balances = ((HashMap)inputStream.readObject());
  320.       this.paychecks = ((HashMap)inputStream.readObject());
  321.       this.sellingOffers = ((HashMap)
  322.         inputStream.readObject());
  323.       this.allOffers = ((HashSet)inputStream.readObject());
  324.       offerCount = ((Integer)inputStream.readObject()).intValue();
  325.       this.publicFund = ((Double)inputStream.readObject()).doubleValue();
  326.       this.offerListeners = ((HashMap)
  327.         inputStream.readObject());
  328.       this.lastLottery = ((Long)inputStream.readObject()).longValue();
  329.       inputStream.close();
  330.       logger.log(Level.INFO, "Economy file successfully read.");
  331.     } catch (Exception ioe) {
  332.       ioe.printStackTrace();
  333.       logger.log(Level.SEVERE, "Error while reading economy file.");
  334.     } finally {
  335.       if (this.balances == null) {
  336.         this.balances = new HashMap();
  337.       }
  338.       if (this.paychecks == null) {
  339.         this.paychecks = new HashMap();
  340.       }
  341.       if (this.sellingOffers == null) {
  342.         this.sellingOffers = new HashMap();
  343.       }
  344.       if (this.allOffers == null) {
  345.         this.allOffers = new HashSet();
  346.       }
  347.       if (this.offerListeners == null)
  348.         this.offerListeners = new HashMap();
  349.     }
  350.   }
  351.  
  352.   private final void readLocations()
  353.   {
  354.     try
  355.     {
  356.       ObjectInputStream inputStream = new ObjectInputStream(
  357.         new FileInputStream(LOCATIONS_FILE));
  358.       this.tradingAreas = ((HashSet)inputStream.readObject());
  359.       this.personalAreas = ((HashSet)inputStream.readObject());
  360.       this.bankingAreas = ((HashSet)inputStream.readObject());
  361.       this.pendingTradeAreas = ((HashMap)
  362.         inputStream.readObject());
  363.       this.pendingPersonalAreas = ((HashMap)
  364.         inputStream.readObject());
  365.       this.pendingBankAreas = ((HashMap)
  366.         inputStream.readObject());
  367.       areaCount = ((Integer)inputStream.readObject()).intValue();
  368.       inputStream.close();
  369.       logger.log(Level.INFO, "Locations file successfully read.");
  370.     } catch (Exception exception) {
  371.       exception.printStackTrace();
  372.       logger.log(Level.SEVERE, "Error while reading locations file.");
  373.     } finally {
  374.       if (this.tradingAreas == null) {
  375.         this.tradingAreas = new HashSet();
  376.       }
  377.       if (this.personalAreas == null) {
  378.         this.personalAreas = new HashSet();
  379.       }
  380.       if (this.bankingAreas == null) {
  381.         this.bankingAreas = new HashSet();
  382.       }
  383.       if (this.pendingTradeAreas == null) {
  384.         this.pendingTradeAreas = new HashMap();
  385.       }
  386.       if (this.pendingPersonalAreas == null) {
  387.         this.pendingPersonalAreas = new HashMap();
  388.       }
  389.       if (this.pendingBankAreas == null)
  390.         this.pendingBankAreas = new HashMap();
  391.     }
  392.   }
  393.  
  394.   private final void readProperties()
  395.     throws FileNotFoundException
  396.   {
  397.     boolean error = false;
  398.     PrintWriter output = new PrintWriter(
  399.       new FileOutputStream(new File("economy.properties")));
  400.     if (PROPERTIES.containsKey("maxTradeAreaLength"))
  401.       try {
  402.         MAX_TRADE_AREA_LENGTH = Integer.parseInt(
  403.           (String)PROPERTIES
  404.           .get("maxTradeAreaLength"));
  405.         if (MAX_TRADE_AREA_LENGTH >= 1) break label90; MAX_TRADE_AREA_LENGTH = 1;
  406.       }
  407.       catch (Exception e)
  408.       {
  409.         error = true;
  410.         e.printStackTrace();
  411.       }
  412.     else {
  413.       output.println("maxTradeAreaLength=15");
  414.     }
  415.     label90: if (PROPERTIES.containsKey("maxTradeAreaSize"))
  416.       try {
  417.         MAX_TRADE_AREA_SIZE = Integer.parseInt(
  418.           (String)PROPERTIES
  419.           .get("maxTradeAreaSize"));
  420.         if (MAX_TRADE_AREA_SIZE >= 1) break label154; MAX_TRADE_AREA_SIZE = 1;
  421.       }
  422.       catch (Exception e) {
  423.         error = true;
  424.         e.printStackTrace();
  425.       }
  426.     else {
  427.       output.println("maxTradeAreaSize=144");
  428.     }
  429.     label154: if (PROPERTIES.containsKey("maxBankAreaLength"))
  430.       try {
  431.         MAX_BANK_AREA_LENGTH = Integer.parseInt(
  432.           (String)PROPERTIES
  433.           .get("maxBankAreaLength"));
  434.         if (MAX_BANK_AREA_LENGTH >= 1) break label218; MAX_BANK_AREA_LENGTH = 1;
  435.       }
  436.       catch (Exception e) {
  437.         error = true;
  438.         e.printStackTrace();
  439.       }
  440.     else {
  441.       output.println("maxBankAreaLength=25");
  442.     }
  443.     label218: if (PROPERTIES.containsKey("maxBankAreaSize"))
  444.       try {
  445.         MAX_BANK_AREA_SIZE = Integer.parseInt(
  446.           (String)PROPERTIES
  447.           .get("maxBankAreaSize"));
  448.         if (MAX_BANK_AREA_SIZE >= 1) break label282; MAX_BANK_AREA_SIZE = 1;
  449.       }
  450.       catch (Exception e) {
  451.         error = true;
  452.         e.printStackTrace();
  453.       }
  454.     else {
  455.       output.println("maxBankAreaSize=400");
  456.     }
  457.     label282: if (PROPERTIES.containsKey("tradeAreaCost"))
  458.       try {
  459.         TRADE_AREA_COST = Double.parseDouble(
  460.           (String)PROPERTIES
  461.           .get("tradeAreaCost"));
  462.         if (TRADE_AREA_COST >= 0.0D) break label347; TRADE_AREA_COST = 0.0D;
  463.       }
  464.       catch (Exception e) {
  465.         error = true;
  466.         e.printStackTrace();
  467.       }
  468.     else {
  469.       output.println("tradeAreaCost=1.0");
  470.     }
  471.     label347: if (PROPERTIES.containsKey("personalAreaCost"))
  472.       try {
  473.         PERSONAL_AREA_COST = Double.parseDouble(
  474.           (String)PROPERTIES
  475.           .get("personalAreaCost"));
  476.         if (PERSONAL_AREA_COST >= 0.0D) break label412; PERSONAL_AREA_COST = 0.0D;
  477.       }
  478.       catch (Exception e) {
  479.         error = true;
  480.         e.printStackTrace();
  481.       }
  482.     else {
  483.       output.println("personalAreaCost=3.0");
  484.     }
  485.     label412: if (PROPERTIES.containsKey("bankAreaCost"))
  486.       try {
  487.         BANK_AREA_COST = Double.parseDouble(
  488.           (String)PROPERTIES
  489.           .get("bankAreaCost"));
  490.         if (BANK_AREA_COST >= 0.0D) break label477; BANK_AREA_COST = 0.0D;
  491.       }
  492.       catch (Exception e) {
  493.         error = true;
  494.         e.printStackTrace();
  495.       }
  496.     else {
  497.       output.println("bankAreaCost=5.0");
  498.     }
  499.     label477: if (PROPERTIES.containsKey("transferFee"))
  500.       try {
  501.         TRANSFER_FEE =
  502.           Double.parseDouble((String)PROPERTIES.get("transferFee"));
  503.         if (TRANSFER_FEE > 1.0D) {
  504.           TRANSFER_FEE = 1.0D; break label557;
  505.         }if (TRANSFER_FEE >= 0.0D) break label557; TRANSFER_FEE = 0.0D;
  506.       }
  507.       catch (Exception e) {
  508.         error = true;
  509.         e.printStackTrace();
  510.       }
  511.     else {
  512.       output.println("transferFee=0.15");
  513.     }
  514.     label557: if (PROPERTIES.containsKey("renameFee"))
  515.       try {
  516.         RENAME_FEE = Double.parseDouble((String)PROPERTIES.get("renameFee"));
  517.         if (RENAME_FEE > 1.0D) {
  518.           RENAME_FEE = 1.0D; break label637;
  519.         }if (RENAME_FEE >= 0.0D) break label637; RENAME_FEE = 0.0D;
  520.       }
  521.       catch (Exception e) {
  522.         error = true;
  523.         e.printStackTrace();
  524.       }
  525.     else {
  526.       output.println("renameFee=0.05");
  527.     }
  528.     label637: if (PROPERTIES.containsKey("startingMoney"))
  529.       try {
  530.         STARTING_MONEY = Double.parseDouble(
  531.           (String)PROPERTIES
  532.           .get("startingMoney"));
  533.         if (STARTING_MONEY >= 0.0D) break label702; STARTING_MONEY = 0.0D;
  534.       }
  535.       catch (Exception e) {
  536.         error = true;
  537.         e.printStackTrace();
  538.       }
  539.     else {
  540.       output.println("startingMoney=10.0");
  541.     }
  542.     label702: if (PROPERTIES.containsKey("tradeAreaColor"))
  543.       try {
  544.         TRADE_AREA_COLOR = (String)Colors.class.getField(
  545.           (String)PROPERTIES.get("tradeAreaColor")).get(null);
  546.       } catch (Exception exception) {
  547.         error = true;
  548.         exception.printStackTrace();
  549.       }
  550.     else {
  551.       output.println("tradeAreaColor=Yellow");
  552.     }
  553.     if (PROPERTIES.containsKey("personalAreaColor"))
  554.       try {
  555.         PERSONAL_AREA_COLOR = (String)Colors.class.getField(
  556.           (String)PROPERTIES.get("personalAreaColor")).get(null);
  557.       } catch (Exception exception) {
  558.         error = true;
  559.         exception.printStackTrace();
  560.       }
  561.     else {
  562.       output.println("personalAreaColor=LightBlue");
  563.     }
  564.     if (PROPERTIES.containsKey("bankAreaColor"))
  565.       try {
  566.         BANK_AREA_COLOR = (String)Colors.class.getField(
  567.           (String)PROPERTIES.get("bankAreaColor")).get(null);
  568.       } catch (Exception exception) {
  569.         error = true;
  570.         exception.printStackTrace();
  571.       }
  572.     else {
  573.       output.println("bankAreaColor=Green");
  574.     }
  575.     if (PROPERTIES.containsKey("offerColor"))
  576.       try {
  577.         OFFER_COLOR = (String)Colors.class.getField(
  578.           (String)PROPERTIES.get("offerColor")).get(null);
  579.       } catch (Exception exception) {
  580.         error = true;
  581.         exception.printStackTrace();
  582.       }
  583.     else {
  584.       output.println("offerColor=LightGray");
  585.     }
  586.     if (PROPERTIES.containsKey("errorColor"))
  587.       try {
  588.         ERROR = (String)Colors.class.getField(
  589.           (String)PROPERTIES.get("errorColor")).get(null);
  590.       } catch (Exception exception) {
  591.         error = true;
  592.         exception.printStackTrace();
  593.       }
  594.     else {
  595.       output.println("errorColor=Red");
  596.     }
  597.     if (PROPERTIES.containsKey("commandColor"))
  598.       try {
  599.         COMMAND = (String)Colors.class.getField(
  600.           (String)PROPERTIES.get("commandColor")).get(null);
  601.       } catch (Exception exception) {
  602.         error = true;
  603.         exception.printStackTrace();
  604.       }
  605.     else {
  606.       output.println("commandColor=Rose");
  607.     }
  608.     if (PROPERTIES.containsKey("infoColor"))
  609.       try {
  610.         INFO = (String)Colors.class.getField(
  611.           (String)PROPERTIES.get("infoColor")).get(null);
  612.       } catch (Exception exception) {
  613.         error = true;
  614.         exception.printStackTrace();
  615.       }
  616.     else {
  617.       output.println("infoColor=Blue");
  618.     }
  619.     if (PROPERTIES.containsKey("moneyColor"))
  620.       try {
  621.         MONEY = (String)Colors.class.getField(
  622.           (String)PROPERTIES.get("moneyColor")).get(null);
  623.       } catch (Exception exception) {
  624.         error = true;
  625.         exception.printStackTrace();
  626.       }
  627.     else {
  628.       output.println("moneyColor=Green");
  629.     }
  630.     if (PROPERTIES.containsKey("onlineColor"))
  631.       try {
  632.         ONLINE = (String)Colors.class.getField(
  633.           (String)PROPERTIES.get("onlineColor")).get(null);
  634.       } catch (Exception exception) {
  635.         error = true;
  636.         exception.printStackTrace();
  637.       }
  638.     else {
  639.       output.println("onlineColor=White");
  640.     }
  641.     if (PROPERTIES.containsKey("offlineColor"))
  642.       try {
  643.         OFFLINE = (String)Colors.class.getField(
  644.           (String)PROPERTIES.get("offlineColor")).get(null);
  645.       } catch (Exception exception) {
  646.         error = true;
  647.         exception.printStackTrace();
  648.       }
  649.     else {
  650.       output.println("offlineColor=Gray");
  651.     }
  652.     if (PROPERTIES.containsKey("maxOffers"))
  653.       try {
  654.         MAX_OFFERS = Integer.parseInt((String)PROPERTIES.get("maxOffers"));
  655.         if (MAX_OFFERS >= 1) break label1396; MAX_OFFERS = 1;
  656.       }
  657.       catch (Exception e) {
  658.         error = true;
  659.         e.printStackTrace();
  660.       }
  661.     else {
  662.       output.println("maxOffers=10");
  663.     }
  664.     label1396: if (PROPERTIES.containsKey("verticalCost"))
  665.       try {
  666.         VERTICAL_COST = Double.parseDouble(
  667.           (String)PROPERTIES
  668.           .get("verticalCost"));
  669.         if (VERTICAL_COST > 1.0D) {
  670.           VERTICAL_COST = 1.0D; break label1476;
  671.         }if (VERTICAL_COST >= 0.0D) break label1476; VERTICAL_COST = 0.0D;
  672.       }
  673.       catch (Exception e) {
  674.         error = true;
  675.         e.printStackTrace();
  676.       }
  677.     else {
  678.       output.println("verticalCost=0.02");
  679.     }
  680.     label1476: if (PROPERTIES.containsKey("lotteryInterval"))
  681.       try {
  682.         LOTTERY_INTERVAL = Double.parseDouble(
  683.           (String)PROPERTIES
  684.           .get("lotteryInterval"));
  685.         if (LOTTERY_INTERVAL >= 0.0D) break label1541; LOTTERY_INTERVAL = 0.0D;
  686.       }
  687.       catch (Exception e) {
  688.         error = true;
  689.         e.printStackTrace();
  690.       }
  691.     else {
  692.       output.println("lotteryInterval=60");
  693.     }
  694.     label1541: if (PROPERTIES.containsKey("playersToHalf"))
  695.       try {
  696.         PLAYERS_TO_HALF = Integer.parseInt(
  697.           (String)PROPERTIES
  698.           .get("playersToHalf"));
  699.         if (PLAYERS_TO_HALF >= 0) break label1604; PLAYERS_TO_HALF = 0;
  700.       }
  701.       catch (Exception e) {
  702.         error = true;
  703.         e.printStackTrace();
  704.       }
  705.     else {
  706.       output.println("playersToHalf=5");
  707.     }
  708.     label1604: if (PROPERTIES.containsKey("maxAreas"))
  709.       try {
  710.         MAX_AREAS = Integer.parseInt((String)PROPERTIES.get("maxAreas"));
  711.         if (MAX_AREAS >= 1) break label1668; MAX_AREAS = 1;
  712.       }
  713.       catch (Exception e) {
  714.         error = true;
  715.         e.printStackTrace();
  716.       }
  717.     else {
  718.       output.println("maxAreas=20");
  719.     }
  720.     label1668: if (PROPERTIES.containsKey("exchange")) {
  721.       ITEM_VALUES = new HashMap();
  722.       for (String kv : ((String)PROPERTIES.get("exchange")).split(",")) {
  723.         int colon = kv.indexOf(':');
  724.         if (colon == -1)
  725.           continue;
  726.         try
  727.         {
  728.           int id = Integer.parseInt(kv.substring(0, colon));
  729.           double value = Double.parseDouble(kv.substring(colon + 1));
  730.           value = Math.round(value * 100.0D) / 100.0D;
  731.           if (value > 0.0D)
  732.             ITEM_VALUES.put(Integer.valueOf(id), Double.valueOf(value));
  733.         }
  734.         catch (Exception e) {
  735.           error = true;
  736.           e.printStackTrace();
  737.         }
  738.       }
  739.     } else {
  740.       output.println("exchange=265:1,42:9,266:10,41:90,264:100,57:900");
  741.     }
  742.     if (error)
  743.       logger.log(Level.SEVERE, "Error while reading properties file.");
  744.     else {
  745.       logger.log(Level.INFO, "Properties file successfully read.");
  746.     }
  747.     output.flush();
  748.     output.close();
  749.   }
  750.  
  751.   private final void writeEconomy()
  752.   {
  753.     try
  754.     {
  755.       ObjectOutputStream outputStream = new ObjectOutputStream(
  756.         new FileOutputStream(ECONOMY_FILE));
  757.       outputStream.writeObject(this.balances);
  758.       outputStream.writeObject(this.paychecks);
  759.       outputStream.writeObject(this.sellingOffers);
  760.       outputStream.writeObject(this.allOffers);
  761.       outputStream.writeObject(new Integer(offerCount));
  762.       outputStream.writeObject(new Double(this.publicFund));
  763.       outputStream.writeObject(this.offerListeners);
  764.       outputStream.writeObject(Long.valueOf(this.lastLottery));
  765.       outputStream.flush();
  766.       outputStream.close();
  767.       logger.log(Level.INFO, "Economy file successfully written.");
  768.     } catch (Exception exception) {
  769.       exception.printStackTrace();
  770.       logger.log(Level.SEVERE, "Error while writing economy file.");
  771.     }
  772.   }
  773.  
  774.   private final void writeLocations()
  775.   {
  776.     try
  777.     {
  778.       ObjectOutputStream outputStream = new ObjectOutputStream(
  779.         new FileOutputStream(LOCATIONS_FILE));
  780.       outputStream.writeObject(this.tradingAreas);
  781.       outputStream.writeObject(this.personalAreas);
  782.       outputStream.writeObject(this.bankingAreas);
  783.       outputStream.writeObject(this.pendingTradeAreas);
  784.       outputStream.writeObject(this.pendingPersonalAreas);
  785.       outputStream.writeObject(this.pendingBankAreas);
  786.       outputStream.writeObject(new Integer(areaCount));
  787.       outputStream.flush();
  788.       outputStream.close();
  789.       logger.log(Level.INFO, "Locations file successfully written.");
  790.     } catch (Exception exception) {
  791.       exception.printStackTrace();
  792.       logger.log(Level.SEVERE, "Error while writing locations file.");
  793.     }
  794.   }
  795.  
  796.   private Iterator<Economy.Offer> offerIterator()
  797.   {
  798.     return this.allOffers.iterator();
  799.   }
  800.  
  801.   private final double getBalance(String player)
  802.   {
  803.     Double balance = (Double)this.balances.get(player.toLowerCase());
  804.     if (balance == null) {
  805.       this.balances.put(player.toLowerCase(), Double.valueOf(0.0D));
  806.       balance = Double.valueOf(0.0D);
  807.     }
  808.     return balance.doubleValue();
  809.   }
  810.  
  811.   private final void setBalance(String player, double balance)
  812.   {
  813.     assert ((balance >= 0.0D) && (
  814.       (this.balances.containsKey(player)) || (
  815.       etc.getServer().getPlayer(player) != null)));
  816.     this.balances.put(player.toLowerCase(), Double.valueOf(balance));
  817.   }
  818.  
  819.   private final void addToBalance(String player, double amount)
  820.   {
  821.     if (getBalance(player) > 1.7976931348623157E+308D - amount)
  822.     {
  823.       if (amount < 0.0D)
  824.         setBalance(player,
  825.           Math.max(0.0D, getBalance(player) +
  826.           amount));
  827.       else {
  828.         setBalance(player, 1.7976931348623157E+308D);
  829.       }
  830.     }
  831.     else
  832.       setBalance(player,
  833.         Math.max(0.0D, getBalance(player) +
  834.         amount));
  835.   }
  836.  
  837.   private final void addOffer(String player, Economy.Offer offer)
  838.   {
  839.     ArrayList playerOffers = (ArrayList)this.sellingOffers.get(
  840.       player.toLowerCase());
  841.     if (playerOffers == null) {
  842.       playerOffers = new ArrayList();
  843.       this.sellingOffers.put(player.toLowerCase(), playerOffers);
  844.     }
  845.     playerOffers.add(offer);
  846.     this.allOffers.add(offer);
  847.   }
  848.  
  849.   private final void removeOffer(Economy.Offer offer)
  850.   {
  851.     ((ArrayList)this.sellingOffers.get(offer.player)).remove(offer);
  852.     this.allOffers.remove(offer);
  853.   }
  854.  
  855.   private final boolean hasOffers()
  856.   {
  857.     return !this.allOffers.isEmpty();
  858.   }
  859.  
  860.   private static final String itemName(int id)
  861.   {
  862.     return Item.Type.fromId(id).name().toLowerCase();
  863.   }
  864.  
  865.   private static final int itemId(String name)
  866.   {
  867.     for (Item.Type type : Item.Type.values()) {
  868.       if (type.name().equalsIgnoreCase(name)) {
  869.         return type.getId();
  870.       }
  871.     }
  872.     return -1;
  873.   }
  874.  
  875.   private Economy.Area getArea(Player player)
  876.   {
  877.     return getArea(player.getX(), player.getY(), player.getZ());
  878.   }
  879.  
  880.   private Economy.Area getArea(double x, double y, double z)
  881.   {
  882.     for (Economy.Area area : this.personalAreas) {
  883.       if (area.withinArea(x, y, z)) {
  884.         return area;
  885.       }
  886.     }
  887.     for (Economy.Area area : this.tradingAreas) {
  888.       if (area.withinArea(x, y, z)) {
  889.         return area;
  890.       }
  891.     }
  892.     for (Economy.Area area : this.bankingAreas) {
  893.       if (area.withinArea(x, y, z)) {
  894.         return area;
  895.       }
  896.     }
  897.     return null;
  898.   }
  899.  
  900.   private ArrayList<Economy.Area> allAreas()
  901.   {
  902.     return new ArrayList(this.tradingAreas.size() +
  903.       this.personalAreas.size() + this.bankingAreas.size())
  904.     {
  905.     };
  906.   }
  907.  
  908.   private boolean canTrade(Player player)
  909.   {
  910.     Economy.Area area = getArea(player);
  911.     if (area == null) {
  912.       return false;
  913.     }
  914.     return area instanceof Economy.TradeArea;
  915.   }
  916.  
  917.   private final int givePlayer(Player player, int id, int amount)
  918.   {
  919.     hn[] items = player.getInventory().getArray();
  920.     int remaining = amount;
  921.  
  922.     for (int index = 0; (index < items.length) && (remaining > 0); index++) {
  923.       if (items[index] == null) {
  924.         continue;
  925.       }
  926.       if (items[index].c != id) {
  927.         continue;
  928.       }
  929.       if (items[index].a == 64) {
  930.         continue;
  931.       }
  932.       int amountToAdd = Math.min(64 - items[index].a, remaining);
  933.       remaining -= amountToAdd;
  934.       items[index].a += amountToAdd;
  935.     }
  936.  
  937.     for (int index = 0; (index < items.length) && (remaining > 0); index++) {
  938.       if (items[index] != null) {
  939.         continue;
  940.       }
  941.       int amountToAdd = Math.min(remaining, 64);
  942.       remaining -= amountToAdd;
  943.       items[index] = new hn(id, amountToAdd);
  944.     }
  945.     player.getInventory().updateInventory();
  946.     return remaining;
  947.   }
  948.  
  949.   private final String format(double amount)
  950.   {
  951.     return String.format("%.2f", new Object[] { Double.valueOf(amount) });
  952.   }
  953.  
  954.   private final String formatTime(double time)
  955.   {
  956.     int hours = (int)(time / 60.0D) % 24;
  957.     int minutes = (int)time % 60;
  958.     int seconds = (int)(60.0D * (time - (int)time) + 0.5D);
  959.     if (hours != 0) {
  960.       return String.format("%02d:%02d:%02d", new Object[] { Integer.valueOf(hours), Integer.valueOf(minutes), Integer.valueOf(seconds) });
  961.     }
  962.     return String.format("%02d:%02d", new Object[] { Integer.valueOf(minutes), Integer.valueOf(seconds) });
  963.   }
  964.  
  965.   private static final String areaColor(Economy.Area area)
  966.   {
  967.     if ((area instanceof Economy.TradeArea))
  968.       return TRADE_AREA_COLOR;
  969.     if ((area instanceof Economy.PersonalArea))
  970.       return PERSONAL_AREA_COLOR;
  971.     if ((area instanceof Economy.BankArea)) {
  972.       return BANK_AREA_COLOR;
  973.     }
  974.     return "§0";
  975.   }
  976.  
  977.   private static final void sendMessage(Player player, String message)
  978.   {
  979.     player.sendMessage(message);
  980.   }
  981.  
  982.   private static final HashMap<String, String> toKV(String[] split)
  983.   {
  984.     HashMap result = new HashMap();
  985.     String[] arrayOfString = split; int j = split.length; for (int i = 0; i < j; i++) { String current = arrayOfString[i];
  986.       int colon = current.indexOf(':');
  987.       if (colon == -1) {
  988.         continue;
  989.       }
  990.       String key = current.substring(0, colon);
  991.       String value = current.substring(colon + 1);
  992.       result.put(key, value);
  993.     }
  994.     return result;
  995.   }
  996.  
  997.   private final int numberOfAreas(Player player)
  998.   {
  999.     int result = 0;
  1000.     for (Economy.Area area : allAreas()) {
  1001.       if (player.getName().equalsIgnoreCase(area.owner)) {
  1002.         result++;
  1003.       }
  1004.     }
  1005.     return result;
  1006.   }
  1007.  
  1008.   private abstract class Area
  1009.     implements Serializable
  1010.   {
  1011.     private static final long serialVersionUID = 2L;
  1012.     private double minX;
  1013.     private double maxX;
  1014.     private double minY;
  1015.     private double maxY;
  1016.     private double minZ;
  1017.     private double maxZ;
  1018.     private final int areaId;
  1019.     private String owner;
  1020.     private String areaName;
  1021.  
  1022.     public Area(double minX, double maxX, double minY, double maxY, double minZ, double maxZ, String owner)
  1023.     {
  1024.       this.minX = minX;
  1025.       this.maxX = maxX;
  1026.       this.minY = minY;
  1027.       this.maxY = maxY;
  1028.       this.minZ = minZ;
  1029.       this.maxZ = maxZ;
  1030.       this.areaId = (Economy.areaCount++);
  1031.       if (Economy.areaCount < 0) {
  1032.         Economy.logger.log(Level.WARNING,
  1033.           "Area id count has overflowed.");
  1034.       }
  1035.       this.owner = owner;
  1036.       this.areaName = "";
  1037.     }
  1038.  
  1039.     public boolean equals(Object other)
  1040.     {
  1041.       if (!(other instanceof Area)) {
  1042.         return false;
  1043.       }
  1044.       Area otherArea = (Area)other;
  1045.       return this.areaId == otherArea.areaId;
  1046.     }
  1047.  
  1048.     public double distanceTo(Player player)
  1049.     {
  1050.       double centerX = this.minX + (this.maxX - this.minX) / 2.0D;
  1051.       double centerZ = this.minZ + (this.maxZ - this.minZ) / 2.0D;
  1052.       double deltaX = player.getX() - centerX;
  1053.       double deltaZ = player.getZ() - centerZ;
  1054.       return Math.sqrt(deltaX * deltaX + deltaZ * deltaZ);
  1055.     }
  1056.  
  1057.     public String directionFrom(Player player)
  1058.     {
  1059.       double centerX = this.minX + (this.maxX - this.minX) / 2.0D;
  1060.       double centerZ = this.minZ + (this.maxZ - this.minZ) / 2.0D;
  1061.       double deltaX = centerX - player.getX();
  1062.       double deltaZ = centerZ - player.getZ();
  1063.       double degrees = -(180.0D * Math.atan2(deltaX, deltaZ) / 3.141592653589793D + 90.0D);
  1064.       if (degrees < 0.0D)
  1065.         degrees += 360.0D;
  1066.       else if (degrees > 360.0D) {
  1067.         degrees -= 360.0D;
  1068.       }
  1069.       return etc.getCompassPointForDirection(degrees);
  1070.     }
  1071.  
  1072.     public double floorSize()
  1073.     {
  1074.       return (this.maxX - this.minX) * (this.maxZ - this.minZ);
  1075.     }
  1076.  
  1077.     public double totalSize()
  1078.     {
  1079.       return floorSize() * (this.maxY - this.minY);
  1080.     }
  1081.  
  1082.     public double price()
  1083.     {
  1084.       return floorSize() * (1.0D + Economy.VERTICAL_COST * (this.maxY - this.minY));
  1085.     }
  1086.  
  1087.     public boolean withinArea(double x, double y, double z)
  1088.     {
  1089.       return (x >= this.minX) && (x <= this.maxX) && (y >= this.minY) &&
  1090.         (y <= this.maxY) && (z >= this.minZ) && (z <= this.maxZ);
  1091.     }
  1092.  
  1093.     public final void setName(String name)
  1094.     {
  1095.       this.areaName = name;
  1096.     }
  1097.  
  1098.     public String toString()
  1099.     {
  1100.       StringBuilder result = new StringBuilder();
  1101.       if (!this.areaName.equals("")) {
  1102.         result.append(this.areaName);
  1103.         result.append(": ");
  1104.       }
  1105.       result.append("(");
  1106.       result.append((int)this.minX);
  1107.       result.append(", ");
  1108.       result.append((int)this.minY);
  1109.       result.append(", ");
  1110.       result.append((int)this.minZ);
  1111.       result.append(") to (");
  1112.       result.append((int)this.maxX);
  1113.       result.append(", ");
  1114.       result.append((int)this.maxY);
  1115.       result.append(", ");
  1116.       result.append((int)this.maxZ);
  1117.       result.append(")");
  1118.       return result.toString();
  1119.     }
  1120.   }
  1121.  
  1122.   private class BankArea extends Economy.Area
  1123.   {
  1124.     private static final long serialVersionUID = 1231436205851667615L;
  1125.  
  1126.     public BankArea(double minX, double maxX, double minY, double maxY, double minZ, double maxZ, String owner)
  1127.     {
  1128.       super(minX, maxX, minY, maxY, minZ, maxZ, owner);
  1129.     }
  1130.  
  1131.     public double price()
  1132.     {
  1133.       return Economy.BANK_AREA_COST * super.price();
  1134.     }
  1135.   }
  1136.  
  1137.   private class CompoundCondition<T> extends Economy.Condition<T>
  1138.   {
  1139.     private static final long serialVersionUID = 4L;
  1140.     private HashSet<Economy.Condition<T>> subConditions = new HashSet();
  1141.  
  1142.     private CompoundCondition()
  1143.     {
  1144.       super(null);
  1145.     }
  1146.  
  1147.     boolean isValid(T parameter)
  1148.     {
  1149.       for (Economy.Condition condition : this.subConditions) {
  1150.         if (!condition.isValid(parameter)) {
  1151.           return false;
  1152.         }
  1153.       }
  1154.       return true;
  1155.     }
  1156.  
  1157.     public boolean addSubCondition(Economy.Condition<T> condition) {
  1158.       return this.subConditions.add(condition);
  1159.     }
  1160.  
  1161.     public boolean removeSubCondition(Economy.Condition<T> condition) {
  1162.       return this.subConditions.remove(condition);
  1163.     }
  1164.   }
  1165.  
  1166.   private abstract class Condition<T>
  1167.     implements Serializable
  1168.   {
  1169.     private static final long serialVersionUID = 3L;
  1170.  
  1171.     private Condition()
  1172.     {
  1173.     }
  1174.  
  1175.     abstract boolean isValid(T paramT);
  1176.   }
  1177.  
  1178.   private final class EconomyListener extends PluginListener
  1179.   {
  1180.     private EconomyListener()
  1181.     {
  1182.     }
  1183.  
  1184.     public void onLogin(Player player)
  1185.     {
  1186.       if ((Economy.this.balances.containsKey(
  1187.         player.getName().toLowerCase())) ||
  1188.         (!player.canUseCommand("/balance"))) {
  1189.         return;
  1190.       }
  1191.       if ((Economy.STARTING_MONEY > 0.0D) && (Economy.this.publicFund >= Economy.STARTING_MONEY)) {
  1192.         Economy.access$5(player, Economy.INFO + "Welcome to the sever.");
  1193.         Economy.access$5(player, Economy.INFO + "Here's " + Economy.MONEY +
  1194.           Economy.this.format(Economy.STARTING_MONEY) + Economy.INFO +
  1195.           " to get you started.");
  1196.         Economy.this.publicFund -= Economy.STARTING_MONEY;
  1197.         Economy.this.addToBalance(player.getName(), Economy.STARTING_MONEY);
  1198.       }
  1199.     }
  1200.  
  1201.     public boolean onMobSpawn(Mob mob)
  1202.     {
  1203.       return Economy.this.getArea(mob.getX(), mob.getY(), mob.getZ()) != null;
  1204.     }
  1205.  
  1206.     public boolean onBlockPlace(Player player, Block block, Block blockClicked, Item itemInHand)
  1207.     {
  1208.       Economy.Area area = Economy.this.getArea(block.getX(), block.getY(),
  1209.         block.getZ());
  1210.       if (area == null) {
  1211.         return false;
  1212.       }
  1213.       if (!area.owner.equalsIgnoreCase(player.getName())) {
  1214.         Economy.access$5(player, Economy.ERROR +
  1215.           "Can't place blocks here. This area belongs to " + (
  1216.           Economy.access$12(area.owner) ? Economy.ONLINE : Economy.OFFLINE) + area.owner +
  1217.           Economy.ERROR + ".");
  1218.         return true;
  1219.       }
  1220.       return false;
  1221.     }
  1222.  
  1223.     public boolean onBlockBreak(Player player, Block block)
  1224.     {
  1225.       Economy.Area area = Economy.this.getArea(block.getX(), block.getY(),
  1226.         block.getZ());
  1227.       if (area == null) {
  1228.         return false;
  1229.       }
  1230.       if (!(area instanceof Economy.PersonalArea)) {
  1231.         return false;
  1232.       }
  1233.       if (!area.owner.equalsIgnoreCase(player.getName())) {
  1234.         Economy.access$5(player, Economy.ERROR +
  1235.           "Can't remove blocks here. This area belongs to " + (
  1236.           Economy.access$12(area.owner) ? Economy.ONLINE : Economy.OFFLINE) + area.owner +
  1237.           Economy.ERROR + ".");
  1238.         return true;
  1239.       }
  1240.       return false;
  1241.     }
  1242.  
  1243.     public boolean onCommand(Player player, String[] split)
  1244.     {
  1245.       if (!Economy.this.isEnabled()) {
  1246.         return false;
  1247.       }
  1248.       String command = split[0].toLowerCase();
  1249.  
  1250.       if (command.equals("/buy")) {
  1251.         buy(player, split);
  1252.         return true;
  1253.       }if (command.equals("/saveeconomy")) {
  1254.         saveEconomy(player, split);
  1255.         return true;
  1256.       }if (command.equals("/lottery")) {
  1257.         lottery(player, split);
  1258.         return true;
  1259.       }if (command.equals("/area")) {
  1260.         if (split.length <= 1) {
  1261.           Economy.access$5(
  1262.             player,
  1263.             Economy.COMMAND +
  1264.             "Usage: /area <add | get | give | list | name | remove>");
  1265.         }
  1266.         String subcommand = split[1].toLowerCase();
  1267.         if (subcommand.equals("add"))
  1268.           addArea(player, split);
  1269.         else if (subcommand.equals("get"))
  1270.           getArea(player, split);
  1271.         else if (subcommand.equals("give"))
  1272.           giveArea(player, split);
  1273.         else if (subcommand.equals("list"))
  1274.           listAreas(player, split);
  1275.         else if (subcommand.equals("name"))
  1276.           nameArea(player, split);
  1277.         else if (subcommand.equals("remove"))
  1278.           removeArea(player, split);
  1279.         else {
  1280.           player
  1281.             .sendMessage(Economy.COMMAND +
  1282.             "Usage: /area <add | get | give | list | name | remove>");
  1283.         }
  1284.         return true;
  1285.       }if (command.equals("/offer")) {
  1286.         if (split.length <= 1) {
  1287.           Economy.access$5(player, Economy.COMMAND +
  1288.             "Usage: /offer <add | list | listen | remove>");
  1289.         }
  1290.         String subcommand = split[1].toLowerCase();
  1291.         if (subcommand.equals("add"))
  1292.           offer(player, split);
  1293.         else if (subcommand.equals("list"))
  1294.           listOffers(player, split);
  1295.         else if (subcommand.equals("remove"))
  1296.           removeOffer(player, split);
  1297.         else if (subcommand.equals("listen"))
  1298.           listenFor(player, split);
  1299.         else {
  1300.           player.sendMessage(Economy.COMMAND +
  1301.             "Usage: /offer <add | list | remove>");
  1302.         }
  1303.         return true;
  1304.       }if (command.equals("/money")) {
  1305.         if (split.length <= 1) {
  1306.           Economy.access$5(
  1307.             player,
  1308.             Economy.COMMAND +
  1309.             "Usage: /money <balance | deposit | give | pay | withdraw>");
  1310.         }
  1311.         String subcommand = split[1].toLowerCase();
  1312.         if (subcommand.equals("balance"))
  1313.           balance(player, split);
  1314.         else if (subcommand.equals("deposit"))
  1315.           deposit(player, split);
  1316.         else if (subcommand.equals("give"))
  1317.           giveMoney(player, split);
  1318.         else if (subcommand.equals("pay"))
  1319.           pay(player, split);
  1320.         else if (subcommand.equals("withdraw"))
  1321.           withdraw(player, split);
  1322.         else {
  1323.           Economy.access$5(
  1324.             player,
  1325.             Economy.COMMAND +
  1326.             "Usage: /money <balance | deposit | give | pay | withdraw>");
  1327.         }
  1328.         return true;
  1329.       }
  1330.       return false;
  1331.     }
  1332.  
  1333.     private final void withdraw(Player player, String[] split) {
  1334.       if (!player.canUseCommand("/money")) {
  1335.         return;
  1336.       }
  1337.  
  1338.       if (split.length < 3) {
  1339.         Economy.access$5(player, Economy.COMMAND +
  1340.           "Usage: /money withdraw <amount | 'all' >");
  1341.         return;
  1342.       }
  1343.  
  1344.       Economy.Area area = Economy.this.getArea(player);
  1345.       if ((area == null) || (!(area instanceof Economy.BankArea))) {
  1346.         Economy.access$5(
  1347.           player,
  1348.           Economy.ERROR +
  1349.           "Error - you must be in a banking area to withdraw money.");
  1350.         if (player.canUseCommand("/area")) {
  1351.           Economy.access$5(player, Economy.INFO +
  1352.             "Try using the \"/area list\" command.");
  1353.         }
  1354.         return;
  1355.       }
  1356.       double withdrawAmount;
  1357.       try {
  1358.         double withdrawAmount = Double.parseDouble(split[2]);
  1359.         withdrawAmount = Math.round(withdrawAmount * 100.0D) / 100.0D;
  1360.       } catch (Exception e) {
  1361.         if (!split[2].equalsIgnoreCase("all")) {
  1362.           Economy.access$5(player, Economy.ERROR +
  1363.             "Error - amount must be a valid number.");
  1364.           return;
  1365.         }
  1366.         withdrawAmount = Economy.this.getBalance(player.getName());
  1367.       }
  1368.  
  1369.       if (withdrawAmount <= 0.0D) {
  1370.         Economy.access$5(player, Economy.ERROR +
  1371.           "Error - must withdraw a positive amount.");
  1372.         return;
  1373.       }
  1374.  
  1375.       if (Economy.this.getBalance(player.getName()) < withdrawAmount) {
  1376.         Economy.access$5(player, Economy.ERROR + "Error - insufficient funds.");
  1377.         Economy.access$5(player, Economy.INFO + "Your current balance is " + Economy.MONEY +
  1378.           Economy.this.format(Economy.access$17(Economy.this, player.getName())) +
  1379.           Economy.INFO + ".");
  1380.         return;
  1381.       }
  1382.  
  1383.       TreeMap VALUE_ITEMS = new TreeMap(
  1384.         new Comparator()
  1385.       {
  1386.         public int compare(Double arg0, Double arg1) {
  1387.           if (arg0.doubleValue() < arg1.doubleValue())
  1388.             return 1;
  1389.           if (arg0 == arg1) {
  1390.             return 0;
  1391.           }
  1392.           return -1;
  1393.         }
  1394.       })
  1395.       {
  1396.       };
  1397.       boolean removed = false;
  1398.       for (Map.Entry entry : VALUE_ITEMS.entrySet()) {
  1399.         double itemValue = ((Double)entry.getKey()).doubleValue();
  1400.         int itemId = ((Integer)entry.getValue()).intValue();
  1401.         int count = (int)(withdrawAmount / itemValue);
  1402.         if (count == 0) {
  1403.           continue;
  1404.         }
  1405.         int remaining = Economy.this.givePlayer(player, itemId, count);
  1406.         withdrawAmount -= (count - remaining) * itemValue;
  1407.         Economy.this.addToBalance(player.getName(), (remaining - count) *
  1408.           itemValue);
  1409.         if (remaining > 0) {
  1410.           Economy.access$5(player, Economy.ERROR + "Error - could not withdraw " +
  1411.             Economy.MONEY + Economy.this.format(withdrawAmount) + Economy.ERROR + ".");
  1412.           Economy.access$5(player, Economy.ERROR +
  1413.             "Please make room in your inventory.");
  1414.           if (removed) {
  1415.             Economy.access$5(player, Economy.INFO +
  1416.               "Your balance has decreased to " +
  1417.               Economy.MONEY +
  1418.               Economy.this
  1419.               .format(Economy.access$17(Economy.this,
  1420.               player.getName())) + Economy.INFO + ".");
  1421.           }
  1422.           return;
  1423.         }
  1424.         removed = true;
  1425.       }
  1426.       if (withdrawAmount > 0.0D) {
  1427.         Economy.access$5(player, Economy.ERROR + "Warning - could not withdraw " +
  1428.           Economy.MONEY + Economy.this.format(withdrawAmount) + Economy.ERROR + ".");
  1429.       }
  1430.       if (removed)
  1431.         Economy.access$5(player, Economy.INFO + "Your balance has decreased to " +
  1432.           Economy.MONEY +
  1433.           Economy.this.format(Economy.access$17(Economy.this, player.getName())) +
  1434.           Economy.INFO + ".");
  1435.     }
  1436.  
  1437.     private final void lottery(Player player, String[] split)
  1438.     {
  1439.       if (!player.canUseCommand("/lottery")) {
  1440.         return;
  1441.       }
  1442.  
  1443.       long currentTime = System.currentTimeMillis();
  1444.       double lotteryMs = Economy.LOTTERY_INTERVAL * 60.0D * 1000.0D;
  1445.       if (currentTime - Economy.this.lastLottery < lotteryMs) {
  1446.         player.sendMessage(Economy.ERROR +
  1447.           "Error - lottery has been run too recently.");
  1448.         player.sendMessage(Economy.ERROR +
  1449.           "You must wait another " +
  1450.           "§f" +
  1451.           Economy.this
  1452.           .formatTime(Economy.LOTTERY_INTERVAL -
  1453.           (currentTime - Economy.this.lastLottery) /
  1454.           1000.0D / 60.0D) + Economy.ERROR +
  1455.           " before trying again.");
  1456.         return;
  1457.       }
  1458.  
  1459.       Economy.this.lastLottery = currentTime;
  1460.  
  1461.       List players = etc.getServer().getPlayerList();
  1462.       Iterator iterator = players.iterator();
  1463.       while (iterator.hasNext()) {
  1464.         if (!((Player)iterator.next()).canUseCommand("/money")) {
  1465.           iterator.remove();
  1466.         }
  1467.       }
  1468.  
  1469.       if (players.size() <= 1) {
  1470.         player
  1471.           .sendMessage(Economy.ERROR +
  1472.           "Error - there must be more people online to have a lottery.");
  1473.         return;
  1474.       }
  1475.  
  1476.       double maxWinnings = Economy.this.publicFund * (
  1477.         1.0D -
  1478.         Math.exp(Math.log(2.0D) / (Economy.PLAYERS_TO_HALF - 1) * (
  1479.         1 - players.size())));
  1480.       maxWinnings = Math.round(100.0D * maxWinnings) / 100.0D;
  1481.  
  1482.       Player winner = (Player)players.get((int)(Math.random() * players.size()));
  1483.  
  1484.       for (Player p : players) {
  1485.         Economy.access$5(p, Economy.ONLINE + player.getName() + Economy.INFO +
  1486.           " has started the lottery!");
  1487.         Economy.access$5(p, Economy.MONEY + Economy.this.format(maxWinnings) + Economy.INFO +
  1488.           " is up for stake!");
  1489.         Economy.access$5(p, Economy.INFO + "And the winner is... " + Economy.ONLINE +
  1490.           winner.getName() + Economy.INFO + "! Congratulations!");
  1491.       }
  1492.  
  1493.       Economy.this.addToBalance(winner.getName(), maxWinnings);
  1494.       Economy.this.publicFund -= maxWinnings;
  1495.  
  1496.       Economy.access$5(winner, Economy.INFO + "Your balance has increased to " + Economy.MONEY +
  1497.         Economy.this.format(Economy.access$17(Economy.this, winner.getName())) + Economy.INFO +
  1498.         ".");
  1499.     }
  1500.  
  1501.     private final void listenFor(Player player, String[] split) {
  1502.       String playerName = player.getName().toLowerCase();
  1503.       if (!player.canUseCommand("/offer")) {
  1504.         return;
  1505.       }
  1506.  
  1507.       if (split.length < 3) {
  1508.         Economy.access$5(
  1509.           player,
  1510.           Economy.COMMAND +
  1511.           "Usage: /offer listen <itemName1|'none'|?> [itemName2] ... [itemNameN]");
  1512.         return;
  1513.       }
  1514.       Iterator localIterator1;
  1515.       if (split[2].equalsIgnoreCase("none")) {
  1516.         boolean found = false;
  1517.  
  1518.         localIterator1 = Economy.this.offerListeners
  1519.           .values().iterator();
  1520.  
  1521.         while (localIterator1.hasNext()) {
  1522.           HashSet listeners = (HashSet)localIterator1.next();
  1523.           if (listeners.contains(playerName)) {
  1524.             found = true;
  1525.           }
  1526.           listeners.remove(playerName);
  1527.         }
  1528.         if (found)
  1529.           Economy.access$5(player, Economy.INFO +
  1530.             "You are no longer listening for any items.");
  1531.         else {
  1532.           Economy.access$5(player, Economy.ERROR +
  1533.             "Error - you are not listening for any items.");
  1534.         }
  1535.         return;
  1536.       }if (split[2].equals("?")) {
  1537.         HashSet listeningFor = new HashSet();
  1538.  
  1539.         localIterator1 = Economy.this.offerListeners
  1540.           .entrySet().iterator();
  1541.  
  1542.         while (localIterator1.hasNext()) {
  1543.           Map.Entry entry = (Map.Entry)localIterator1.next();
  1544.           if (!((HashSet)entry.getValue()).contains(
  1545.             player.getName().toLowerCase())) continue;
  1546.           listeningFor.add((Integer)entry.getKey());
  1547.         }
  1548.  
  1549.         if (listeningFor.size() == 0) {
  1550.           Economy.access$5(player, Economy.INFO +
  1551.             "You are not listening for any items.");
  1552.         } else {
  1553.           StringBuilder message = new StringBuilder();
  1554.           message.append(Economy.INFO);
  1555.           message.append("You are listening for ");
  1556.           int listenerIndex = 0;
  1557.           for (Integer id : listeningFor) {
  1558.             message.append(Economy.access$26(id.intValue()));
  1559.             if (listenerIndex < listeningFor.size() - 1) {
  1560.               if (listeningFor.size() > 2) {
  1561.                 message.append(',');
  1562.               }
  1563.               message.append(' ');
  1564.             }
  1565.             if (listenerIndex == listeningFor.size() - 2) {
  1566.               message.append("and ");
  1567.             }
  1568.             listenerIndex++;
  1569.           }
  1570.           message.append(".");
  1571.           Economy.access$5(player, message.toString());
  1572.         }
  1573.         return;
  1574.       }
  1575.  
  1576.       for (int itemIndex = 2; itemIndex < split.length; itemIndex++) {
  1577.         int itemId = Economy.access$0(split[itemIndex]);
  1578.         if (itemId == -1) {
  1579.           Economy.access$5(player, Economy.ERROR +
  1580.             "Error - could not find item id for " +
  1581.             split[itemIndex] + ".");
  1582.         }
  1583.         else
  1584.         {
  1585.           HashSet listeners =
  1586.             (HashSet)Economy.this.offerListeners
  1587.             .get(Integer.valueOf(itemId));
  1588.           if (listeners == null) {
  1589.             listeners = new HashSet();
  1590.             Economy.this.offerListeners.put(Integer.valueOf(itemId), listeners);
  1591.           }
  1592.  
  1593.           if (listeners.contains(playerName)) {
  1594.             Economy.access$5(player, Economy.INFO +
  1595.               "You are no longer listening for " +
  1596.               split[itemIndex] + ".");
  1597.             listeners.remove(playerName);
  1598.             return;
  1599.           }
  1600.  
  1601.           listeners.add(playerName);
  1602.           Economy.access$5(player, Economy.INFO + "You are now listening for " +
  1603.             split[itemIndex] + ".");
  1604.         }
  1605.       }
  1606.     }
  1607.  
  1608.     private final void giveArea(Player player, String[] split)
  1609.     {
  1610.       if (!player.canUseCommand("/area")) {
  1611.         return;
  1612.       }
  1613.  
  1614.       if (split.length < 4) {
  1615.         Economy.access$5(player, Economy.COMMAND +
  1616.           "Usage: /area give <areaId> <playerName>");
  1617.         return;
  1618.       }
  1619.  
  1620.       try
  1621.       {
  1622.         areaId = Integer.parseInt(split[2]);
  1623.       }
  1624.       catch (Exception e)
  1625.       {
  1626.         int areaId;
  1627.         Economy.access$5(player, Economy.ERROR +
  1628.           "Error - area id must be a valid number.");
  1629.         return;
  1630.       }
  1631.       int areaId;
  1632.       if (player.getName().equalsIgnoreCase(split[3])) {
  1633.         Economy.access$5(player, Economy.ERROR +
  1634.           "Error - you can't transfer an area to yourself.");
  1635.         return;
  1636.       }
  1637.  
  1638.       String otherName = split[3].toLowerCase();
  1639.       Player otherPlayer = etc.getServer().getPlayer(otherName);
  1640.       if ((otherPlayer == null) &&
  1641.         (!Economy.this.balances.containsKey(otherName))) {
  1642.         Economy.access$5(player, Economy.ERROR + "Error - can't find player " +
  1643.           Economy.OFFLINE + otherName + Economy.ERROR + ".");
  1644.         return;
  1645.       }
  1646.  
  1647.       for (Economy.Area area : Economy.this.allAreas()) {
  1648.         if (area.areaId != areaId) {
  1649.           continue;
  1650.         }
  1651.         if ((!area.owner.equalsIgnoreCase(player.getName())) &&
  1652.           (!player.isAdmin())) {
  1653.           Economy.access$5(player, Economy.ERROR +
  1654.             "Error - you can't transfer that area.");
  1655.           return;
  1656.         }
  1657.  
  1658.         double transferPrice = Economy.TRANSFER_FEE * area.price();
  1659.         String color = Economy.access$29(area);
  1660.  
  1661.         if (Economy.this.getBalance(player.getName()) < transferPrice) {
  1662.           Economy.access$5(player, Economy.ERROR + "Error - insufficient funds.");
  1663.           Economy.access$5(player, Economy.ERROR + "It will cost " + Economy.MONEY +
  1664.             Economy.this.format(transferPrice) + Economy.ERROR +
  1665.             " to transfer that area.");
  1666.           return;
  1667.         }
  1668.  
  1669.         area.owner = split[3].toLowerCase();
  1670.         if (area.areaName.equals("")) {
  1671.           Economy.access$5(player, Economy.INFO + "You have transferred area ID " +
  1672.             color + area.areaId + Economy.INFO + " to " + (
  1673.             Economy.access$12(otherName) ? Economy.ONLINE : Economy.OFFLINE) +
  1674.             otherName + Economy.INFO + ".");
  1675.           if (otherPlayer != null)
  1676.             Economy.access$5(otherPlayer, Economy.INFO + Economy.ONLINE +
  1677.               player.getName().toLowerCase() + Economy.INFO +
  1678.               " has given you area ID " + color +
  1679.               area.areaId + Economy.INFO + ".");
  1680.         }
  1681.         else {
  1682.           Economy.access$5(player, Economy.INFO + "You have transferred " + color +
  1683.             area.areaName + Economy.INFO + " to " + (
  1684.             Economy.access$12(otherName) ? Economy.ONLINE : Economy.OFFLINE) +
  1685.             otherName + Economy.INFO + ".");
  1686.           if (otherPlayer != null) {
  1687.             Economy.access$5(otherPlayer, Economy.INFO + Economy.ONLINE +
  1688.               player.getName().toLowerCase() + Economy.INFO +
  1689.               " has given you " + color + area.areaName +
  1690.               Economy.INFO + ".");
  1691.           }
  1692.         }
  1693.         Economy.this.addToBalance(player.getName().toLowerCase(),
  1694.           -transferPrice);
  1695.         Economy.this.publicFund += transferPrice;
  1696.         Economy.access$5(player, Economy.INFO + "You spent " + Economy.MONEY +
  1697.           Economy.this.format(transferPrice) + Economy.INFO +
  1698.           " transferring that area.");
  1699.         Economy.access$5(player, Economy.INFO + "Your balance has decreased to " +
  1700.           Economy.MONEY +
  1701.           Economy.this.format(Economy.access$17(Economy.this, player.getName())) +
  1702.           Economy.INFO + ".");
  1703.         return;
  1704.       }
  1705.     }
  1706.  
  1707.     private final void getArea(Player player, String[] split)
  1708.     {
  1709.       if (!player.canUseCommand("/area"))
  1710.         return;
  1711.       String playerName;
  1712.       String playerName;
  1713.       if (split.length < 3)
  1714.         playerName = player.getName().toLowerCase();
  1715.       else {
  1716.         playerName = split[2].toLowerCase();
  1717.       }
  1718.  
  1719.       if (!Economy.access$12(playerName)) {
  1720.         Economy.access$5(player, Economy.ERROR + "Error - " + Economy.OFFLINE + playerName +
  1721.           Economy.ERROR + " is not online.");
  1722.         return;
  1723.       }
  1724.  
  1725.       Player otherPlayer = etc.getServer().getPlayer(playerName);
  1726.       Economy.Area area = Economy.this.getArea(otherPlayer);
  1727.       if (area == null) {
  1728.         if (playerName.equalsIgnoreCase(player.getName())) {
  1729.           Economy.access$5(player, Economy.INFO + "You are not in any areas.");
  1730.           if (player.canUseCommand("/area"))
  1731.             Economy.access$5(player, Economy.INFO +
  1732.               "Try using the \"/area list\" command.");
  1733.         }
  1734.         else {
  1735.           Economy.access$5(player, Economy.ONLINE + playerName + Economy.INFO +
  1736.             " is not in any areas.");
  1737.         }
  1738.         return;
  1739.       }
  1740.       String owner = area.owner;
  1741.       String color = Economy.access$29(area);
  1742.       StringBuilder message = new StringBuilder();
  1743.       message.append(Economy.INFO);
  1744.       if ((area.areaName.equals("")) || ((area instanceof Economy.PersonalArea))) {
  1745.         if (player.getName().equalsIgnoreCase(playerName)) {
  1746.           message.append("You are in ");
  1747.           if (player.getName().equalsIgnoreCase(owner)) {
  1748.             if (area.areaName.equals(""))
  1749.               message.append("your own area. " + color + "(" +
  1750.                 area.areaId + ")");
  1751.             else
  1752.               message.append(color + area.areaName + Economy.INFO + "." +
  1753.                 color + " (" + area.areaId + ")");
  1754.           }
  1755.           else {
  1756.             message.append((Economy.access$12(owner) ? Economy.ONLINE : Economy.OFFLINE) +
  1757.               owner + "'s " + Economy.INFO + "area.");
  1758.             if (player.isAdmin())
  1759.               message.append(color + " (" + area.areaId + ")");
  1760.           }
  1761.         }
  1762.         else {
  1763.           message.append((Economy.access$12(playerName) ? Economy.ONLINE : Economy.OFFLINE) +
  1764.             playerName + Economy.INFO + " is in ");
  1765.           if (player.getName().equalsIgnoreCase(owner)) {
  1766.             if (area.areaName.equals(""))
  1767.               message.append("your area. " + color + "(" +
  1768.                 area.areaId + ")");
  1769.             else
  1770.               message.append(color + area.areaName + Economy.INFO + "." +
  1771.                 color + " (" + area.areaId + ")");
  1772.           }
  1773.           else {
  1774.             message.append((Economy.access$12(owner) ? Economy.ONLINE : Economy.OFFLINE) +
  1775.               owner + "'s " + Economy.INFO + "area.");
  1776.             if (player.isAdmin())
  1777.               message.append(color + " (" + area.areaId + ")");
  1778.           }
  1779.         }
  1780.       }
  1781.       else {
  1782.         if (playerName.equalsIgnoreCase(player.getName()))
  1783.           message.append("You are in ");
  1784.         else {
  1785.           message.append((Economy.access$12(playerName) ? Economy.ONLINE : Economy.OFFLINE) +
  1786.             playerName + Economy.INFO + " is in ");
  1787.         }
  1788.         message.append(color + area.areaName);
  1789.         message.append(Economy.INFO + ".");
  1790.         if ((player.getName().equalsIgnoreCase(owner)) ||
  1791.           (player.isAdmin())) {
  1792.           message.append(color);
  1793.           message.append(" (");
  1794.           message.append(area.areaId);
  1795.           message.append(")");
  1796.         }
  1797.       }
  1798.       Economy.access$5(player, message.toString());
  1799.     }
  1800.  
  1801.     private final void deposit(Player player, String[] split)
  1802.     {
  1803.       if (!player.canUseCommand("/money")) {
  1804.         return;
  1805.       }
  1806.  
  1807.       Economy.Area area = Economy.this.getArea(player);
  1808.       if ((area == null) || (!(area instanceof Economy.BankArea))) {
  1809.         Economy.access$5(
  1810.           player,
  1811.           Economy.ERROR +
  1812.           "Error - you must be in a banking area to make a deposit.");
  1813.         if (player.canUseCommand("/area")) {
  1814.           Economy.access$5(player, Economy.INFO +
  1815.             "Try using the \"/area list\" command.");
  1816.         }
  1817.         return;
  1818.       }
  1819.  
  1820.       Inventory inventory = player.getInventory();
  1821.       hn[] inventoryArray = inventory.getArray();
  1822.  
  1823.       double totalDeposit = 0.0D;
  1824.  
  1825.       for (int index = 0; index < inventoryArray.length; index++) {
  1826.         if (inventoryArray[index] == null) {
  1827.           continue;
  1828.         }
  1829.         int id = inventoryArray[index].c;
  1830.         if (!Economy.ITEM_VALUES.containsKey(Integer.valueOf(id))) {
  1831.           continue;
  1832.         }
  1833.         int pileSize = inventoryArray[index].a;
  1834.         double depositAmount = pileSize * ((Double)Economy.ITEM_VALUES.get(Integer.valueOf(id))).doubleValue();
  1835.         totalDeposit += depositAmount;
  1836.         Economy.this.addToBalance(player.getName().toLowerCase(),
  1837.           depositAmount);
  1838.         inventoryArray[index] = null;
  1839.       }
  1840.       if (totalDeposit == 0.0D) {
  1841.         Economy.access$5(player, Economy.ERROR +
  1842.           "Error - you don't have anything to deposit.");
  1843.         return;
  1844.       }
  1845.       player.getInventory().updateInventory();
  1846.       Economy.access$5(player, Economy.INFO + "You have deposited " + Economy.MONEY +
  1847.         Economy.this.format(totalDeposit) + Economy.INFO + ".");
  1848.       Economy.access$5(player, Economy.INFO +
  1849.         "Your balance has increased to " +
  1850.         Economy.MONEY +
  1851.         Economy.this
  1852.         .format(Economy.access$17(Economy.this,
  1853.         player.getName().toLowerCase())) + Economy.INFO + ".");
  1854.     }
  1855.  
  1856.     private final void giveMoney(Player player, String[] split)
  1857.     {
  1858.       if ((!player.canUseCommand("/money")) || (!player.isAdmin())) {
  1859.         return;
  1860.       }
  1861.  
  1862.       if (split.length < 3) {
  1863.         Economy.access$5(player, Economy.COMMAND + "Usage: /money give <amount>");
  1864.         return;
  1865.       }
  1866.  
  1867.       try
  1868.       {
  1869.         double amount = Double.parseDouble(split[2]);
  1870.         amount = Math.round(amount * 100.0D) / 100.0D;
  1871.       } catch (Exception e) {
  1872.         Economy.access$5(player, Economy.ERROR +
  1873.           "Error - amount must be a valid number.");
  1874.         return;
  1875.       }
  1876.       double amount;
  1877.       if (amount == 0.0D) {
  1878.         Economy.access$5(player, Economy.ERROR + "Error - amount cannot equal 0.");
  1879.         return;
  1880.       }
  1881.  
  1882.       Economy.this.addToBalance(player.getName(), amount);
  1883.       if (amount > 0.0D)
  1884.         Economy.access$5(player, Economy.INFO + "Your balance has increased to " +
  1885.           Economy.MONEY +
  1886.           Economy.this.format(Economy.access$17(Economy.this, player.getName())) +
  1887.           Economy.INFO + ".");
  1888.       else
  1889.         Economy.access$5(player, Economy.INFO + "Your balance has decreased to " +
  1890.           Economy.MONEY +
  1891.           Economy.this.format(Economy.access$17(Economy.this, player.getName())) +
  1892.           Economy.INFO + ".");
  1893.     }
  1894.  
  1895.     private final void saveEconomy(Player player, String[] split)
  1896.     {
  1897.       if (!player.canUseCommand("/saveEconomy")) {
  1898.         return;
  1899.       }
  1900.       Economy.this.writeEconomy();
  1901.       Economy.this.writeLocations();
  1902.  
  1903.       Economy.access$5(player, Economy.INFO + "Economy files saved.");
  1904.     }
  1905.  
  1906.     public void onBlockRightClicked(Player player, Block block, Item item)
  1907.     {
  1908.       String currentPlayer = player.getName().toLowerCase();
  1909.       if (item.getItemId() != -1)
  1910.         return;
  1911.       String areaType;
  1912.       if (Economy.this.pendingTradeAreas.containsKey(currentPlayer)) {
  1913.         ArrayList blocks = (ArrayList)Economy.this.pendingTradeAreas.get(currentPlayer);
  1914.         areaType = "trade";
  1915.       }
  1916.       else
  1917.       {
  1918.         String areaType;
  1919.         if (Economy.this.pendingPersonalAreas
  1920.           .containsKey(currentPlayer)) {
  1921.           ArrayList blocks = (ArrayList)Economy.this.pendingPersonalAreas.get(currentPlayer);
  1922.           areaType = "personal";
  1923.         }
  1924.         else
  1925.         {
  1926.           String areaType;
  1927.           if (Economy.this.pendingBankAreas.containsKey(currentPlayer)) {
  1928.             ArrayList blocks = (ArrayList)Economy.this.pendingBankAreas.get(currentPlayer);
  1929.             areaType = "bank";
  1930.           } else {
  1931.             return;
  1932.           }
  1933.         }
  1934.       }
  1935.       String areaType;
  1936.       ArrayList blocks;
  1937.       for (Economy.Area area : Economy.this.allAreas()) {
  1938.         if ((!area.withinArea(block.getX(), block.getY(), block.getZ())) || (
  1939.           ((area instanceof Economy.PersonalArea)) &&
  1940.           (area.owner.equalsIgnoreCase(currentPlayer)) && (
  1941.           (areaType.equals("trade")) ||
  1942.           (areaType.equals("bank"))))) {
  1943.           continue;
  1944.         }
  1945.         String color = Economy.access$29(area);
  1946.         if (player.getName().equalsIgnoreCase(area.owner)) {
  1947.           if (area.areaName.equals(""))
  1948.             Economy.access$5(
  1949.               player,
  1950.               Economy.ERROR +
  1951.               "Error - that block is already part of area ID " +
  1952.               color + area.areaId + Economy.ERROR + ".");
  1953.           else
  1954.             Economy.access$5(player, Economy.ERROR +
  1955.               "Error - that block is already part of " +
  1956.               color + area.areaName + Economy.INFO + "." +
  1957.               color + " (" + area.areaId + ")");
  1958.         }
  1959.         else {
  1960.           StringBuilder message = new StringBuilder();
  1961.           if ((area.areaName.equals("")) ||
  1962.             ((area instanceof Economy.PersonalArea))) {
  1963.             message.append(Economy.ERROR +
  1964.               "Error - that block is already part of " + (
  1965.               Economy.access$12(area.owner) ? Economy.ONLINE : Economy.OFFLINE) +
  1966.               "'s" + Economy.ERROR + " area.");
  1967.             if (player.isAdmin())
  1968.               message
  1969.                 .append(color + " (" + area.areaId +
  1970.                 ")");
  1971.           }
  1972.           else {
  1973.             message.append(Economy.ERROR +
  1974.               "Error - that block is already part of " +
  1975.               color + area.areaName + Economy.ERROR + ".");
  1976.             if (player.isAdmin()) {
  1977.               message
  1978.                 .append(color + " (" + area.areaId +
  1979.                 ")");
  1980.             }
  1981.           }
  1982.           Economy.access$5(player, message.toString());
  1983.         }
  1984.         return;
  1985.       }
  1986.  
  1987.       if (blocks.size() == 3) {
  1988.         Block block0 = (Block)blocks.get(0);
  1989.         Block block1 = (Block)blocks.get(1);
  1990.         Block block2 = (Block)blocks.get(2);
  1991.         double xmin = Math.min(block1.getX(), block0.getX());
  1992.         double xmax = Math.max(block1.getX(), block0.getX()) + 1;
  1993.         double zmin = Math.min(block1.getZ(), block0.getZ());
  1994.         double zmax = Math.max(block1.getZ(), block0.getZ()) + 1;
  1995.         double ymin = Math.min(block2.getY(), block.getY());
  1996.         double ymax = Math.max(block2.getY(), block.getY()) + 1;
  1997.         double deltaX = xmax - xmin;
  1998.         double deltaY = ymax - ymin;
  1999.         double deltaZ = zmax - zmin;
  2000.         double floorSize = deltaX * deltaZ;
  2001.  
  2002.         if (deltaY <= 1.0D) {
  2003.           ymax = ymin + 2.0D;
  2004.           deltaY = ymax - ymin;
  2005.         }
  2006.  
  2007.         if ((areaType.equals("trade")) &&
  2008.           ((deltaX > Economy.MAX_TRADE_AREA_LENGTH) || (deltaZ > Economy.MAX_TRADE_AREA_LENGTH)) &&
  2009.           (!player.isAdmin())) {
  2010.           Economy.access$5(
  2011.             player,
  2012.             Economy.ERROR +
  2013.             "Error - area too long. Trade area side lengths must be less than " +
  2014.             Economy.MAX_TRADE_AREA_LENGTH);
  2015.           Economy.this.pendingTradeAreas.remove(currentPlayer);
  2016.           return;
  2017.         }
  2018.         if ((areaType.equals("trade")) && (floorSize > Economy.MAX_TRADE_AREA_SIZE) &&
  2019.           (!player.isAdmin())) {
  2020.           Economy.access$5(
  2021.             player,
  2022.             Economy.ERROR +
  2023.             "Error - area too large. Maximum trade area size is " +
  2024.             Economy.MAX_TRADE_AREA_SIZE + "blocks^2");
  2025.           Economy.this.pendingTradeAreas.remove(currentPlayer);
  2026.           return;
  2027.         }
  2028.         if ((areaType.equals("bank")) &&
  2029.           ((deltaX > Economy.MAX_BANK_AREA_LENGTH) || (deltaZ > Economy.MAX_BANK_AREA_LENGTH)) &&
  2030.           (!player.isAdmin())) {
  2031.           Economy.access$5(
  2032.             player,
  2033.             Economy.ERROR +
  2034.             "Error - area too long. Bank area side lengths must be less than " +
  2035.             Economy.MAX_BANK_AREA_LENGTH + ".");
  2036.           Economy.this.pendingBankAreas.remove(currentPlayer);
  2037.           return;
  2038.         }
  2039.         if ((areaType.equals("bank")) && (floorSize > Economy.MAX_BANK_AREA_SIZE) &&
  2040.           (!player.isAdmin())) {
  2041.           Economy.access$5(
  2042.             player,
  2043.             Economy.ERROR +
  2044.             "Error - area too large. Maximum bank area size is " +
  2045.             Economy.MAX_BANK_AREA_SIZE + "blocks^2");
  2046.           Economy.this.pendingBankAreas.remove(currentPlayer);
  2047.           return;
  2048.         }
  2049.  
  2050.         double areaCost = 0.0D;
  2051.  
  2052.         if (areaType.equals("trade"))
  2053.         {
  2054.           areaCost = areaCost + floorSize * Economy.TRADE_AREA_COST * (
  2055.             1.0D + Economy.VERTICAL_COST * deltaY);
  2056.           if (areaCost > Economy.this.getBalance(currentPlayer)) {
  2057.             Economy.access$5(player, Economy.ERROR +
  2058.               "Error - insufficient funds.");
  2059.             Economy.access$5(player, Economy.ERROR +
  2060.               "A trading area of that size will cost " +
  2061.               Economy.MONEY + Economy.this.format(areaCost) + Economy.ERROR + ".");
  2062.             Economy.this.pendingTradeAreas.remove(currentPlayer);
  2063.             Economy.access$5(player, Economy.INFO +
  2064.               "You are no longer defining trading areas.");
  2065.             return;
  2066.           }
  2067.           Economy.this.addToBalance(currentPlayer, -areaCost);
  2068.           Economy.this.publicFund += areaCost;
  2069.         } else if (areaType.equals("personal"))
  2070.         {
  2071.           areaCost = areaCost + floorSize * Economy.PERSONAL_AREA_COST * (
  2072.             1.0D + Economy.VERTICAL_COST * deltaY);
  2073.           if (areaCost > Economy.this.getBalance(currentPlayer)) {
  2074.             Economy.access$5(player, Economy.ERROR +
  2075.               "Error - insufficient funds.");
  2076.             Economy.access$5(player, Economy.ERROR +
  2077.               "A personal area of that size will cost " +
  2078.               Economy.MONEY + Economy.this.format(areaCost) + Economy.ERROR + ".");
  2079.             Economy.this.pendingPersonalAreas.remove(currentPlayer);
  2080.             Economy.access$5(player, Economy.INFO +
  2081.               "You are no longer defining personl areas.");
  2082.             return;
  2083.           }
  2084.           Economy.this.addToBalance(currentPlayer, -areaCost);
  2085.           Economy.this.publicFund += areaCost;
  2086.         } else if (areaType.equals("bank"))
  2087.         {
  2088.           areaCost = areaCost + floorSize * Economy.BANK_AREA_COST * (
  2089.             1.0D + Economy.VERTICAL_COST * deltaY);
  2090.           if (areaCost > Economy.this.getBalance(currentPlayer)) {
  2091.             Economy.access$5(player, Economy.ERROR +
  2092.               "Error - insufficient funds.");
  2093.             Economy.access$5(player, Economy.ERROR +
  2094.               "A banking area of that size will cost " +
  2095.               Economy.MONEY + Economy.this.format(areaCost) + Economy.ERROR + ".");
  2096.             Economy.this.pendingBankAreas.remove(currentPlayer);
  2097.             Economy.access$5(player, Economy.INFO +
  2098.               "You are no longer defining banking areas.");
  2099.             return;
  2100.           }
  2101.           Economy.this.addToBalance(currentPlayer, -areaCost);
  2102.           Economy.this.publicFund += areaCost;
  2103.         }
  2104.  
  2105.         if (areaType.equals("trade")) {
  2106.           Economy.Area newArea = new Economy.TradeArea(Economy.this, xmin, xmax, ymin, ymax, zmin, zmax,
  2107.             currentPlayer);
  2108.           Economy.this.tradingAreas.add(newArea);
  2109.           Economy.this.pendingTradeAreas.remove(currentPlayer);
  2110.           Economy.access$5(player, Economy.INFO +
  2111.             "You have defined a trading area. (Area id " +
  2112.             Economy.TRADE_AREA_COLOR + newArea.areaId + Economy.INFO + ")");
  2113.         } else if (areaType.equals("personal")) {
  2114.           Economy.Area newArea = new Economy.PersonalArea(Economy.this, xmin, xmax, ymin, ymax, zmin,
  2115.             zmax, currentPlayer);
  2116.           Economy.this.personalAreas.add(newArea);
  2117.           Economy.this.pendingPersonalAreas.remove(currentPlayer);
  2118.           Economy.access$5(player, Economy.INFO +
  2119.             "You have defined a personal area. (Area id " +
  2120.             Economy.PERSONAL_AREA_COLOR + newArea.areaId + Economy.INFO + ")");
  2121.         } else if (areaType.equals("bank")) {
  2122.           Economy.Area newArea = new Economy.BankArea(Economy.this, xmin, xmax, ymin, ymax, zmin, zmax,
  2123.             currentPlayer);
  2124.           Economy.this.bankingAreas.add(newArea);
  2125.           Economy.this.pendingBankAreas.remove(currentPlayer);
  2126.           Economy.access$5(player, Economy.INFO +
  2127.             "You have defined a banking area. (Area id " +
  2128.             Economy.BANK_AREA_COLOR + newArea.areaId + Economy.INFO + ")");
  2129.         }
  2130.         Economy.access$5(player, Economy.INFO + "You have bought the area for " +
  2131.           Economy.MONEY + Economy.this.format(areaCost) + Economy.INFO + ".");
  2132.         Economy.access$5(player, Economy.INFO + "Your balance has decreased to " +
  2133.           Economy.MONEY +
  2134.           Economy.this.format(Economy.access$17(Economy.this, currentPlayer)) + Economy.INFO +
  2135.           ".");
  2136.         if (player.canUseCommand("/nameArea")) {
  2137.           Economy.access$5(player, Economy.INFO +
  2138.             "You can now name this area with /nameArea.");
  2139.         }
  2140.         return;
  2141.       }
  2142.  
  2143.       blocks.add(block);
  2144.       if (blocks.size() == 1)
  2145.         Economy.access$5(player, Economy.INFO + "Now right click the other corner.");
  2146.       else if (blocks.size() == 2)
  2147.         Economy.access$5(player, Economy.INFO +
  2148.           "Next, right click the floor of your area.");
  2149.       else if (blocks.size() == 3)
  2150.         Economy.access$5(player, Economy.INFO +
  2151.           "Finally, right click the ceiling of your area.");
  2152.     }
  2153.  
  2154.     private final void removeArea(Player player, String[] split)
  2155.     {
  2156.       if (!player.canUseCommand("/area")) {
  2157.         return;
  2158.       }
  2159.  
  2160.       if (split.length < 3) {
  2161.         Economy.access$5(player, Economy.COMMAND +
  2162.           "Usage: /area remove <areaId|'all'>");
  2163.         return;
  2164.       }
  2165.  
  2166.       if ((Economy.this.tradingAreas.isEmpty()) &&
  2167.         (Economy.this.personalAreas.isEmpty()) &&
  2168.         (Economy.this.bankingAreas.isEmpty())) {
  2169.         Economy.access$5(player, Economy.ERROR + "Error - no areas to remove.");
  2170.         return;
  2171.       }
  2172.       int areaId;
  2173.       try {
  2174.         areaId = Integer.parseInt(split[2]);
  2175.       }
  2176.       catch (Exception e)
  2177.       {
  2178.         int areaId;
  2179.         if (!split[2].equalsIgnoreCase("all")) {
  2180.           Economy.access$5(player, Economy.ERROR +
  2181.             "Error - area id must be a valid number.");
  2182.           return;
  2183.         }
  2184.         areaId = -1;
  2185.       }
  2186.       boolean removed = false;
  2187.  
  2188.       Iterator tradingAreaIterator = Economy.this.tradingAreas
  2189.         .iterator();
  2190.       while (tradingAreaIterator.hasNext()) {
  2191.         Economy.Area area = (Economy.Area)tradingAreaIterator.next();
  2192.         if ((area.areaId == areaId) || (areaId == -1)) {
  2193.           if (!player.getName().equalsIgnoreCase(area.owner)) {
  2194.             if (areaId == -1) {
  2195.               continue;
  2196.             }
  2197.             if (!player.isAdmin()) {
  2198.               Economy.access$5(player, Economy.ERROR +
  2199.                 "Error - you cannot remove that area.");
  2200.               return;
  2201.             }
  2202.           }
  2203.           removed = true;
  2204.           tradingAreaIterator.remove();
  2205.           if (areaId != -1) {
  2206.             Economy.access$5(player, Economy.INFO + "Area successfully removed.");
  2207.             return;
  2208.           }
  2209.         }
  2210.       }
  2211.       Iterator personalAreaIterator = Economy.this.personalAreas
  2212.         .iterator();
  2213.       while (personalAreaIterator.hasNext()) {
  2214.         Economy.Area area = (Economy.Area)personalAreaIterator.next();
  2215.         if ((area.areaId == areaId) || (areaId == -1)) {
  2216.           if (!player.getName().equalsIgnoreCase(area.owner)) {
  2217.             if (areaId == -1) {
  2218.               continue;
  2219.             }
  2220.             if (!player.isAdmin()) {
  2221.               Economy.access$5(player, Economy.ERROR +
  2222.                 "Error - you cannot remove that area.");
  2223.               return;
  2224.             }
  2225.           }
  2226.           removed = true;
  2227.           personalAreaIterator.remove();
  2228.           if (areaId != -1) {
  2229.             Economy.access$5(player, Economy.INFO + "Area successfully removed.");
  2230.             return;
  2231.           }
  2232.         }
  2233.       }
  2234.       Iterator bankAreaIterator = Economy.this.bankingAreas
  2235.         .iterator();
  2236.       while (bankAreaIterator.hasNext()) {
  2237.         Economy.Area area = (Economy.Area)bankAreaIterator.next();
  2238.         if ((area.areaId == areaId) || (areaId == -1)) {
  2239.           if (!player.getName().equalsIgnoreCase(area.owner)) {
  2240.             if (areaId == -1) {
  2241.               continue;
  2242.             }
  2243.             if (!player.isAdmin()) {
  2244.               Economy.access$5(player, Economy.ERROR +
  2245.                 "Error - you cannot remove that area.");
  2246.               return;
  2247.             }
  2248.           }
  2249.           removed = true;
  2250.           bankAreaIterator.remove();
  2251.           if (areaId != -1) {
  2252.             Economy.access$5(player, Economy.INFO + "Area successfully removed.");
  2253.             return;
  2254.           }
  2255.         }
  2256.       }
  2257.       if (areaId == -1) {
  2258.         if (removed)
  2259.           Economy.access$5(player, Economy.INFO + "All areas removed.");
  2260.         else {
  2261.           Economy.access$5(player, Economy.ERROR +
  2262.             "Error - you can't remove any areas.");
  2263.         }
  2264.         return;
  2265.       }
  2266.       Economy.access$5(player, Economy.ERROR + "Error - could not find area id " +
  2267.         areaId + ".");
  2268.     }
  2269.  
  2270.     private final void nameArea(Player player, String[] split)
  2271.     {
  2272.       if (!player.canUseCommand("/area")) {
  2273.         return;
  2274.       }
  2275.  
  2276.       if (split.length < 4) {
  2277.         Economy.access$5(player, Economy.COMMAND +
  2278.           "Usage: /area name <areaId> <newName>");
  2279.         return;
  2280.       }
  2281.  
  2282.       try
  2283.       {
  2284.         areaId = Integer.parseInt(split[2]);
  2285.       }
  2286.       catch (Exception e)
  2287.       {
  2288.         int areaId;
  2289.         Economy.access$5(player, Economy.ERROR +
  2290.           "Error - area id must be a valid number.");
  2291.         return;
  2292.       }
  2293.       int areaId;
  2294.       StringBuilder newName = new StringBuilder();
  2295.       for (int index = 3; index < split.length; index++) {
  2296.         newName.append(split[index]);
  2297.         if (index < split.length - 1) {
  2298.           newName.append(' ');
  2299.         }
  2300.       }
  2301.  
  2302.       for (Economy.Area area : Economy.this.allAreas()) {
  2303.         if (area.areaId == areaId) {
  2304.           if ((!player.getName().equalsIgnoreCase(area.owner)) &&
  2305.             (!player.isAdmin())) {
  2306.             Economy.access$5(player, Economy.ERROR +
  2307.               "Error - you cannot rename that area.");
  2308.             return;
  2309.           }
  2310.           double renameFee = area.floorSize() * Economy.RENAME_FEE;
  2311.           String color;
  2312.           if ((area instanceof Economy.TradeArea)) {
  2313.             String color = Economy.TRADE_AREA_COLOR;
  2314.             renameFee *= Economy.TRADE_AREA_COST;
  2315.           } else if ((area instanceof Economy.PersonalArea)) {
  2316.             String color = Economy.PERSONAL_AREA_COLOR;
  2317.             renameFee *= Economy.PERSONAL_AREA_COST;
  2318.           } else if ((area instanceof Economy.BankArea)) {
  2319.             String color = Economy.BANK_AREA_COLOR;
  2320.             renameFee *= Economy.BANK_AREA_COST;
  2321.           } else {
  2322.             color = "§0";
  2323.           }
  2324.           if ((!area.areaName.equals("")) &&
  2325.             (Economy.this.getBalance(player.getName()) < renameFee)) {
  2326.             Economy.access$5(player, Economy.ERROR +
  2327.               "Error - insufficient funds.");
  2328.             Economy.access$5(player, Economy.ERROR + "It will cost " + Economy.MONEY +
  2329.               Economy.this.format(renameFee) + Economy.ERROR +
  2330.               " to rename that area.");
  2331.             Economy.access$5(player, Economy.INFO +
  2332.               "Your current balance is " +
  2333.               Economy.this
  2334.               .format(Economy.access$17(Economy.this,
  2335.               player.getName())) + Economy.INFO + ".");
  2336.             return;
  2337.           }
  2338.           Economy.access$5(player, Economy.INFO +
  2339.             "Area name successfully changed to " + color +
  2340.             newName.toString() + Economy.INFO + ".");
  2341.           if (!area.areaName.equals("")) {
  2342.             Economy.this.addToBalance(player.getName(), -renameFee);
  2343.             Economy.this.publicFund += renameFee;
  2344.             Economy.access$5(player, Economy.INFO +
  2345.               "Your balance has decreased to " +
  2346.               Economy.MONEY +
  2347.               Economy.this
  2348.               .format(Economy.access$17(Economy.this,
  2349.               player.getName())) + Economy.INFO + ".");
  2350.           } else if (renameFee > 0.0D) {
  2351.             Economy.access$5(player, Economy.INFO + "You will be charged " +
  2352.               Economy.MONEY + Economy.this.format(renameFee) + Economy.INFO +
  2353.               " the next time you rename this area.");
  2354.           }
  2355.           area.areaName = newName.toString();
  2356.           return;
  2357.         }
  2358.       }
  2359.  
  2360.       Economy.access$5(player, Economy.ERROR + "Error - could not find area id " +
  2361.         areaId + ".");
  2362.     }
  2363.  
  2364.     private final void listAreas(Player player, String[] split)
  2365.     {
  2366.       if (!player.canUseCommand("/area"))
  2367.         return;
  2368.       Economy.Condition displayCondition;
  2369.       Economy.Condition displayCondition;
  2370.       if (split.length > 2) {
  2371.         if (split[2].equals("?")) {
  2372.           Economy.access$5(player, Economy.COMMAND +
  2373.             "Usage: /area list [playerName] [page]");
  2374.           return;
  2375.         }
  2376.         displayCondition = new Economy.Condition(Economy.this, split, player)
  2377.         {
  2378.           boolean isValid(Economy.Area area) {
  2379.             if (!area.owner.equalsIgnoreCase(this.val$split[2])) {
  2380.               return false;
  2381.             }
  2382.  
  2383.             return (!(area instanceof Economy.PersonalArea)) ||
  2384.               (this.val$player.isAdmin()) ||
  2385.               (this.val$player.getName().equalsIgnoreCase(
  2386.               area.owner));
  2387.           }
  2388.         };
  2389.       }
  2390.       else
  2391.       {
  2392.         displayCondition = new Economy.Condition(Economy.this, player)
  2393.         {
  2394.           boolean isValid(Economy.Area area) {
  2395.             if ((area instanceof Economy.PersonalArea)) {
  2396.               return area.owner
  2397.                 .equalsIgnoreCase(this.val$player.getName());
  2398.             }
  2399.             return true;
  2400.           }
  2401.         };
  2402.       }
  2403.       if ((Economy.this.tradingAreas.isEmpty()) &&
  2404.         (Economy.this.personalAreas.isEmpty()) &&
  2405.         (Economy.this.bankingAreas.isEmpty())) {
  2406.         Economy.access$5(player, Economy.INFO + "No areas defined.");
  2407.         return;
  2408.       }
  2409.  
  2410.       ArrayList validAreas = new ArrayList();
  2411.       for (Economy.Area area : Economy.this.allAreas()) {
  2412.         if (displayCondition.isValid(area)) {
  2413.           validAreas.add(area);
  2414.         }
  2415.       }
  2416.  
  2417.       if (validAreas.size() == 0) {
  2418.         if (player.getName().equalsIgnoreCase(split[2]))
  2419.           Economy.access$5(player, Economy.INFO +
  2420.             "You don't currently own any areas.");
  2421.         else {
  2422.           Economy.access$5(player, (Economy.access$12(split[2]) ? Economy.ONLINE : Economy.OFFLINE) +
  2423.             split[2].toLowerCase() + Economy.INFO +
  2424.             " doesn't currently own any areas.");
  2425.         }
  2426.         return;
  2427.       }
  2428.       if (split.length > 2) {
  2429.         Economy.access$5(player, (Economy.access$12(split[2]) ? Economy.ONLINE : Economy.OFFLINE) +
  2430.           split[2].toLowerCase() + "'s" + Economy.INFO + " areas:");
  2431.       }
  2432.       for (Economy.Area area : validAreas) {
  2433.         StringBuilder message = new StringBuilder();
  2434.         String areaColor = Economy.access$29(area);
  2435.         message.append(areaColor);
  2436.         message.append(area.areaName);
  2437.         message.append(" [");
  2438.         message.append(Economy.this.format(area.distanceTo(player)));
  2439.         message.append(' ');
  2440.         message.append(area.directionFrom(player));
  2441.         message.append("]");
  2442.         if ((area.owner.equalsIgnoreCase(player.getName())) ||
  2443.           (player.isAdmin())) {
  2444.           message.append(" (");
  2445.           message.append(area.areaId);
  2446.           message.append(", ");
  2447.           message.append(Economy.MONEY);
  2448.           message.append(Economy.this.format(area.price()));
  2449.           message.append(areaColor);
  2450.           message.append(")");
  2451.         }
  2452.         Economy.access$5(player, message.toString());
  2453.       }
  2454.     }
  2455.  
  2456.     private final void addArea(Player player, String[] split)
  2457.     {
  2458.       String name = player.getName().toLowerCase();
  2459.       if (!player.canUseCommand("/area")) {
  2460.         return;
  2461.       }
  2462.  
  2463.       if (split.length < 3) {
  2464.         Economy.access$5(player, Economy.COMMAND +
  2465.           "Usage: /area add ['trade'|'personal'|'bank']");
  2466.         return;
  2467.       }
  2468.  
  2469.       if (Economy.this.numberOfAreas(player) >= Economy.MAX_AREAS) {
  2470.         Economy.access$5(player, Economy.ERROR + "Error - you cannot own more than " +
  2471.           Economy.MAX_AREAS + " areas.");
  2472.         return;
  2473.       }
  2474.  
  2475.       if ((!split[2].equalsIgnoreCase("trade")) &&
  2476.         (!split[2].equalsIgnoreCase("personal")) &&
  2477.         (!split[2].equalsIgnoreCase("bank"))) {
  2478.         Economy.access$5(player, Economy.COMMAND +
  2479.           "Usage: /area add ['trade'|'personal'|'bank']");
  2480.         return;
  2481.       }
  2482.  
  2483.       if (Economy.this.pendingTradeAreas.containsKey(name)) {
  2484.         Economy.this.pendingTradeAreas.remove(name);
  2485.         if (split[2].equalsIgnoreCase("trade")) {
  2486.           Economy.access$5(player, Economy.INFO +
  2487.             "No longer defining trading areas.");
  2488.           return;
  2489.         }if (split[2].equalsIgnoreCase("personal")) {
  2490.           Economy.access$5(player, Economy.INFO + "Now defining personal areas.");
  2491.           Economy.this.pendingPersonalAreas.put(name,
  2492.             new ArrayList());
  2493.         } else if (split[2].equalsIgnoreCase("bank")) {
  2494.           Economy.access$5(player, Economy.INFO + "Now defining banking areas.");
  2495.           Economy.this.pendingBankAreas.put(name,
  2496.             new ArrayList());
  2497.         }
  2498.       } else if (Economy.this.pendingPersonalAreas.containsKey(name)) {
  2499.         Economy.this.pendingPersonalAreas.remove(name);
  2500.         if (split[2].equalsIgnoreCase("trade")) {
  2501.           Economy.access$5(player, Economy.INFO + "Now defining trading areas.");
  2502.           Economy.this.pendingTradeAreas.put(name,
  2503.             new ArrayList()); } else {
  2504.           if (split[2].equalsIgnoreCase("personal")) {
  2505.             Economy.access$5(player, Economy.INFO +
  2506.               "No longer defining personal areas.");
  2507.             return;
  2508.           }if (split[2].equalsIgnoreCase("bank")) {
  2509.             Economy.access$5(player, Economy.INFO + "Now defining banking areas.");
  2510.             Economy.this.pendingBankAreas.put(name,
  2511.               new ArrayList());
  2512.           }
  2513.         }
  2514.       } else if (Economy.this.pendingBankAreas.containsKey(name)) {
  2515.         Economy.this.pendingBankAreas.remove(name);
  2516.         if (split[2].equalsIgnoreCase("trade")) {
  2517.           Economy.access$5(player, Economy.INFO + "Now defining trading areas.");
  2518.           Economy.this.pendingTradeAreas.put(name,
  2519.             new ArrayList());
  2520.         } else if (split[2].equalsIgnoreCase("personal")) {
  2521.           Economy.access$5(player, Economy.INFO + "Now defining personal areas.");
  2522.           Economy.this.pendingPersonalAreas.put(name,
  2523.             new ArrayList());
  2524.         } else if (split[2].equalsIgnoreCase("bank")) {
  2525.           Economy.access$5(player, Economy.INFO +
  2526.             "No longer defining banking areas.");
  2527.           return;
  2528.         }
  2529.       }
  2530.       else if (split[2].equalsIgnoreCase("trade")) {
  2531.         Economy.this.pendingTradeAreas.put(name,
  2532.           new ArrayList());
  2533.         Economy.access$5(player, Economy.INFO + "Now defining trading areas.");
  2534.       } else if (split[2].equalsIgnoreCase("personal")) {
  2535.         Economy.this.pendingPersonalAreas.put(name,
  2536.           new ArrayList());
  2537.         Economy.access$5(player, Economy.INFO + "Now defining personal areas.");
  2538.       } else if (split[2].equalsIgnoreCase("bank")) {
  2539.         Economy.this.pendingBankAreas.put(name,
  2540.           new ArrayList());
  2541.         Economy.access$5(player, Economy.INFO + "Now defining banking areas.");
  2542.       }
  2543.  
  2544.       Economy.access$5(
  2545.         player,
  2546.         Economy.INFO +
  2547.         "Right click one corner of the area with nothing in your hands.");
  2548.     }
  2549.  
  2550.     private void balance(Player player, String[] split)
  2551.     {
  2552.       if (!player.canUseCommand("/money")) {
  2553.         return;
  2554.       }
  2555.  
  2556.       if ((split.length > 2) && (player.isAdmin())) {
  2557.         String other = split[2].toLowerCase();
  2558.         if (other.equals("public"))
  2559.           Economy.access$5(player, Economy.INFO + "The public fund is at " + Economy.MONEY +
  2560.             Economy.this.format(Economy.this.publicFund) + Economy.INFO + ".");
  2561.         else if (!Economy.this.balances.containsKey(other))
  2562.           Economy.access$5(player, Economy.ERROR + "Error - could not find " +
  2563.             other + ".");
  2564.         else {
  2565.           Economy.access$5(player, (Economy.access$12(other) ? Economy.ONLINE : Economy.OFFLINE) +
  2566.             other + "'s" + Economy.INFO + " current balance is " +
  2567.             Economy.MONEY + Economy.this.format(Economy.access$17(Economy.this, other)) +
  2568.             Economy.INFO + ".");
  2569.         }
  2570.         return;
  2571.       }
  2572.  
  2573.       Economy.access$5(player, Economy.INFO + "Your current balance is " + Economy.MONEY +
  2574.         Economy.this.format(Economy.access$17(Economy.this, player.getName())) + Economy.INFO +
  2575.         ".");
  2576.     }
  2577.  
  2578.     private void pay(Player player, String[] split)
  2579.     {
  2580.       if (!player.canUseCommand("/money")) {
  2581.         return;
  2582.       }
  2583.  
  2584.       if (split.length < 4) {
  2585.         Economy.access$5(player, Economy.COMMAND +
  2586.           "Usage: /money pay <player> <amount> [message]");
  2587.         return;
  2588.       }
  2589.  
  2590.       String payTo = split[2].toLowerCase();
  2591.       if ((!Economy.access$12(payTo)) && (!Economy.this.balances.containsKey(payTo))) {
  2592.         Economy.access$5(player, Economy.INFO + "Could not find " + payTo + ".");
  2593.         return;
  2594.       }
  2595.  
  2596.       try
  2597.       {
  2598.         double paymentAmount = Double.parseDouble(split[3]);
  2599.         paymentAmount = Math.round(paymentAmount * 100.0D) / 100.0D;
  2600.       } catch (Exception e) {
  2601.         Economy.access$5(player, Economy.ERROR +
  2602.           "Error - must specify a valid number.");
  2603.         return;
  2604.       }
  2605.       double paymentAmount;
  2606.       if (paymentAmount <= 0.0D) {
  2607.         Economy.access$5(player, Economy.ERROR +
  2608.           "Error - payment amount must positive.");
  2609.         return;
  2610.       }
  2611.  
  2612.       double balance = Economy.this.getBalance(player.getName());
  2613.       if (paymentAmount > balance) {
  2614.         Economy.access$5(player, Economy.ERROR + "Error - insufficient funds.");
  2615.         Economy.access$5(player, Economy.INFO + "Your current balance is " + Economy.MONEY +
  2616.           Economy.this.format(balance) + Economy.INFO + ".");
  2617.         return;
  2618.       }
  2619.  
  2620.       StringBuilder message = null;
  2621.       if (split.length > 4) {
  2622.         message = new StringBuilder();
  2623.         for (int index = 4; index < split.length; index++) {
  2624.           message.append(split[index]);
  2625.           if (index < split.length - 1) {
  2626.             message.append(' ');
  2627.           }
  2628.         }
  2629.       }
  2630.  
  2631.       Economy.this.addToBalance(player.getName(), -paymentAmount);
  2632.       Economy.this.addToBalance(payTo, paymentAmount);
  2633.  
  2634.       Economy.access$5(player, Economy.INFO + "Payment sent.");
  2635.       Player otherPlayer = etc.getServer().getPlayer(payTo);
  2636.       if (otherPlayer != null) {
  2637.         Economy.access$5(otherPlayer, Economy.ONLINE + player.getName() + Economy.INFO +
  2638.           " has sent you " + Economy.MONEY + Economy.this.format(paymentAmount) +
  2639.           Economy.INFO + ".");
  2640.         Economy.access$5(otherPlayer, Economy.INFO +
  2641.           "Your balance has increased to " + Economy.MONEY +
  2642.           Economy.this.format(Economy.access$17(Economy.this, payTo)) + Economy.INFO + ".");
  2643.         if (message != null)
  2644.           Economy.access$5(otherPlayer, Economy.ONLINE + player.getName() + Economy.INFO +
  2645.             " says " + message.toString());
  2646.       }
  2647.     }
  2648.  
  2649.     private void offer(Player player, String[] split)
  2650.     {
  2651.       if (!player.canUseCommand("/offer")) {
  2652.         return;
  2653.       }
  2654.  
  2655.       if (split.length < 5) {
  2656.         Economy.access$5(
  2657.           player,
  2658.           Economy.COMMAND +
  2659.           "Usage: /offer add <itemName> <amount|'all'> <unitPrice>");
  2660.         return;
  2661.       }
  2662.  
  2663.       if (!Economy.this.canTrade(player)) {
  2664.         Economy.access$5(
  2665.           player,
  2666.           Economy.ERROR +
  2667.           "Error - cannot trade here. Please locate a trading area.");
  2668.         if (player.canUseCommand("/area")) {
  2669.           Economy.access$5(player, Economy.INFO +
  2670.             "Try using the \"/area list\" command.");
  2671.         }
  2672.         return;
  2673.       }
  2674.  
  2675.       if (((ArrayList)Economy.this.sellingOffers.get(player.getName().toLowerCase()))
  2676.         .size() >= Economy.MAX_OFFERS) {
  2677.         Economy.access$5(player, Economy.ERROR + "Error - you can't have more than " +
  2678.           Economy.INFO + Economy.MAX_OFFERS + Economy.ERROR + " offers at once.");
  2679.         return;
  2680.       }
  2681.  
  2682.       int id = Economy.access$0(split[2]);
  2683.       if (id == -1) {
  2684.         Economy.access$5(player, Economy.ERROR + "Error - could not find id for " +
  2685.           split[2] + ".");
  2686.         return;
  2687.       }
  2688.  
  2689.       boolean offerAll = false;
  2690.       int amount = 0;
  2691.       try {
  2692.         amount = Integer.parseInt(split[3]);
  2693.       } catch (Exception e) {
  2694.         if (!split[3].equalsIgnoreCase("all")) {
  2695.           Economy.access$5(player, Economy.ERROR +
  2696.             "Error - amount must be a valid number.");
  2697.           return;
  2698.         }
  2699.         offerAll = true;
  2700.       }
  2701.  
  2702.       Inventory inventory = player.getInventory();
  2703.       hn[] inventoryArray = inventory.getArray();
  2704.  
  2705.       int totalAmount = 0;
  2706.       for (int index = 0; index < inventoryArray.length; index++) {
  2707.         if (inventoryArray[index] == null) {
  2708.           continue;
  2709.         }
  2710.         if (inventoryArray[index].c == id) {
  2711.           totalAmount += inventoryArray[index].a;
  2712.         }
  2713.       }
  2714.  
  2715.       if (offerAll) {
  2716.         amount = totalAmount;
  2717.       }
  2718.  
  2719.       if (amount <= 0) {
  2720.         if (offerAll) {
  2721.           Economy.access$5(player, Economy.ERROR + "Error - you do not have any " +
  2722.             split[2].toLowerCase() + ".");
  2723.           return;
  2724.         }
  2725.         Economy.access$5(player, Economy.ERROR + "Error - amount must be positive.");
  2726.         return;
  2727.       }
  2728.  
  2729.       if (totalAmount < amount) {
  2730.         Economy.access$5(player, Economy.ERROR + "Error - you do not have enough " +
  2731.           split[2].toLowerCase() + ".");
  2732.         return;
  2733.       }
  2734.  
  2735.       try
  2736.       {
  2737.         double unitPrice = Double.parseDouble(split[4]);
  2738.         unitPrice = Math.round(unitPrice * 100.0D) / 100.0D;
  2739.       } catch (Exception e) {
  2740.         Economy.access$5(player, Economy.ERROR +
  2741.           "Error - unit price must be a valid number.");
  2742.         return;
  2743.       }
  2744.       double unitPrice;
  2745.       if (unitPrice <= 0.0D) {
  2746.         Economy.access$5(player, Economy.ERROR +
  2747.           "Error - unit price must be positive.");
  2748.         return;
  2749.       }
  2750.  
  2751.       int tempAmount = amount;
  2752.  
  2753.       for (int index = 0; (index < inventoryArray.length) && (tempAmount > 0); index++) {
  2754.         if (inventoryArray[index] == null) {
  2755.           continue;
  2756.         }
  2757.         if (inventoryArray[index].c != id) {
  2758.           continue;
  2759.         }
  2760.         if (inventoryArray[index].a == 64) {
  2761.           continue;
  2762.         }
  2763.         int amountToRemove = Math.min(inventoryArray[index].a,
  2764.           tempAmount);
  2765.         tempAmount -= amountToRemove;
  2766.         inventoryArray[index].a -= amountToRemove;
  2767.         if (inventoryArray[index].a <= 0) {
  2768.           inventoryArray[index] = null;
  2769.         }
  2770.  
  2771.       }
  2772.  
  2773.       for (int index = 0; (index < inventoryArray.length) && (tempAmount > 0); index++) {
  2774.         if (inventoryArray[index] == null) {
  2775.           continue;
  2776.         }
  2777.         if (inventoryArray[index].c != id) {
  2778.           continue;
  2779.         }
  2780.         int amountToRemove = Math.min(inventoryArray[index].a,
  2781.           tempAmount);
  2782.         tempAmount -= amountToRemove;
  2783.         inventoryArray[index].a -= amountToRemove;
  2784.         if (inventoryArray[index].a <= 0) {
  2785.           inventoryArray[index] = null;
  2786.         }
  2787.       }
  2788.  
  2789.       player.getInventory().updateInventory();
  2790.  
  2791.       ArrayList currentOffers =
  2792.         (ArrayList)Economy.this.sellingOffers
  2793.         .get(player.getName().toLowerCase());
  2794.       if (currentOffers != null) {
  2795.         for (Economy.Offer offer : currentOffers) {
  2796.           if ((Economy.Offer.access$0(offer) == id) && (Economy.Offer.access$1(offer) == unitPrice))
  2797.           {
  2798.             Economy.Offer tmp903_901 = offer; Economy.Offer.access$3(tmp903_901, Economy.Offer.access$2(tmp903_901) + amount);
  2799.             Economy.access$5(player, Economy.INFO +
  2800.               "Your offer has been combined with offer id " +
  2801.               Economy.Offer.access$4(offer) + ".");
  2802.             return;
  2803.           }
  2804.         }
  2805.       }
  2806.  
  2807.       Economy.Offer offer = new Economy.Offer(Economy.this, player.getName().toLowerCase(), id, amount,
  2808.         unitPrice);
  2809.       Economy.this.addOffer(player.getName().toLowerCase(), offer);
  2810.  
  2811.       Economy.access$5(player, Economy.INFO +
  2812.         "Your offer has been placed. Your offer id is " +
  2813.         Economy.Offer.access$4(offer) + ".");
  2814.       HashSet listeners = (HashSet)Economy.this.offerListeners.get(Integer.valueOf(id));
  2815.       if (listeners == null) {
  2816.         return;
  2817.       }
  2818.       for (String playerName : listeners) {
  2819.         if (playerName.equalsIgnoreCase(player.getName())) {
  2820.           continue;
  2821.         }
  2822.         Player listener = etc.getServer().getPlayer(playerName);
  2823.         if (listener == null) {
  2824.           continue;
  2825.         }
  2826.         Economy.access$5(listener, Economy.INFO + player.getName() +
  2827.           " has put up an offer for " + amount + " " +
  2828.           Economy.access$26(id) + ".");
  2829.       }
  2830.     }
  2831.  
  2832.     private void buy(Player player, String[] split)
  2833.     {
  2834.       if (!player.canUseCommand("/buy")) {
  2835.         return;
  2836.       }
  2837.  
  2838.       if (split.length < 4) {
  2839.         Economy.access$5(player, Economy.COMMAND +
  2840.           "Usage: /buy <itemName> <amount> <unitPrice>");
  2841.         return;
  2842.       }
  2843.  
  2844.       if (!Economy.this.canTrade(player)) {
  2845.         Economy.access$5(
  2846.           player,
  2847.           Economy.ERROR +
  2848.           "Error - cannot trade here. Please locate a trading area.");
  2849.         if (player.canUseCommand("/area")) {
  2850.           Economy.access$5(player, Economy.INFO +
  2851.             "Try using the \"/area list\" command.");
  2852.         }
  2853.         return;
  2854.       }
  2855.  
  2856.       int id = Economy.access$0(split[1]);
  2857.       if (id == -1) {
  2858.         Economy.access$5(player, Economy.ERROR + "Error - could not find id for " +
  2859.           split[1] + ".");
  2860.         return;
  2861.       }
  2862.  
  2863.       try
  2864.       {
  2865.         buyingAmount = Integer.parseInt(split[2]);
  2866.       }
  2867.       catch (Exception e)
  2868.       {
  2869.         int buyingAmount;
  2870.         Economy.access$5(player, Economy.ERROR +
  2871.           "Error - amount must be a valid number.");
  2872.         return;
  2873.       }
  2874.       int buyingAmount;
  2875.       if (buyingAmount <= 0) {
  2876.         Economy.access$5(player, Economy.ERROR +
  2877.           "Error - amount must be a positive number.");
  2878.         return;
  2879.       }
  2880.  
  2881.       Inventory inventory = player.getInventory();
  2882.       hn[] array = inventory.getArray();
  2883.       int canHold = 0;
  2884.       for (int index = 0; index < array.length; index++) {
  2885.         if (array[index] == null) {
  2886.           canHold += 64;
  2887.         }
  2888.         else {
  2889.           if (array[index].c != id) {
  2890.             continue;
  2891.           }
  2892.           canHold += 64 - array[index].a;
  2893.         }
  2894.       }
  2895.       if (buyingAmount > canHold) {
  2896.         if (canHold == 0) {
  2897.           Economy.access$5(player, Economy.ERROR + "Error - you can't hold any " +
  2898.             split[1].toLowerCase() + ".");
  2899.         } else {
  2900.           Economy.access$5(player, Economy.ERROR + "Error - you can't hold " +
  2901.             buyingAmount + " " + split[1].toLowerCase() + ".");
  2902.           Economy.access$5(player, Economy.ERROR + "You can only hold " + canHold +
  2903.             " " + split[1].toLowerCase() + ".");
  2904.         }
  2905.         return;
  2906.       }
  2907.  
  2908.       try
  2909.       {
  2910.         double unitPrice = Double.parseDouble(split[3]);
  2911.         unitPrice = Math.round(unitPrice * 100.0D) / 100.0D;
  2912.       } catch (Exception e) {
  2913.         Economy.access$5(player, Economy.ERROR +
  2914.           "Error - unit price must be a valid number.");
  2915.         return;
  2916.       }
  2917.       double unitPrice;
  2918.       if (unitPrice <= 0.0D) {
  2919.         Economy.access$5(player, Economy.ERROR +
  2920.           "Error - unit price must be a positive number.");
  2921.         return;
  2922.       }
  2923.  
  2924.       double totalMoney = buyingAmount * unitPrice;
  2925.  
  2926.       if (Economy.this.getBalance(player.getName()) < unitPrice) {
  2927.         Economy.access$5(player, Economy.ERROR + "Error - insufficient funds.");
  2928.         Economy.access$5(player, Economy.INFO + "Your current balance is " + Economy.MONEY +
  2929.           Economy.this.format(Economy.access$17(Economy.this, player.getName())) +
  2930.           Economy.INFO + ".");
  2931.         return;
  2932.       }
  2933.  
  2934.       if (Economy.this.getBalance(player.getName()) < totalMoney) {
  2935.         Economy.access$5(player, Economy.ERROR + "Warning - can't buy " +
  2936.           buyingAmount + " " + split[1].toLowerCase() + ".");
  2937.         buyingAmount = (int)(Economy.this.getBalance(player.getName()) / unitPrice);
  2938.         Economy.access$5(player, Economy.ERROR + "You will only buy up to " +
  2939.           buyingAmount + " " + split[1].toLowerCase() + ".");
  2940.       }
  2941.  
  2942.       while (buyingAmount > 0) {
  2943.         Economy.Offer bestOffer = null;
  2944.         int mostItems = -1;
  2945.         double bestPrice = 1.7976931348623157E+308D;
  2946.  
  2947.         Iterator iterator = Economy.this.offerIterator();
  2948.         while (iterator.hasNext()) {
  2949.           Economy.Offer offer = (Economy.Offer)iterator.next();
  2950.           if ((Economy.Offer.access$0(offer) != id) ||
  2951.             (Economy.Offer.access$5(offer).equalsIgnoreCase(player.getName())) ||
  2952.             (Economy.Offer.access$1(offer) > unitPrice))
  2953.           {
  2954.             continue;
  2955.           }
  2956.  
  2957.           int canBuy = Math.min(
  2958.             (int)(totalMoney / Economy.Offer.access$1(offer)),
  2959.             buyingAmount);
  2960.           if (canBuy <= 0) {
  2961.             continue;
  2962.           }
  2963.           double price = canBuy * Economy.Offer.access$1(offer);
  2964.  
  2965.           if (canBuy > mostItems) {
  2966.             mostItems = canBuy;
  2967.             bestOffer = offer;
  2968.             bestPrice = price;
  2969.           } else if ((canBuy == mostItems) && (price < bestPrice)) {
  2970.             bestOffer = offer;
  2971.             bestPrice = price;
  2972.           }
  2973.  
  2974.         }
  2975.  
  2976.         if (bestOffer == null) {
  2977.           Economy.access$5(player, Economy.INFO +
  2978.             "Could not find a player selling " + Economy.access$26(id) +
  2979.             ".");
  2980.           Economy.access$5(player, Economy.INFO + "Could not buy " + buyingAmount +
  2981.             " " + Economy.access$26(id) + ".");
  2982.           return;
  2983.         }
  2984.  
  2985.         int sellingAmount = Math.min(mostItems, Economy.Offer.access$2(bestOffer));
  2986.         double sellingPrice = sellingAmount * Economy.Offer.access$1(bestOffer);
  2987.         Economy.this.addToBalance(player.getName(), -sellingPrice);
  2988.         totalMoney -= sellingPrice;
  2989.         Economy.this.addToBalance(Economy.Offer.access$5(bestOffer), sellingPrice);
  2990.         player.getInventory().giveItem(id, sellingAmount);
  2991.         player.getInventory().updateInventory();
  2992.         Economy.access$5(player, Economy.INFO + "You bought " + sellingAmount + " " +
  2993.           Economy.access$26(id) + " from " + (
  2994.           Economy.access$12(Economy.Offer.access$5(bestOffer)) ? Economy.ONLINE : Economy.OFFLINE) +
  2995.           Economy.Offer.access$5(bestOffer) + Economy.INFO + " for " + Economy.MONEY +
  2996.           Economy.this.format(sellingPrice) + Economy.INFO + ".");
  2997.         Player seller = etc.getServer().getPlayer(Economy.Offer.access$5(bestOffer));
  2998.         if (seller != null) {
  2999.           Economy.access$5(seller, Economy.ONLINE + player.getName() + Economy.INFO +
  3000.             " bought " + sellingAmount + " " + Economy.access$26(id) +
  3001.             " for " + Economy.MONEY + Economy.this.format(sellingPrice) + ".");
  3002.           Economy.access$5(seller, Economy.INFO + "Your balance has increased to " +
  3003.             Economy.MONEY +
  3004.             Economy.this.format(Economy.access$17(Economy.this, Economy.Offer.access$5(bestOffer))) +
  3005.             Economy.INFO + ".");
  3006.         }
  3007.         buyingAmount -= sellingAmount;
  3008.         Economy.Offer tmp1449_1447 = bestOffer; Economy.Offer.access$3(tmp1449_1447, Economy.Offer.access$2(tmp1449_1447) - sellingAmount);
  3009.  
  3010.         if (Economy.Offer.access$2(bestOffer) <= 0) {
  3011.           Economy.this.removeOffer(bestOffer);
  3012.         }
  3013.  
  3014.         HashSet listeners =
  3015.           (HashSet)Economy.this.offerListeners
  3016.           .get(Integer.valueOf(Economy.Offer.access$0(bestOffer)));
  3017.         if (listeners == null) {
  3018.           continue;
  3019.         }
  3020.         for (String playerName : listeners) {
  3021.           if ((playerName.equalsIgnoreCase(player.getName())) ||
  3022.             (playerName.equalsIgnoreCase(Economy.Offer.access$5(bestOffer)))) {
  3023.             continue;
  3024.           }
  3025.           Player listener = etc.getServer().getPlayer(playerName);
  3026.           if (listener == null) {
  3027.             continue;
  3028.           }
  3029.           if (Economy.Offer.access$2(bestOffer) <= 0)
  3030.             Economy.access$5(listener,
  3031.               (Economy.access$12(Economy.Offer.access$5(bestOffer)) ? Economy.ONLINE : Economy.OFFLINE) +
  3032.               Economy.Offer.access$5(bestOffer) + "'s" + Economy.INFO +
  3033.               " offer for " + sellingAmount + " " +
  3034.               Economy.access$26(Economy.Offer.access$0(bestOffer)) +
  3035.               " has been bought.");
  3036.           else {
  3037.             Economy.access$5(listener,
  3038.               (Economy.access$12(Economy.Offer.access$5(bestOffer)) ? Economy.ONLINE : Economy.OFFLINE) +
  3039.               Economy.Offer.access$5(bestOffer) + "'s" + Economy.INFO +
  3040.               " offer for " + (
  3041.               sellingAmount + Economy.Offer.access$2(bestOffer)) +
  3042.               " " + Economy.access$26(Economy.Offer.access$0(bestOffer)) +
  3043.               " has " + Economy.Offer.access$2(bestOffer) +
  3044.               " remaining.");
  3045.           }
  3046.         }
  3047.       }
  3048.       Economy.access$5(player, Economy.INFO + "Your balance has decreased to " + Economy.MONEY +
  3049.         Economy.this.format(Economy.access$17(Economy.this, player.getName())) + Economy.INFO +
  3050.         ".");
  3051.     }
  3052.  
  3053.     private void listOffers(Player player, String[] split)
  3054.     {
  3055.       if (!player.canUseCommand("/offer")) {
  3056.         return;
  3057.       }
  3058.  
  3059.       if (!Economy.this.hasOffers()) {
  3060.         Economy.access$5(player, Economy.INFO + "No current offers.");
  3061.         if (player.canUseCommand("/offer")) {
  3062.           Economy.access$5(
  3063.             player,
  3064.             Economy.INFO +
  3065.             "Try selling things with the \"/offer add\" command.");
  3066.         }
  3067.         return;
  3068.       }
  3069.       Economy.Condition displayCondition;
  3070.       Economy.Condition displayCondition;
  3071.       if (split.length > 2) {
  3072.         if (split[2].equals("?")) {
  3073.           Economy.access$5(player, Economy.COMMAND +
  3074.             "Usage: /offer list [playerName]");
  3075.           return;
  3076.         }
  3077.         ArrayList offers =
  3078.           (ArrayList)Economy.this.sellingOffers
  3079.           .get(split[2].toLowerCase());
  3080.         if ((offers == null) || (offers.size() == 0)) {
  3081.           Economy.access$5(player, (Economy.access$12(split[2]) ? Economy.ONLINE : Economy.OFFLINE) +
  3082.             split[2].toLowerCase() + Economy.INFO +
  3083.             " currently has no offers.");
  3084.           return;
  3085.         }
  3086.  
  3087.         displayCondition = new Economy.Condition(Economy.this, split)
  3088.         {
  3089.           boolean isValid(Economy.Offer offer) {
  3090.             return Economy.Offer.access$5(offer).equalsIgnoreCase(this.val$split[2]);
  3091.           } } ;
  3092.       } else {
  3093.         displayCondition = new Economy.Condition(Economy.this)
  3094.         {
  3095.           boolean isValid(Economy.Offer offer) {
  3096.             return true;
  3097.           }
  3098.         };
  3099.       }
  3100.       Economy.access$5(player, Economy.INFO + "Current offers: ");
  3101.       Iterator playerOfferIterator = Economy.this.sellingOffers
  3102.         .entrySet().iterator();
  3103.       while (playerOfferIterator.hasNext()) {
  3104.         Map.Entry currentPlayerOffers =
  3105.           (Map.Entry)playerOfferIterator
  3106.           .next();
  3107.         String sellerName = (String)currentPlayerOffers.getKey();
  3108.         ArrayList offers = (ArrayList)currentPlayerOffers.getValue();
  3109.         if (offers.size() == 0)
  3110.         {
  3111.           continue;
  3112.         }
  3113.         StringBuilder condensedOffers = new StringBuilder();
  3114.         condensedOffers.append(Economy.OFFER_COLOR);
  3115.         Iterator offerIterator = offers.iterator();
  3116.         boolean hasOffers = false;
  3117.         while (offerIterator.hasNext()) {
  3118.           Economy.Offer offer = (Economy.Offer)offerIterator.next();
  3119.           if (!displayCondition.isValid(offer)) {
  3120.             continue;
  3121.           }
  3122.           hasOffers = true;
  3123.           condensedOffers.append(offer.toString());
  3124.           if ((player.getName().equalsIgnoreCase(Economy.Offer.access$5(offer))) ||
  3125.             (player.isAdmin())) {
  3126.             condensedOffers.append("[");
  3127.             condensedOffers.append(Economy.Offer.access$4(offer));
  3128.             condensedOffers.append("]");
  3129.           }
  3130.           if (offerIterator.hasNext()) {
  3131.             condensedOffers.append(" ");
  3132.           }
  3133.         }
  3134.         if (hasOffers) {
  3135.           StringBuilder playerName = new StringBuilder();
  3136.           playerName.append(Economy.access$12(sellerName) ? Economy.ONLINE : Economy.OFFLINE);
  3137.           playerName.append(sellerName);
  3138.  
  3139.           Player seller = etc.getServer().getPlayer(sellerName);
  3140.           if (seller != null) {
  3141.             Economy.Area sellerArea = Economy.this.getArea(seller);
  3142.             if ((sellerArea != null) &&
  3143.               ((sellerArea instanceof Economy.TradeArea)) &&
  3144.               (!sellerArea.areaName.equals(""))) {
  3145.               playerName.append(Economy.TRADE_AREA_COLOR);
  3146.               playerName.append(" (");
  3147.               playerName.append(sellerArea.areaName);
  3148.               playerName.append(")");
  3149.             }
  3150.           }
  3151.  
  3152.           playerName.append(Economy.OFFER_COLOR);
  3153.           playerName.append(": ");
  3154.           Economy.access$5(player, playerName.toString() +
  3155.             condensedOffers.toString());
  3156.         }
  3157.       }
  3158.     }
  3159.  
  3160.     private void removeOffer(Player player, String[] split)
  3161.     {
  3162.       if (!player.canUseCommand("/offer")) {
  3163.         return;
  3164.       }
  3165.  
  3166.       if (split.length < 3) {
  3167.         Economy.access$5(player, Economy.COMMAND +
  3168.           "Usage: /offer remove [offerId|'all']");
  3169.         return;
  3170.       }
  3171.  
  3172.       int offerId = -1;
  3173.       boolean removeAll = false;
  3174.       try {
  3175.         offerId = Integer.parseInt(split[2]);
  3176.       } catch (Exception e) {
  3177.         if (!split[2].equalsIgnoreCase("all")) {
  3178.           Economy.access$5(player, Economy.ERROR +
  3179.             "Error - offer id must be a valid number.");
  3180.           return;
  3181.         }
  3182.         removeAll = true;
  3183.       }
  3184.       ArrayList currentOffers =
  3185.         (ArrayList)Economy.this.sellingOffers
  3186.         .get(player.getName().toLowerCase());
  3187.       if ((currentOffers == null) || (currentOffers.size() == 0)) {
  3188.         Economy.access$5(player, Economy.ERROR +
  3189.           "Error - you currently have no offers.");
  3190.         return;
  3191.       }
  3192.  
  3193.       Iterator offerIterator = currentOffers.iterator();
  3194.       while (offerIterator.hasNext()) {
  3195.         Economy.Offer offer = (Economy.Offer)offerIterator.next();
  3196.         if ((Economy.Offer.access$4(offer) == offerId) || (removeAll)) {
  3197.           int remaining = Economy.this.givePlayer(player,
  3198.             Economy.Offer.access$0(offer), Economy.Offer.access$2(offer));
  3199.           if (remaining != 0) {
  3200.             Economy.access$5(player, Economy.ERROR +
  3201.               "Error - please make room in your inventory.");
  3202.             Economy.access$5(player, Economy.ERROR +
  3203.               "Could not remove all of offer id " +
  3204.               Economy.Offer.access$4(offer));
  3205.             notifyOfRemove(offer, remaining);
  3206.             Economy.Offer.access$3(offer, remaining);
  3207.             return;
  3208.           }
  3209.           offerIterator.remove();
  3210.           Economy.this.allOffers.remove(offer);
  3211.           if (!removeAll) {
  3212.             Economy.access$5(player, Economy.INFO +
  3213.               "Offer successfully removed.");
  3214.             return;
  3215.           }
  3216.           notifyOfRemove(offer, 0);
  3217.         }
  3218.       }
  3219.  
  3220.       if (removeAll) {
  3221.         Economy.access$5(player, Economy.INFO + "All offers removed.");
  3222.         return;
  3223.       }
  3224.  
  3225.       Economy.access$5(player, Economy.ERROR + "Error - could not find offer id " +
  3226.         offerId);
  3227.     }
  3228.  
  3229.     private final void notifyOfRemove(Economy.Offer offer, int remaining)
  3230.     {
  3231.       HashSet listeners =
  3232.         (HashSet)Economy.this.offerListeners
  3233.         .get(Integer.valueOf(Economy.Offer.access$0(offer)));
  3234.       if (listeners == null) {
  3235.         return;
  3236.       }
  3237.       for (String playerName : listeners) {
  3238.         if (playerName.equalsIgnoreCase(Economy.Offer.access$5(offer))) {
  3239.           continue;
  3240.         }
  3241.         Player listener = etc.getServer().getPlayer(playerName);
  3242.         if (listener == null) {
  3243.           continue;
  3244.         }
  3245.         if (remaining <= 0)
  3246.           Economy.access$5(listener, (Economy.access$12(Economy.Offer.access$5(offer)) ? Economy.ONLINE :
  3247.             Economy.OFFLINE) +
  3248.             Economy.Offer.access$5(offer) +
  3249.             "'s" +
  3250.             Economy.INFO +
  3251.             " offer for " +
  3252.             Economy.Offer.access$2(offer) +
  3253.             " " +
  3254.             Economy.access$26(Economy.Offer.access$0(offer)) +
  3255.             " has been removed.");
  3256.         else
  3257.           Economy.access$5(listener, (Economy.access$12(Economy.Offer.access$5(offer)) ? Economy.ONLINE :
  3258.             Economy.OFFLINE) +
  3259.             Economy.Offer.access$5(offer) +
  3260.             "'s" +
  3261.             Economy.INFO +
  3262.             " offer for " +
  3263.             Economy.Offer.access$2(offer) +
  3264.             " " +
  3265.             Economy.access$26(Economy.Offer.access$0(offer)) +
  3266.             " has " + remaining + " remaining.");
  3267.       }
  3268.     }
  3269.   }
  3270.  
  3271.   private final class Offer
  3272.     implements Serializable
  3273.   {
  3274.     private static final long serialVersionUID = 1L;
  3275.     private String player;
  3276.     private final int itemId;
  3277.     private final double unitPrice;
  3278.     private int amount;
  3279.     private final int offerId;
  3280.  
  3281.     public Offer(String player, int id, int amount, double unitPrice)
  3282.     {
  3283.       this.player = player;
  3284.       this.itemId = id;
  3285.       this.amount = amount;
  3286.       this.unitPrice = unitPrice;
  3287.       this.offerId = (Economy.offerCount++);
  3288.       if (Economy.offerCount < 0)
  3289.         Economy.logger.log(Level.WARNING,
  3290.           "Offer id count has overflowed.");
  3291.     }
  3292.  
  3293.     public boolean equals(Object other)
  3294.     {
  3295.       if (!(other instanceof Offer)) {
  3296.         return false;
  3297.       }
  3298.       Offer otherOffer = (Offer)other;
  3299.       return this.offerId == otherOffer.offerId;
  3300.     }
  3301.  
  3302.     public String toString()
  3303.     {
  3304.       StringBuilder result = new StringBuilder();
  3305.       result.append("(");
  3306.       result.append(this.amount);
  3307.       result.append(Economy.access$26(this.itemId));
  3308.       result.append(",");
  3309.       result.append(Economy.MONEY);
  3310.       result.append(Economy.this.format(this.unitPrice));
  3311.       result.append(Economy.OFFER_COLOR);
  3312.       result.append(")");
  3313.       return result.toString();
  3314.     }
  3315.   }
  3316.  
  3317.   private class PersonalArea extends Economy.Area
  3318.   {
  3319.     private static final long serialVersionUID = 1175775527803459405L;
  3320.  
  3321.     public PersonalArea(double minX, double maxX, double minY, double maxY, double minZ, double maxZ, String owner)
  3322.     {
  3323.       super(minX, maxX, minY, maxY, minZ, maxZ, owner);
  3324.     }
  3325.  
  3326.     public double price()
  3327.     {
  3328.       return Economy.PERSONAL_AREA_COST * super.price();
  3329.     }
  3330.   }
  3331.  
  3332.   private class TradeArea extends Economy.Area
  3333.   {
  3334.     private static final long serialVersionUID = 7906766924747483195L;
  3335.  
  3336.     public TradeArea(double minX, double maxX, double minY, double maxY, double minZ, double maxZ, String owner)
  3337.     {
  3338.       super(minX, maxX, minY, maxY, minZ, maxZ, owner);
  3339.     }
  3340.  
  3341.     public double price()
  3342.     {
  3343.       return Economy.TRADE_AREA_COST * super.price();
  3344.     }
  3345.   }
  3346. }
  3347.  
  3348. /* Location:           C:\Users\Juntalis\Downloads\Economy.jar
  3349.  * Qualified Name:     Economy
  3350.  * JD-Core Version:    0.6.0
  3351.  */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement