Browse Source

* fixed question mark symbols and added allow-multiple-accounts to cfg

mastercake10 8 years ago
parent
commit
8fe9b453c2
2 changed files with 18 additions and 1 deletions
  1. 4 0
      TimeIsMoney2/src/config.yml
  2. 14 1
      TimeIsMoney2/src/de/Linus122/TimeIsMoney/Main.java

+ 4 - 0
TimeIsMoney2/src/config.yml

@@ -16,6 +16,9 @@ display-messages-in-actionbar-time: 10
 give_money_every_second: 600
 store-money-in-bank: false
 
+# Define if multiple accounts should get payed with the same ip-address. You may disable this if your players are using multiple acconts per ip. 
+allow-multiple-accounts: true
+
 # Payouts will be delivered by "chance" instead "permission".
 choose-payout-by-chance: false
 
@@ -40,6 +43,7 @@ payouts:
 message: "&aYou earned &c%money% &afor 10 minutes online time!"
 message_payoutlimit_reached: "&cYou have reached the payout limit today. You earned 0$"
 message_afk: "&cYou havn't earned money because you were afk!"
+message_multiple_ips: "&cYou havn't earned money because you're playing with multiple accounts!"
 message_actionbar: "&aYou earned &c%money% &afor 10 minutes online time!"
 message_payoutlimit_reached_actionbar: "&cYou have reached the payout limit today. You got 0$"
 message_afk_actionbar: "&cYou havn't earned money because you were afk!"

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

@@ -65,6 +65,7 @@ public class Main extends JavaPlugin{
 	boolean use18Features = true;
 	
 	public static List<String> disabledWorlds;
+	public static HashMap<String, Player> boundIPs = new HashMap<String, Player>();
 	
 	@SuppressWarnings({ "deprecation", "unchecked" })
 	@Override
@@ -104,6 +105,9 @@ public class Main extends JavaPlugin{
 			public void run(){
 				for(Player p : Bukkit.getOnlinePlayers()){
 					if(disabledWorlds.contains(p.getWorld().getName())) continue;
+					if(!boundIPs.containsKey(p.getAddress().getHostName())){
+						boundIPs.put(p.getAddress().getHostName(), p);
+					}
 					if(onlineSeconds.containsKey(p)){
 						
 						onlineSeconds.put(p, onlineSeconds.get(p) + 1);
@@ -294,6 +298,15 @@ public class Main extends JavaPlugin{
 			}	
 		}
 		
+		if(!finalconfig.getBoolean("allow-multiple-accounts")){
+			if(boundIPs.containsKey(p.getAddress().getHostName())){
+				if(boundIPs.get(p.getAddress().getHostName()) != p){
+					sendMessage(p, finalconfig.getString("message_multiple_ips"));
+					return;
+				}
+			}
+		}
+		
 		//AFK CHECK
 		if(!finalconfig.getBoolean("afk_payout") && !p.hasPermission("tim.afkbypass")){
 			//ESENTIALS_AFK_FEATURE
@@ -354,7 +367,7 @@ public class Main extends JavaPlugin{
 		}else{
 			payedMoney.put(p.getName(), payout.payout_amount);
 		}
-		
+
 		lastLocation.put(p, p.getLocation());
 	
 	}