mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Merge branch 'master' into frontdoor
This commit is contained in:
commit
3babf8388c
@ -2,5 +2,17 @@ package me.StevenLawson.TotalFreedomMod.Commands;
|
|||||||
|
|
||||||
public enum AdminLevel
|
public enum AdminLevel
|
||||||
{
|
{
|
||||||
ALL, OP, SUPER, SENIOR
|
ALL("All Player Commands"), OP("OP Commands"), SUPER("SuperAdmin Commands"), SENIOR("Senior Admin Commands");
|
||||||
|
//
|
||||||
|
private final String friendlyName;
|
||||||
|
|
||||||
|
private AdminLevel(String friendlyName)
|
||||||
|
{
|
||||||
|
this.friendlyName = friendlyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFriendlyName()
|
||||||
|
{
|
||||||
|
return friendlyName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,21 +46,7 @@ public class TFM_CommandLoader
|
|||||||
|
|
||||||
for (TFM_CommandInfo commandInfo : commandList)
|
for (TFM_CommandInfo commandInfo : commandList)
|
||||||
{
|
{
|
||||||
String description = commandInfo.getDescription();
|
TFM_DynamicCommand dynamicCommand = new TFM_DynamicCommand(commandInfo);
|
||||||
switch (commandInfo.getLevel())
|
|
||||||
{
|
|
||||||
case SENIOR:
|
|
||||||
description = "Senior " + (commandInfo.getSource() == SourceType.ONLY_CONSOLE ? "Console" : "") + " Command - " + description;
|
|
||||||
break;
|
|
||||||
case SUPER:
|
|
||||||
description = "Superadmin Command - " + description;
|
|
||||||
break;
|
|
||||||
case OP:
|
|
||||||
description = "OP Command - " + description;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
TFM_DynamicCommand dynamicCommand = new TFM_DynamicCommand(commandInfo.getCommandName(), description, commandInfo.getUsage(), commandInfo.getAliases());
|
|
||||||
|
|
||||||
Command existing = commandMap.getCommand(dynamicCommand.getName());
|
Command existing = commandMap.getCommand(dynamicCommand.getName());
|
||||||
if (existing != null)
|
if (existing != null)
|
||||||
@ -191,7 +177,7 @@ public class TFM_CommandLoader
|
|||||||
return commandList;
|
return commandList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TFM_CommandInfo
|
public static class TFM_CommandInfo
|
||||||
{
|
{
|
||||||
private final String commandName;
|
private final String commandName;
|
||||||
private final Class<?> commandClass;
|
private final Class<?> commandClass;
|
||||||
@ -234,6 +220,26 @@ public class TFM_CommandLoader
|
|||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDescriptionPermissioned()
|
||||||
|
{
|
||||||
|
String _description = description;
|
||||||
|
|
||||||
|
switch (this.getLevel())
|
||||||
|
{
|
||||||
|
case SENIOR:
|
||||||
|
_description = "Senior " + (this.getSource() == SourceType.ONLY_CONSOLE ? "Console" : "") + " Command - " + _description;
|
||||||
|
break;
|
||||||
|
case SUPER:
|
||||||
|
_description = "Superadmin Command - " + _description;
|
||||||
|
break;
|
||||||
|
case OP:
|
||||||
|
_description = "OP Command - " + _description;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _description;
|
||||||
|
}
|
||||||
|
|
||||||
public AdminLevel getLevel()
|
public AdminLevel getLevel()
|
||||||
{
|
{
|
||||||
return level;
|
return level;
|
||||||
@ -270,11 +276,15 @@ public class TFM_CommandLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TFM_DynamicCommand extends Command implements PluginIdentifiableCommand
|
public class TFM_DynamicCommand extends Command implements PluginIdentifiableCommand
|
||||||
{
|
{
|
||||||
public TFM_DynamicCommand(String commandName, String description, String usage, List<String> aliases)
|
private final TFM_CommandInfo commandInfo;
|
||||||
|
|
||||||
|
private TFM_DynamicCommand(TFM_CommandInfo commandInfo)
|
||||||
{
|
{
|
||||||
super(commandName, description, usage, aliases);
|
super(commandInfo.getCommandName(), commandInfo.getDescriptionPermissioned(), commandInfo.getUsage(), commandInfo.getAliases());
|
||||||
|
|
||||||
|
this.commandInfo = commandInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -312,6 +322,11 @@ public class TFM_CommandLoader
|
|||||||
{
|
{
|
||||||
return TotalFreedomMod.plugin;
|
return TotalFreedomMod.plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TFM_CommandInfo getCommandInfo()
|
||||||
|
{
|
||||||
|
return commandInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TFM_CommandLoader getInstance()
|
public static TFM_CommandLoader getInstance()
|
||||||
|
@ -7,14 +7,16 @@ import java.util.HashMap;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import me.StevenLawson.TotalFreedomMod.Commands.AdminLevel;
|
||||||
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
|
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
|
||||||
|
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader.TFM_DynamicCommand;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandMap;
|
import org.bukkit.command.CommandMap;
|
||||||
import org.bukkit.command.PluginIdentifiableCommand;
|
import org.bukkit.command.PluginIdentifiableCommand;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import static me.StevenLawson.TotalFreedomMod.HTTPD.HTMLGenerationTools.*;
|
import static me.StevenLawson.TotalFreedomMod.HTTPD.HTMLGenerationTools.*;
|
||||||
import static org.apache.commons.lang3.StringEscapeUtils.*;
|
import static org.apache.commons.lang3.StringEscapeUtils.*;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
public class Module_help extends TFM_HTTPD_Module
|
public class Module_help extends TFM_HTTPD_Module
|
||||||
{
|
{
|
||||||
@ -36,7 +38,11 @@ public class Module_help extends TFM_HTTPD_Module
|
|||||||
return paragraph("Error loading commands.");
|
return paragraph("Error loading commands.");
|
||||||
}
|
}
|
||||||
|
|
||||||
responseBody.append(heading("Command Help", 1)).append(paragraph("This page is an automatically generated listing of all plugin commands that are currently live on the server. Please note that it does not include vanilla server commands."));
|
responseBody
|
||||||
|
.append(heading("Command Help", 1))
|
||||||
|
.append(paragraph(
|
||||||
|
"This page is an automatically generated listing of all plugin commands that are currently live on the server. "
|
||||||
|
+ "Please note that it does not include vanilla server commands."));
|
||||||
|
|
||||||
final Map<String, List<Command>> commandsByPlugin = new HashMap<String, List<Command>>();
|
final Map<String, List<Command>> commandsByPlugin = new HashMap<String, List<Command>>();
|
||||||
|
|
||||||
@ -74,31 +80,31 @@ public class Module_help extends TFM_HTTPD_Module
|
|||||||
@Override
|
@Override
|
||||||
public int compare(Command a, Command b)
|
public int compare(Command a, Command b)
|
||||||
{
|
{
|
||||||
|
if (a instanceof TFM_DynamicCommand && b instanceof TFM_DynamicCommand)
|
||||||
|
{
|
||||||
|
String aName = ((TFM_DynamicCommand) a).getCommandInfo().getLevel().name() + a.getName();
|
||||||
|
String bName = ((TFM_DynamicCommand) b).getCommandInfo().getLevel().name() + b.getName();
|
||||||
|
return aName.compareTo(bName);
|
||||||
|
}
|
||||||
return a.getName().compareTo(b.getName());
|
return a.getName().compareTo(b.getName());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
responseBody.append(heading(pluginName, 2)).append("<ul>\r\n");
|
responseBody.append(heading(pluginName, 2)).append("<ul>\r\n");
|
||||||
|
|
||||||
|
AdminLevel lastTfmCommandLevel = null;
|
||||||
for (Command command : commands)
|
for (Command command : commands)
|
||||||
{
|
{
|
||||||
responseBody
|
if ("TotalFreedomMod".equals(pluginName))
|
||||||
.append("<li><div><span class=\"commandName\">")
|
|
||||||
.append(escapeHtml4(command.getName()))
|
|
||||||
.append("</span> - Usage: <span class=\"commandUsage\">")
|
|
||||||
.append(escapeHtml4(command.getUsage().replace("<command>", command.getName()).trim()))
|
|
||||||
.append("</span>");
|
|
||||||
|
|
||||||
if (!command.getAliases().isEmpty())
|
|
||||||
{
|
{
|
||||||
responseBody.append(" - Aliases: <span class=\"commandAliases\">")
|
AdminLevel tfmCommandLevel = ((TFM_DynamicCommand) command).getCommandInfo().getLevel();
|
||||||
.append(escapeHtml4(StringUtils.join(command.getAliases(), ", ")))
|
if (lastTfmCommandLevel == null || lastTfmCommandLevel != tfmCommandLevel)
|
||||||
.append("</span>");
|
{
|
||||||
|
responseBody.append("</ul>\r\n").append(heading(tfmCommandLevel.getFriendlyName(), 3)).append("<ul>\r\n");
|
||||||
}
|
}
|
||||||
|
lastTfmCommandLevel = tfmCommandLevel;
|
||||||
responseBody.append("<br /><span class=\"commandDescription\">")
|
}
|
||||||
.append(escapeHtml4(command.getDescription()))
|
responseBody.append(buildDescription(command));
|
||||||
.append("</span></div></li>\r\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
responseBody.append("</ul>\r\n");
|
responseBody.append("</ul>\r\n");
|
||||||
@ -107,10 +113,33 @@ public class Module_help extends TFM_HTTPD_Module
|
|||||||
return responseBody.toString();
|
return responseBody.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String buildDescription(Command command)
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
sb.append(
|
||||||
|
"<li><span class=\"commandName\">{$CMD_NAME}</span> - Usage: <span class=\"commandUsage\">{$CMD_USAGE}</span>"
|
||||||
|
.replace("{$CMD_NAME}", escapeHtml4(command.getName().trim()))
|
||||||
|
.replace("{$CMD_USAGE}", escapeHtml4(command.getUsage().trim())));
|
||||||
|
|
||||||
|
if (!command.getAliases().isEmpty())
|
||||||
|
{
|
||||||
|
sb.append(
|
||||||
|
" - Aliases: <span class=\"commandAliases\">{$CMD_ALIASES}</span>"
|
||||||
|
.replace("{$CMD_ALIASES}", escapeHtml4(StringUtils.join(command.getAliases(), ", "))));
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.append(
|
||||||
|
"<br><span class=\"commandDescription\">{$CMD_DESC}</span></li>\r\n"
|
||||||
|
.replace("{$CMD_DESC}", escapeHtml4(command.getDescription().trim())));
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTitle()
|
public String getTitle()
|
||||||
{
|
{
|
||||||
return "TotalFreedomMod :: WebHelp";
|
return "TotalFreedomMod :: Command Help";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -99,6 +99,7 @@ public class TFM_ProtectedArea implements Serializable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public static void loadProtectedAreas()
|
public static void loadProtectedAreas()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -48,6 +48,7 @@ public class TFM_ServerInterface
|
|||||||
nameBans.remove(name);
|
nameBans.remove(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public static void banUsername(String name, String reason, String source, Date expireDate)
|
public static void banUsername(String name, String reason, String source, Date expireDate)
|
||||||
{
|
{
|
||||||
name = name.toLowerCase().trim();
|
name = name.toLowerCase().trim();
|
||||||
|
@ -795,6 +795,7 @@ public class TFM_Util
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public static boolean isFromHostConsole(String senderName)
|
public static boolean isFromHostConsole(String senderName)
|
||||||
{
|
{
|
||||||
return ((List<String>) TFM_ConfigEntry.HOST_SENDER_NAMES.getList()).contains(senderName.toLowerCase());
|
return ((List<String>) TFM_ConfigEntry.HOST_SENDER_NAMES.getList()).contains(senderName.toLowerCase());
|
||||||
|
Loading…
Reference in New Issue
Block a user