Avoiding creating blank spaces in the config

This commit is contained in:
Acrobot 2012-12-31 02:28:39 +01:00
parent f48027e80c
commit 23b6e59fa0
3 changed files with 31 additions and 29 deletions

View File

@ -4,10 +4,7 @@ import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.*;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
@ -38,7 +35,6 @@ public class Configuration {
try {
if (path.toLowerCase().replace("_", "").startsWith("newline")) {
writer.write('\n');
continue;
}
@ -46,11 +42,17 @@ public class Configuration {
field.set(null, ValueParser.parseToJava(config.get(path)));
} else {
writer.write('\n' + FieldParser.parse(field));
if (clazz.getDeclaredField("NEWLINE_" + path) != null) {
writer.write('\n');
}
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
continue;
}
}

View File

@ -9,65 +9,65 @@ public class Messages {
public static String prefix = ChatColor.GREEN + "[Shop] " + ChatColor.RESET;
public static String iteminfo = ChatColor.GREEN + "Item Information: " + ChatColor.RESET;
public static byte NEWLINE_1; ///////////////////////////////////////////////////
public static byte NEWLINE_iteminfo; ///////////////////////////////////////////////////
public static String ACCESS_DENIED = "You don't have permission to do that!";
public static byte NEWLINE_2; ///////////////////////////////////////////////////
public static byte NEWLINE_ACCESS_DENIED; ///////////////////////////////////////////////////
public static String NOT_ENOUGH_MONEY = "You don't have enough money!";
public static String NOT_ENOUGH_MONEY_SHOP = "Shop owner doesn't have enough money!";
public static byte NEWLINE_3; ///////////////////////////////////////////////////
public static byte NEWLINE_NOT_ENOUGH_MONEY_SHO; ///////////////////////////////////////////////////
public static String NO_BUYING_HERE = "You can't buy here!";
public static String NO_SELLING_HERE = "You can't sell here!";
public static byte NEWLINE_4; ///////////////////////////////////////////////////
public static byte NEWLINE_NO_SELLING_HERE; ///////////////////////////////////////////////////
public static String NOT_ENOUGH_SPACE_IN_INVENTORY = "You haven't got enough space in inventory!";
public static String NOT_ENOUGH_SPACE_IN_CHEST = "There isn't enough space in chest!";
public static String NOT_ENOUGH_ITEMS_TO_SELL = "You don't have enough items to sell!";
public static byte NEWLINE_5; ///////////////////////////////////////////////////
public static byte NEWLINE_NOT_ENOUGH_ITEMS_TO_SELL; ///////////////////////////////////////////////////
public static String NOT_ENOUGH_STOCK = "This shop is out of stock.";
public static String NOT_ENOUGH_STOCK_IN_YOUR_SHOP = "Your %material shop is out of stock!";
public static byte NEWLINE_6; ///////////////////////////////////////////////////
public static byte NEWLINE_ENOUGH_STOCK_IN_YOUR_SHOP; ///////////////////////////////////////////////////
public static String YOU_BOUGHT_FROM_SHOP = "You bought %item from %owner for %price.";
public static String SOMEBODY_BOUGHT_FROM_YOUR_SHOP = "%buyer bought %item for %price from you.";
public static byte NEWLINE_7; ///////////////////////////////////////////////////
public static byte NEWLINE_SOMEBODY_BOUGHT_FROM_YOUR_SHOP; ///////////////////////////////////////////////////
public static String YOU_SOLD_TO_SHOP = "You sold %item to %buyer for %price.";
public static String SOMEBODY_SOLD_TO_YOUR_SHOP = "%seller sold %item for %price to you.";
public static byte NEWLINE_8; ///////////////////////////////////////////////////
public static byte NEWLINE_SOMEBODY_SOLD_TO_YOUR_SHOP; ///////////////////////////////////////////////////
public static String YOU_CANNOT_CREATE_SHOP = "You can't create this type of shop!";
public static String NO_CHEST_DETECTED = "Couldn't find a chest!";
public static String INVALID_SHOP_DETECTED = "The shop cannot be used! (It might lack a chest!)";
public static String CANNOT_ACCESS_THE_CHEST = "You don't have permissions to access this chest!";
public static byte NEWLINE_9; ///////////////////////////////////////////////////
public static byte NEWLINE_CANNOT_ACCESS_THE_CHEST; ///////////////////////////////////////////////////
public static String PROTECTED_SHOP = "Successfully protected the shop with LWC!";
public static String SHOP_CREATED = "Shop successfully created!";
public static String SHOP_REFUNDED = "You have been refunded %amount.";
public static byte NEWLINE_10; ///////////////////////////////////////////////////
public static byte NEWLINE_SHOP_REFUNDED; ///////////////////////////////////////////////////
public static String RESTRICTED_SIGN_CREATED = "Sign succesfully created!";
public static byte NEWLINE_11; ///////////////////////////////////////////////////
public static byte NEWLINE_RESTRICTED_SIGN_CREATED; ///////////////////////////////////////////////////
public static String NO_PERMISSION = "You don't have permissions to do that!";
public static String INCORRECT_ITEM_ID = "You have specified invalid item id!";
public static String NOT_ENOUGH_PROTECTIONS = "You have reached the protection limit!";
public static byte NEWLINE_12; ///////////////////////////////////////////////////
public static byte NEWLINE_NOT_ENOUGH_PROTECTIONS; ///////////////////////////////////////////////////
public static String CANNOT_CREATE_SHOP_HERE = "You can't create shop here!";

View File

@ -9,7 +9,7 @@ public class Properties {
@ConfigurationComment("(When not using Vault) Preferred economy plugin to use (iConomy/BOSEconomy/Essentials).")
public static String PREFERRED_ECONOMY_PLUGIN = "";
public static byte NEWLINE_1; ///////////////////////////////////////////////////
public static byte NEWLINE_PREFERRED_ECONOMY_PLUGIN; ///////////////////////////////////////////////////
@ConfigurationComment("(In 1/1000th of a second) How often can a player use the shop sign?")
public static int SHOP_INTERACTION_INTERVAL = 250;
@ -29,7 +29,7 @@ public class Properties {
@ConfigurationComment("If true, when you left-click your own shop sign you won't open chest's inventory, but instead you will start destroying the sign.")
public static boolean ALLOW_LEFT_CLICK_DESTROYING = true;
public static byte NEWLINE_2; ///////////////////////////////////////////////////
public static byte NEWLINE_ALLOW_LEFT_CLICK_DESTROYING; ///////////////////////////////////////////////////
@ConfigurationComment("If true, if the shop is empty, the sign is destroyed and put into the chest, so the shop isn't usable anymore.")
public static boolean REMOVE_EMPTY_SHOPS = false;
@ -37,7 +37,7 @@ public class Properties {
@ConfigurationComment("If true, if the REMOVE_EMPTY_SHOPS option is turned on, the chest is also destroyed.")
public static boolean REMOVE_EMPTY_CHESTS = false;
public static byte NEWLINE_3; ///////////////////////////////////////////////////
public static byte NEWLINE_REMOVE_EMPTY_CHESTS; ///////////////////////////////////////////////////
@ConfigurationComment("First line of your Admin Shop's sign should look like this:")
public static String ADMIN_SHOP_NAME = "Admin Shop";
@ -57,12 +57,12 @@ public class Properties {
@ConfigurationComment("How much money do you get back when destroying a sign?")
public static double SHOP_REFUND_PRICE = 0;
public static byte NEWLINE_4; ///////////////////////////////////////////////////
public static byte NEWLINE_SHOP_REFUND_PRICE; ///////////////////////////////////////////////////
@ConfigurationComment("Should we block shops that sell things for more than they buy? (This prevents newbies from creating shops that would be exploited)")
public static boolean BLOCK_SHOPS_WITH_SELL_PRICE_HIGHER_THAN_BUY_PRICE = true;
public static byte NEWLINE_5; ///////////////////////////////////////////////////
public static byte NEWLINE_BLOCK_SHOPS_WITH_SELL_PRICE_HIGHER_THAN_BUY_PRICE; ///////////////////////////////////////////////////
@ConfigurationComment("Do you want to allow other players to build a shop on a block where there's one already?")
public static boolean ALLOW_MULTIPLE_SHOPS_AT_ONE_BLOCK = false;
@ -70,7 +70,7 @@ public class Properties {
@ConfigurationComment("Can shops be used even when the seller doesn't have enough items? (The price will be scaled adequatly to the item amount)")
public static boolean ALLOW_PARTIAL_TRANSACTIONS = true;
public static byte NEWLINE_6; ///////////////////////////////////////////////////
public static byte NEWLINE_ALLOW_PARTIAL_TRANSACTIONS; ///////////////////////////////////////////////////
@ConfigurationComment("Do you want to show \"Out of stock\" messages?")
public static boolean SHOW_MESSAGE_OUT_OF_STOCK = true;
@ -81,7 +81,7 @@ public class Properties {
@ConfigurationComment("Do you want to show \"Somebody bought/sold... \" messages?")
public static boolean SHOW_TRANSACTION_INFORMATION_OWNER = true;
public static byte NEWLINE_7; ///////////////////////////////////////////////////
public static byte NEWLINE_SHOW_TRANSACTION_INFORMATION_OWNER; ///////////////////////////////////////////////////
@ConfigurationComment("If true, plugin will log transactions in its own file")
public static boolean LOG_TO_FILE = false;
@ -95,7 +95,7 @@ public class Properties {
@ConfigurationComment("How long should transaction information be stored in the database (in seconds, -1 means forever)?")
public static int RECORD_TIME_TO_LIVE = 600;
public static byte NEWLINE_8; ///////////////////////////////////////////////////
public static byte NEWLINE_RECORD_TIME_TO_LIV; ///////////////////////////////////////////////////
@ConfigurationComment("Do you want to use built-in protection against chest destruction?")
public static boolean USE_BUILT_IN_PROTECTION = true;
@ -115,7 +115,7 @@ public class Properties {
@ConfigurationComment("Do you want to protect shop signs with LWC?")
public static boolean PROTECT_SIGN_WITH_LWC = false;
public static byte NEWLINE_9; ///////////////////////////////////////////////////
public static byte NEWLINE_PROTECT_SIGN_WITH_LWC; ///////////////////////////////////////////////////
@ConfigurationComment("If true, plugin will generate shop statistics webpage.")
public static boolean GENERATE_STATISTICS_PAGE = false;
@ -126,7 +126,7 @@ public class Properties {
@ConfigurationComment("How often should the website be generated?")
public static long STATISTICS_PAGE_GENERATION_INTERVAL = 60;
public static byte NEWLINE_10; ///////////////////////////////////////////////////
public static byte NEWLINE_STATISTICS_PAGE_GENERATION_INTERVAL; ///////////////////////////////////////////////////
@ConfigurationComment("Do you want to only let people build inside shop plots?")
public static boolean TOWNY_INTEGRATION = false;
@ -134,7 +134,7 @@ public class Properties {
@ConfigurationComment("If true, only plot owners are able to build inside a shop plot. If false, every town's resident is able to build there.")
public static boolean TOWNY_SHOPS_FOR_OWNERS_ONLY = true;
public static byte NEWLINE_11; ///////////////////////////////////////////////////
public static byte NEWLINE_TOWNY_SHOPS_FOR_OWNERS_ONLY; ///////////////////////////////////////////////////
@ConfigurationComment("Do you want to only let people build inside regions?")
public static boolean WORLDGUARD_INTEGRATION = false;
@ -145,7 +145,7 @@ public class Properties {
@ConfigurationComment("Do you want ChestShop to respect WorldGuard's chest protection?")
public static boolean WORLDGUARD_USE_PROTECTION = false;
public static byte NEWLINE_12; ///////////////////////////////////////////////////
public static byte NEWLINE_WORLDGUARD_USE_PROTECTION; ///////////////////////////////////////////////////
@ConfigurationComment("How much Heroes exp should people get for creating a ChestShop?")
public static double HEROES_EXP = 100;