Browse Source

changed project structure

mastercake10 7 years ago
parent
commit
630e9f6ff1

+ 0 - 84
TimeIsMoney2/bin/config.yml

@@ -1,84 +0,0 @@
-configuration-version: 12
-
-debug-log: false
-
-# You can disable the plugin's payout feature in certain worlds
-disabled_in_worlds:
-- "creative_world"
-
-# You can define if the player gets a payout whether player is afk or not.
-# the permission tim.afkbypass would avoid this for certain user or groups.
-afk_payout: false
-display-messages-in-chat: true
-display-messages-in-actionbar: true
-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 accounts per ip.
-allow-multiple-accounts: true
-
-# Payouts will be delivered by "chance" instead "permission".
-choose-payout-by-chance: false
-
-# You can add as many payouts you want. You only can choose between "permission"
-# and "chance", not both.
-payouts:
-  1:
-    payout_amount: 50
-    max_payout_per_day: 1000
-    # chance: 10
-    permission:
-  2:
-    payout_amount: 100
-    max_payout_per_day: 10000
-    commands:
-      - /give %player% diamond 1
-    # chance: 90
-    # You can use any permission name you want. e.g. myserver.donor
-    permission: tim.vip
-
-# Translations
-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 haven't earned money because you were afk!"
-message_atm_noperms: "&cYou don't have the permission to use ATM's!"
-message_atm_nomoneyinbank: "&cYou don't have enough money in bank!"
-message_atm_nomoney: "&cYou don't have enough money!"
-
-# ATM -> Place down a sign with [atm] on the first line to use it!
-enable_atm: true
-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. 
-group-atms: false
-# Example groups for seperating all worlds:
-#atm_groups:
-#  group1:
-#  - world
-#  group2:
-#  - world_nether
-#  group3:
-#   - world_the_end
-# Example groups for seperating skyblock worlds and survival worlds:
-#atm_groups:
-#  group1:
-#  - ASkyblock_world
-#  - Askyblock_spawn
-#  group2:
-#  - survival_world
-#  - farm_world

BIN
TimeIsMoney2/bin/modules/atm/ATM.class


+ 0 - 17
TimeIsMoney2/bin/plugin.yml

@@ -1,17 +0,0 @@
-name: TimeIsMoney
-depends: [Vault]
-soft-depends: [Essentials]
-author: Linus122
-main: de.Linus122.TimeIsMoney.Main
-version: 1960
-description: Gives money for online time
-commands:
-   timeismoney:
-      description: Reloads the Config
-      aliases: tim
-      usage: /<command>
-      permission: tim.reload
-   atm:
-      description: Opens the atm for other player
-      usage: /<command>
-      permission: tim.admin

BIN
TimeIsMoney2/bin/v1_10_R1/NBTUtils.class


BIN
TimeIsMoney2/bin/v1_11_R1/NBTUtils.class


BIN
TimeIsMoney2/bin/v1_12_R1/NBTUtils.class


BIN
TimeIsMoney2/bin/v1_8_R1/NBTUtils.class


BIN
TimeIsMoney2/bin/v1_8_R2/NBTUtils.class


BIN
TimeIsMoney2/bin/v1_8_R3/NBTUtils.class


BIN
TimeIsMoney2/bin/v1_9_R1/NBTUtils.class


BIN
TimeIsMoney2/bin/v1_9_R2/NBTUtils.class


+ 1 - 3
TimeIsMoney2/src/modules/atm/ATM.java → TimeIsMoney2/src/de/Linus122/TimeIsMoney/ATM.java

@@ -1,4 +1,4 @@
-package modules.atm;
+package de.Linus122.TimeIsMoney;
 
 import java.io.File;
 import java.io.IOException;
@@ -30,8 +30,6 @@ import org.bukkit.plugin.Plugin;
 
 import com.google.common.primitives.Doubles;
 
