Telesphoreo 2020-11-09 21:05:33 -06:00
parent 609053e13f
commit 2c19ce5c65
4 changed files with 79 additions and 12 deletions

View File

@ -13,10 +13,9 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "List, add, or remove master builders, reload the master builder list, or view the info of master builders.", usage = "/<command> <list | <<add | remove> <username>>>")
@CommandParameters(description = "List, add, or remove master builders. Master builders can also clear their own IPs.", usage = "/<command> <list | clearip <ip> | clearips | <<add | remove> <username>>>")
public class Command_mbconfig extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
@ -33,6 +32,68 @@ public class Command_mbconfig extends FreedomCommand
return true;
}
case "clearips":
{
if (args.length > 1)
{
return false;
}
if (senderIsConsole)
{
msg("Only in-game players may use this command.", ChatColor.RED);
return true;
}
PlayerData data = plugin.pl.getData(sender.getName());
if (!data.isMasterBuilder())
{
msg("You are not a master builder!", ChatColor.RED);
return true;
}
int counter = data.getIps().size() - 1;
data.clearIps();
data.addIp(FUtil.getIp(playerSender));
plugin.sql.addPlayer(data);
msg(counter + " IPs removed.");
msg(data.getIps().get(0) + " is now your only IP address");
FUtil.staffAction(sender.getName(), "Clearing my IPs", true);
return true;
}
case "clearip":
{
if (args.length < 2)
{
return false;
}
if (senderIsConsole)
{
msg("Only in-game players may use this command.", ChatColor.RED);
return true;
}
PlayerData data = plugin.pl.getData(sender.getName());
final String targetIp = FUtil.getIp(playerSender);
if (!data.isMasterBuilder())
{
msg("You are not a master builder!", ChatColor.RED);
return true;
}
if (targetIp.equals(args[1]))
{
msg("You cannot remove your current IP.");
return true;
}
data.removeIp(args[1]);
plugin.sql.addPlayer(data);
msg("Removed IP " + args[1]);
msg("Current IPs: " + StringUtils.join(data.getIps(), ", "));
return true;
}
case "add":
{
if (args.length < 2)
@ -123,7 +184,6 @@ public class Command_mbconfig extends FreedomCommand
}
return true;
}
default:
{
return false;
@ -136,7 +196,7 @@ public class Command_mbconfig extends FreedomCommand
{
if (args.length == 1)
{
return Arrays.asList("add", "remove", "list");
return Arrays.asList("add", "remove", "list", "clearips", "clearip");
}
else if (args.length == 2)
{
@ -144,10 +204,19 @@ public class Command_mbconfig extends FreedomCommand
{
return FUtil.getPlayerList();
}
else if (args[0].equalsIgnoreCase("remove") || args[0].equalsIgnoreCase("list"))
else if (args[0].equalsIgnoreCase("remove"))
{
return plugin.pl.getMasterBuilderNames();
}
else if (args[0].equalsIgnoreCase("clearip"))
{
PlayerData data = plugin.pl.getData(sender.getName());
if (data.isMasterBuilder())
{
return data.getIps();
}
return Collections.emptyList();
}
}
return Collections.emptyList();
}

View File

@ -5,6 +5,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.discord.Discord;
import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.staff.StaffMember;
@ -16,10 +17,9 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Manage your staff entry.", usage = "/<command> [-o <staff member>] <clearips | clearip <ip> | setlogin <message> | clearlogin | setscformat <format> | clearscformat> | oldtags | logstick | syncroles>")
@CommandParameters(description = "Manage your admin entry.", usage = "/<command> [-o <admin name>] <clearips | clearip <ip> | setlogin <message> | clearlogin | setscformat <format> | clearscformat> | oldtags | logstick | syncroles>")
public class Command_myadmin extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
@ -85,7 +85,6 @@ public class Command_myadmin extends FreedomCommand
plugin.sl.save(target);
plugin.sl.updateTables();
plugin.pl.syncIps(target);
msg(counter + " IPs removed.");
@ -121,7 +120,7 @@ public class Command_myadmin extends FreedomCommand
}
else
{
msg("You cannot remove that staff members's current IP.");
msg("You cannot remove that staff members current IP.");
}
return true;
}
@ -175,7 +174,7 @@ public class Command_myadmin extends FreedomCommand
msg("Please run /linkdiscord first!", ChatColor.RED);
return true;
}
boolean synced = plugin.dc.syncRoles(target, playerData.getDiscordID());
boolean synced = Discord.syncRoles(target, playerData.getDiscordID());
if (synced)
{
msg("Successfully synced your roles.", ChatColor.GREEN);

View File

@ -93,7 +93,7 @@ public class SQLite extends FreedomService
{
try
{
connection.createStatement().execute("CREATE TABLE `players` (`username` VARCHAR NOT NULL, `ips` VARCHAR NOT NULL, `notes` VARCHAR, `tag` VARCHAR, `discord_id` VARCHAR, `backup_codes` VARCHAR, `donator` BOOLEAN NOT NULL, `master_builder` BOOLEAN NOT NULL,`verification` BOOLEAN NOT NULL, `ride_mode` VARCHAR NOT NULL, `coins` INT NOT NULL, `items` VARCHAR, `total_votes` INT NOT NULL, `display_discord` BOOLEAN NOT NULL, `reddit_username` VARCHAR, `login_message` VARCHAR);");
connection.createStatement().execute("CREATE TABLE `players` (`username` VARCHAR NOT NULL, `ips` VARCHAR NOT NULL, `notes` VARCHAR, `tag` VARCHAR, `discord_id` VARCHAR, `backup_codes` VARCHAR, `donator` BOOLEAN NOT NULL, `master_builder` BOOLEAN NOT NULL,`verification` BOOLEAN NOT NULL, `ride_mode` VARCHAR NOT NULL, `coins` INT, `items` VARCHAR, `total_votes` INT NOT NULL, `display_discord` BOOLEAN NOT NULL, `reddit_username` VARCHAR, `login_message` VARCHAR);");
}
catch (SQLException e)
{

View File

@ -19,7 +19,6 @@ import org.bukkit.entity.Player;
public class StaffMember
{
@Getter
@Setter
private String name;