70 lines
1.4 KiB
Java
70 lines
1.4 KiB
Java
package fr.xephi.authme.settings;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.UUID;
|
|
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.entity.Player;
|
|
|
|
import cn.citycraft.PluginHelper.config.FileConfig;
|
|
import fr.xephi.authme.AuthMe;
|
|
|
|
/**
|
|
*
|
|
* @author Xephi59
|
|
*/
|
|
public class OtherAccounts extends FileConfig {
|
|
|
|
private static OtherAccounts others = null;
|
|
|
|
public OtherAccounts() {
|
|
super(AuthMe.getInstance(), "otheraccounts.yml");
|
|
others = this;
|
|
}
|
|
|
|
public static OtherAccounts getInstance() {
|
|
if (others == null) {
|
|
others = new OtherAccounts();
|
|
}
|
|
return others;
|
|
}
|
|
|
|
public void addPlayer(final String pname) {
|
|
try {
|
|
final Player player = Bukkit.getPlayer(pname);
|
|
if (player == null) {
|
|
return;
|
|
}
|
|
if (!this.getStringList(pname).contains(player.getName())) {
|
|
this.getStringList(pname).add(player.getName());
|
|
save();
|
|
}
|
|
} catch (NoSuchMethodError | Exception e) {
|
|
}
|
|
}
|
|
|
|
public void clear(final String pname) {
|
|
set(pname, new ArrayList<String>());
|
|
save();
|
|
}
|
|
|
|
public List<String> getAllPlayersByUUID(final UUID uuid) {
|
|
return this.getStringList(uuid.toString());
|
|
}
|
|
|
|
public void removePlayer(final String pname) {
|
|
try {
|
|
final Player player = Bukkit.getPlayer(pname);
|
|
if (player == null) {
|
|
return;
|
|
}
|
|
if (this.getStringList(pname).contains(player.getName())) {
|
|
this.getStringList(pname).remove(player.getName());
|
|
save();
|
|
}
|
|
} catch (NoSuchMethodError | Exception e) {
|
|
}
|
|
}
|
|
}
|