use of gg.projecteden.nexus.models.cooldown.CooldownService in project Nexus by ProjectEdenGG.
the class WelcomeCommand method welcome.
@Path("[player]")
void welcome(Player player) {
if (player != null) {
if (Rank.of(player) != Rank.GUEST)
error("Prevented accidental welcome");
if (new HoursService().get(player).has(TickTime.HOUR))
error("Prevented accidental welcome");
}
if (new CooldownService().check(UUID0, "welc", TickTime.SECOND.x(20))) {
String message = getMessage();
if (player == null)
message = message.replaceAll(" \\[player]", "");
else
message = message.replaceAll("\\[player]", player.getName());
runCommand("ch qm g " + message);
} else {
if (player == null)
runCommand("ch qm g Welcome to the server!");
else
runCommand("ch qm g Welcome to the server, " + player.getName());
}
}
use of gg.projecteden.nexus.models.cooldown.CooldownService in project Nexus by ProjectEdenGG.
the class KitCommand method kit.
@Path("<kit>")
void kit(Kit kit) {
WorldGroup worldGroup = worldGroup();
if (worldGroup != WorldGroup.SURVIVAL && worldGroup != WorldGroup.CREATIVE)
error("Kits may only be claimed in survival and creative");
if (!player().hasPermission("kit." + kit.getName()))
error("You do not have permission to use this kit");
CooldownService service = new CooldownService();
if (!service.check(player(), "kit-" + kit.getName(), kit.getDelay()))
error("You must wait " + service.getDiff(player(), "kit-" + kit.getName()) + " before you can receive that kit again");
PlayerUtils.giveItems(player(), Arrays.asList(kit.getItems()));
send(PREFIX + "You have been given the &e" + StringUtils.camelCase(kit.getName()) + " &3kit");
}
use of gg.projecteden.nexus.models.cooldown.CooldownService in project Nexus by ProjectEdenGG.
the class HoleInTheWall method onPlayerInteract.
@Override
public void onPlayerInteract(Minigamer minigamer, PlayerInteractEvent event) {
Match match = minigamer.getMatch();
HoleInTheWallArena arena = match.getArena();
HoleInTheWallMatchData matchData = match.getMatchData();
if (event.getClickedBlock() != null) {
if (event.getAction() == Action.LEFT_CLICK_BLOCK)
if (MaterialTag.STAINED_GLASS.isTagged(event.getClickedBlock().getType())) {
if (isInAnswerRegion(minigamer, event.getClickedBlock().getLocation())) {
Player player = event.getPlayer();
player.playSound(player.getLocation(), Sound.BLOCK_STONE_BREAK, SoundCategory.BLOCKS, 1F, 1F);
player.getInventory().addItem(new ItemStack(event.getClickedBlock().getType()));
event.getClickedBlock().setType(Material.AIR);
}
}
if (ActionGroup.CLICK_BLOCK.applies(event))
if (MaterialTag.SIGNS.isTagged(event.getClickedBlock().getType())) {
Sign sign = (Sign) event.getClickedBlock().getState();
if (stripColor(sign.getLine(2)).contains("Fast Forward")) {
Track track = matchData.getTrack(minigamer);
if (track != null) {
UUID uuid = minigamer.getPlayer().getUniqueId();
String type = "HoleInTheWall-Skip";
if (new CooldownService().check(uuid, type, TickTime.SECOND.x(3)))
track.skip();
else
minigamer.tell("You must wait &e" + new CooldownService().getDiff(uuid, type));
}
}
}
}
}
use of gg.projecteden.nexus.models.cooldown.CooldownService in project Nexus by ProjectEdenGG.
the class ICustomCommand method checkCooldown.
private void checkCooldown(CustomCommand command, Cooldown cooldown, String commandId) {
if (cooldown != null) {
boolean bypass = false;
if (!(command.getEvent().getSender() instanceof Player))
bypass = true;
else if (cooldown.bypass().length() > 0 && command.getEvent().getPlayer().hasPermission(cooldown.bypass()))
bypass = true;
if (!bypass) {
int ticks = cooldown.value().x(cooldown.x());
CooldownService service = new CooldownService();
UUID uuid = cooldown.global() ? UUID0 : ((Player) command.getEvent().getSender()).getUniqueId();
String type = "command:" + commandId;
if (!service.check(uuid, type, ticks))
throw new CommandCooldownException(uuid, type);
}
}
}
use of gg.projecteden.nexus.models.cooldown.CooldownService in project Nexus by ProjectEdenGG.
the class DailyRewardsCommand method reset.
@Confirm
@Path("reset [player]")
void reset(@Arg(value = "self", permission = Group.ADMIN) DailyRewardUser user) {
try {
if (!new CooldownService().check(player(), resetCooldownType, TickTime.DAY))
throw new CommandCooldownException(player(), resetCooldownType);
user.endStreak();
service.save(user);
send(player(), PREFIX + "Your streak has been cleared");
player().closeInventory();
} catch (CommandCooldownException ex) {
send(player(), ex.getMessage());
}
}
Aggregations