-import de.Linus122.TimeIsMoney.Main;
-
 import static de.Linus122.TimeIsMoney.Utils.CC;
 
 public class ATM implements Listener, CommandExecutor {

+ 8 - 9
TimeIsMoney2/src/de/Linus122/TimeIsMoney/Main.java

@@ -36,17 +36,14 @@ import org.bukkit.plugin.RegisteredServiceProvider;
 import org.bukkit.plugin.SimplePluginManager;
 import org.bukkit.plugin.java.JavaPlugin;
 
-import modules.atm.ATM;
-import net.milkbowl.vault.economy.Economy;
-
 import static de.Linus122.TimeIsMoney.Utils.CC;
 
 public class Main extends JavaPlugin {
 
-    public static Economy economy = null;
+    public static net.milkbowl.vault.economy.Economy economy = null;
     private static ActionBarUtils actionBarUtils = null;
     private static final int CFG_VERSION = 12;
-    public static int PL_VERSION;
+    public static String PL_VERSION;
     public static YamlConfiguration finalconfig;
     private static List<String> disabledWorlds;
     private static final HashMap<String, UUID> boundIPs = new HashMap<>();
@@ -55,6 +52,7 @@ public class Main extends JavaPlugin {
     private final HashMap<UUID, Integer> onlineSeconds = new HashMap<>();
     private final HashMap<UUID, Location> lastLocation = new HashMap<>();
     private String message;
+    private String messageActionbar;
     private final ConsoleCommandSender clogger = this.getServer().getConsoleSender();
     private int currentDay = 0;
     private boolean use18Features = true;
@@ -62,9 +60,8 @@ public class Main extends JavaPlugin {
     @SuppressWarnings({"deprecation", "unchecked"})
     @Override
     public void onEnable() {
-        PL_VERSION = Integer.parseInt(this.getDescription().getVersion());
         this.getCommand("timeismoney").setExecutor(new Cmd(this));
-
+        PL_VERSION = this.getDescription().getVersion();
         currentDay = (new Date()).getDay();
 
         File config = new File("plugins/TimeIsMoney/config.yml");
@@ -128,6 +125,8 @@ public class Main extends JavaPlugin {
 
         message = finalconfig.getString("message");
         message = CC(message);
+        messageActionbar = finalconfig.getString("message_actionbar");
+        messageActionbar = CC(messageActionbar);
 
         try {
             FileInputStream fis = new FileInputStream(new File("plugins/TimeIsMoney/payed_today.data"));
@@ -217,7 +216,7 @@ public class Main extends JavaPlugin {
     }
 
     private boolean setupEconomy() {
-        RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
+        RegisteredServiceProvider<net.milkbowl.vault.economy.Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
         if (economyProvider != null) {
             economy = economyProvider.getProvider();
         }
@@ -327,7 +326,7 @@ public class Main extends JavaPlugin {
             sendMessage(p, message.replace("%money%", economy.format(payout.payout_amount)));
         }
         if (finalconfig.getBoolean("display-messages-in-actionbar") && use18Features) {
-            sendActionbar(p, message.replace("%money%", economy.format(payout.payout_amount)));
+            sendActionbar(p, messageActionbar.replace("%money%", economy.format(payout.payout_amount)));
         }
         for (String cmd : payout.commands) {
             dispatchCommandSync(cmd.replace("/", "").replaceAll("%player%", p.getName()));

+ 25 - 15
TimeIsMoney2/src/de/Linus122/TimeIsMoney/Metrics.java

@@ -19,7 +19,7 @@ import com.google.gson.Gson;
 
 /*
  * SpaceIOMetrics main class by Linus122
- * version: 0.02
+ * version: 0.03
  * 
  */
 public class Metrics {
@@ -27,6 +27,8 @@ public class Metrics {
 	private final Gson gson = new Gson();
 	
 	private String URL = "https://spaceio.de/update/%s";
+	private final String VERSION = "0.03";
+	private int REFRESH_INTERVAL = 600000;
 	
 	public Metrics(Plugin pl){
 		this.pl = pl;
@@ -43,19 +45,27 @@ public class Metrics {
 		}
 
 		URL = String.format(URL, pl.getName());
+		
+		// fetching refresh interval first
+		pl.getServer().getScheduler().runTaskLaterAsynchronously(pl, () -> {
+			String dataJson = collectData();
+			try{
+				REFRESH_INTERVAL = sendData(dataJson);
+			}catch(Exception e){}
+		}, 20L * 5);
+		
+		// executing repeating task, our main metrics updater
 		pl.getServer().getScheduler().runTaskTimerAsynchronously(pl, () -> {
 			String dataJson = collectData();
 			try{
 				sendData(dataJson);
-			}catch(Exception e){
-				// skip
-				//e.printStackTrace();
-			}
-		}, 20L * 5, 20L * 60 * 10);
+			}catch(Exception e){}
+			
+		}, 20L * (REFRESH_INTERVAL / 1000), 20L * (REFRESH_INTERVAL / 1000));
 	}
 	private String collectData() {
 		Data data = new Data();
-
+		
 		// collect plugin list
 		for(Plugin plug : pl.getServer().getPluginManager().getPlugins()) data.plugs.put(plug.getName(), plug.getDescription().getVersion());
 		
@@ -93,19 +103,21 @@ public class Metrics {
 		
 		return gson.toJson(data);
 	}
-	private void sendData(String dataJson) throws Exception{
+	private int sendData(String dataJson) throws Exception{
 		java.net.URL obj = new java.net.URL(URL);
 		HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
 
 		con.setRequestMethod("POST");
 		con.setRequestProperty("User-Agent", "Java/Bukkit");
+		con.setRequestProperty("Metrics-Version", this.VERSION);
 
 		con.setDoOutput(true);
 		DataOutputStream wr = new DataOutputStream(con.getOutputStream());
 		wr.writeBytes(dataJson);
 		wr.flush();
 		wr.close();
-		con.getResponseCode();
+		
+		return Integer.parseInt(con.getHeaderField("interval-millis"));
 	}
 	private String getVersion(){
         String packageName = pl.getServer().getClass().getPackage().getName();
@@ -132,15 +144,13 @@ public class Metrics {
         //prints first version-related file
         for (File f : fileList) {
             try {
-                BufferedReader myReader = new BufferedReader(new FileReader(f));
+                BufferedReader br = new BufferedReader(new FileReader(f));
                 String strLine = null;
-                while ((strLine = myReader.readLine()) != null) {
+                while ((strLine = br.readLine()) != null) {
                     return strLine;
                 }
-                myReader.close();
-            } catch (Exception e) {
-                
-            }
+                br.close();
+            } catch (Exception e) {}
         }
 		return "unknown";    
 	}

+ 1 - 1
TimeIsMoney2/src/plugin.yml

@@ -3,7 +3,7 @@ depends: [Vault]
 soft-depends: [Essentials]
 author: Linus122
 main: de.Linus122.TimeIsMoney.Main
-version: 1960
+version: 1.9.6.1
 description: Gives money for online time
 commands:
    timeismoney: