Changed Mutes to use UUIDs instead of strings of UUIDs. Also used Bukkit.getPlayer() in both ShadowMute and DeathMute.

master
Joey Hines 2018-10-09 17:21:38 -05:00
parent 1a03c2fc72
commit 2f54beb845
3 changed files with 16 additions and 21 deletions

View File

@ -28,7 +28,7 @@ public class QoL extends MavenPlugin {
public static FileConfiguration config; public static FileConfiguration config;
private Logger log = Logger.getLogger( "Minecraft" ); private Logger log = Logger.getLogger( "Minecraft" );
private static List<String> mutes = new ArrayList<>(); private static List<UUID> mutes = new ArrayList<>();
private static List<UUID> deathMutes = new ArrayList<>(); private static List<UUID> deathMutes = new ArrayList<>();
private static boolean whitelist = false; private static boolean whitelist = false;
private static boolean timeout = false; private static boolean timeout = false;
@ -217,23 +217,25 @@ public class QoL extends MavenPlugin {
} }
public static void addSM(Player player) { public static void addSM(Player player) {
if (!mutes.contains(player.getUniqueId().toString())) { if (!mutes.contains(player.getUniqueId())) {
mutes.add(player.getUniqueId().toString()); mutes.add(player.getUniqueId());
} }
} }
public static void addDeathMute(Player player) { public static void addDeathMute(Player player) {
deathMutes.add(player.getUniqueId()); if (!deathMutes.contains(player.getUniqueId())) {
deathMutes.add(player.getUniqueId());
}
} }
public static boolean hasSM(Player player) {
return mutes.contains(player.getUniqueId());
public static boolean hasSM(Player player) { return mutes.contains(player.getUniqueId().toString()); } }
public static boolean hasDeathMute(Player player) { return deathMutes.contains(player.getUniqueId()); } public static boolean hasDeathMute(Player player) { return deathMutes.contains(player.getUniqueId()); }
public static void removeSM(Player player) { public static void removeSM(Player player) {
mutes.remove(player.getUniqueId().toString()); mutes.remove(player.getUniqueId());
} }
public static boolean getWhitelist() { public static boolean getWhitelist() {

View File

@ -31,19 +31,14 @@ public class DeathMuteCommand implements CommandExecutor {
return true; return true;
} }
Player argPlayer = null; Player argPlayer = Bukkit.getPlayer(args[0]);
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
if (onlinePlayer.getName().equalsIgnoreCase(args[0])) {
argPlayer = onlinePlayer;
}
}
if (argPlayer == null) { if (argPlayer == null) {
EtzTechUtil.sms(commandSender, ChatColor.RED + "No player found."); EtzTechUtil.sms(commandSender, ChatColor.RED + "No player found.");
return true; return true;
} }
final Player player = argPlayer;
final Player player = argPlayer;
EtzTechUtil.sms(commandSender, ChatColor.GREEN + "Death Muting " + ChatColor.YELLOW + EtzTechUtil.sms(commandSender, ChatColor.GREEN + "Death Muting " + ChatColor.YELLOW +
player.getName()); player.getName());

View File

@ -8,11 +8,13 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.omg.CORBA.TypeCodePackage.BadKind;
import xyz.etztech.qol.EtzTechUtil; import xyz.etztech.qol.EtzTechUtil;
import xyz.etztech.qol.Lang; import xyz.etztech.qol.Lang;
import xyz.etztech.qol.QoL; import xyz.etztech.qol.QoL;
import xyz.etztech.qol.other.ShadowMuteTime; import xyz.etztech.qol.other.ShadowMuteTime;
import java.io.BufferedReader;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
@ -44,17 +46,13 @@ public class ShadowMuteCommand implements CommandExecutor {
return true; return true;
} }
Player argPlayer = null; Player argPlayer = Bukkit.getPlayer(args[0]);
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
if (onlinePlayer.getName().equalsIgnoreCase(args[0])) {
argPlayer = onlinePlayer;
}
}
if (argPlayer == null) { if (argPlayer == null) {
EtzTechUtil.sms(commandSender, ChatColor.RED + "No player found."); EtzTechUtil.sms(commandSender, ChatColor.RED + "No player found.");
return true; return true;
} }
final Player player = argPlayer; final Player player = argPlayer;
ShadowMuteTime smt; ShadowMuteTime smt;