Search in sources :

Example 1 with BankerService

use of gg.projecteden.nexus.models.banker.BankerService in project Nexus by ProjectEdenGG.

the class Easter20Command method onSignClick.

@EventHandler
public void onSignClick(PlayerInteractEvent event) {
    if (!ActionGroup.CLICK_BLOCK.applies(event))
        return;
    if (!MaterialTag.SIGNS.isTagged(event.getClickedBlock().getType()))
        return;
    if (event.getHand() == null || !event.getHand().equals(EquipmentSlot.HAND))
        return;
    Sign sign = (Sign) event.getClickedBlock().getState();
    if (!header.equals(sign.getLine(0)))
        return;
    SettingService service = new SettingService();
    Player player = event.getPlayer();
    Setting setting = service.get(player, "easter2020");
    Setting found = service.get(player, "easter2020Found");
    String name = sign.getLine(1);
    if (found.getValue() != null && found.getValue().contains(name)) {
        send(player, PREFIX + "You have already found this egg. Go search around warps for more");
        return;
    }
    int clicked = 0;
    if (Utils.isInt(setting.getValue()))
        clicked = Integer.parseInt(setting.getValue());
    clicked++;
    if (clicked == 19) {
        send(player, PREFIX + "You have found all the eggs! You have won &e$10,000");
        new BankerService().deposit(player, 10000, ShopGroup.SURVIVAL, TransactionCause.EVENT);
    } else if (clicked % 3 == 0) {
        ItemStack headPaper = new ItemBuilder(Material.PAPER).name("&3Coupon for 1 HDB head").lore("&eThis coupon is valid for one head from the head database. " + "Claim it with a staff member").build();
        PlayerUtils.giveItem(player, headPaper);
        send(player, PREFIX + "You have found &e" + name + "'s &3easter egg. You have been given &eone head database coupon");
    } else {
        send(player, PREFIX + "You have found &e" + name + "'s &3easter egg. You have been given &e$500");
        new BankerService().deposit(player, 500, ShopGroup.SURVIVAL, TransactionCause.EVENT);
    }
    setting.setValue(clicked + "");
    service.save(setting);
    if (found.getValue() == null)
        found.setValue(name);
    else
        found.setValue(found.getValue() + name);
    service.save(found);
}
Also used : Player(org.bukkit.entity.Player) OfflinePlayer(org.bukkit.OfflinePlayer) ItemBuilder(gg.projecteden.nexus.utils.ItemBuilder) SettingService(gg.projecteden.nexus.models.setting.SettingService) Setting(gg.projecteden.nexus.models.setting.Setting) Sign(org.bukkit.block.Sign) BankerService(gg.projecteden.nexus.models.banker.BankerService) ItemStack(org.bukkit.inventory.ItemStack) EventHandler(org.bukkit.event.EventHandler)

Example 2 with BankerService

use of gg.projecteden.nexus.models.banker.BankerService in project Nexus by ProjectEdenGG.

the class WhoIsCommand method run.

