Search in sources :

Example 1 with McMMOPlayer

use of com.gmail.nossr50.datatypes.player.McMMOPlayer in project Foundation by kangarko.

the class ItemsAdderHook method getActivePartyChat.

String getActivePartyChat(final Player player) {
    try {
        final McMMOPlayer mcplayer = UserManager.getPlayer(player);
        if (mcplayer != null) {
            final Party party = mcplayer.getParty();
            final ChatChannel channelType = mcplayer.getChatChannel();
            return channelType == ChatChannel.PARTY || channelType == ChatChannel.PARTY_OFFICER && party != null ? party.getName() : null;
        }
    } catch (final Throwable throwable) {
        if (!errorLogged) {
            Common.warning("Failed getting mcMMO party chat for " + player.getName() + " due to error. Returning null." + " Ensure you have the latest mcMMO version, if so, contact plugin authors to update the integration. Error was: " + throwable);
            errorLogged = true;
        }
    }
    return null;
}
Also used : ChatChannel(com.gmail.nossr50.datatypes.chat.ChatChannel) Party(com.gmail.nossr50.datatypes.party.Party) McMMOPlayer(com.gmail.nossr50.datatypes.player.McMMOPlayer)

Example 2 with McMMOPlayer

use of com.gmail.nossr50.datatypes.player.McMMOPlayer in project GDHooks by bloodmc.

the class McMMOProvider method onRuptureDamageEvent.

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onRuptureDamageEvent(McMMOEntityDamageByRuptureEvent event) {
    final McMMOPlayer mcmmoPlayer = event.getMcMMODamager();
    final Player player = mcmmoPlayer.getPlayer();
    final World world = player.getWorld();
    if (!GriefDefender.getCore().isEnabled(world.getUID())) {
        return;
    }
    final Entity targetEntity = event.getEntity();
    final Location location = targetEntity.getLocation();
    final PlayerData playerData = GriefDefender.getCore().getPlayerData(world.getUID(), player.getUniqueId());
    final Claim claim = GriefDefender.getCore().getClaimAt(location);
    final Set<Context> contexts = new HashSet<>();
    contexts.add(new Context("mcmmo:damage_amount", String.valueOf(event.getFinalDamage())));
    final Tristate result = GriefDefender.getPermissionManager().getActiveFlagPermissionValue(event, location, claim, playerData.getUser(), RUPTURE_DAMAGE, player, targetEntity, contexts, null, true);
    if (result == Tristate.FALSE) {
        event.setCancelled(true);
    }
}
Also used : Context(com.griefdefender.api.permission.Context) Entity(org.bukkit.entity.Entity) Player(org.bukkit.entity.Player) McMMOPlayer(com.gmail.nossr50.datatypes.player.McMMOPlayer) Tristate(com.griefdefender.api.Tristate) McMMOPlayer(com.gmail.nossr50.datatypes.player.McMMOPlayer) World(org.bukkit.World) PlayerData(com.griefdefender.api.data.PlayerData) Claim(com.griefdefender.api.claim.Claim) Location(org.bukkit.Location) HashSet(java.util.HashSet) EventHandler(org.bukkit.event.EventHandler)

Example 3 with McMMOPlayer

use of com.gmail.nossr50.datatypes.player.McMMOPlayer 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 4 with McMMOPlayer

use of com.gmail.nossr50.datatypes.player.McMMOPlayer in project Nexus by ProjectEdenGG.

the class McMMOResetProvider method init.

