Can now enable/disable specific skills for PVP & PVE

This commit is contained in:
GJ 2012-05-03 10:39:17 -04:00
parent 3218c544dc
commit 3e91bc8c1e
4 changed files with 134 additions and 44 deletions

View File

@ -18,6 +18,7 @@ Version 1.3.07
+ Added a permission node for Farmer's Diet + Added a permission node for Farmer's Diet
+ Added config options for enabling/disabling specific double drops + Added config options for enabling/disabling specific double drops
+ Added automatic zip backup of flatfile database & config files + Added automatic zip backup of flatfile database & config files
+ Added config options to enable/disable specific skills for PVP & PVE
= Fixed /p and /a incompatibilities with bChatManager = Fixed /p and /a incompatibilities with bChatManager
= Fixed Iron Grip working reversely = Fixed Iron Grip working reversely
= Fixed NPE when user clicked the HUD button with Spout = Fixed NPE when user clicked the HUD button with Spout

View File

@ -315,6 +315,8 @@ public class Config extends ConfigLoader {
public int getPowerLevelCap() { return config.getInt("General.Power_Level_Cap", 0); } public int getPowerLevelCap() { return config.getInt("General.Power_Level_Cap", 0); }
/* PVP & PVE Settings */ /* PVP & PVE Settings */
public boolean getAcrobaticsPVP() { return config.getBoolean("Skills.Acrobatics.Enabled_For_PVP", true); }
public boolean getAcrobaticsPVE() { return config.getBoolean("Skills.Acrobatics.Enabled_For_PVE", true); }
public boolean getArcheryPVP() { return config.getBoolean("Skills.Archery.Enabled_For_PVP", true); } public boolean getArcheryPVP() { return config.getBoolean("Skills.Archery.Enabled_For_PVP", true); }
public boolean getArcheryPVE() { return config.getBoolean("Skills.Archery.Enabled_For_PVE", true); } public boolean getArcheryPVE() { return config.getBoolean("Skills.Archery.Enabled_For_PVE", true); }
public boolean getAxesPVP() { return config.getBoolean("Skills.Axes.Enabled_For_PVP", true); } public boolean getAxesPVP() { return config.getBoolean("Skills.Axes.Enabled_For_PVP", true); }

View File

@ -35,6 +35,8 @@ import com.gmail.nossr50.skills.combat.Unarmed;
import com.gmail.nossr50.skills.misc.Acrobatics; import com.gmail.nossr50.skills.misc.Acrobatics;
public class Combat { public class Combat {
private static Config configInstance = Config.getInstance();
private static Permissions permInstance = Permissions.getInstance();
/** /**
* Apply combat modifiers and process and XP gain. * Apply combat modifiers and process and XP gain.
@ -60,53 +62,89 @@ public class Combat {
combatAbilityChecks(attacker); combatAbilityChecks(attacker);
if (ItemChecks.isSword(itemInHand) && Permissions.getInstance().swords(attacker)) { if (ItemChecks.isSword(itemInHand) && permInstance.swords(attacker)) {
if (Permissions.getInstance().swordsBleed(attacker)) { if (!configInstance.getSwordsPVP()) {
if (targetType.equals(EntityType.PLAYER) || (targetType.equals(EntityType.WOLF) && ((Wolf) target).isTamed())) {
return;
}
}
if (!configInstance.getSwordsPVE()) {
if (!targetType.equals(EntityType.PLAYER) || !(targetType.equals(EntityType.WOLF) && ((Wolf) target).isTamed())) {
return;
}
}
if (permInstance.swordsBleed(attacker)) {
Swords.bleedCheck(attacker, target, plugin); Swords.bleedCheck(attacker, target, plugin);
} }
if (PPa.getAbilityMode(AbilityType.SERRATED_STRIKES) && Permissions.getInstance().serratedStrikes(attacker)) { if (PPa.getAbilityMode(AbilityType.SERRATED_STRIKES) && permInstance.serratedStrikes(attacker)) {
applyAbilityAoE(attacker, target, event.getDamage() / 4, plugin, SkillType.SWORDS); applyAbilityAoE(attacker, target, event.getDamage() / 4, plugin, SkillType.SWORDS);
BleedTimer.add(target, 5); BleedTimer.add(target, 5);
} }
startGainXp(attacker, PPa, target, SkillType.SWORDS, plugin); startGainXp(attacker, PPa, target, SkillType.SWORDS, plugin);
} }
else if (ItemChecks.isAxe(itemInHand) && Permissions.getInstance().axes(attacker)) { else if (ItemChecks.isAxe(itemInHand) && permInstance.axes(attacker)) {
if (Permissions.getInstance().axeBonus(attacker)) { if (!configInstance.getAxesPVP()) {
if (targetType.equals(EntityType.PLAYER) || (targetType.equals(EntityType.WOLF) && ((Wolf) target).isTamed())) {
return;
}
}
if (!configInstance.getAxesPVE()) {
if (!targetType.equals(EntityType.PLAYER) || !(targetType.equals(EntityType.WOLF) && ((Wolf) target).isTamed())) {
return;
}
}
if (permInstance.axeBonus(attacker)) {
Axes.axesBonus(attacker, event); Axes.axesBonus(attacker, event);
} }
if (Permissions.getInstance().criticalHit(attacker)) { if (permInstance.criticalHit(attacker)) {
Axes.axeCriticalCheck(attacker, event); Axes.axeCriticalCheck(attacker, event);
} }
if (Permissions.getInstance().impact(attacker)) { if (permInstance.impact(attacker)) {
Axes.impact(attacker, target, event); Axes.impact(attacker, target, event);
} }
if (PPa.getAbilityMode(AbilityType.SKULL_SPLIITER) && Permissions.getInstance().skullSplitter(attacker)) { if (PPa.getAbilityMode(AbilityType.SKULL_SPLIITER) && permInstance.skullSplitter(attacker)) {
applyAbilityAoE(attacker, target, event.getDamage() / 2, plugin, SkillType.AXES); applyAbilityAoE(attacker, target, event.getDamage() / 2, plugin, SkillType.AXES);
} }
startGainXp(attacker, PPa, target, SkillType.AXES, plugin); startGainXp(attacker, PPa, target, SkillType.AXES, plugin);
} }
else if (itemInHand.getType().equals(Material.AIR) && Permissions.getInstance().unarmed(attacker)) { else if (itemInHand.getType().equals(Material.AIR) && permInstance.unarmed(attacker)) {
if (Permissions.getInstance().unarmedBonus(attacker)) { if (!configInstance.getUnarmedPVP()) {
if (targetType.equals(EntityType.PLAYER) || (targetType.equals(EntityType.WOLF) && ((Wolf) target).isTamed())) {
return;
}
}
if (!configInstance.getUnarmedPVE()) {
if (!targetType.equals(EntityType.PLAYER) || !(targetType.equals(EntityType.WOLF) && ((Wolf) target).isTamed())) {
return;
}
}
if (permInstance.unarmedBonus(attacker)) {
Unarmed.unarmedBonus(PPa, event); Unarmed.unarmedBonus(PPa, event);
} }
if (PPa.getAbilityMode(AbilityType.BERSERK) && Permissions.getInstance().berserk(attacker)) { if (PPa.getAbilityMode(AbilityType.BERSERK) && permInstance.berserk(attacker)) {
event.setDamage((int) (event.getDamage() * 1.5)); event.setDamage((int) (event.getDamage() * 1.5));
} }
if (targetType.equals(EntityType.PLAYER) && Permissions.getInstance().disarm(attacker)) { if (targetType.equals(EntityType.PLAYER) && permInstance.disarm(attacker)) {
Unarmed.disarmProcCheck(attacker, (Player) target); Unarmed.disarmProcCheck(attacker, (Player) target);
} }
startGainXp(attacker, PPa, target, SkillType.UNARMED, plugin); startGainXp(attacker, PPa, target, SkillType.UNARMED, plugin);
} }
else if (itemInHand.getType().equals(Material.BONE) && Permissions.getInstance().beastLore(attacker)) { else if (itemInHand.getType().equals(Material.BONE) && permInstance.beastLore(attacker)) {
Taming.beastLore(event, target, attacker); Taming.beastLore(event, target, attacker);
} }
break; break;
@ -118,16 +156,28 @@ public class Combat {
Player master = (Player) wolf.getOwner(); Player master = (Player) wolf.getOwner();
PlayerProfile PPo = Users.getProfile(master); PlayerProfile PPo = Users.getProfile(master);
if (Permissions.getInstance().taming(master)) { if (!configInstance.getTamingPVP()) {
if (Permissions.getInstance().fastFoodService(master)) { if (targetType.equals(EntityType.PLAYER) || (targetType.equals(EntityType.WOLF) && ((Wolf) target).isTamed())) {
return;
}
}
if (!configInstance.getTamingPVE()) {
if (!targetType.equals(EntityType.PLAYER) || !(targetType.equals(EntityType.WOLF) && ((Wolf) target).isTamed())) {
return;
}
}
if (permInstance.taming(master)) {
if (permInstance.fastFoodService(master)) {
Taming.fastFoodService(PPo, wolf, event); Taming.fastFoodService(PPo, wolf, event);
} }
if (Permissions.getInstance().sharpenedClaws(master)) { if (permInstance.sharpenedClaws(master)) {
Taming.sharpenedClaws(PPo, event); Taming.sharpenedClaws(PPo, event);
} }
if (Permissions.getInstance().gore(master)) { if (permInstance.gore(master)) {
Taming.gore(PPo, event, master, plugin); Taming.gore(PPo, event, master, plugin);
} }
@ -137,13 +187,38 @@ public class Combat {
break; break;
case ARROW: case ARROW:
archeryCheck((EntityDamageByEntityEvent) event, plugin); if (!configInstance.getArcheryPVP() && ((Arrow) damager).getShooter().getType().equals(EntityType.PLAYER)) {
if (targetType.equals(EntityType.PLAYER) || (targetType.equals(EntityType.WOLF) && ((Wolf) target).isTamed())) {
return;
}
}
if (!configInstance.getArcheryPVE() && !((Arrow) damager).getShooter().getType().equals(EntityType.PLAYER)) {
if (!targetType.equals(EntityType.PLAYER) || !(targetType.equals(EntityType.WOLF) && ((Wolf) target).isTamed())) {
return;
}
}
archeryCheck(event, plugin);
break; break;
} }
if (targetType.equals(EntityType.PLAYER)) { if (targetType.equals(EntityType.PLAYER)) {
Swords.counterAttackChecks(event); if (configInstance.getSwordsPVP() && damagerType.equals(EntityType.PLAYER)) {
Acrobatics.dodgeChecks(event); Swords.counterAttackChecks(event);
}
if (configInstance.getSwordsPVE() && !damagerType.equals(EntityType.PLAYER)) {
Swords.counterAttackChecks(event);
}
if (configInstance.getAcrobaticsPVP() && damagerType.equals(EntityType.PLAYER)) {
Acrobatics.dodgeChecks(event);
}
if (configInstance.getAcrobaticsPVE() && !damagerType.equals(EntityType.PLAYER)) {
Acrobatics.dodgeChecks(event);
}
} }
} }
@ -181,7 +256,9 @@ public class Combat {
Player defender = (Player) target; Player defender = (Player) target;
if (defender.getItemInHand().getType().equals(Material.AIR)) { if (defender.getItemInHand().getType().equals(Material.AIR)) {
Unarmed.deflectCheck(defender, event); if (configInstance.getUnarmedPVP()) {
Unarmed.deflectCheck(defender, event);
}
} }
} }
@ -190,9 +267,9 @@ public class Combat {
PlayerProfile PPa = Users.getProfile(attacker); PlayerProfile PPa = Users.getProfile(attacker);
int damage = event.getDamage(); int damage = event.getDamage();
if (Permissions.getInstance().archery(attacker) && damage > 0) { if (permInstance.archery(attacker) && damage > 0) {
if (Permissions.getInstance().archeryBonus(attacker)) { if (permInstance.archeryBonus(attacker)) {
/*Archery needs a damage bonus to be viable in PVP*/ /*Archery needs a damage bonus to be viable in PVP*/
int skillLvl = Users.getProfile(attacker).getSkillLevel(SkillType.ARCHERY); int skillLvl = Users.getProfile(attacker).getSkillLevel(SkillType.ARCHERY);
@ -209,7 +286,7 @@ public class Combat {
event.setDamage(event.getDamage() + archeryBonus); event.setDamage(event.getDamage() + archeryBonus);
} }
if (Permissions.getInstance().trackArrows(attacker)) { if (permInstance.trackArrows(attacker)) {
Archery.trackArrows(pluginx, target, PPa); Archery.trackArrows(pluginx, target, PPa);
} }
@ -224,7 +301,7 @@ public class Combat {
return; return;
} }
if (Permissions.getInstance().daze(attacker)) { if (permInstance.daze(attacker)) {
Archery.dazeCheck(defender, attacker); Archery.dazeCheck(defender, attacker);
} }
} }
@ -250,7 +327,7 @@ public class Combat {
* @param cause DamageCause to pass to damage event * @param cause DamageCause to pass to damage event
*/ */
private static void dealDamage(LivingEntity target, int dmg, DamageCause cause) { private static void dealDamage(LivingEntity target, int dmg, DamageCause cause) {
if (Config.getInstance().getEventCallbackEnabled()) { if (configInstance.getEventCallbackEnabled()) {
EntityDamageEvent ede = (EntityDamageEvent) new FakeEntityDamageEvent(target, cause, dmg); EntityDamageEvent ede = (EntityDamageEvent) new FakeEntityDamageEvent(target, cause, dmg);
mcMMO.p.getServer().getPluginManager().callEvent(ede); mcMMO.p.getServer().getPluginManager().callEvent(ede);
@ -273,7 +350,7 @@ public class Combat {
* @param attacker Player to pass to event as damager * @param attacker Player to pass to event as damager
*/ */
private static void dealDamage(LivingEntity target, int dmg, Player attacker) { private static void dealDamage(LivingEntity target, int dmg, Player attacker) {
if (Config.getInstance().getEventCallbackEnabled()) { if (configInstance.getEventCallbackEnabled()) {
EntityDamageEvent ede = (EntityDamageByEntityEvent) new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg); EntityDamageEvent ede = (EntityDamageByEntityEvent) new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg);
mcMMO.p.getServer().getPluginManager().callEvent(ede); mcMMO.p.getServer().getPluginManager().callEvent(ede);
@ -325,6 +402,7 @@ public class Combat {
} }
break; break;
case PLAYER: case PLAYER:
Player defender = (Player) entity; Player defender = (Player) entity;
@ -347,6 +425,9 @@ public class Combat {
} }
break; break;
default:
break;
} }
switch (type) { switch (type) {
@ -358,12 +439,16 @@ public class Combat {
BleedTimer.add((LivingEntity) entity, 5); BleedTimer.add((LivingEntity) entity, 5);
break; break;
case AXES: case AXES:
if (entity instanceof Player) { if (entity instanceof Player) {
((Player) entity).sendMessage(LocaleLoader.getString("Axes.Combat.Cleave.Struck")); ((Player) entity).sendMessage(LocaleLoader.getString("Axes.Combat.Cleave.Struck"));
} }
break; break;
default:
break;
} }
dealDamage((LivingEntity) entity, damageAmount, attacker); dealDamage((LivingEntity) entity, damageAmount, attacker);
@ -384,7 +469,7 @@ public class Combat {
double baseXP = 0; double baseXP = 0;
if (target instanceof Player) { if (target instanceof Player) {
if (!Config.getInstance().getExperienceGainsPlayerVersusPlayerEnabled()) { if (!configInstance.getExperienceGainsPlayerVersusPlayerEnabled()) {
return; return;
} }
@ -392,72 +477,72 @@ public class Combat {
PlayerProfile PPd = Users.getProfile(defender); PlayerProfile PPd = Users.getProfile(defender);
if (System.currentTimeMillis() >= (PPd.getRespawnATS() * 1000) + 5000 && ((PPd.getLastLogin() + 5) * 1000) < System.currentTimeMillis() && defender.getHealth() >= 1) { if (System.currentTimeMillis() >= (PPd.getRespawnATS() * 1000) + 5000 && ((PPd.getLastLogin() + 5) * 1000) < System.currentTimeMillis() && defender.getHealth() >= 1) {
baseXP = 20 * Config.getInstance().getPlayerVersusPlayerXP(); baseXP = 20 * configInstance.getPlayerVersusPlayerXP();
} }
} }
else if (!target.hasMetadata("mcmmoFromMobSpawner")) { else if (!target.hasMetadata("mcmmoFromMobSpawner")) {
if (target instanceof Animals && !target.hasMetadata("mcmmoSummoned")) { if (target instanceof Animals && !target.hasMetadata("mcmmoSummoned")) {
baseXP = Config.getInstance().getAnimalsXP(); baseXP = configInstance.getAnimalsXP();
} }
else { else {
EntityType type = target.getType(); EntityType type = target.getType();
switch (type) { switch (type) {
case BLAZE: case BLAZE:
baseXP = Config.getInstance().getBlazeXP(); baseXP = configInstance.getBlazeXP();
break; break;
case CAVE_SPIDER: case CAVE_SPIDER:
baseXP = Config.getInstance().getCaveSpiderXP(); baseXP = configInstance.getCaveSpiderXP();
break; break;
case CREEPER: case CREEPER:
baseXP = Config.getInstance().getCreeperXP(); baseXP = configInstance.getCreeperXP();
break; break;
case ENDER_DRAGON: case ENDER_DRAGON:
baseXP = Config.getInstance().getEnderDragonXP(); baseXP = configInstance.getEnderDragonXP();
break; break;
case ENDERMAN: case ENDERMAN:
baseXP = Config.getInstance().getEndermanXP(); baseXP = configInstance.getEndermanXP();
break; break;
case GHAST: case GHAST:
baseXP = Config.getInstance().getGhastXP(); baseXP = configInstance.getGhastXP();
break; break;
case MAGMA_CUBE: case MAGMA_CUBE:
baseXP = Config.getInstance().getMagmaCubeXP(); baseXP = configInstance.getMagmaCubeXP();
break; break;
case IRON_GOLEM: case IRON_GOLEM:
if (!((IronGolem) target).isPlayerCreated()) if (!((IronGolem) target).isPlayerCreated())
baseXP = Config.getInstance().getIronGolemXP(); baseXP = configInstance.getIronGolemXP();
break; break;
case PIG_ZOMBIE: case PIG_ZOMBIE:
baseXP = Config.getInstance().getPigZombieXP(); baseXP = configInstance.getPigZombieXP();
break; break;
case SILVERFISH: case SILVERFISH:
baseXP = Config.getInstance().getSilverfishXP(); baseXP = configInstance.getSilverfishXP();
break; break;
case SKELETON: case SKELETON:
baseXP = Config.getInstance().getSkeletonXP(); baseXP = configInstance.getSkeletonXP();
break; break;
case SLIME: case SLIME:
baseXP = Config.getInstance().getSlimeXP(); baseXP = configInstance.getSlimeXP();
break; break;
case SPIDER: case SPIDER:
baseXP = Config.getInstance().getSpiderXP(); baseXP = configInstance.getSpiderXP();
break; break;
case ZOMBIE: case ZOMBIE:
baseXP = Config.getInstance().getZombieXP(); baseXP = configInstance.getZombieXP();
break; break;
default: default:

View File

@ -114,6 +114,8 @@ Abilities:
### ###
Skills: Skills:
Acrobatics: Acrobatics:
Enabled_For_PVP: true
Enabled_For_PVE: true
Level_Cap: 0 Level_Cap: 0
Archery: Archery:
Enabled_For_PVP: true Enabled_For_PVP: true