mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
This commit is contained in:
parent
609053e13f
commit
2c19ce5c65
@ -13,10 +13,9 @@ 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 = "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
|
public class Command_mbconfig 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)
|
||||||
{
|
{
|
||||||
@ -33,6 +32,68 @@ public class Command_mbconfig extends FreedomCommand
|
|||||||
return true;
|
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":
|
case "add":
|
||||||
{
|
{
|
||||||
if (args.length < 2)
|
if (args.length < 2)
|
||||||
@ -123,7 +184,6 @@ public class Command_mbconfig extends FreedomCommand
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -136,7 +196,7 @@ public class Command_mbconfig extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (args.length == 1)
|
if (args.length == 1)
|
||||||
{
|
{
|
||||||
return Arrays.asList("add", "remove", "list");
|
return Arrays.asList("add", "remove", "list", "clearips", "clearip");
|
||||||
}
|
}
|
||||||
else if (args.length == 2)
|
else if (args.length == 2)
|
||||||
{
|
{
|
||||||
@ -144,10 +204,19 @@ public class Command_mbconfig extends FreedomCommand
|
|||||||
{
|
{
|
||||||
return FUtil.getPlayerList();
|
return FUtil.getPlayerList();
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("remove") || args[0].equalsIgnoreCase("list"))
|
else if (args[0].equalsIgnoreCase("remove"))
|
||||||
{
|
{
|
||||||
return plugin.pl.getMasterBuilderNames();
|
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();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import java.util.Arrays;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.discord.Discord;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.staff.StaffMember;
|
import me.totalfreedom.totalfreedommod.staff.StaffMember;
|
||||||
@ -16,10 +17,9 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
|
@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
|
public class Command_myadmin 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)
|
||||||
{
|
{
|
||||||
@ -85,7 +85,6 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
|
|
||||||
plugin.sl.save(target);
|
plugin.sl.save(target);
|
||||||
plugin.sl.updateTables();
|
plugin.sl.updateTables();
|
||||||
|
|
||||||
plugin.pl.syncIps(target);
|
plugin.pl.syncIps(target);
|
||||||
|
|
||||||
msg(counter + " IPs removed.");
|
msg(counter + " IPs removed.");
|
||||||
@ -121,7 +120,7 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg("You cannot remove that staff members's current IP.");
|
msg("You cannot remove that staff members current IP.");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -175,7 +174,7 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
msg("Please run /linkdiscord first!", ChatColor.RED);
|
msg("Please run /linkdiscord first!", ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
boolean synced = plugin.dc.syncRoles(target, playerData.getDiscordID());
|
boolean synced = Discord.syncRoles(target, playerData.getDiscordID());
|
||||||
if (synced)
|
if (synced)
|
||||||
{
|
{
|
||||||
msg("Successfully synced your roles.", ChatColor.GREEN);
|
msg("Successfully synced your roles.", ChatColor.GREEN);
|
||||||
|
@ -93,7 +93,7 @@ public class SQLite extends FreedomService
|
|||||||
{
|
{
|
||||||
try
|
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)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,6 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public class StaffMember
|
public class StaffMember
|
||||||
{
|
{
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private String name;
|
private String name;
|
||||||
|
Loading…
Reference in New Issue
Block a user