@Async
@Path("<player>")
void run(Nerd nerd) {
    line();
    line();
    send("&3Who the fuck is &6&l" + nerd.getNickname() + "&3?");
    HoursService hoursService = new HoursService();
    GeoIPService geoipService = new GeoIPService();
    Punishments punishments = Punishments.of(nerd);
    boolean history = punishments.hasHistory();
    JsonBuilder alts = punishments.getAltsMessage();
    Hours hours = hoursService.get(nerd);
    String rank = nerd.getRank().getColoredName();
    String firstJoin = shortDateTimeFormat(nerd.getFirstJoin());
    String lastJoinQuitLabel = null;
    String lastJoinQuitDate = null;
    String lastJoinQuitDiff = null;
    if (nerd.isOnline()) {
        if (nerd.getLastQuit() != null) {
            lastJoinQuitLabel = "Last Quit";
            lastJoinQuitDate = shortDateTimeFormat(nerd.getLastQuit());
            lastJoinQuitDiff = Timespan.of(nerd.getLastQuit()).format();
        }
    } else {
        lastJoinQuitLabel = "Last Join";
        lastJoinQuitDate = shortDateTimeFormat(nerd.getLastQuit());
        lastJoinQuitDiff = Timespan.of(nerd.getLastJoin()).format();
    }
    Set<String> pastNames = nerd.getPastNames();
    Godmode godmode = new GodmodeService().get(nerd);
    JsonBuilder json = json();
    if (nerd.hasNickname())
        json.newline().next("&3Real Name: &e" + nerd.getName()).group();
    json.newline().next("&3Rank: &e" + rank).group();
    json.newline().next("&3First Join: &e" + firstJoin).group();
    if (lastJoinQuitDate != null)
        json.newline().next("&3" + lastJoinQuitLabel + ": &e" + lastJoinQuitDiff + " ago").hover("&e" + lastJoinQuitDate).group();
    if (hours.getTotal() > 0)
        json.newline().next("&3Hours: &e" + TimespanBuilder.ofSeconds(hours.getTotal()).noneDisplay(true).format()).group();
    if (history)
        json.newline().next("&3History: &e" + punishments.getPunishments().size()).command("/history " + nerd.getName()).hover("&eClick to view history").group();
    if (alts != null)
        json.newline().next("&3Alts: &e").next(alts).group();
    if (!pastNames.isEmpty())
        json.newline().next("&3Past Names: &e" + String.join("&3, &e", pastNames)).group();
    try {
        GeoIP geoip = geoipService.get(nerd);
        if (!isNullOrEmpty(geoip.getIp()))
            json.newline().next("&3GeoIP: &e" + geoip.getFriendlyLocationString()).hover("&e" + geoip.getIp()).suggest(geoip.getIp()).group();
    } catch (InvalidInputException ex) {
        json.newline().next("&3GeoIP: &c" + ex.getMessage()).group();
    }
    try {
        json.newline().next("&3Location: &e" + getLocationString(nerd.getLocation())).hover("&eClick to TP").command("/tp " + nerd.getName()).group();
    } catch (InvalidInputException ex) {
        json.newline().next("&3Location: &c" + ex.getMessage()).group();
    }
    json.newline().next("&3Balances:");
    for (ShopGroup shopGroup : ShopGroup.values()) if (new BankerService().getBalance(nerd, shopGroup) != 500)
        json.newline().next("  &3" + camelCase(shopGroup) + ": &e" + new BankerService().getBalanceFormatted(nerd, shopGroup)).group();
    if (nerd.isOnline()) {
        Player player = nerd.getOnlinePlayer();
        json.newline().next("&3Minecraft Version: &e" + PlayerUtils.getPlayerVersion(player));
        json.newline().next("&3Client Brand Name: &e" + player.getClientBrandName()).group();
        final LocalResourcePackUser packUser = new LocalResourcePackUserService().get(nerd);
        json.newline().next("&3Saturn: &e" + packUser.getSaturnStatus()).group();
        json.newline().next("&3Titan: &e" + packUser.getTitanStatus()).group();
        json.newline().next("&3Gamemode: &e" + camelCase(player.getGameMode())).group();
        json.newline().next("&3God mode: &e" + godmode.isEnabled()).group();
        json.newline().next("&3Fly mode: &e" + player.getAllowFlight() + " &3(" + (player.isFlying() ? "flying" : "not flying") + ")").group();
        final ChatVisibility chatVisibility = player.getClientOption(ClientOption.CHAT_VISIBILITY);
        if (chatVisibility != ChatVisibility.FULL)
            json.newline().next("&3Chat Visibility: &e" + camelCase(chatVisibility));
    }
    json.newline().next("&3OP: &e" + nerd.getOfflinePlayer().isOp()).group();
    send(json);
}
Also used : GeoIP(gg.projecteden.nexus.models.geoip.GeoIP) InvalidInputException(gg.projecteden.nexus.framework.exceptions.postconfigured.InvalidInputException) Player(org.bukkit.entity.Player) Hours(gg.projecteden.nexus.models.hours.Hours) Godmode(gg.projecteden.nexus.models.godmode.Godmode) GeoIPService(gg.projecteden.nexus.models.geoip.GeoIPService) HoursService(gg.projecteden.nexus.models.hours.HoursService) StringUtils.getLocationString(gg.projecteden.nexus.utils.StringUtils.getLocationString) GodmodeService(gg.projecteden.nexus.models.godmode.GodmodeService) JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) ShopGroup(gg.projecteden.nexus.models.shop.Shop.ShopGroup) LocalResourcePackUser(gg.projecteden.nexus.models.resourcepack.LocalResourcePackUser) ChatVisibility(com.destroystokyo.paper.ClientOption.ChatVisibility) BankerService(gg.projecteden.nexus.models.banker.BankerService) LocalResourcePackUserService(gg.projecteden.nexus.models.resourcepack.LocalResourcePackUserService) Punishments(gg.projecteden.nexus.models.punishments.Punishments) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Async(gg.projecteden.annotations.Async)

Example 3 with BankerService

use of gg.projecteden.nexus.models.banker.BankerService in project Nexus by ProjectEdenGG.

the class KillerMoney method onEntityKill.

