소스 검색

added opportunity to change atm values

mastercake10 7 년 전
부모
커밋
b53f9306dc
3개의 변경된 파일26개의 추가작업 그리고 12개의 파일을 삭제
  1. 6 0
      TimeIsMoney2/src/config.yml
  2. 5 1
      TimeIsMoney2/src/de/Linus122/TimeIsMoney/Main.java
  3. 15 11
      TimeIsMoney2/src/modules/atm/ATM.java

+ 6 - 0
TimeIsMoney2/src/config.yml

@@ -56,6 +56,12 @@ atm_title: "&cATM"
 atm_withdraw: "&cWithdraw"
 atm_deposit: "&cDeposit"
 atm_balance: "&cBank balance:"
+atm_worth_gradation:
+  - 10.0
+  - 100.0
+  - 1000.0
+  - 10000.0
+
 
 # You can seperate the ATM balances for different worlds by group them. Just set group-atms to true and write atm_groups as described below.
 # Note: Existing bank accounts will be removed when enabling this feature. 

+ 5 - 1
TimeIsMoney2/src/de/Linus122/TimeIsMoney/Main.java

@@ -19,6 +19,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Random;
+import java.util.Set;
 import java.util.UUID;
 
 import org.bukkit.Bukkit;
@@ -95,10 +96,13 @@ public class Main extends JavaPlugin{
 			this.saveDefaultConfig();
 		}
 		
-		if(getConfig().getBoolean("enable_atm")) new ATM(this);
 		
+	    
 		finalconfig = YamlConfiguration.loadConfiguration(config);
 		disabledWorlds = getConfig().getStringList("disabled_in_worlds");
