mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-28 12:47:36 +00:00
Switched over to TelnetCommandEvent
some TFM_CommandBlocker cleanup
This commit is contained in:
parent
4daad76e74
commit
9c61cc2768
@ -1,3 +1,3 @@
|
||||
#Build Number for ANT. Do not edit!
|
||||
#Tue Dec 17 15:17:32 CET 2013
|
||||
build.number=681
|
||||
#Tue Dec 17 16:24:16 CET 2013
|
||||
build.number=682
|
||||
|
@ -1,24 +1,17 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Listener;
|
||||
|
||||
import java.util.Set;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_CommandBlocker;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.RemoteServerCommandEvent;
|
||||
import org.bukkit.event.server.ServerCommandEvent;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class TFM_ServerListener implements Listener
|
||||
{
|
||||
@ -57,6 +50,7 @@ public class TFM_ServerListener implements Listener
|
||||
}
|
||||
}
|
||||
}*/
|
||||
@Deprecated // Moved to TFM_TelnetListener
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onRemoteServerCommand(RemoteServerCommandEvent event)
|
||||
{
|
||||
@ -66,6 +60,7 @@ public class TFM_ServerListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated // Moved to TFM_TelnetListener
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onServerCommand(ServerCommandEvent event)
|
||||
{
|
||||
@ -97,111 +92,4 @@ public class TFM_ServerListener implements Listener
|
||||
event.setMotd(ChatColor.RED + "Server is full.");
|
||||
}
|
||||
}
|
||||
|
||||
private static class TFM_ServerListener_DummyCommandSender implements CommandSender
|
||||
{
|
||||
private final String senderName;
|
||||
|
||||
public TFM_ServerListener_DummyCommandSender(String senderName)
|
||||
{
|
||||
this.senderName = senderName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String[] messages)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Server getServer()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return senderName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(String name)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(Permission perm)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String name)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(Permission perm)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionAttachment addAttachment(Plugin plugin)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionAttachment addAttachment(Plugin plugin, int ticks)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttachment(PermissionAttachment attachment)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recalculatePermissions()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<PermissionAttachmentInfo> getEffectivePermissions()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOp()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOp(boolean value)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Listener;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_CommandBlocker;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Superadmin;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -9,12 +9,12 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class TFM_CustomListener implements Listener
|
||||
public class TFM_TelnetListener implements Listener
|
||||
{
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onTelnetPreLogin(me.StevenLawson.BukkitTelnet.TelnetPreLoginEvent event)
|
||||
{
|
||||
|
||||
{
|
||||
|
||||
final String ip = event.getIp();
|
||||
if (ip == null || ip.isEmpty())
|
||||
{
|
||||
@ -36,7 +36,16 @@ public class TFM_CustomListener implements Listener
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
event.setName(player.getName());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onTelnetCommand(me.StevenLawson.BukkitTelnet.TelnetCommandEvent event)
|
||||
{
|
||||
if (TFM_CommandBlocker.getInstance().isCommandBlocked(event.getCommand(), event.getSender()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -14,14 +14,13 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class TFM_CommandBlocker
|
||||
{
|
||||
private Map<String, TFM_CommandBlocker_BlockedCommandEntry> blockedCommands = new HashMap<String, TFM_CommandBlocker_BlockedCommandEntry>();
|
||||
private Map<String, CommandBlockerEntry> blockedCommands = new HashMap<String, CommandBlockerEntry>();
|
||||
|
||||
private TFM_CommandBlocker()
|
||||
{
|
||||
parseBlockingRules();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public final void parseBlockingRules()
|
||||
{
|
||||
blockedCommands.clear();
|
||||
@ -83,7 +82,7 @@ public class TFM_CommandBlocker
|
||||
message = parts[3];
|
||||
}
|
||||
|
||||
TFM_CommandBlocker_BlockedCommandEntry blockedCommandEntry = new TFM_CommandBlocker_BlockedCommandEntry(rank, action, command, message);
|
||||
CommandBlockerEntry blockedCommandEntry = new CommandBlockerEntry(rank, action, command, message);
|
||||
|
||||
Command bukkitCommand = commandMap.getCommand(command);
|
||||
if (bukkitCommand == null)
|
||||
@ -137,7 +136,7 @@ public class TFM_CommandBlocker
|
||||
return false;
|
||||
}
|
||||
|
||||
TFM_CommandBlocker_BlockedCommandEntry blockedCommandEntry = blockedCommands.get(command);
|
||||
final CommandBlockerEntry blockedCommandEntry = blockedCommands.get(command);
|
||||
|
||||
if (blockedCommandEntry != null)
|
||||
{
|
||||
@ -224,7 +223,9 @@ public class TFM_CommandBlocker
|
||||
|
||||
private enum CommandBlockerAction
|
||||
{
|
||||
BLOCK("b"), BLOCK_AND_EJECT("a"), BLOCK_UNKNOWN("u");
|
||||
BLOCK("b"),
|
||||
BLOCK_AND_EJECT("a"),
|
||||
BLOCK_UNKNOWN("u");
|
||||
private final String token;
|
||||
|
||||
private CommandBlockerAction(String token)
|
||||
@ -250,14 +251,14 @@ public class TFM_CommandBlocker
|
||||
}
|
||||
}
|
||||
|
||||
private static class TFM_CommandBlocker_BlockedCommandEntry
|
||||
private static class CommandBlockerEntry
|
||||
{
|
||||
private final CommandBlockerRank rank;
|
||||
private final CommandBlockerAction action;
|
||||
private String command;
|
||||
private final String message;
|
||||
|
||||
public TFM_CommandBlocker_BlockedCommandEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String message)
|
||||
public CommandBlockerEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String message)
|
||||
{
|
||||
this.rank = rank;
|
||||
this.action = action;
|
||||
@ -321,10 +322,10 @@ public class TFM_CommandBlocker
|
||||
|
||||
public static TFM_CommandBlocker getInstance()
|
||||
{
|
||||
return TFM_CommandBlockerNewHolder.INSTANCE;
|
||||
return TFM_CommandBlockerHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class TFM_CommandBlockerNewHolder
|
||||
private static class TFM_CommandBlockerHolder
|
||||
{
|
||||
private static final TFM_CommandBlocker INSTANCE = new TFM_CommandBlocker();
|
||||
}
|
||||
|
@ -3,7 +3,12 @@ package me.StevenLawson.TotalFreedomMod;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command;
|
||||
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
|
||||
import me.StevenLawson.TotalFreedomMod.HTTPD.TFM_HTTPD_Manager;
|
||||
@ -309,7 +314,7 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
pm.registerEvents(new TFM_PlayerListener(), plugin);
|
||||
pm.registerEvents(new TFM_WeatherListener(), plugin);
|
||||
pm.registerEvents(new TFM_ServerListener(), plugin);
|
||||
pm.registerEvents(new TFM_CustomListener(), plugin);
|
||||
pm.registerEvents(new TFM_TelnetListener(), plugin);
|
||||
}
|
||||
|
||||
private static void setAppProperties()
|
||||
|
Loading…
Reference in New Issue
Block a user