mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-09-28 22:47:46 +02:00
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:
parent
3104ba1b48
commit
22c5e20703
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user