forked from ChestShop-authors/ChestShop-3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToggle.java
More file actions
61 lines (48 loc) · 1.69 KB
/
Toggle.java
File metadata and controls
61 lines (48 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.Acrobot.ChestShop.Commands;
import com.Acrobot.ChestShop.Configuration.Messages;
import com.Acrobot.ChestShop.Database.Account;
import com.Acrobot.ChestShop.UUIDs.NameManager;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.UUID;
/**
* @author KingFaris10
*/
public class Toggle implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
return false;
}
Player player = (Player) sender;
if (args.length != 0) {
return false;
}
Account account = NameManager.getOrCreateAccount(player);
account.setIgnoreMessages(!account.isIgnoringMessages());
if (account.isIgnoringMessages()) {
Messages.TOGGLE_MESSAGES_OFF.sendWithPrefix(player);
} else {
Messages.TOGGLE_MESSAGES_ON.sendWithPrefix(player);
}
return true;
}
public static boolean isIgnoring(OfflinePlayer player) {
return player != null && NameManager.getOrCreateAccount(player).isIgnoringMessages();
}
public static boolean isIgnoring(UUID playerId) {
Account account = NameManager.getAccount(playerId);
return account != null && account.isIgnoringMessages();
}
/**
* @deprecated Use {@link #isIgnoring(UUID)}
*/
@Deprecated
public static boolean isIgnoring(String playerName) {
return isIgnoring(Bukkit.getOfflinePlayer(playerName));
}
}