Ejemplo n.º 1
0
 public static void sendInfo(Player p, Item item) {
   String key = item.getItemId() + ":" + item.getDamage();
   p.sendMessage(WShop.PRE + key);
   p.sendMessage(WShop.PRE + "Price (sell): " + PRICES.getDouble(key + "_sell", -1));
   p.sendMessage(WShop.PRE + "Price (buy): " + PRICES.getDouble(key + "_buy", -1));
   p.sendMessage(WShop.PRE + "Amount: " + ITEMS.getInt(key, 0));
 }
Ejemplo n.º 2
0
 /**
  * @param p - The player buying an item.
  * @param item - The item the player wants to buy.
  */
 public static void buyItem(Player p, Item item) {
   String key = item.getItemId() + ":" + item.getDamage();
   int amount = ITEMS.getInt(key, 0);
   if (amount == -1) {
     p.sendMessage(WShop.PRE + "The server does not sell that item at this time.");
     return;
   }
   if (amount < item.getAmount()) {
     p.sendMessage(WShop.PRE + "The server does not have that much of " + key);
     return;
   } // end if
   double price = PRICES.getDouble(key + "_buy", -1);
   if (price == -1) {
     p.sendMessage(WShop.PRE + "The server does not sell that item at this time." + key);
     return;
   }
   if (canPay(p, price)) {
     payPlayer(p, -price); // Make sure we charge them here, not pay them. Negate the price.
     p.giveItem(item);
     ITEMS.setInt(key, amount - item.getAmount());
     p.sendMessage(
         WShop.PRE
             + "Bought an item. ID:"
             + item.getItemId()
             + ", Damage:"
             + item.getDamage()
             + ", Amount:"
             + item.getAmount()
             + ", Cost:"
             + price);
   } else {
     p.sendMessage(WShop.PRE + "You do not have enough money to buy " + key);
     return;
   }
 } // end buyItem
Ejemplo n.º 3
0
 /**
  * @param p - The player trying to sell.
  * @param item - The item to sell, commonly the players help item.
  */
 public static void sellItem(Player p, Item item) {
   String key = item.getItemId() + ":" + item.getDamage();
   double price = PRICES.getDouble(key + "_sell", -1);
   if (price == -1) {
     p.sendMessage(WShop.PRE + "The server does not buy that item at this time.");
     return;
   }
   int amount = ITEMS.getInt(key, 0);
   p.getInventory().removeItem(item);
   ITEMS.setInt(key, amount + item.getAmount());
   payPlayer(p, price);
   return;
 } // end sellItem
Ejemplo n.º 4
0
  private static void loadPropertiesFiles(File dataFolder) {
    // Use Configuration once it's finished.
    PropertiesFile pf = new PropertiesFile(new File(dataFolder, "watching.properties"));
    blockBreak = pf.getBoolean("blockBreak", true, "Watch when players break blocks");
    blockPlace = pf.getBoolean("blockPlace", true, "Watch when players place blocks");
    teleport = pf.getBoolean("teleport", true, "Watch when players teleport around");
    chestChanges =
        pf.getBoolean("chestChanges", true, "Watch when players add/remove items from chests");
    commands = pf.getBoolean("commands", true, "Watch for all player commands");
    chat = pf.getBoolean("chat", true, "Watch for player chat");
    login = pf.getBoolean("login", true, "Watch for player logins");
    disconnect = pf.getBoolean("disconnect", true, "Watch for player disconnects");
    doorOpen = pf.getBoolean("doorOpen", false, "Watch for when player opens doors");
    buttonPress = pf.getBoolean("buttonPress", false, "Watch for when player pushes buttons");
    leverSwitch = pf.getBoolean("leverSwitch", false, "Watch for when player switches levers");
    fire = pf.getBoolean("fireLogging", true, "Watch for when players start fires");
    leafDrops = pf.getBoolean("leafDrops", true, "Watch for when leaves drop");
    tntExplosions = pf.getBoolean("tntExplosions", true, "Watch for when TNT explodes");
    creeperExplosions =
        pf.getBoolean("creeperExplosions", true, "Watch for when Creepers explodes");
    miscExplosions = pf.getBoolean("miscExplosions", true, "Watch for miscellaneous explosions");
    ipPlayer = pf.getBoolean("ipPlayer", false, "Add player's IP when login");
    pf.save();

    pf = new PropertiesFile(new File(dataFolder, "BigBrother.properties"));
    freedMem = pf.getDouble("freedMem", 0.0, "The amount of memory freed by BB");
    stickItem = pf.getLong("stickItem", 280l, "The item used for /bb stick");
    restoreFire = pf.getBoolean("restoreFire", false, "Restore fire when rolling back");
    autoWatch = pf.getBoolean("autoWatch", true, "Automatically start watching players");
    defaultSearchRadius =
        pf.getInt("defaultSearchRadius", 2, "Default search radius for bbhere and bbfind");
    mysql = pf.getBoolean("MySQL", true, "If true, uses MySQL. If false, uses Sqlite");
    flatLog =
        pf.getBoolean(
            "flatFileLogs", false, "If true, will also log actions to .logs (one for each player)");
    mysqlUser = pf.getString("mysqlUser", "root", "Username for MySQL db (if applicable)");
    mysqlPass = pf.getString("mysqlPass", "root", "Password for MySQL db (if applicable)");
    mysqlDB =
        pf.getString(
            "mysqlDB", "jdbc:mysql://localhost:3306/minecraft", "DB for MySQL (if applicable)");
    BBDataBlock.BBDATA_TABLE_MYSQL =
        BBDataBlock.BBDATA_TABLE_MYSQL
            + " ENGINE="
            + pf.getString("engine", "INNODB", "Engine for the Database (INNODB is recommended)")
            + ";";

    sendDelay =
        pf.getInt("sendDelay", 4, "Delay to batch send updates to database (4-5 recommended)");
    pf.save();
  }