Use appropriate data structure

- Convert the HashMaps in DisbandSubCommand and LeaveSubCommand to Lists
This commit is contained in:
FTTT 2021-11-07 17:31:11 -08:00
parent 196689db62
commit 5654fc9a0f
2 changed files with 10 additions and 8 deletions

View file

@ -1,6 +1,7 @@
package me.totalfreedom.tfguilds.command; package me.totalfreedom.tfguilds.command;
import java.util.HashMap; import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.tfguilds.Common; import me.totalfreedom.tfguilds.Common;
import me.totalfreedom.tfguilds.TFGuilds; import me.totalfreedom.tfguilds.TFGuilds;
import me.totalfreedom.tfguilds.guild.Guild; import me.totalfreedom.tfguilds.guild.Guild;
@ -14,7 +15,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class DisbandSubCommand extends Common implements SubCommand public class DisbandSubCommand extends Common implements SubCommand
{ {
private final HashMap<CommandSender, Boolean> confirm = new HashMap<>(); private final List<CommandSender> confirm = new ArrayList<>();
@Override @Override
public void execute(CommandSender sender, Player playerSender, String[] args) public void execute(CommandSender sender, Player playerSender, String[] args)
@ -61,12 +62,12 @@ public class DisbandSubCommand extends Common implements SubCommand
} }
private void disband(CommandSender sender, Guild guild) private void disband(CommandSender sender, Guild guild)
{ {
if (!confirm.containsKey(sender)) if (!confirm.contains(sender))
{ {
sender.sendMessage(WARN + "Are you sure you want to disband the guild " sender.sendMessage(WARN + "Are you sure you want to disband the guild "
+ ChatColor.GOLD + guild.getName() + ChatColor.GRAY + "? Type " + ChatColor.GOLD + guild.getName() + ChatColor.GRAY + "? Type "
+ ChatColor.GOLD + "/g disband" + ChatColor.GRAY + " again within 10 seconds to confirm."); + ChatColor.GOLD + "/g disband" + ChatColor.GRAY + " again within 10 seconds to confirm.");
confirm.put(sender, true); confirm.add(sender);
new BukkitRunnable() new BukkitRunnable()
{ {
@Override @Override

View file

@ -1,6 +1,7 @@
package me.totalfreedom.tfguilds.command; package me.totalfreedom.tfguilds.command;
import java.util.HashMap; import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.tfguilds.Common; import me.totalfreedom.tfguilds.Common;
import me.totalfreedom.tfguilds.TFGuilds; import me.totalfreedom.tfguilds.TFGuilds;
import me.totalfreedom.tfguilds.guild.Guild; import me.totalfreedom.tfguilds.guild.Guild;
@ -12,7 +13,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class LeaveSubCommand extends Common implements SubCommand public class LeaveSubCommand extends Common implements SubCommand
{ {
private final HashMap<CommandSender, Boolean> confirm = new HashMap<>(); private final List<CommandSender> confirm = new ArrayList<>();
@Override @Override
public void execute(CommandSender sender, Player playerSender, String[] args) public void execute(CommandSender sender, Player playerSender, String[] args)
@ -36,13 +37,13 @@ public class LeaveSubCommand extends Common implements SubCommand
return; return;
} }
if (!confirm.containsKey(sender)) if (!confirm.contains(sender))
{ {
sender.sendMessage(WARN + "Are you sure you want to leave " sender.sendMessage(WARN + "Are you sure you want to leave "
+ ChatColor.GOLD + guild.getName() + ChatColor.GRAY + "? Type " + ChatColor.GOLD + guild.getName() + ChatColor.GRAY + "? Type "
+ ChatColor.GOLD + "/g leave" + ChatColor.GOLD + "/g leave"
+ ChatColor.GRAY + " again within 10 seconds to confirm."); + ChatColor.GRAY + " again within 10 seconds to confirm.");
confirm.put(sender, true); confirm.add(sender);
new BukkitRunnable() new BukkitRunnable()
{ {
@Override @Override