mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-16 12:26:12 +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;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
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)
|
public void adminChat(CommandSender sender, String message)
|
||||||
{
|
{
|
||||||
String name = sender.getName() + " " + plugin.rm.getDisplay(sender).getColoredTag() + ChatColor.WHITE;
|
Displayable display = plugin.rm.getDisplay(sender);
|
||||||
FLog.info("[ADMIN] " + name + ": " + message);
|
FLog.info("[ADMIN] " + sender.getName() + " " + display.getTag() + ": " + message);
|
||||||
checkMentions(message, true);
|
checkMentions(message, true);
|
||||||
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(player))
|
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,11 +29,18 @@ public class CommandSpy extends FreedomService
|
|||||||
{
|
{
|
||||||
for (Player player : server.getOnlinePlayers())
|
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())
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdmin(event.getPlayer()) && !plugin.al.isSeniorAdmin(player))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (player != event.getPlayer())
|
||||||
{
|
{
|
||||||
FUtil.playerMsg(player, event.getPlayer().getName() + ": " + event.getMessage());
|
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.ConfigLoadable;
|
||||||
import net.pravian.aero.base.ConfigSavable;
|
import net.pravian.aero.base.ConfigSavable;
|
||||||
import net.pravian.aero.base.Validatable;
|
import net.pravian.aero.base.Validatable;
|
||||||
import net.pravian.aero.config.YamlConfig;
|
|
||||||
import net.pravian.aero.util.Ips;
|
import net.pravian.aero.util.Ips;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
@ -46,6 +45,12 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private String tag = null;
|
private String tag = null;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private Boolean commandSpy = false;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private Boolean oldAdminMode = false;
|
||||||
|
|
||||||
public static final String CONFIG_FILENAME = "admins.yml";
|
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);
|
loginMessage = cs.getString("login_message", null);
|
||||||
discordID = cs.getString("discord_id", null);
|
discordID = cs.getString("discord_id", null);
|
||||||
tag = cs.getString("tag", null);
|
tag = cs.getString("tag", null);
|
||||||
|
commandSpy = cs.getBoolean("command_spy", false);
|
||||||
|
oldAdminMode = cs.getBoolean("old_admin_mode", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -112,6 +119,8 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
cs.set("login_message", loginMessage);
|
cs.set("login_message", loginMessage);
|
||||||
cs.set("discord_id", discordID);
|
cs.set("discord_id", discordID);
|
||||||
cs.set("tag", tag);
|
cs.set("tag", tag);
|
||||||
|
cs.set("command_spy", commandSpy);
|
||||||
|
cs.set("old_admin_mode", oldAdminMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAtLeast(Rank pRank)
|
public boolean isAtLeast(Rank pRank)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
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)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
|
|
||||||
FPlayer playerdata = plugin.pl.getPlayer(playerSender);
|
Admin admin = plugin.al.getAdmin(playerSender);
|
||||||
playerdata.setCommandSpy(!playerdata.cmdspyEnabled());
|
admin.setCommandSpy(!admin.getCommandSpy());
|
||||||
msg("CommandSpy " + (playerdata.cmdspyEnabled() ? "enabled." : "disabled."));
|
plugin.al.save();
|
||||||
|
plugin.al.updateTables();
|
||||||
|
msg("CommandSpy " + (admin.getCommandSpy() ? "enabled." : "disabled."));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -105,9 +105,17 @@ public class Command_list extends FreedomCommand
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Displayable display = plugin.rm.getDisplay(p);
|
final Displayable display = plugin.rm.getDisplay(p);
|
||||||
|
if (!senderIsConsole && plugin.al.isAdmin(playerSender) && plugin.al.getAdmin(playerSender).getOldAdminMode())
|
||||||
|
{
|
||||||
|
n.add(getOldPrefix(display) + p.getName());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
n.add(display.getColoredTag() + p.getName());
|
n.add(display.getColoredTag() + p.getName());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
String playerType = listFilter.toString().toLowerCase().replace('_', ' ');
|
String playerType = listFilter.toString().toLowerCase().replace('_', ' ');
|
||||||
onlineUsers.append("Connected ")
|
onlineUsers.append("Connected ")
|
||||||
.append(playerType)
|
.append(playerType)
|
||||||
@ -127,6 +135,24 @@ public class Command_list extends FreedomCommand
|
|||||||
return true;
|
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
|
private enum ListFilter
|
||||||
{
|
{
|
||||||
PLAYERS,
|
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());
|
tag = FUtil.colorize(admin.getTag());
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
plugin.pl.getPlayer(playerSender).setTag(tag);
|
plugin.pl.getPlayer(playerSender).setTag(tag);
|
||||||
|
}
|
||||||
FLog.info(playerSender.getName() + " is no longer vanished.");
|
FLog.info(playerSender.getName() + " is no longer vanished.");
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
|
@ -9,6 +9,8 @@ public interface Displayable
|
|||||||
|
|
||||||
public String getTag();
|
public String getTag();
|
||||||
|
|
||||||
|
public String getAbbr();
|
||||||
|
|
||||||
public ChatColor getColor();
|
public ChatColor getColor();
|
||||||
|
|
||||||
public String getColoredName();
|
public String getColoredName();
|
||||||
|
@ -18,6 +18,8 @@ public enum Rank implements Displayable
|
|||||||
private final Type type;
|
private final Type type;
|
||||||
@Getter
|
@Getter
|
||||||
private final String name;
|
private final String name;
|
||||||
|
@Getter
|
||||||
|
private final String abbr;
|
||||||
private final String determiner;
|
private final String determiner;
|
||||||
@Getter
|
@Getter
|
||||||
private final String tag;
|
private final String tag;
|
||||||
@ -30,9 +32,10 @@ public enum Rank implements Displayable
|
|||||||
{
|
{
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.abbr = abbr;
|
||||||
this.determiner = determiner;
|
this.determiner = determiner;
|
||||||
this.tag = abbr.isEmpty() ? "" : "[" + abbr + "]";
|
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;
|
this.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,6 +51,12 @@ public enum Rank implements Displayable
|
|||||||
return determiner + " " + color + ChatColor.ITALIC + name;
|
return determiner + " " + color + ChatColor.ITALIC + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAbbr()
|
||||||
|
{
|
||||||
|
return abbr;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isConsole()
|
public boolean isConsole()
|
||||||
{
|
{
|
||||||
return getType() == Type.ADMIN_CONSOLE;
|
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)
|
public static Rank findRank(String string)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -13,6 +13,8 @@ public enum Title implements Displayable
|
|||||||
@Getter
|
@Getter
|
||||||
private final String name;
|
private final String name;
|
||||||
@Getter
|
@Getter
|
||||||
|
private final String abbr;
|
||||||
|
@Getter
|
||||||
private final String tag;
|
private final String tag;
|
||||||
@Getter
|
@Getter
|
||||||
private final String coloredTag;
|
private final String coloredTag;
|
||||||
@ -23,8 +25,9 @@ public enum Title implements Displayable
|
|||||||
{
|
{
|
||||||
this.determiner = determiner;
|
this.determiner = determiner;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.tag = "[" + tag + "]";
|
|
||||||
this.coloredTag = ChatColor.DARK_GRAY + "[" + color + tag + ChatColor.DARK_GRAY + "]" + color;
|
this.coloredTag = ChatColor.DARK_GRAY + "[" + color + tag + ChatColor.DARK_GRAY + "]" + color;
|
||||||
|
this.abbr = tag;
|
||||||
|
this.tag = "[" + tag + "]";
|
||||||
this.color = color;
|
this.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,4 +43,10 @@ public enum Title implements Displayable
|
|||||||
return determiner + " " + color + ChatColor.ITALIC + name;
|
return determiner + " " + color + ChatColor.ITALIC + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAbbr()
|
||||||
|
{
|
||||||
|
return abbr;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user