@Override
public void init() {
    McMMOPlayer mcmmoPlayer = UserManager.getPlayer(player);
    int totalPowerLevel = 0;
    boolean _canPrestigeAll = true;
    for (ResetSkillType skill : ResetSkillType.values()) {
        int powerLevel = Math.min(TIER_ONE, mcmmoPlayer.getSkillLevel(PrimarySkillType.valueOf(skill.name())));
        totalPowerLevel += powerLevel;
        if (powerLevel < TIER_ONE)
            _canPrestigeAll = false;
    }
    final boolean canPrestigeAll = _canPrestigeAll;
    ItemBuilder all = new ItemBuilder(Material.BEACON).name("&eAll Skills").lore("&3Power Level: &e" + totalPowerLevel + "/" + TIER_ONE_ALL + "", "&3&lReward:", "&f- " + DEPOSIT_PRETTY + " per level " + TIER_ONE + " skill (x" + MAX_DEPOSIT_MULTIPLIER + " if level " + TIER_TWO + ")", "&f- " + DEPOSIT_ALL_PRETTY + " bonus (x" + MAX_DEPOSIT_ALL_MULTIPLIER + " if every skill is level " + TIER_TWO + ")", "&f- All normal rewards", "&f- When your health gets low, this breastplate will give you the strength of an angry barbarian!").glow(mcmmoPlayer.getPowerLevel() >= TIER_ONE_ALL);
    ItemStack reset = new ItemBuilder(Material.BARRIER).name("&cReset all with &lno reward").build();
    contents.set(0, 4, ClickableItem.of(all, e -> {
        if (!canPrestigeAll)
            return;
        ConfirmationMenu.builder().title("&4Confirm Prestige All?").onConfirm(e2 -> {
            player.closeInventory();
            prestigeAll(player);
        }).open(player);
    }));
    contents.set(5, 4, ClickableItem.of(reset, e -> ConfirmationMenu.builder().title("&4Confirm Reset All? (No Rewards)").onConfirm(e2 -> {
        player.closeInventory();
        resetAll(mcmmoPlayer);
    }).open(player)));
    McMMOPrestige mcMMOPrestige = service.getPrestige(player.getUniqueId().toString());
    for (ResetSkillType skill : ResetSkillType.values()) {
        ItemBuilder item = new ItemBuilder(skill.getMaterial()).itemFlags(ItemFlag.HIDE_POTION_EFFECTS, ItemFlag.HIDE_ATTRIBUTES).name("&e" + StringUtils.camelCase(skill.name())).lore("&3Level: &e" + mcmmoPlayer.getSkillLevel(PrimarySkillType.valueOf(skill.name())), "", "&3&lReward:", "&f" + DEPOSIT_PRETTY + " (x" + MAX_DEPOSIT_MULTIPLIER + " for level " + TIER_TWO + ")", "&f" + skill.getRewardDescription(), "", "&3Number of Prestieges: &e" + mcMMOPrestige.getPrestige(skill.name())).glow(mcmmoPlayer.getSkillLevel(PrimarySkillType.valueOf(skill.name())) >= TIER_ONE);
        contents.set(skill.getRow(), skill.getColumn(), ClickableItem.of(item, (e) -> {
            if (mcmmoPlayer.getSkillLevel(PrimarySkillType.valueOf(skill.name())) < TIER_ONE)
                return;
            ConfirmationMenu.builder().title("Confirm Prestige?").onConfirm((e2) -> {
                player.closeInventory();
                prestige(player, skill, true);
            }).open(player);
        }));
    }
}
Also used : ItemFlag(org.bukkit.inventory.ItemFlag) TIER_ONE(gg.projecteden.nexus.features.mcmmo.McMMO.TIER_ONE) StringUtils(gg.projecteden.nexus.utils.StringUtils) Getter(lombok.Getter) Enchantment(org.bukkit.enchantments.Enchantment) Player(org.bukkit.entity.Player) McMMOPlayer(com.gmail.nossr50.datatypes.player.McMMOPlayer) ClickableItem(gg.projecteden.nexus.features.menus.api.ClickableItem) TIER_ONE_ALL(gg.projecteden.nexus.features.mcmmo.McMMO.TIER_ONE_ALL) McMMOPrestige(gg.projecteden.nexus.models.mcmmo.McMMOPrestige) Enchant(gg.projecteden.nexus.utils.Enchant) PlayerUtils(gg.projecteden.nexus.utils.PlayerUtils) TransactionCause(gg.projecteden.nexus.models.banker.Transaction.TransactionCause) McMMOService(gg.projecteden.nexus.models.mcmmo.McMMOService) BankerService(gg.projecteden.nexus.models.banker.BankerService) Nickname(gg.projecteden.nexus.models.nickname.Nickname) TIER_TWO(gg.projecteden.nexus.features.mcmmo.McMMO.TIER_TWO) Material(org.bukkit.Material) ConfirmationMenu(gg.projecteden.nexus.features.menus.MenuUtils.ConfirmationMenu) ItemBuilder(gg.projecteden.nexus.utils.ItemBuilder) ShopGroup(gg.projecteden.nexus.models.shop.Shop.ShopGroup) UserManager(com.gmail.nossr50.util.player.UserManager) Koda(gg.projecteden.nexus.features.chat.Koda) LuckPermsUtils(gg.projecteden.nexus.utils.LuckPermsUtils) PermissionChange(gg.projecteden.nexus.utils.LuckPermsUtils.PermissionChange) ItemStack(org.bukkit.inventory.ItemStack) GemCommand(gg.projecteden.nexus.features.crates.GemCommand) Title(gg.projecteden.nexus.features.menus.api.annotations.Title) InventoryProvider(gg.projecteden.nexus.features.menus.api.content.InventoryProvider) AllArgsConstructor(lombok.AllArgsConstructor) PrimarySkillType(com.gmail.nossr50.datatypes.skills.PrimarySkillType) ItemBuilder(gg.projecteden.nexus.utils.ItemBuilder) McMMOPlayer(com.gmail.nossr50.datatypes.player.McMMOPlayer) ItemStack(org.bukkit.inventory.ItemStack) McMMOPrestige(gg.projecteden.nexus.models.mcmmo.McMMOPrestige)

Example 5 with McMMOPlayer

use of com.gmail.nossr50.datatypes.player.McMMOPlayer in project TriggerReactor by wysohn.

the class McMmoSupport method removeXp.

/**
 * remove 'xp' from target player's 'skillType'
 *
 * @param player
 * @param skillType
 * @param xp
 */
public void removeXp(Player player, String skillType, int xp) {
    McMMOPlayer mmoPlayer = (McMMOPlayer) player(player.getName());
    if (mmoPlayer == null)
        throw new RuntimeException("Could not find MCMMO info for player " + player.getName());
    SkillType type = SkillType.valueOf(skillType);
    mmoPlayer.removeXp(type, xp);
}
Also used : McMMOPlayer(com.gmail.nossr50.datatypes.player.McMMOPlayer) SkillType(com.gmail.nossr50.datatypes.skills.SkillType)

Aggregations

McMMOPlayer (com.gmail.nossr50.datatypes.player.McMMOPlayer)14 SkillType (com.gmail.nossr50.datatypes.skills.SkillType)7 BankerService (gg.projecteden.nexus.models.banker.BankerService)3 McMMOPrestige (gg.projecteden.nexus.models.mcmmo.McMMOPrestige)3 Party (com.gmail.nossr50.datatypes.party.Party)2 PrimarySkillType (com.gmail.nossr50.datatypes.skills.PrimarySkillType)2 Player (org.bukkit.entity.Player)2 ChatChannel (com.gmail.nossr50.datatypes.chat.ChatChannel)1 AbilityType (com.gmail.nossr50.datatypes.skills.AbilityType)1 UserManager (com.gmail.nossr50.util.player.UserManager)1 Tristate (com.griefdefender.api.Tristate)1 Claim (com.griefdefender.api.claim.Claim)1 PlayerData (com.griefdefender.api.data.PlayerData)1 Context (com.griefdefender.api.permission.Context)1 Koda (gg.projecteden.nexus.features.chat.Koda)1 GemCommand (gg.projecteden.nexus.features.crates.GemCommand)1 TIER_ONE (gg.projecteden.nexus.features.mcmmo.McMMO.TIER_ONE)1 TIER_ONE_ALL (gg.projecteden.nexus.features.mcmmo.McMMO.TIER_ONE_ALL)1 TIER_TWO (gg.projecteden.nexus.features.mcmmo.McMMO.TIER_TWO)1 ConfirmationMenu (gg.projecteden.nexus.features.menus.MenuUtils.ConfirmationMenu)1