From 770db8d5940201b30a382a9c170475c0ae86999a Mon Sep 17 00:00:00 2001 From: Steven Lawson Date: Tue, 20 Sep 2011 23:31:59 -0400 Subject: [PATCH] Added config.yml based superadmin list. --- .../TotalFreedomMod/TotalFreedomMod.java | 32 ++++++++++++------- src/plugin.yml | 2 +- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java index 978749bd..ead79c2b 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java +++ b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java @@ -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 superadmins = new ArrayList(); 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); } } diff --git a/src/plugin.yml b/src/plugin.yml index ec774235..c06b9849 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -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: