mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-30 02:05:41 +00:00
Old admin mode and commandspy saving
This commit is contained in:
parent
200a856413
commit
ffbe71f5dd
@ -1,6 +1,8 @@
|
||||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
||||
@ -129,17 +131,43 @@ public class ChatManager extends FreedomService
|
||||
}
|
||||
}
|
||||
|
||||
public String getOldPrefix(Displayable display)
|
||||
{
|
||||
ChatColor color = display.getColor();
|
||||
|
||||
if (color.equals(ChatColor.AQUA))
|
||||
{
|
||||
color = ChatColor.GOLD;
|
||||
}
|
||||
else if (color.equals(ChatColor.GOLD))
|
||||
{
|
||||
color = ChatColor.LIGHT_PURPLE;
|
||||
}
|
||||
|
||||
String prefix = "(" + display.getAbbr() + ")";
|
||||
|
||||
return color + prefix;
|
||||
}
|
||||
|
||||
public void adminChat(CommandSender sender, String message)
|
||||
{
|
||||
String name = sender.getName() + " " + plugin.rm.getDisplay(sender).getColoredTag() + ChatColor.WHITE;
|
||||
FLog.info("[ADMIN] " + name + ": " + message);
|
||||
Displayable display = plugin.rm.getDisplay(sender);
|
||||
FLog.info("[ADMIN] " + sender.getName() + " " + display.getTag() + ": " + message);
|
||||
checkMentions(message, true);
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (plugin.al.isAdmin(player))
|
||||
{
|
||||
player.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + name + ": " + ChatColor.GOLD + message);
|
||||
Admin admin = plugin.al.getAdmin(player);
|
||||
if (admin.getOldAdminMode())
|
||||
{
|
||||
player.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + sender.getName() + " " + getOldPrefix(display) + ChatColor.WHITE + ": " + ChatColor.AQUA + message);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + sender.getName() + " " + display.getColoredTag() + ChatColor.WHITE + ": " + ChatColor.GOLD + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,9 +29,16 @@ public class CommandSpy extends FreedomService
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).cmdspyEnabled())
|
||||
if (plugin.al.isAdmin(player) && plugin.al.getAdmin(player).getCommandSpy())
|
||||
{
|
||||
FUtil.playerMsg(player, event.getPlayer().getName() + ": " + event.getMessage());
|
||||
if (plugin.al.isAdmin(event.getPlayer()) && !plugin.al.isSeniorAdmin(player))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (player != event.getPlayer())
|
||||
{
|
||||
FUtil.playerMsg(player, event.getPlayer().getName() + ": " + event.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.base.ConfigLoadable;
|
||||
import net.pravian.aero.base.ConfigSavable;
|
||||
import net.pravian.aero.base.Validatable;
|
||||
import net.pravian.aero.config.YamlConfig;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
@ -46,6 +45,12 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
|
||||
@Getter
|
||||
@Setter
|
||||
private String tag = null;
|
||||
@Getter
|
||||
@Setter
|
||||
private Boolean commandSpy = false;
|
||||
@Getter
|
||||
@Setter
|
||||
private Boolean oldAdminMode = false;
|
||||
|
||||
public static final String CONFIG_FILENAME = "admins.yml";
|
||||
|
||||
@ -98,6 +103,8 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
|
||||
loginMessage = cs.getString("login_message", null);
|
||||
discordID = cs.getString("discord_id", null);
|
||||
tag = cs.getString("tag", null);
|
||||
commandSpy = cs.getBoolean("command_spy", false);
|
||||
oldAdminMode = cs.getBoolean("old_admin_mode", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -112,6 +119,8 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
|
||||
cs.set("login_message", loginMessage);
|
||||
cs.set("discord_id", discordID);
|
||||
cs.set("tag", tag);
|
||||
cs.set("command_spy", commandSpy);
|
||||
cs.set("old_admin_mode", oldAdminMode);
|
||||
}
|
||||
|
||||
public boolean isAtLeast(Rank pRank)
|
||||
|
@ -1,6 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -15,9 +15,11 @@ public class Command_cmdspy extends FreedomCommand
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
|
||||
FPlayer playerdata = plugin.pl.getPlayer(playerSender);
|
||||
playerdata.setCommandSpy(!playerdata.cmdspyEnabled());
|
||||
msg("CommandSpy " + (playerdata.cmdspyEnabled() ? "enabled." : "disabled."));
|
||||
Admin admin = plugin.al.getAdmin(playerSender);
|
||||
admin.setCommandSpy(!admin.getCommandSpy());
|
||||
plugin.al.save();
|
||||
plugin.al.updateTables();
|
||||
msg("CommandSpy " + (admin.getCommandSpy() ? "enabled." : "disabled."));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -105,8 +105,16 @@ public class Command_list extends FreedomCommand
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final Displayable display = plugin.rm.getDisplay(p);
|
||||
n.add(display.getColoredTag() + p.getName());
|
||||
if (!senderIsConsole && plugin.al.isAdmin(playerSender) && plugin.al.getAdmin(playerSender).getOldAdminMode())
|
||||
{
|
||||
n.add(getOldPrefix(display) + p.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
n.add(display.getColoredTag() + p.getName());
|
||||
}
|
||||
}
|
||||
String playerType = listFilter.toString().toLowerCase().replace('_', ' ');
|
||||
onlineUsers.append("Connected ")
|
||||
@ -127,6 +135,24 @@ public class Command_list extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getOldPrefix(Displayable display)
|
||||
{
|
||||
ChatColor color = display.getColor();
|
||||
|
||||
if (color.equals(ChatColor.AQUA))
|
||||
{
|
||||
color = ChatColor.GOLD;
|
||||
}
|
||||
else if (color.equals(ChatColor.GOLD))
|
||||
{
|
||||
color = ChatColor.LIGHT_PURPLE;
|
||||
}
|
||||
|
||||
String prefix = "[" + display.getAbbr() + "]";
|
||||
|
||||
return color + prefix;
|
||||
}
|
||||
|
||||
private enum ListFilter
|
||||
{
|
||||
PLAYERS,
|
||||
|
@ -0,0 +1,26 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Toggle old admin formatting", usage = "/<command>", aliases = "oam")
|
||||
public class Command_oldadminmode extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
|
||||
Admin admin = plugin.al.getAdmin(playerSender);
|
||||
admin.setOldAdminMode(!admin.getOldAdminMode());
|
||||
plugin.al.save();
|
||||
plugin.al.updateTables();
|
||||
msg("Old admin mode has been " + (admin.getOldAdminMode() ? "enabled." : "disabled."));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -39,7 +39,10 @@ public class Command_vanish extends FreedomCommand
|
||||
{
|
||||
tag = FUtil.colorize(admin.getTag());
|
||||
}
|
||||
plugin.pl.getPlayer(playerSender).setTag(tag);
|
||||
else
|
||||
{
|
||||
plugin.pl.getPlayer(playerSender).setTag(tag);
|
||||
}
|
||||
FLog.info(playerSender.getName() + " is no longer vanished.");
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
|
@ -9,6 +9,8 @@ public interface Displayable
|
||||
|
||||
public String getTag();
|
||||
|
||||
public String getAbbr();
|
||||
|
||||
public ChatColor getColor();
|
||||
|
||||
public String getColoredName();
|
||||
|
@ -18,6 +18,8 @@ public enum Rank implements Displayable
|
||||
private final Type type;
|
||||
@Getter
|
||||
private final String name;
|
||||
@Getter
|
||||
private final String abbr;
|
||||
private final String determiner;
|
||||
@Getter
|
||||
private final String tag;
|
||||
@ -30,9 +32,10 @@ public enum Rank implements Displayable
|
||||
{
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
this.abbr = abbr;
|
||||
this.determiner = determiner;
|
||||
this.tag = abbr.isEmpty() ? "" : "[" + abbr + "]";
|
||||
this.coloredTag = abbr.isEmpty() ? "" : ChatColor.DARK_GRAY + "[" + color + abbr + ChatColor.DARK_GRAY + "]" + color;
|
||||
this.coloredTag = ChatColor.DARK_GRAY + "[" + color + abbr + ChatColor.DARK_GRAY + "]" + color;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@ -48,6 +51,12 @@ public enum Rank implements Displayable
|
||||
return determiner + " " + color + ChatColor.ITALIC + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAbbr()
|
||||
{
|
||||
return abbr;
|
||||
}
|
||||
|
||||
public boolean isConsole()
|
||||
{
|
||||
return getType() == Type.ADMIN_CONSOLE;
|
||||
@ -98,21 +107,6 @@ public enum Rank implements Displayable
|
||||
}
|
||||
}
|
||||
|
||||
public Rank getPlayerVariant()
|
||||
{
|
||||
switch (this)
|
||||
{
|
||||
case TELNET_ADMIN:
|
||||
case TELNET_CONSOLE:
|
||||
return TELNET_ADMIN;
|
||||
case SENIOR_ADMIN:
|
||||
case SENIOR_CONSOLE:
|
||||
return SENIOR_ADMIN;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Rank findRank(String string)
|
||||
{
|
||||
try
|
||||
|
@ -13,6 +13,8 @@ public enum Title implements Displayable
|
||||
@Getter
|
||||
private final String name;
|
||||
@Getter
|
||||
private final String abbr;
|
||||
@Getter
|
||||
private final String tag;
|
||||
@Getter
|
||||
private final String coloredTag;
|
||||
@ -23,8 +25,9 @@ public enum Title implements Displayable
|
||||
{
|
||||
this.determiner = determiner;
|
||||
this.name = name;
|
||||
this.tag = "[" + tag + "]";
|
||||
this.coloredTag = ChatColor.DARK_GRAY + "[" + color + tag + ChatColor.DARK_GRAY + "]" + color;
|
||||
this.abbr = tag;
|
||||
this.tag = "[" + tag + "]";
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@ -40,4 +43,10 @@ public enum Title implements Displayable
|
||||
return determiner + " " + color + ChatColor.ITALIC + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAbbr()
|
||||
{
|
||||
return abbr;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user