Added preliminary TFM support for TelnetRequestDataTagsEvent.

This commit is contained in:
StevenLawson 2014-08-20 21:23:22 -04:00
parent b02764ddca
commit d0a435a5d6

View File

@ -1,10 +1,16 @@
package me.StevenLawson.TotalFreedomMod.Listener; package me.StevenLawson.TotalFreedomMod.Listener;
import java.util.Iterator;
import java.util.Map;
import me.StevenLawson.BukkitTelnet.api.TelnetCommandEvent; import me.StevenLawson.BukkitTelnet.api.TelnetCommandEvent;
import me.StevenLawson.BukkitTelnet.api.TelnetRequestDataTagsEvent;
import me.StevenLawson.BukkitTelnet.api.TelnetPreLoginEvent; import me.StevenLawson.BukkitTelnet.api.TelnetPreLoginEvent;
import me.StevenLawson.TotalFreedomMod.Bridge.TFM_EssentialsBridge;
import me.StevenLawson.TotalFreedomMod.TFM_CommandBlocker; import me.StevenLawson.TotalFreedomMod.TFM_CommandBlocker;
import me.StevenLawson.TotalFreedomMod.TFM_Admin; import me.StevenLawson.TotalFreedomMod.TFM_Admin;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList; import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -40,4 +46,38 @@ public class TFM_TelnetListener implements Listener
event.setCancelled(true); event.setCancelled(true);
} }
} }
@EventHandler(priority = EventPriority.NORMAL)
public void onTelnetRequestDataTags(TelnetRequestDataTagsEvent event)
{
final Iterator<Map.Entry<Player, Map<String, Object>>> it = event.getDataTags().entrySet().iterator();
while (it.hasNext())
{
final Map.Entry<Player, Map<String, Object>> entry = it.next();
final Player player = entry.getKey();
final Map<String, Object> playerTags = entry.getValue();
boolean isAdmin = false;
boolean isTelnetAdmin = false;
boolean isSeniorAdmin = false;
final TFM_Admin admin = TFM_AdminList.getEntry(player);
if (admin != null)
{
boolean isActivated = admin.isActivated();
isAdmin = isActivated;
isTelnetAdmin = isActivated && admin.isTelnetAdmin();
isSeniorAdmin = isActivated && admin.isSeniorAdmin();
}
playerTags.put("tfm.admin.isAdmin", isAdmin);
playerTags.put("tfm.admin.isTelnetAdmin", isTelnetAdmin);
playerTags.put("tfm.admin.isSeniorAdmin", isSeniorAdmin);
playerTags.put("tfm.playerdata.getTag", TFM_PlayerData.getPlayerData(player).getTag());
playerTags.put("tfm.essentialsBridge.getNickname", TFM_EssentialsBridge.getNickname(player.getName()));
}
}
} }