use of com.gmail.nossr50.datatypes.skills.SkillType in project GDHooks by bloodmc.
the class McMMOProvider method onPlayerSkillEvent.
public boolean onPlayerSkillEvent(McMMOPlayerSkillEvent event, Object target, Set<Context> contexts) {
final Player player = event.getPlayer();
final World world = player.getWorld();
if (!GriefDefender.getCore().isEnabled(world.getUID())) {
return true;
}
final Location location = player.getLocation();
final PlayerData playerData = GriefDefender.getCore().getPlayerData(world.getUID(), player.getUniqueId());
final Claim claim = GriefDefender.getCore().getClaimAt(location);
final String skillType = event.getSkill().name().toLowerCase().replace(" ", "_");
contexts.add(new Context("mcmmo:skill_level", String.valueOf(event.getSkillLevel())));
contexts.add(new Context("mcmmo:skill_type", skillType));
final Tristate result = GriefDefender.getPermissionManager().getActiveFlagPermissionValue(event, location, claim, playerData.getUser(), SKILL_USE, player, target, contexts, null, true);
if (result == Tristate.FALSE) {
return false;
}
return true;
}
use of com.gmail.nossr50.datatypes.skills.SkillType in project GDHooks by bloodmc.
the class McMMOProvider method onPlayerXpGain.
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerXpGain(McMMOPlayerXpGainEvent event) {
final String skillType = event.getSkill().name().toLowerCase().replace(" ", "_");
final String reason = event.getXpGainReason().name().toLowerCase();
final Player player = event.getPlayer();
final World world = player.getWorld();
if (!GriefDefender.getCore().isEnabled(world.getUID())) {
return;
}
final Set<Context> contexts = new HashSet<>();
contexts.add(new Context("mcmmo:skill_level", String.valueOf(event.getSkillLevel())));
contexts.add(new Context("mcmmo:skill_type", skillType));
contexts.add(new Context("mcmmo:reason", reason));
final Location location = player.getLocation();
final PlayerData playerData = GriefDefender.getCore().getPlayerData(world.getUID(), player.getUniqueId());
final Claim claim = GriefDefender.getCore().getClaimAt(location);
final Double xpGained = GriefDefender.getPermissionManager().getActiveOptionValue(TypeToken.get(Double.class), MCMMO_XP_GAIN_MODIFIER, playerData.getUser(), claim, contexts);
if (xpGained != null && xpGained != 1.0) {
event.setRawXpGained(event.getRawXpGained() * xpGained.floatValue());
}
}
use of com.gmail.nossr50.datatypes.skills.SkillType in project GDHooks by bloodmc.
the class McMMOProvider method onPlayerDisarmEvent.
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerDisarmEvent(McMMOPlayerDisarmEvent event) {
final Player player = event.getPlayer();
final World world = player.getWorld();
if (!GriefDefender.getCore().isEnabled(world.getUID())) {
return;
}
final Player targetPlayer = event.getDefender();
final Location location = targetPlayer.getLocation();
final PlayerData playerData = GriefDefender.getCore().getPlayerData(world.getUID(), player.getUniqueId());
final Claim claim = GriefDefender.getCore().getClaimAt(location);
final String skillType = event.getSkill().name().toLowerCase().replace(" ", "_");
final Set<Context> contexts = new HashSet<>();
contexts.add(new Context("mcmmo:skill_level", String.valueOf(event.getSkillLevel())));
contexts.add(new Context("mcmmo:skill_type", skillType));
final Tristate result = GriefDefender.getPermissionManager().getActiveFlagPermissionValue(event, location, claim, playerData.getUser(), PLAYER_DISARM, player, targetPlayer, contexts, null, true);
if (result == Tristate.FALSE) {
event.setCancelled(true);
}
}
use of com.gmail.nossr50.datatypes.skills.SkillType in project Depenizen by DenizenScript.
the class McMMOCommand method execute.
@Override
public void execute(ScriptEntry scriptEntry) {
ElementTag action = scriptEntry.getElement("action");
ElementTag state = scriptEntry.getElement("state");
ElementTag type = scriptEntry.getElement("type");
ElementTag quantity = scriptEntry.getElement("quantity");
ElementTag party = scriptEntry.getElement("party");
ElementTag skill = scriptEntry.getElement("skill");
PlayerTag player = Utilities.getEntryPlayer(scriptEntry);
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), action, type, state, quantity, party, skill);
}
switch(Action.valueOf(action.asString().toUpperCase())) {
case ADD:
{
if (quantity.asDouble() >= 0 && skill != null && player != null) {
switch(Type.valueOf(type.asString().toUpperCase())) {
case LEVELS:
{
if (player.isOnline()) {
ExperienceAPI.addLevel(player.getPlayerEntity(), skill.asString(), quantity.asInt());
} else {
ExperienceAPI.addLevelOffline(player.getName(), skill.asString(), quantity.asInt());
}
break;
}
case XP:
{
if (player.isOnline()) {
ExperienceAPI.addRawXP(player.getPlayerEntity(), skill.asString(), quantity.asFloat());
} else {
ExperienceAPI.addRawXPOffline(player.getName(), skill.asString(), quantity.asFloat());
}
}
}
} else if (party != null && PartyManager.getParty(party.asString()) != null) {
PartyAPI.addToParty(player.getPlayerEntity(), party.asString());
}
break;
}
case REMOVE:
{
if (quantity.asDouble() >= 0 && skill != null && player != null) {
switch(Type.valueOf(type.asString().toUpperCase())) {
case LEVELS:
{
if (player.isOnline()) {
ExperienceAPI.setLevel(player.getPlayerEntity(), skill.asString(), ExperienceAPI.getLevel(player.getPlayerEntity(), skill.asString()) - quantity.asInt());
} else {
ExperienceAPI.setLevelOffline(player.getName(), skill.asString(), ExperienceAPI.getLevelOffline(player.getName(), skill.asString()) - quantity.asInt());
}
break;
}
case XP:
{
if (player.isOnline()) {
ExperienceAPI.removeXP(player.getPlayerEntity(), skill.asString(), quantity.asInt());
} else {
ExperienceAPI.removeXPOffline(player.getName(), skill.asString(), quantity.asInt());
}
break;
}
}
} else if (player != null && player.isOnline() && party != null && PartyManager.getParty(party.asString()) != null) {
if (PartyAPI.getPartyLeader(party.asString()).equals(player.getName())) {
PartyManager.disbandParty(PartyManager.getParty(party.asString()));
} else {
PartyAPI.removeFromParty(player.getPlayerEntity());
}
} else if (player != null) {
mcMMO.getDatabaseManager().removeUser(player.getName(), player.getUUID());
}
break;
}
case SET:
{
if (quantity.asDouble() >= 0 && skill != null && player != null) {
switch(Type.valueOf(type.asString().toUpperCase())) {
case LEVELS:
{
if (player.isOnline()) {
ExperienceAPI.setLevel(player.getPlayerEntity(), skill.asString(), quantity.asInt());
} else {
ExperienceAPI.setLevelOffline(player.getName(), skill.asString(), quantity.asInt());
}
break;
}
case XP:
{
if (player.isOnline()) {
ExperienceAPI.setXP(player.getPlayerEntity(), skill.asString(), quantity.asInt());
} else {
ExperienceAPI.setXPOffline(player.getName(), skill.asString(), quantity.asInt());
}
break;
}
}
} else {
switch(Type.valueOf(type.asString().toUpperCase())) {
case LEADER:
{
if (party != null && PartyManager.getParty(party.asString()) != null) {
PartyAPI.setPartyLeader(party.asString(), player.getName());
}
break;
}
case XPRATE:
{
if (quantity.asInt() > 0) {
ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(quantity.asInt());
}
break;
}
case HARDCORE:
{
if (skill == null) {
return;
}
PrimarySkillType skillType = PrimarySkillType.getSkill(skill.asString());
boolean isEnabled = mcMMO.p.getGeneralConfig().getHardcoreStatLossEnabled(skillType);
switch(State.valueOf(state.asString().toUpperCase())) {
case TOGGLE:
{
mcMMO.p.getGeneralConfig().setHardcoreStatLossEnabled(skillType, !isEnabled);
break;
}
case TRUE:
{
mcMMO.p.getGeneralConfig().setHardcoreStatLossEnabled(skillType, true);
break;
}
case FALSE:
{
mcMMO.p.getGeneralConfig().setHardcoreStatLossEnabled(skillType, false);
break;
}
}
break;
}
case VAMPIRISM:
{
if (skill == null) {
return;
}
PrimarySkillType skillType = PrimarySkillType.getSkill(skill.asString());
boolean isEnabled = mcMMO.p.getGeneralConfig().getHardcoreVampirismEnabled(skillType);
switch(State.valueOf(state.asString().toUpperCase())) {
case TOGGLE:
{
mcMMO.p.getGeneralConfig().setHardcoreVampirismEnabled(skillType, !isEnabled);
break;
}
case TRUE:
{
mcMMO.p.getGeneralConfig().setHardcoreVampirismEnabled(skillType, true);
break;
}
case FALSE:
{
mcMMO.p.getGeneralConfig().setHardcoreVampirismEnabled(skillType, false);
break;
}
}
break;
}
}
}
break;
}
}
}
use of com.gmail.nossr50.datatypes.skills.SkillType 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);
}
Aggregations