fonkfader avatar fonkfader committed d5a4cf5

- added Configuration class for more visibility, need work on it later
- updated version to 2.1.2

Comments (0)

Files changed (2)

 main: me.fonkfader.EmeraldEconLink.EmeraldEconLink
 name: EmeraldEconLink
-version: 2.1.1
+version: 2.1.2
 author: Fonkfader
 description: use items as currency.
 softdepend : [Vault]

src/me/fonkfader/EmeraldEconLink/Configuration.java

+package me.fonkfader.EmeraldEconLink;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.List;
+
+import org.bukkit.Server;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.configuration.file.YamlConfiguration;
+
+import com.nisovin.shopkeepers.ShopkeepersPlugin;
+
+public class Configuration {
+	
+	
+private static EmeraldEconLink plugin;
+	
+	public Configuration (EmeraldEconLink plugin){
+		
+		this.plugin = plugin;}
+
+
+
+
+
+public static String messageAdd;
+public static String messageRemove;
+public static String messageHack;
+public static String currencyName;
+public static List<Integer> itemsId;
+public static List<Integer> itemsCost;
+public static List<Integer> itemsCanBeBlock;
+public static List<Integer> blocksId;
+public static String messageAddBank;
+public static String messageRemoveBank;
+public static String messageNoPerm;
+public static String messageNoPlace;
+public static String messageNoPlaceReceive;
+public static String messageNoEnoughtItems;
+public static String messageNoEnoughtMoney;
+public static String messageSend;
+public static String messageReceive;
+public static String infoCommandDisplayName;
+public static String signDepositDisplayName;
+public static String signDispenserDisplayName;
+public static boolean EnableItemOnEarnMoney;
+public static boolean oneItemOnEarnMoney;
+public static boolean DisableChatMessage;
+public static List<String> DisabledWorlds;
+public static long tiksPerChecksForEnableItemOnEarnMoney;
+
+public static void loadConfig (){
+	
+	
+	
+	loadYamls();
+	if (!plugin.config.contains("EnableItemOnEarnMoney")) {
+		plugin.config.set("EnableItemOnEarnMoney", false);
+	}
+	if (!plugin.config.contains("DisableChatMessage")) {
+		plugin.config.set("DisableChatMessage", false);
+	}
+	if (!plugin.config.contains("DisabledWorlds")) {
+		String[] listOfStrings = { "creative", "otherWorld" };
+		plugin.config.set("DisabledWorlds", Arrays.asList(listOfStrings));
+	}
+	if (!plugin.config.contains("itemsId")) {
+		String[] listOfStrings = {"388"};
+		plugin.config.set("itemsId", Arrays.asList(listOfStrings));
+	}
+	if (!plugin.config.contains("itemsCost")) {
+		String[] listOfStrings = {"10"};
+		plugin.config.set("itemsCost", Arrays.asList(listOfStrings));
+	}
+	if (!plugin.config.contains("itemsCanBeBlock")) {
+		String[] listOfStrings = {"388"};
+		plugin.config.set("itemsCanBeBlock", Arrays.asList(listOfStrings));
+	}
+	if (!plugin.config.contains("blocksId")) {
+		String[] listOfStrings = {"133"};
+		plugin.config.set("blocksId", Arrays.asList(listOfStrings));
+	}
+	if (!plugin.config.contains("infoCommandDisplayName")) {
+		
+		plugin.config.set("infoCommandDisplayName", "Server currency infos");
+	}
+	if (!plugin.config.contains("signDispenserDisplayName")) {
+		
+		plugin.config.set("signDispenserDisplayName", "CASH");
+	}
+	if (!plugin.config.contains("signDepositDisplayName")) {
+		
+		plugin.config.set("signDepositDisplayName", "DEPOSIT");
+	}
+	if (!plugin.config.contains("randomItemOnEarnMoney")) {
+		plugin.config.set("oneItemOnEarnMoney", false);
+	}
+	if (!plugin.config.contains("tiksPerChecksForEnableItemOnEarnMoney")) {
+		plugin.config.set("tiksPerChecksForEnableItemOnEarnMoney", 100);
+	}
+
+	try {
+			plugin.config.save(plugin.configFile);
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	loadConfigVariable();
+	
+	
+}
+
+public static void loadConfigVariable(){
+	messageAdd = plugin.config.getString("message_add");
+	messageRemove =  plugin.config.getString("message_remove");
+	messageHack = plugin.config.getString("message_hack");
+	currencyName = plugin.config.getString("currencyName");
+	itemsId = plugin.config.getIntegerList("itemsId");
+	itemsCost = plugin.config.getIntegerList("itemsCost");
+	itemsCanBeBlock = plugin.config.getIntegerList("itemsCanBeBlock");
+	blocksId = plugin.config.getIntegerList("blocksId");
+	messageAddBank = plugin.config.getString("message_addBank");
+	messageRemoveBank = plugin.config.getString("message_removeBank");
+	messageNoPerm = plugin.config.getString("message_nopermissons");
+	messageNoPlace = plugin.config.getString("message_NoPlace");
+	messageNoPlaceReceive = plugin.config.getString("message_NoPlaceReceive");
+	messageNoEnoughtItems = plugin.config.getString("message_NoEnoughtItem");
+	messageNoEnoughtMoney = plugin.config.getString("message_NoEnoughtMoney");
+	messageSend = plugin.config.getString("message_Send");
+	messageReceive = plugin.config.getString("message_Receive");
+	infoCommandDisplayName = plugin.config.getString("infoCommandDisplayName");
+	signDispenserDisplayName = plugin.config.getString("signDispenserDisplayName");
+	signDepositDisplayName = plugin.config.getString("signDepositDisplayName");
+	EnableItemOnEarnMoney =  plugin.config.getBoolean("EnableItemOnEarnMoney");
+	oneItemOnEarnMoney = plugin.config.getBoolean("oneItemOnEarnMoney");
+	DisabledWorlds = plugin.config.getStringList("DisabledWorlds");
+	DisableChatMessage = plugin.config.getBoolean("DisableChatMessage");
+	tiksPerChecksForEnableItemOnEarnMoney = plugin.config.getLong("tiksPerChecksForEnableItemOnEarnMoney");
+}
+
+public static void firstRun() throws Exception {
+	if (!plugin.configFile.exists()) {
+		plugin.configFile.getParentFile().mkdirs();
+		copy(plugin.getResource("plugin.config.yml"), plugin.configFile);
+	}
+}
+
+private static void copy(InputStream in, File file) {
+	try {
+		OutputStream out = new FileOutputStream(file);
+		byte[] buf = new byte[1024];
+		int len;
+		while ((len = in.read(buf)) > 0) {
+			out.write(buf, 0, len);
+		}
+		out.close();
+		in.close();
+	} catch (Exception e) {
+		e.printStackTrace();
+	}
+}
+
+public static void loadYamls() {
+	try {
+		plugin.config.load(plugin.configFile);
+
+	} catch (Exception e) {
+		e.printStackTrace();
+	}
+}
+
+public void saveYamls() {
+	try {
+		plugin.config.save(plugin.configFile);
+	} catch (IOException e) {
+		e.printStackTrace();
+	}
+}
+
+
+
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.