hey guys i have never tried to do this but i have made a gui with prices and stuff and the people might want to change the prices how i can do that ? for example i want in the gui to be an option to add in the config to add price but the gui seems like this with buying. Code (Text): case RABBIT_HIDE: Double clsay = econ.getBalance(player); if (clsay >= 15000.00){ econ.withdrawPlayer(player, 15000.00); player.sendMessage("You just bought....."); player.closeInventory(); player.playSound(player.getLocation(), Sound.NOTE_PLING, 3, 3); } }else{ if(econ.getBalance(player) < 15000.00){ player.closeInventory(); player.sendMessage("§cYou don't have enough money to afford it."); player.playSound(player.getLocation(), Sound.NOTE_BASS, 3, 4); } } break; but the thing is i want to add the 3 of them to be in gui to change the price by the config how i can add them to the config to change the money value? i just set them to the config with the same name? or i just leave the players to play with the current prices that this type of game has? 1. if (clsay >= 15000.00){ 2. econ.withdrawPlayer(player, 15000.00); 3. if(econ.getBalance(player) < 15000.00){ this is how it should look in the config. Code (Text): Slot[1]: Price: <===
For config you can create a default config like the plugin.yml but you rename config.yml and on your onEnable() Code (Text): c = getConfig(); c.options().copyDefaults(true); saveConfig(); after in the config.yml you can put like Code (Text): MONEY_ITEM: 150000 and to get value from the config Code (Text): Double reward = Double.valueOf(Main.c.getDouble("MONEY_ITEM")); EconomyResponse r = Main.r.econ.withdrawPlayer(Player.getName(), reward.doubleValue());
i also tried this one but it's not seems to be correct Code (Text): case WOOD_HOE: Double clsay = econ.getBalance(player, getConfig().getDouble("Slot1.Price") >= clsay); if (clsay >= clsay){ //buy stuff }else{ if(econ.getBalance(player) < clsay){ //send not money message. getBalance has red line thought and if i click it its just making it as like this econ.getBalance(player); than econ.getBalance(player, getConfig().getDouble("Slot1.Price") >= clsay); what about this: Code (Text): Double reward = Double.valueOf(this.getConfig().getDouble("MONEY_ITEM")); if (reward >= reward){ econ.withdrawPlayer(player, reward); player.closeInventory(); player.playSound(player.getLocation(), Sound.NOTE_PLING, 3, 3); } }else{ if(econ.getBalance(player) < reward){ player.closeInventory(); player.sendMessage("§cYou don't have enough money to afford it."); player.playSound(player.getLocation(), Sound.NOTE_BASS, 3, 4);
i think i solved it guys. Code (Text): Double bank = econ.getBalance(player); int price = this.getConfig().getInt("Price"); if (bank >= price){ econ.withdrawPlayer(player, price); player.closeInventory(); player.playSound(player.getLocation(), Sound.NOTE_PLING, 3, 3); } }else{ if(bank < price){ player.closeInventory();