summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Essentials/src/com/earth2me/essentials/Essentials.java6
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java74
-rw-r--r--Essentials/src/worth.yml365
3 files changed, 274 insertions, 171 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java
index fc7ab229e..1dba4c403 100644
--- a/Essentials/src/com/earth2me/essentials/Essentials.java
+++ b/Essentials/src/com/earth2me/essentials/Essentials.java
@@ -51,7 +51,6 @@ public class Essentials extends JavaPlugin
public Essentials() throws IOException
{
- loadClasses();
}
public static void ensureEnabled(Server server)
@@ -62,10 +61,6 @@ public class Essentials extends JavaPlugin
pm.enablePlugin(ess);
}
- public static void loadClasses()
- {
- }
-
public static Essentials getStatic()
{
return staticThis;
@@ -100,6 +95,7 @@ public class Essentials extends JavaPlugin
public void onEnable()
{
setStatic();
+ new EssentialsUpgrade(this.getDescription().getVersion(), this.getDataFolder());
confList = new ArrayList<IConf>();
settings = new Settings(this.getDataFolder());
confList.add(settings);
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java b/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java
new file mode 100644
index 000000000..36d83e716
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java
@@ -0,0 +1,74 @@
+package com.earth2me.essentials;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.bukkit.Material;
+import org.bukkit.inventory.ItemStack;
+
+public class EssentialsUpgrade {
+ private static boolean alreadyRun = false;
+ private final static Logger logger = Logger.getLogger("Minecraft");
+
+ EssentialsUpgrade(String version, File dataFolder) {
+ if (alreadyRun == true) return;
+ alreadyRun = true;
+ moveWorthValuesToWorthYml(dataFolder);
+ }
+
+ private void moveWorthValuesToWorthYml(File dataFolder) {
+ try {
+ File configFile = new File(dataFolder, "config.yml");
+ EssentialsConf conf = new EssentialsConf(configFile);
+ conf.load();
+ Worth w = new Worth(dataFolder);
+ for (Material mat : Material.values()) {
+ int id = mat.getId();
+ double value = conf.getDouble("worth-"+id, Double.NaN);
+ if (!Double.isNaN(value)) {
+ w.setPrice(new ItemStack(mat, 1, (short)0, (byte)0), value);
+ }
+ }
+ removeLinesFromConfig(configFile,"\\s*#?\\s*worth-[0-9]+.*", "# Worth values have been moved to worth.yml");
+ } catch (Throwable e) {
+ logger.log(Level.WARNING, "Error while upgrading the files", e);
+ }
+ }
+
+ private void removeLinesFromConfig(File file, String regex, String info) throws Exception {
+ boolean needUpdate = false;
+ BufferedReader br = new BufferedReader(new FileReader(file));
+ File tempFile = File.createTempFile("essentialsupgrade", ".yml");
+ BufferedWriter bw = new BufferedWriter(new FileWriter(tempFile));
+ do {
+ String line = br.readLine();
+ if (line == null) break;
+ if (line.matches(regex)) {
+ if (needUpdate == false && info != null) {
+ bw.write(info, 0, info.length());
+ bw.newLine();
+ }
+ needUpdate = true;
+ } else {
+ if (line.endsWith("\r\n")) {
+ bw.write(line, 0, line.length() - 2);
+ } else if (line.endsWith("\r") || line.endsWith("\n")) {
+ bw.write(line, 0, line.length() - 1);
+ } else {
+ bw.write(line, 0, line.length());
+ }
+ bw.newLine();
+ }
+ } while(true);
+ br.close();
+ bw.close();
+ if (needUpdate) {
+ file.renameTo(new File(file.getParentFile(), file.getName().concat("."+System.currentTimeMillis()+".upgraded")));
+ tempFile.renameTo(file);
+ }
+ }
+}
diff --git a/Essentials/src/worth.yml b/Essentials/src/worth.yml
index bb38091c1..47194af07 100644
--- a/Essentials/src/worth.yml
+++ b/Essentials/src/worth.yml
@@ -1,166 +1,199 @@
-worth-1: 2
-worth-2: 1
-worth-3: 1
-worth-4: 1
-worth-5: 1
-worth-6: 2
-worth-7: 1000
-worth-8: 1
-worth-9: 1
-worth-10: 1
-worth-11: 1
-worth-12: 1
-worth-13: 1
-worth-14: 45
-worth-15: 18
-worth-16: 15
-worth-17: 2
-worth-18: 0
-worth-19: 80
-worth-20: 10
-worth-21: 100
-worth-22: 500
-worth-23: 9
-worth-24: 5
-worth-25: 40
-worth-35: 8
-worth-37: 2
-worth-38: 2
-worth-39: 2
-worth-40: 2
-worth-41: 400
-worth-42: 160
-worth-43: 3
-worth-44: 3
-worth-45: 40
-worth-46: 10000
-worth-47: 20
-worth-48: 90
-worth-49: 130
-worth-50: 1
-worth-53: 8
-worth-54: 15
-worth-55: 7
-worth-56: 200
-worth-57: 1500
-worth-58: 20
-worth-60: 3
-worth-61: 10
-worth-65: 10
-worth-66: 40
-worth-67: 22
-worth-68: 1
-worth-69: 7
-worth-70: 10
-worth-71: 15
-worth-72: 10
-worth-73: 30
-worth-74: 30
-worth-76: 10
-worth-77: 7
-worth-81: 10
-worth-82: 3
-worth-83: 15
-worth-85: 10
-worth-86: 50
-worth-91: 60
-worth-256: 40
-worth-257: 80
-worth-258: 60
-worth-260: 10
-worth-261: 75
-worth-262: 10
-worth-263: 3
-worth-264: 230
-worth-265: 20
-worth-266: 50
-worth-267: 60
-worth-268: 10
-worth-269: 10
-worth-270: 10
-worth-271: 10
-worth-272: 40
-worth-273: 40
-worth-274: 40
-worth-275: 40
-worth-276: 700
-worth-277: 350
-worth-278: 1000
-worth-279: 1000
-worth-280: 1
-worth-281: 6
-worth-282: 30
-worth-283: 200
-worth-284: 220
-worth-285: 300
-worth-286: 300
-worth-287: 5
-worth-288: 3
-worth-289: 19
-worth-290: 10
-worth-291: 40
-worth-292: 60
-worth-293: 600
-worth-294: 200
-worth-295: 5
-worth-296: 9
-worth-297: 20
-worth-298: 20
-worth-299: 40
-worth-300: 20
-worth-301: 17
-worth-302: 40
-worth-303: 40
-worth-304: 50
-worth-305: 30
-worth-306: 120
-worth-307: 300
-worth-308: 250
-worth-309: 50
-worth-310: 1500
-worth-311: 3000
-worth-312: 2200
-worth-313: 1500
-worth-314: 300
-worth-315: 600
-worth-316: 400
-worth-317: 250
-worth-320: 6
-worth-321: 50
-worth-322: 500
-worth-323: 10
-worth-324: 30
-worth-325: 10
-worth-326: 10
-worth-327: 30
-worth-328: 20
-worth-329: 100
-worth-330: 35
-worth-331: 1
-worth-332: 1
-worth-333: 5
-worth-334: 10
-worth-335: 15
-worth-336: 10
-worth-337: 8
-worth-338: 10
-worth-339: 30
-worth-340: 35
-worth-341: 50
-worth-342: 35
-worth-343: 30
-worth-344: 1
-worth-345: 50
-worth-346: 25
-worth-347: 100
-worth-348: 11
-worth-349: 5
-worth-350: 20
-worth-351: 10
-worth-352: 10
-worth-353: 5
-worth-354: 100
-worth-355: 25
-worth-356: 10
-worth-2256: 950
-worth-2257: 1000 \ No newline at end of file
+worth:
+ stonebutton:
+ '0': 7.0
+ wood: 1.0
+ arrow: 10.0
+ diamondpickaxe: 1000.0
+ rawfish: 5.0
+ minecart: 20.0
+ leatherchestplate: 40.0
+ storageminecart: 35.0
+ leaves:
+ '0': 0.0
+ feather: 3.0
+ goldchestplate: 600.0
+ mushroomsoup: 30.0
+ bread: 20.0
+ stationarywater:
+ '0': 1.0
+ workbench: 20.0
+ stonehoe: 40.0
+ brownmushroom: 2.0
+ wool:
+ '0': 8.0
+ mossycobblestone: 90.0
+ diamondhoe: 600.0
+ woodsword: 10.0
+ torch:
+ '0': 1.0
+ grass: 1.0
+ poweredminecart: 30.0
+ snowball: 1.0
+ goldenapple: 500.0
+ leatherleggings: 20.0
+ log:
+ '0': 2.0
+ diamondaxe: 1000.0
+ slimeball: 50.0
+ fence: 10.0
+ stonespade: 40.0
+ claybrick: 10.0
+ noteblock: 40.0
+ ironaxe: 60.0
+ coalore: 15.0
+ clayball: 8.0
+ fishingrod: 25.0
+ ironhoe: 60.0
+ goldrecord: 950.0
+ ironpickaxe: 80.0
+ irondoor: 35.0
+ bucket: 10.0
+ redrose: 2.0
+ grilledpork: 6.0
+ gravel: 1.0
+ wooddoor: 30.0
+ chainmailhelmet: 40.0
+ ironchestplate: 300.0
+ diamondblock: 1500.0
+ diamondhelmet: 1500.0
+ goldhelmet: 300.0
+ redstonetorchon:
+ '0': 10.0
+ ironspade: 40.0
+ furnace:
+ '0': 10.0
+ ironsword: 60.0
+ dispenser:
+ '0': 9.0
+ woodaxe: 10.0
+ seeds: 5.0
+ painting: 50.0
+ woodplate:
+ '0': 10.0
+ redstoneore: 30.0
+ diamondspade: 350.0
+ waterbucket: 10.0
+ water:
+ '0': 1.0
+ bedrock: 1000.0
+ irondoorblock:
+ '0': 15.0
+ goldhoe: 200.0
+ sand: 1.0
+ goldsword: 200.0
+ stoneaxe: 40.0
+ bookshelf: 20.0
+ ironblock: 160.0
+ jackolantern:
+ '0': 60.0
+ boat: 5.0
+ diamondchestplate: 3000.0
+ redstonewire:
+ '0': 7.0
+ redmushroom: 2.0
+ string: 5.0
+ stoneplate:
+ '0': 10.0
+ wallsign:
+ '0': 1.0
+ cactus:
+ '0': 10.0
+ sulphur: 19.0
+ rails:
+ '0': 40.0
+ ironore: 18.0
+ leatherhelmet: 20.0
+ stone: 2.0
+ egg: 1.0
+ diamondore: 200.0
+ woodhoe: 10.0
+ goldleggings: 400.0
+ chainmailleggings: 50.0
+ yellowflower: 2.0
+ ironhelmet: 120.0
+ obsidian: 130.0
+ dirt: 1.0
+ leather: 10.0
+ leatherboots: 17.0
+ lever:
+ '0': 7.0
+ cobblestone: 1.0
+ cake: 100.0
+ woodstairs:
+ '0': 8.0
+ ironingot: 20.0
+ goldore: 45.0
+ pumpkin:
+ '0': 50.0
+ bed: 25.0
+ watch: 100.0
+ ironleggings: 250.0
+ sign: 10.0
+ doublestep:
+ '0': 3.0
+ woodpickaxe: 10.0
+ stonepickaxe: 40.0
+ chainmailboots: 30.0
+ diamondleggings: 2200.0
+ cookedfish: 20.0
+ saddle: 100.0
+ cobblestonestairs:
+ '0': 22.0
+ tnt: 10000.0
+ glowingredstoneore: 30.0
+ apple: 10.0
+ woodspade: 10.0
+ goldingot: 50.0
+ diode: 10.0
+ soil:
+ '0': 3.0
+ clay: 3.0
+ goldblock: 400.0
+ stick: 1.0
+ paper: 30.0
+ brick: 40.0
+ stationarylava:
+ '0': 1.0
+ chest: 15.0
+ sandstone: 5.0
+ goldpickaxe: 300.0
+ compass: 50.0
+ sugarcane: 10.0
+ diamondsword: 700.0
+ goldboots: 250.0
+ sponge: 80.0
+ stonesword: 40.0
+ coal:
+ '0': 3.0
+ goldaxe: 300.0
+ bone: 10.0
+ diamond: 230.0
+ glass: 10.0
+ goldspade: 220.0
+ lapisblock: 500.0
+ lavabucket: 30.0
+ wheat: 9.0
+ ladder:
+ '0': 10.0
+ sugarcaneblock:
+ '0': 15.0
+ bowl: 6.0
+ chainmailchestplate: 40.0
+ sapling:
+ '0': 2.0
+ diamondboots: 1500.0
+ lapisore: 100.0
+ lava:
+ '0': 1.0
+ milkbucket: 15.0
+ redstone: 1.0
+ greenrecord: 1000.0
+ inksack:
+ '0': 10.0
+ glowstonedust: 11.0
+ book: 35.0
+ bow: 75.0
+ ironboots: 50.0
+ step:
+ '0': 3.0
+ sugar: 5.0