+		
+		if(getConfig().getBoolean("enable_atm")) new ATM(this);
+		
 		final int seconds = getConfig().getInt("give_money_every_second");
 		Bukkit.getScheduler().runTaskTimerAsynchronously(this, new Runnable(){
 			public void run(){

+ 15 - 11
TimeIsMoney2/src/modules/atm/ATM.java

@@ -29,6 +29,8 @@ import org.bukkit.inventory.ItemStack;
 import org.bukkit.inventory.meta.ItemMeta;
 import org.bukkit.plugin.Plugin;
 
+import com.google.common.primitives.Doubles;
+
 import de.Linus122.TimeIsMoney.Main;
 
 public class ATM implements Listener, CommandExecutor {
@@ -37,7 +39,7 @@ public class ATM implements Listener, CommandExecutor {
 	public static YamlConfiguration cfg;
 	public static File fileBankAccounts = new File("plugins/TimeIsMoney/data.dat");
 	
-	double[] worths = {10000, 1000, 100, 10};
+	double[] worths = new double[4];
 	
 	public ATM(Main pl){
 		this.pl = pl;
@@ -52,6 +54,8 @@ public class ATM implements Listener, CommandExecutor {
 			}	
 		}
 		cfg = YamlConfiguration.loadConfiguration(fileBankAccounts);
+		
+		worths = Doubles.toArray(Main.finalconfig.getDoubleList("atm_worth_gradation"));
 	}
 	public static void withdrawBank(Player p, double amount){
 		String bankString = getBankString(p);
@@ -167,7 +171,7 @@ public class ATM implements Listener, CommandExecutor {
 					// left side
 					if(e.getSlot() < 4){
 	
-						double amount = worths[e.getSlot()];
+						double amount = worths[3 - e.getSlot()];
 						
 						if(ATM.bankHas(p, amount)){
 							ATM.withdrawBank(p, amount);
@@ -180,7 +184,7 @@ public class ATM implements Listener, CommandExecutor {
 					// right side
 					if(e.getSlot() > 4){
 						
-						double amount = worths[worths.length - (e.getSlot() - 5) - 1];
+						double amount = worths[3 - (3 - (e.getSlot() - 5))];
 						
 						if(Main.economy.has((Player) e.getWhoClicked(), amount)){
 							ATM.depositBank(p, amount);
@@ -216,28 +220,28 @@ public class ATM implements Listener, CommandExecutor {
 		//
 		is = new ItemStack(Material.CLAY_BRICK, 1);
 		im = is.getItemMeta();
-		im.setDisplayName(Main.finalconfig.getString("atm_withdraw").replace('&', '§') + " §a" + Main.economy.format(10));
+		im.setDisplayName(Main.finalconfig.getString("atm_withdraw").replace('&', '§') + " §a" + Main.economy.format(worths[0]));
 		is.setItemMeta(im);
 		atm_gui.setItem(3, is);
 		
 		//
 		is = new ItemStack(Material.IRON_INGOT, 1);
 		im = is.getItemMeta();
-		im.setDisplayName(Main.finalconfig.getString("atm_withdraw").replace('&', '§') +  " §a" + Main.economy.format(100));
+		im.setDisplayName(Main.finalconfig.getString("atm_withdraw").replace('&', '§') +  " §a" + Main.economy.format(worths[1]));
 		is.setItemMeta(im);
 		atm_gui.setItem(2, is);
 		
 		//
 		is = new ItemStack(Material.GOLD_INGOT, 1);
 		im = is.getItemMeta();
-		im.setDisplayName(Main.finalconfig.getString("atm_withdraw").replace('&', '§') + " §a" + Main.economy.format(1000));
+		im.setDisplayName(Main.finalconfig.getString("atm_withdraw").replace('&', '§') + " §a" + Main.economy.format(worths[2]));
 		is.setItemMeta(im);
 		atm_gui.setItem(1, is);
 		
 		//
 		is = new ItemStack(Material.DIAMOND, 1);
 		im = is.getItemMeta();
-		im.setDisplayName(Main.finalconfig.getString("atm_withdraw").replace('&', '§') + " §a" + Main.economy.format(10000));
+		im.setDisplayName(Main.finalconfig.getString("atm_withdraw").replace('&', '§') + " §a" + Main.economy.format(worths[3]));
 		is.setItemMeta(im);
 		atm_gui.setItem(0, is);
 		
@@ -245,28 +249,28 @@ public class ATM implements Listener, CommandExecutor {
 		//
 		is = new ItemStack(Material.CLAY_BRICK, 1);
 		im = is.getItemMeta();
-		im.setDisplayName(Main.finalconfig.getString("atm_deposit").replace('&', '§') + " §4" + Main.economy.format(10));
+		im.setDisplayName(Main.finalconfig.getString("atm_deposit").replace('&', '§') + " §4" + Main.economy.format(worths[0]));
 		is.setItemMeta(im);
 		atm_gui.setItem(5, is);
 		
 		//
 		is = new ItemStack(Material.IRON_INGOT, 1);
 		im = is.getItemMeta();
-		im.setDisplayName(Main.finalconfig.getString("atm_deposit").replace('&', '§') + " §4" + Main.economy.format(100));
+		im.setDisplayName(Main.finalconfig.getString("atm_deposit").replace('&', '§') + " §4" + Main.economy.format(worths[1]));
 		is.setItemMeta(im);
 		atm_gui.setItem(6, is);
 		
 		//
 		is = new ItemStack(Material.GOLD_INGOT, 1);
 		im = is.getItemMeta();
-		im.setDisplayName(Main.finalconfig.getString("atm_deposit").replace('&', '§') + " §4" + Main.economy.format(1000));
+		im.setDisplayName(Main.finalconfig.getString("atm_deposit").replace('&', '§') + " §4" + Main.economy.format(worths[2]));
 		is.setItemMeta(im);
 		atm_gui.setItem(7, is);
 		
 		//
 		is = new ItemStack(Material.DIAMOND, 1);
 		im = is.getItemMeta();
-		im.setDisplayName(Main.finalconfig.getString("atm_deposit").replace('&', '§') + " §4" + Main.economy.format(10000));
+		im.setDisplayName(Main.finalconfig.getString("atm_deposit").replace('&', '§') + " §4" + Main.economy.format(worths[3]));
 		is.setItemMeta(im);
 		atm_gui.setItem(8, is);