permissions for adding role
This commit is contained in:
parent
b0d6a768ae
commit
f06475d62b
3 changed files with 23 additions and 41 deletions
|
@ -1,8 +1,6 @@
|
||||||
package me.night.nullvalkyrie.commands;
|
package me.night.nullvalkyrie.commands;
|
||||||
|
|
||||||
import com.google.common.cache.Cache;
|
import me.night.nullvalkyrie.database.RankDataManager;
|
||||||
import com.google.common.cache.CacheBuilder;
|
|
||||||
import me.night.nullvalkyrie.database.ranks.RankManager;
|
|
||||||
import me.night.nullvalkyrie.ui.Rank;
|
import me.night.nullvalkyrie.ui.Rank;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
@ -13,8 +11,6 @@ import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
public class RankCommand extends Command {
|
public class RankCommand extends Command {
|
||||||
|
|
||||||
|
@ -23,18 +19,14 @@ public class RankCommand extends Command {
|
||||||
"rank",
|
"rank",
|
||||||
new String[]{},
|
new String[]{},
|
||||||
"Set rank of players",
|
"Set rank of players",
|
||||||
""
|
"nv.rank.add"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Cache<UUID, Long> cooldown = CacheBuilder.newBuilder().expireAfterWrite(5, TimeUnit.SECONDS).build();
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(CommandSender sender, String[] args) {
|
public void onCommand(CommandSender sender, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player player) {
|
||||||
Player player = (Player) sender;
|
|
||||||
if (!cooldown.asMap().containsKey(player.getUniqueId())) {
|
|
||||||
if (!player.isOp()) {
|
if (!player.isOp()) {
|
||||||
player.sendMessage(ChatColor.RED + "You must be server operator to use this command");
|
player.sendMessage(ChatColor.RED + "You must be server operator to use this command");
|
||||||
return;
|
return;
|
||||||
|
@ -44,27 +36,16 @@ public class RankCommand extends Command {
|
||||||
OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]);
|
OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]);
|
||||||
for (Rank rank : Rank.values()) {
|
for (Rank rank : Rank.values()) {
|
||||||
if (rank.name().equalsIgnoreCase(args[1])) {
|
if (rank.name().equalsIgnoreCase(args[1])) {
|
||||||
RankManager.setRank(target.getUniqueId(), rank);
|
RankDataManager.setRank(target.getUniqueId(), rank);
|
||||||
player.sendMessage(ChatColor.GREEN + "You changed " + target.getName() + "'s rank to " + rank.getDisplay());
|
player.sendMessage(ChatColor.GREEN + "You changed " + target.getName() + "'s rank to " + rank.getDisplay());
|
||||||
if (target.isOnline()) {
|
if (target.isOnline())
|
||||||
target.getPlayer().sendMessage(ChatColor.GREEN + player.getName() + " set your rank to " + rank.getDisplay());
|
target.getPlayer().sendMessage(ChatColor.GREEN + player.getName() + " set your rank to " + rank.getDisplay());
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
player.sendMessage(ChatColor.RED + "Invalid Rank, please specify a valid rank, ROOKIE, SPECIAL, ADMIN, OWNER");
|
player.sendMessage(ChatColor.RED + "Invalid Rank, please specify a valid rank, ROOKIE, SPECIAL, ADMIN, OWNER");
|
||||||
} else {
|
} else player.sendMessage("This player has never played in this server before!");
|
||||||
player.sendMessage("This player has never played in this server before!");
|
} else player.sendMessage(ChatColor.RED + "Invalid parameter, use /rank <Player> <Rank>");
|
||||||
}
|
|
||||||
} else {
|
|
||||||
player.sendMessage(ChatColor.RED + "Invalid parameter, use /rank <Player> <Rank>");
|
|
||||||
}
|
|
||||||
cooldown.put(player.getUniqueId(), System.currentTimeMillis() + 5000);
|
|
||||||
} else {
|
|
||||||
long distance = cooldown.asMap().get(player.getUniqueId()) - System.currentTimeMillis();
|
|
||||||
player.sendMessage(ChatColor.RED + "You are on a " + TimeUnit.MILLISECONDS.toSeconds(distance) + " seconds cooldown to use the command again");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import java.util.UUID;
|
||||||
public class AnimatedSideBar {
|
public class AnimatedSideBar {
|
||||||
private static final Map<UUID, Integer> Tasks = new HashMap<>();
|
private static final Map<UUID, Integer> Tasks = new HashMap<>();
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
|
|
||||||
public AnimatedSideBar(UUID uuid) {
|
public AnimatedSideBar(UUID uuid) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,7 @@ depend: [ProtocolLib]
|
||||||
permissions:
|
permissions:
|
||||||
nv.command.use:
|
nv.command.use:
|
||||||
default: true
|
default: true
|
||||||
|
nv.rank.add:
|
||||||
|
default: op
|
||||||
libraries:
|
libraries:
|
||||||
- "io.github.cdimascio:dotenv-java:2.3.1"
|
- "io.github.cdimascio:dotenv-java:2.3.1"
|
||||||
|
|
Loading…
Reference in a new issue