Added config.yml based superadmin list.

This commit is contained in:
Steven Lawson 2011-09-20 23:31:59 -04:00
parent f528d5be97
commit 770db8d594
2 changed files with 21 additions and 13 deletions

View file

@ -1,6 +1,7 @@
package me.StevenLawson.TotalFreedomMod;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
@ -9,14 +10,29 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.config.Configuration;
public class TotalFreedomMod extends JavaPlugin
{
private Logger log = Logger.getLogger("Minecraft");
private static final Logger log = Logger.getLogger("Minecraft");
protected static Configuration CONFIG;
private List<String> superadmins = new ArrayList<String>();
public void onEnable()
{
CONFIG = getConfiguration();
CONFIG.load();
if (CONFIG.getString("superadmins", null) == null)
{
log.log(Level.INFO, "[Total Freedom Mod] - Generating default config file (plugins/TotalFreedomMod/config.yml)...");
CONFIG.setProperty("superadmins", new String[] {"madgeek1450", "markbyron"});
CONFIG.save();
CONFIG.load();
}
superadmins = CONFIG.getStringList("superadmins", null);
log.log(Level.INFO, "[Total Freedom Mod] - Enabled! - Version: " + this.getDescription().getVersion() + " by Madgeek1450");
log.log(Level.INFO, "[Total Freedom Mod] - Loaded superadmins: " + superadmins.toString());
if (!Bukkit.getOnlineMode())
{
@ -204,15 +220,7 @@ public class TotalFreedomMod extends JavaPlugin
private boolean isUserSuperadmin(String userName)
{
if (!Bukkit.getOnlineMode())
{
return false;
}
return Arrays.asList(
"miwojedk",
"markbyron",
"madgeek1450"
).contains(userName.toLowerCase());
if (!Bukkit.getOnlineMode()) return false;
return superadmins.contains(userName);
}
}

View file

@ -1,6 +1,6 @@
name: TotalFreedomMod
main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod
version: 1.0.2
version: 1.1.2
description: Plugin for the Total Freedom server
author: StevenLawson / Madgeek1450
commands: