Myadmin tags and misc improvements

This commit is contained in:
ZeroEpoch1969 2018-02-21 18:22:13 -07:00
parent c8683ea489
commit 2bffcef9a9
No known key found for this signature in database
GPG Key ID: E0AAB104FB9F8FDF
8 changed files with 78 additions and 11 deletions

View File

@ -158,9 +158,9 @@
<dependency> <dependency>
<groupId>net.dv8tion</groupId> <groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId> <artifactId>JDA</artifactId>
<version>3.5.0_327-withDependencies</version> <version>3.5.1_339-withDependencies</version>
<scope>system</scope> <scope>system</scope>
<systemPath>${project.basedir}/lib/JDA-3.5.0_327-withDependencies.jar</systemPath> <systemPath>${project.basedir}/lib/JDA-3.5.1_339-withDependencies.jar</systemPath>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -43,6 +43,9 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
@Getter @Getter
@Setter @Setter
private String discordID = null; private String discordID = null;
@Getter
@Setter
private String tag = null;
public static final String CONFIG_FILENAME = "admins.yml"; public static final String CONFIG_FILENAME = "admins.yml";
@ -69,7 +72,8 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
.append("- Custom Login Message: ").append(loginMessage).append("\n") .append("- Custom Login Message: ").append(loginMessage).append("\n")
.append("- Rank: ").append(rank.getName()).append("\n") .append("- Rank: ").append(rank.getName()).append("\n")
.append("- Is Active: ").append(active).append("\n") .append("- Is Active: ").append(active).append("\n")
.append("- Discord ID: ").append(discordID).append("\n"); .append("- Discord ID: ").append(discordID).append("\n")
.append("- Tag: ").append(tag);
return output.toString(); return output.toString();
} }
@ -93,6 +97,7 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
lastLogin = FUtil.stringToDate(cs.getString("last_login")); lastLogin = FUtil.stringToDate(cs.getString("last_login"));
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);
} }
@Override @Override
@ -106,6 +111,7 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
cs.set("last_login", FUtil.dateToString(lastLogin)); cs.set("last_login", FUtil.dateToString(lastLogin));
cs.set("login_message", loginMessage); cs.set("login_message", loginMessage);
cs.set("discord_id", discordID); cs.set("discord_id", discordID);
cs.set("tag", tag);
} }
public boolean isAtLeast(Rank pRank) public boolean isAtLeast(Rank pRank)

View File

@ -13,7 +13,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH) @CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Manage my admin entry", usage = "/<command> [-o <admin>] <clearips | clearip <ip> | setlogin <message> | clearlogin>") @CommandParameters(description = "Manage my admin entry", usage = "/<command> [-o <admin>] <clearips | clearip <ip> | setlogin <message> | clearlogin | settag <tag> | cleartag>")
public class Command_myadmin extends FreedomCommand public class Command_myadmin extends FreedomCommand
{ {
@ -160,6 +160,27 @@ public class Command_myadmin extends FreedomCommand
return true; return true;
} }
case "settag":
{
FUtil.adminAction(sender.getName(), "Setting personal default tag" + (init == null ? "" : " for " + targetPlayer.getName()), false);
String tag = StringUtils.join(args, " ", 1, args.length);
target.setTag(tag);
msg((init == null ? "Your" : targetPlayer.getName() + "'s") + " default tag is now: " + FUtil.colorize(target.getTag()));
plugin.al.save();
plugin.al.updateTables();
return true;
}
case "cleartag":
{
FUtil.adminAction(sender.getName(), "Clearing personal default tag" + (init == null ? "" : " for " + targetPlayer.getName()), false);
String tag = StringUtils.join(args, " ", 1, args.length);
target.setTag(null);
plugin.al.save();
plugin.al.updateTables();
return true;
}
default: default:
{ {
return false; return false;

View File

@ -8,7 +8,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH) @CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Op everyone on the server, optionally change everyone's gamemode at the same time.", usage = "/<command> [-c | -s]") @CommandParameters(description = "Op everyone on the server, optionally change everyone's gamemode at the same time.", usage = "/<command> [-c | -s | -a]")
public class Command_opall extends FreedomCommand public class Command_opall extends FreedomCommand
{ {
@ -31,6 +31,11 @@ public class Command_opall extends FreedomCommand
doSetGamemode = true; doSetGamemode = true;
targetGamemode = GameMode.SURVIVAL; targetGamemode = GameMode.SURVIVAL;
} }
else if (args[0].equals("-a"))
{
doSetGamemode = true;
targetGamemode = GameMode.ADVENTURE;
}
} }
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())

View File

@ -2,22 +2,36 @@ package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH) @CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Sets everyone's Worldedit block modification limit to the default.", usage = "/<command>", aliases = "setl,swl") @CommandParameters(description = "Sets everyone's Worldedit block modification limit to the default limit or to a custom limit.", usage = "/<command> [limit]", aliases = "setl,swl")
public class Command_setlimit extends FreedomCommand public class Command_setlimit extends FreedomCommand
{ {
@Override @Override
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)
{ {
FUtil.adminAction(sender.getName(), "Setting everyone's Worldedit block modification limit to 2500.", true); int amount = 2500;
if (args.length > 0)
{
try
{
amount = Math.max(1, Math.min(10000, Integer.parseInt(args[0])));
}
catch (NumberFormatException ex)
{
msg("Invalid number: " + args[0], ChatColor.RED);
return true;
}
}
FUtil.adminAction(sender.getName(), "Setting everyone's Worldedit block modification limit to " + amount + ".", true);
for (final Player player : server.getOnlinePlayers()) for (final Player player : server.getOnlinePlayers())
{ {
plugin.web.setLimit(player, 2500); plugin.web.setLimit(player, amount);
} }
return true; return true;
} }

View File

@ -2,13 +2,14 @@ package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH) @CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Kicks everyone and stops the server.", usage = "/<command>") @CommandParameters(description = "Kicks everyone and stops the server.", usage = "/<command> [reason]")
public class Command_stop extends FreedomCommand public class Command_stop extends FreedomCommand
{ {
@ -17,9 +18,16 @@ public class Command_stop extends FreedomCommand
{ {
FUtil.bcastMsg("Server is going offline!", ChatColor.LIGHT_PURPLE); FUtil.bcastMsg("Server is going offline!", ChatColor.LIGHT_PURPLE);
String reason = "Server is going offline, come back in about 20 seconds.";
if (args.length > 0)
{
reason = StringUtils.join(args, " ", 0, args.length);
}
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
player.kickPlayer("Server is going offline, come back in about 20 seconds."); player.kickPlayer(reason);
} }
server.shutdown(); server.shutdown();

View File

@ -16,7 +16,7 @@ public class Command_wipewarps extends FreedomCommand
@Override @Override
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)
{ {
if (!server.getPluginManager().isPluginEnabled("Essentials")) if (!plugin.esb.isEssentialsEnabled())
{ {
msg("Essentials is not enabled on this server"); msg("Essentials is not enabled on this server");
return true; return true;

View File

@ -114,6 +114,10 @@ public class RankManager extends FreedomService
public void updateDisplay(Player player) public void updateDisplay(Player player)
{ {
if (!player.isOnline())
{
return;
}
FPlayer fPlayer = plugin.pl.getPlayer(player); FPlayer fPlayer = plugin.pl.getPlayer(player);
if (plugin.al.isAdmin(player)) if (plugin.al.isAdmin(player))
{ {
@ -190,6 +194,15 @@ public class RankManager extends FreedomService
FUtil.bcastMsg(ChatColor.AQUA + player.getName() + " is " + loginMsg); FUtil.bcastMsg(ChatColor.AQUA + player.getName() + " is " + loginMsg);
plugin.pl.getPlayer(player).setTag(display.getColoredTag()); plugin.pl.getPlayer(player).setTag(display.getColoredTag());
if (isAdmin)
{
Admin admin = plugin.al.getAdmin(player);
if (admin.getTag() != null)
{
plugin.pl.getPlayer(player).setTag(FUtil.colorize(admin.getTag()));
}
}
String displayName = display.getColor() + player.getName(); String displayName = display.getColor() + player.getName();
try try
{ {