From 73ee1f36243e1ba8dea21b77b3d70749061c48cc Mon Sep 17 00:00:00 2001 From: JeromSar Date: Wed, 18 Feb 2015 19:24:04 +0100 Subject: [PATCH] Implement SuperAdmin service --- .../StevenLawson/TotalFreedomMod/TFM_AdminList.java | 11 +++++++++++ .../StevenLawson/TotalFreedomMod/TotalFreedomMod.java | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_AdminList.java b/src/me/StevenLawson/TotalFreedomMod/TFM_AdminList.java index 8cd7bd3..05d8343 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_AdminList.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_AdminList.java @@ -1,5 +1,6 @@ package me.StevenLawson.TotalFreedomMod; +import com.google.common.base.Function; import com.google.common.collect.Sets; import java.util.Collections; import java.util.Date; @@ -24,6 +25,7 @@ import org.bukkit.entity.Player; public class TFM_AdminList { + public static final Function SUPERADMIN_SERVICE; private static final Map adminList; private static final Set superUUIDs; private static final Set telnetUUIDs; @@ -40,6 +42,15 @@ public class TFM_AdminList seniorUUIDs = new HashSet(); seniorConsoleNames = new HashSet(); superIps = new HashSet(); + + SUPERADMIN_SERVICE = new Function() { + + @Override + public Boolean apply(Player f) + { + return isSuperAdmin(f); + } + }; } private TFM_AdminList() diff --git a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java index 8965ab1..ec29de4 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java +++ b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java @@ -1,5 +1,6 @@ package me.StevenLawson.TotalFreedomMod; +import com.google.common.base.Function; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -25,6 +26,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.plugin.PluginManager; +import org.bukkit.plugin.ServicePriority; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; import org.mcstats.Metrics; @@ -111,6 +113,9 @@ public class TotalFreedomMod extends JavaPlugin TFM_ProtectedArea.autoAddSpawnpoints(); } + // Start SuperAdmin service + server.getServicesManager().register(Function.class, TFM_AdminList.SUPERADMIN_SERVICE, plugin, ServicePriority.Normal); + final PluginManager pm = server.getPluginManager(); pm.registerEvents(new TFM_EntityListener(), plugin); pm.registerEvents(new TFM_BlockListener(), plugin);