Fixed Ignore (I hope)
This commit is contained in:
@@ -2,11 +2,13 @@ command ignore {
|
|||||||
[string:player] {
|
[string:player] {
|
||||||
perm utils.ignore;
|
perm utils.ignore;
|
||||||
run ignore player;
|
run ignore player;
|
||||||
help Ignore a player.;
|
type player;
|
||||||
|
help Ignores or Unignores a player.;
|
||||||
}
|
}
|
||||||
[empty] {
|
[empty] {
|
||||||
perm utils.ignore;
|
perm utils.ignore;
|
||||||
run list;
|
run list;
|
||||||
|
type player;
|
||||||
help Lists everyone you ignore.;
|
help Lists everyone you ignore.;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,6 +16,7 @@ command unignore {
|
|||||||
[string:player] {
|
[string:player] {
|
||||||
perm utils.ignore;
|
perm utils.ignore;
|
||||||
run unignore player;
|
run unignore player;
|
||||||
|
type player;
|
||||||
help Unignore a player.;
|
help Unignore a player.;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,83 +62,38 @@ public class Ignore implements Module{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings({ "unchecked", "deprecation" })
|
||||||
public boolean ignore(CommandSender sender, String player, boolean allowIgnore)
|
public boolean ignore(CommandSender sender, String player, boolean allowIgnore)
|
||||||
{
|
{
|
||||||
JSONArray isIgnoredBy;
|
|
||||||
JSONArray ignores = (JSONArray) DataManager.getOrDefault(sender, "ignores", new JSONArray());
|
JSONArray ignores = (JSONArray) DataManager.getOrDefault(sender, "ignores", new JSONArray());
|
||||||
String uuidOfSender = ((Player)sender).getUniqueId().toString();
|
|
||||||
String uuidOfPlayer = player;
|
|
||||||
|
|
||||||
if ( sender.getName().equals(player) )
|
OfflinePlayer p = Utils.isUUID(player)?
|
||||||
{
|
Bukkit.getOfflinePlayer(UUID.fromString(player)) :
|
||||||
getLogger().message(sender, true, "You can't ignore yourself. :P");
|
Bukkit.getOfflinePlayer(player);
|
||||||
return true;
|
|
||||||
}
|
String pName = ((Player) p).getDisplayName();
|
||||||
|
String pUUID = p.getUniqueId().toString();
|
||||||
if ( Utils.isUUID(player) )
|
String sUUID = ((Player) sender).getUniqueId().toString();
|
||||||
{
|
|
||||||
isIgnoredBy = (JSONArray) DataManager.getOrDefault(player, "isIgnoredBy", new JSONArray());
|
if (pUUID.equals(sUUID)) {
|
||||||
|
getLogger().message(sender, true, "§7You can't ignore yourself :P");
|
||||||
if (isIgnoredBy.contains(uuidOfSender))
|
return true;
|
||||||
{
|
}
|
||||||
isIgnoredBy.remove(uuidOfSender);
|
|
||||||
ignores.remove(uuidOfPlayer);
|
if (ignores.contains(pUUID)) {
|
||||||
getLogger().message(sender, "§7You are no longer ignoring §3" + player + "§7.");
|
ignores.remove(pUUID);
|
||||||
}
|
getLogger().message(sender, "§7You are no longer ignoring §3" + pName + "§7.");
|
||||||
else if (allowIgnore)
|
}
|
||||||
{
|
else if (!allowIgnore){
|
||||||
isIgnoredBy.add(uuidOfSender);
|
getLogger().message(sender, "§7You were never ignoring §3" + pName + "§7.");
|
||||||
ignores.add(uuidOfPlayer);
|
}
|
||||||
getLogger().message(sender, "§7You are now ignoring §3" + player + "§7.");
|
else {
|
||||||
}
|
ignores.add(pUUID);
|
||||||
else
|
getLogger().message(sender, "§7You are now ignoring §3" + pName + "§7.");
|
||||||
{
|
}
|
||||||
getLogger().message(sender, "§7You weren't ignoring §3" + player + "§7.");
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
DataManager.setData(player, "isIgnoredBy", isIgnoredBy);
|
|
||||||
DataManager.setData(sender, "ignores", ignores);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Player toBeIgnored = Bukkit.getPlayer(player);
|
|
||||||
if (toBeIgnored != null)
|
|
||||||
{
|
|
||||||
isIgnoredBy = (JSONArray) DataManager.getOrDefault(toBeIgnored, "isIgnoredBy", new JSONArray());
|
|
||||||
uuidOfPlayer = toBeIgnored.getUniqueId().toString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getLogger().message(sender, true, "§3" + player + "§7 isn't online. To ignore them, use their UUID.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isIgnoredBy.contains(uuidOfSender))
|
|
||||||
{
|
|
||||||
isIgnoredBy.remove(uuidOfSender);
|
|
||||||
ignores.remove(uuidOfPlayer);
|
|
||||||
getLogger().message(sender, "§7You are no longer ignoring §3" + toBeIgnored.getDisplayName() + "§7.");
|
|
||||||
}
|
|
||||||
else if (allowIgnore)
|
|
||||||
{
|
|
||||||
isIgnoredBy.add(uuidOfSender);
|
|
||||||
ignores.add(uuidOfPlayer);
|
|
||||||
getLogger().message(sender, "§7You are now ignoring §3" + toBeIgnored.getDisplayName() + "§7.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getLogger().message(sender, "§7You weren't ignoring §3" + toBeIgnored.getDisplayName() + "§7.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
DataManager.setData(toBeIgnored, "isIgnoredBy", isIgnoredBy);
|
|
||||||
DataManager.setData(sender, "ignores", ignores);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BroadcastFilter getIgnoredBy(CommandSender sender) {
|
public static BroadcastFilter getIgnoredBy(CommandSender sender) {
|
||||||
@@ -158,10 +113,15 @@ public class Ignore implements Module{
|
|||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private BroadcastFilter _getIgnoredBy(CommandSender sender) {
|
private BroadcastFilter _getIgnoredBy(CommandSender sender) {
|
||||||
JSONArray isIgnoredBy = (JSONArray) DataManager.getOrDefault(sender, "isIgnoredBy", new JSONArray());
|
|
||||||
return new BroadcastFilter() {
|
return new BroadcastFilter() {
|
||||||
|
|
||||||
|
private final String sUUID = sender instanceof Player?
|
||||||
|
((Player) sender).getUniqueId().toString() : "CONSOLE";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean sendTo(CommandSender recipient) {
|
public boolean sendTo(CommandSender recipient) {
|
||||||
|
if (sUUID.equals("CONSOLE"))
|
||||||
|
return true;
|
||||||
|
|
||||||
if (recipient instanceof Player)
|
if (recipient instanceof Player)
|
||||||
{
|
{
|
||||||
@@ -169,7 +129,9 @@ public class Ignore implements Module{
|
|||||||
|
|
||||||
if (player.hasPermission("utils.ignore.override"))
|
if (player.hasPermission("utils.ignore.override"))
|
||||||
return true;
|
return true;
|
||||||
return !isIgnoredBy.contains( player.getUniqueId().toString() );
|
|
||||||
|
JSONArray ignores = (JSONArray) DataManager.getOrDefault(player, "ignores", new JSONArray());
|
||||||
|
return !ignores.contains(sUUID);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user