@EventHandler
public void onEntityKill(EntityDeathEvent event) {
    Player player = event.getEntity().getKiller();
    if (player == null)
        return;
    if (!GameMode.SURVIVAL.equals(player.getGameMode()))
        return;
    if (player.getWorld().getName().contains("events"))
        return;
    // the annotation is a lie
    if (event.getEntity().getEntitySpawnReason() == null)
        return;
    if (UNNATURAL_SPAWN_REASONS.contains(event.getEntity().getEntitySpawnReason()))
        return;
    if (event.getEntity().getLastDamageCause() != null)
        if (DEATH_CAUSE_BLACKLIST.contains(event.getEntity().getLastDamageCause().getCause()))
            return;
    if (event.getEntityType() == EntityType.ENDERMAN && player.getWorld().getEnvironment() == Environment.THE_END)
        return;
    MobMoney mob = MobMoney.of(event.getEntityType().name());
    if (mob == null)
        return;
    if (!mob.getAllowedWorldGroups().contains(WorldGroup.of(player)))
        return;
    double boost = BoostConfig.multiplierOf(Boostable.KILLER_MONEY);
    double money = mob.getRandomMoney() * boost;
    new BankerService().deposit(player, money, ShopGroup.of(player), TransactionCause.KILLER_MONEY);
}
Also used : Player(org.bukkit.entity.Player) BankerService(gg.projecteden.nexus.models.banker.BankerService) EventHandler(org.bukkit.event.EventHandler)

Example 4 with BankerService

use of gg.projecteden.nexus.models.banker.BankerService in project Nexus by ProjectEdenGG.

the class McMMOResetProvider method prestige.

public void prestige(Player player, ResetSkillType skill, boolean broadcast) {
    McMMOPlayer mcmmoPlayer = UserManager.getPlayer(player);
    int reward = DEPOSIT;
    if (mcmmoPlayer.getSkillLevel(PrimarySkillType.valueOf(skill.name())) >= TIER_TWO)
        reward *= MAX_DEPOSIT_MULTIPLIER;
    skill.onClick(player);
    new BankerService().deposit(player, reward, ShopGroup.SURVIVAL, TransactionCause.MCMMO_RESET);
    mcmmoPlayer.modifySkill(PrimarySkillType.valueOf(skill.name()), 0);
    McMMOPrestige mcMMOPrestige = service.getPrestige(player.getUniqueId().toString());
    mcMMOPrestige.prestige(skill.name());
    service.save(mcMMOPrestige);
    // TODO Koda Broadcast
    if (broadcast)
        Koda.say(Nickname.of(player) + " has reset their " + skill.name().toLowerCase() + " skill for the " + StringUtils.getNumberWithSuffix(mcMMOPrestige.getPrestige(skill.name())) + " time!");
}
Also used : McMMOPlayer(com.gmail.nossr50.datatypes.player.McMMOPlayer) BankerService(gg.projecteden.nexus.models.banker.BankerService) McMMOPrestige(gg.projecteden.nexus.models.mcmmo.McMMOPrestige)

Example 5 with BankerService

use of gg.projecteden.nexus.models.banker.BankerService in project Nexus by ProjectEdenGG.

the class BalanceAppCommand method check.

@Command(value = "Check a player's balance", literals = false)
void check(@Desc("player") @Default("self") Nerd player, @Desc("gamemode") @Default("SURVIVAL") @Optional ShopGroup gamemode) {
    boolean isSelf = PlayerUtils.isSelf(player, verify());
    String formatted = new BankerService().getBalanceFormatted(player, gamemode);
    replyEphemeral(camelCase(gamemode) + " balance" + (isSelf ? "" : " of " + player.getNickname()) + ": " + formatted);
}
Also used : BankerService(gg.projecteden.nexus.models.banker.BankerService) Command(gg.projecteden.discord.appcommands.annotations.Command) NexusAppCommand(gg.projecteden.nexus.features.discord.appcommands.NexusAppCommand)

Aggregations

BankerService (gg.projecteden.nexus.models.banker.BankerService)13 Player (org.bukkit.entity.Player)5 ShopGroup (gg.projecteden.nexus.models.shop.Shop.ShopGroup)4 VoterService (gg.projecteden.nexus.models.voter.VoterService)3 EventHandler (org.bukkit.event.EventHandler)3 McMMOPlayer (com.gmail.nossr50.datatypes.player.McMMOPlayer)2 Command (gg.projecteden.discord.appcommands.annotations.Command)2 NexusAppCommand (gg.projecteden.nexus.features.discord.appcommands.NexusAppCommand)2 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)2 InvalidInputException (gg.projecteden.nexus.framework.exceptions.postconfigured.InvalidInputException)2 Hours (gg.projecteden.nexus.models.hours.Hours)2 HoursService (gg.projecteden.nexus.models.hours.HoursService)2 McMMOPrestige (gg.projecteden.nexus.models.mcmmo.McMMOPrestige)2 Voter (gg.projecteden.nexus.models.voter.Voter)2 ItemBuilder (gg.projecteden.nexus.utils.ItemBuilder)2 Sign (org.bukkit.block.Sign)2 ChatVisibility (com.destroystokyo.paper.ClientOption.ChatVisibility)1 PrimarySkillType (com.gmail.nossr50.datatypes.skills.PrimarySkillType)1 ClickableItem (fr.minuskube.inv.ClickableItem)1 InventoryContents (fr.minuskube.inv.content.InventoryContents)1