Changed how uName works

(I still don't like the uName class at all, it will probably change in
the near future)
This commit is contained in:
Acrobot 2012-11-23 21:03:02 +01:00
parent 3104ba1b48
commit 22c5e20703
1 changed files with 20 additions and 3 deletions

View File

@ -1,14 +1,18 @@
package com.Acrobot.ChestShop.Utils;
import com.Acrobot.ChestShop.Config.BreezeConfiguration;
import com.Acrobot.ChestShop.Permission;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import java.io.File;
import java.io.IOException;
/**
* @author Acrobot
*/
public class uName {
public static BreezeConfiguration config;
public static YamlConfiguration config;
public static File file;
public static String getName(String shortName) {
return config.getString(shortName, shortName);
@ -20,7 +24,7 @@ public class uName {
}
config.set(stripName(name), name);
config.reload();
reload();
}
public static String stripName(String name) {
@ -34,4 +38,17 @@ public class uName {
public static boolean canUseName(Player player, String name) {
return shortenName(player).equals(name) || Permission.otherName(player, name);
}
public static void load() {
config = YamlConfiguration.loadConfiguration(file);
}
public static void reload() {
try {
config.save(file);
} catch (IOException e) {
e.printStackTrace();
}
load();
}
}