Assorted cleanup, fixed bug with abilities not working.

This commit is contained in:
GJ 2012-03-14 13:33:00 -04:00
parent 9ef1c3b5bf
commit ab8f1a4ea6
8 changed files with 224 additions and 173 deletions

View File

@ -25,6 +25,7 @@ Version 2.0.00-dev
= Fixed bug where Tree Feller could be used without permissions = Fixed bug where Tree Feller could be used without permissions
= Fixed exploit where falling sand & gravel weren't tracked = Fixed exploit where falling sand & gravel weren't tracked
= Fixed exploit where Acrobatics could be leveled via Dodge on party members. = Fixed exploit where Acrobatics could be leveled via Dodge on party members.
= Fixed exploit where you could gain combat XP on animals summoned by Call of the Wild
! Changed PTP to prevent teleporting if you've been hurt in the last 30 seconds (configurable) ! Changed PTP to prevent teleporting if you've been hurt in the last 30 seconds (configurable)
! Changed Chimera Wing failure check to use the maxWorldHeight. ! Changed Chimera Wing failure check to use the maxWorldHeight.
! Changed inspect failed message to say inspect rather than whois ! Changed inspect failed message to say inspect rather than whois
@ -33,6 +34,8 @@ Version 2.0.00-dev
! Changed mmoedit to save a profile when used (this will make mctop update) ! Changed mmoedit to save a profile when used (this will make mctop update)
! Changed a few Runnable tasks to have their own classes ! Changed a few Runnable tasks to have their own classes
! Changed parties so that a player will leave their existing party if they enter a world where they don't have party permissions. ! Changed parties so that a player will leave their existing party if they enter a world where they don't have party permissions.
! Changed Call of the Wild to summon animals already tamed.
! Changed mob spawner tracking to use new Metadata API
Version 1.3.02 Version 1.3.02
+ Added in game guides for Mining, Excavation, and Acrobatics. Simply type /skillname ? to access them + Added in game guides for Mining, Excavation, and Acrobatics. Simply type /skillname ? to access them

View File

@ -258,7 +258,7 @@ public class Combat {
* @param dmg Amount of damage to attempt to do * @param dmg Amount of damage to attempt to do
* @param attacker Player to pass to event as damager * @param attacker Player to pass to event as damager
*/ */
public static void dealDamage(LivingEntity target, int dmg, Player attacker) { private static void dealDamage(LivingEntity target, int dmg, Player attacker) {
if (LoadProperties.eventCallback) { if (LoadProperties.eventCallback) {
EntityDamageEvent ede = (EntityDamageByEntityEvent) new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg); EntityDamageEvent ede = (EntityDamageByEntityEvent) new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg);
Bukkit.getPluginManager().callEvent(ede); Bukkit.getPluginManager().callEvent(ede);
@ -380,8 +380,7 @@ public class Combat {
* @param skillType The skill being used * @param skillType The skill being used
* @param plugin mcMMO plugin instance * @param plugin mcMMO plugin instance
*/ */
public static void startGainXp(Player attacker, PlayerProfile PP, LivingEntity target, SkillType skillType, mcMMO pluginx) public static void startGainXp(Player attacker, PlayerProfile PP, LivingEntity target, SkillType skillType, mcMMO pluginx) {
{
double baseXP = 0; double baseXP = 0;
if (target instanceof Player) { if (target instanceof Player) {
@ -392,18 +391,15 @@ public class Combat {
Player defender = (Player) target; Player defender = (Player) target;
PlayerProfile PPd = Users.getProfile(defender); PlayerProfile PPd = Users.getProfile(defender);
if (System.currentTimeMillis() >= (PPd.getRespawnATS() * 1000) + 5000 && if (System.currentTimeMillis() >= (PPd.getRespawnATS() * 1000) + 5000 && ((PPd.getLastLogin() + 5) * 1000) < System.currentTimeMillis() && defender.getHealth() >= 1) {
((PPd.getLastLogin() + 5) * 1000) < System.currentTimeMillis() &&
defender.getHealth() >= 1) {
baseXP = 20 * LoadProperties.pvpxprewardmodifier; baseXP = 20 * LoadProperties.pvpxprewardmodifier;
} }
} }
else if (!pluginx.misc.mobSpawnerList.contains(target.getEntityId())) { else if (!target.hasMetadata("fromMobSpawner")) {
if (target instanceof Animals) { if (target instanceof Animals && !target.hasMetadata("summoned")) {
baseXP = LoadProperties.animalXP; //I'm assuming the 10x multiplier here was accidental... baseXP = LoadProperties.animalXP;
} }
else else {
{
EntityType type = target.getType(); EntityType type = target.getType();
switch (type) { switch (type) {
@ -471,5 +467,4 @@ public class Combat {
Bukkit.getScheduler().scheduleSyncDelayedTask(pluginx, new GainXp(attacker, PP, skillType, baseXP, target), 0); Bukkit.getScheduler().scheduleSyncDelayedTask(pluginx, new GainXp(attacker, PP, skillType, baseXP, target), 0);
} }
} }
} }

View File

@ -15,7 +15,6 @@ public class Misc
{ {
String location = "mcmmo.properties"; String location = "mcmmo.properties";
public ArrayList<Integer> mobSpawnerList = new ArrayList<Integer>();
public HashSet<Block> blockWatchList = new HashSet<Block>(); public HashSet<Block> blockWatchList = new HashSet<Block>();
public HashMap<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>(); public HashMap<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>();
public ArrayList<LivingEntity> bleedTracker = new ArrayList<LivingEntity>(); public ArrayList<LivingEntity> bleedTracker = new ArrayList<LivingEntity>();

View File

@ -20,6 +20,7 @@ import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityTameEvent; import org.bukkit.event.entity.EntityTameEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.metadata.FixedMetadataValue;
import com.gmail.nossr50.Combat; import com.gmail.nossr50.Combat;
import com.gmail.nossr50.Users; import com.gmail.nossr50.Users;
@ -144,11 +145,6 @@ public class mcEntityListener implements Listener {
LivingEntity x = event.getEntity(); LivingEntity x = event.getEntity();
x.setFireTicks(0); x.setFireTicks(0);
/* Remove mob from mob spawner list */
if (plugin.misc.mobSpawnerList.contains(x.getEntityId())) {
plugin.misc.mobSpawnerList.remove((Object)x.getEntityId());
}
/* Remove bleed track */ /* Remove bleed track */
if(plugin.misc.bleedTracker.contains(x)) { if(plugin.misc.bleedTracker.contains(x)) {
plugin.misc.addToBleedRemovalQue(x); plugin.misc.addToBleedRemovalQue(x);
@ -169,7 +165,7 @@ public class mcEntityListener implements Listener {
@EventHandler (priority = EventPriority.MONITOR) @EventHandler (priority = EventPriority.MONITOR)
public void onCreatureSpawn(CreatureSpawnEvent event) { public void onCreatureSpawn(CreatureSpawnEvent event) {
if (event.getSpawnReason().equals(SpawnReason.SPAWNER) && !LoadProperties.xpGainsMobSpawners) { if (event.getSpawnReason().equals(SpawnReason.SPAWNER) && !LoadProperties.xpGainsMobSpawners) {
plugin.misc.mobSpawnerList.add(event.getEntity().getEntityId()); event.getEntity().setMetadata("fromMobSpawner", new FixedMetadataValue(plugin, true));
} }
} }
@ -291,7 +287,7 @@ public class mcEntityListener implements Listener {
public void onEntityTame(EntityTameEvent event) { public void onEntityTame(EntityTameEvent event) {
Player player = (Player) event.getOwner(); Player player = (Player) event.getOwner();
if (mcPermissions.getInstance().taming(player)) { if (mcPermissions.getInstance().taming(player) && !event.getEntity().hasMetadata("summoned")) {
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = Users.getProfile(player);
EntityType type = event.getEntityType(); EntityType type = event.getEntityType();
int xp = 0; int xp = 0;

View File

@ -267,10 +267,10 @@ public class mcPlayerListener implements Listener {
/* CALL OF THE WILD CHECKS */ /* CALL OF THE WILD CHECKS */
if (player.isSneaking() && mcPermissions.getInstance().taming(player)) { if (player.isSneaking() && mcPermissions.getInstance().taming(player)) {
if (is.getType().equals(Material.RAW_FISH)) { if (is.getType().equals(Material.RAW_FISH)) {
Taming.animalSummon(EntityType.OCELOT, player); Taming.animalSummon(EntityType.OCELOT, player, plugin);
} }
else if (is.getType().equals(Material.BONE)) { else if (is.getType().equals(Material.BONE)) {
Taming.animalSummon(EntityType.WOLF, player); Taming.animalSummon(EntityType.WOLF, player, plugin);
} }
} }

View File

@ -129,7 +129,7 @@ public class Fishing {
final int ENCHANTMENT_CHANCE = 10; final int ENCHANTMENT_CHANCE = 10;
boolean enchanted = false; boolean enchanted = false;
ItemStack fishingResults = theCatch.getItemStack(); ItemStack fishingResults = theCatch.getItemStack();
player.sendMessage(mcLocale.getString("Fishing.ItemFound")); player.sendMessage(mcLocale.getString("Fishing.ItemFound"));
if (Repair.isArmor(fishingResults) || Repair.isTools(fishingResults)) { if (Repair.isArmor(fishingResults) || Repair.isTools(fishingResults)) {
if (Math.random() * 100 <= ENCHANTMENT_CHANCE) { if (Math.random() * 100 <= ENCHANTMENT_CHANCE) {
@ -148,8 +148,8 @@ public class Fishing {
enchanted = true; enchanted = true;
int randomEnchantLevel = (int) (Math.random() * newEnchant.getMaxLevel()) + 1; int randomEnchantLevel = (int) (Math.random() * newEnchant.getMaxLevel()) + 1;
if (randomEnchantLevel == 0) { if (randomEnchantLevel < newEnchant.getStartLevel()) {
randomEnchantLevel = 1; randomEnchantLevel = newEnchant.getStartLevel();
} }
fishingResults.addEnchantment(newEnchant, randomEnchantLevel); fishingResults.addEnchantment(newEnchant, randomEnchantLevel);

View File

@ -428,12 +428,14 @@ public class Skills {
activate = false; activate = false;
break; break;
} }
/* FALLS THROUGH */
case GREEN_TERRA: case GREEN_TERRA:
if (!ability.blockCheck(block.getType())) { if (!ability.blockCheck(block.getType())) {
activate = false; activate = false;
break; break;
} }
break;
default: default:
activate = false; activate = false;

View File

@ -1,15 +1,17 @@
package com.gmail.nossr50.skills; package com.gmail.nossr50.skills;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.Wolf; import org.bukkit.entity.Wolf;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import com.gmail.nossr50.Users; import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
@ -18,152 +20,206 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.locale.mcLocale;
public class Taming public class Taming {
{
public static void fastFoodService(PlayerProfile PPo, Wolf theWolf, EntityDamageEvent event) /**
{ * Apply the Fast Food Service ability.
int health = theWolf.getHealth(); *
int maxHealth = theWolf.getMaxHealth(); * @param PPo The PlayerProfile of the wolf's owner
int damage = event.getDamage(); * @param theWolf The wolf using the ability
if(PPo.getSkillLevel(SkillType.TAMING) >= 50) * @param event The event to modify
{ */
if(health < maxHealth) public static void fastFoodService (PlayerProfile PPo, Wolf theWolf, EntityDamageEvent event) {
{ final int SKILL_ACTIVATION_LEVEL = 50;
if(Math.random() * 10 > 5) final int ACTIVATION_CHANCE = 50;
{
if(health + damage <= maxHealth) int health = theWolf.getHealth();
theWolf.setHealth(health + damage); int maxHealth = theWolf.getMaxHealth();
else int damage = event.getDamage();
theWolf.setHealth(maxHealth);
} if (PPo.getSkillLevel(SkillType.TAMING) >= SKILL_ACTIVATION_LEVEL) {
} if (health < maxHealth) {
} if (Math.random() * 100 < ACTIVATION_CHANCE) {
} if (health + damage <= maxHealth) {
theWolf.setHealth(health + damage);
public static void sharpenedClaws(PlayerProfile PPo, EntityDamageEvent event) }
{ else {
if(PPo.getSkillLevel(SkillType.TAMING) >= 750) theWolf.setHealth(maxHealth);
{ }
event.setDamage(event.getDamage() + 2); }
} }
} }
}
public static void gore(PlayerProfile PPo, EntityDamageEvent event, Player master, mcMMO pluginx)
{ /**
if(Math.random() * 1000 <= PPo.getSkillLevel(SkillType.TAMING)) * Apply the Sharpened Claws ability.
{ *
Entity entity = event.getEntity(); * @param PPo The PlayerProfile of the wolf's owner
event.setDamage(event.getDamage() * 2); * @param event The event to modify
*/
if(entity instanceof Player) public static void sharpenedClaws(PlayerProfile PPo, EntityDamageEvent event) {
{ final int SKILL_ACTIVATION_LEVEL = 750;
Player target = (Player)entity; final int SHARPENED_CLAWS_BONUS = 2;
target.sendMessage(mcLocale.getString("Combat.StruckByGore")); //$NON-NLS-1$
Users.getProfile(target).setBleedTicks(2); if (PPo.getSkillLevel(SkillType.TAMING) >= SKILL_ACTIVATION_LEVEL) {
} event.setDamage(event.getDamage() + SHARPENED_CLAWS_BONUS);
else }
pluginx.misc.addToBleedQue((LivingEntity)entity); }
master.sendMessage(mcLocale.getString("Combat.Gore")); //$NON-NLS-1$ /**
} * Apply the Gore ability.
} *
* @param PPo The PlayerProfile of the wolf's owner
public static String getOwnerName(Wolf theWolf) * @param event The event to modify
{ * @param master The wolf's master
Player owner = null; * @param plugin mcMMO plugin instance
*/
if (theWolf.getOwner() instanceof Player) public static void gore(PlayerProfile PPo, EntityDamageEvent event, Player master, mcMMO plugin) {
{ final int GORE_MULTIPLIER = 2;
owner = (Player)theWolf.getOwner();
return owner.getName(); if (Math.random() * 1000 <= PPo.getSkillLevel(SkillType.TAMING)) {
} Entity entity = event.getEntity();
else event.setDamage(event.getDamage() * GORE_MULTIPLIER);
return "Offline Master";
} if (entity instanceof Player) {
Player target = (Player) entity;
public static void preventDamage(EntityDamageEvent event, mcMMO plugin)
{ target.sendMessage(mcLocale.getString("Combat.StruckByGore"));
DamageCause cause = event.getCause(); Users.getProfile(target).setBleedTicks(2);
Wolf wolf = (Wolf) event.getEntity(); }
else {
plugin.misc.addToBleedQue((LivingEntity)entity);
}
master.sendMessage(mcLocale.getString("Combat.Gore"));
}
}
/**
* Get the name of a wolf's owner.
*
* @param theWolf The wolf whose owner's name to get
* @return the name of the wolf's owner, or "Offline Master" if the owner is offline
*/
public static String getOwnerName(Wolf theWolf) {
AnimalTamer tamer = theWolf.getOwner();
if (tamer instanceof Player) {
Player owner = (Player) tamer;
return owner.getName();
}
else {
return "Offline Master";
}
}
/**
* Prevent damage to wolves based on various skills.
*
* @param event The event to modify
* @param plugin mcMMO plugin instance
*/
public static void preventDamage(EntityDamageEvent event, mcMMO plugin) {
final int ENVIRONMENTALLY_AWARE_LEVEL = 100;
final int THICK_FUR_LEVEL = 250;
final int SHOCK_PROOF_LEVEL = 500;
final int THICK_FUR_MODIFIER = 2;
final int SHOCK_PROOF_MODIFIER = 6;
DamageCause cause = event.getCause();
Wolf wolf = (Wolf) event.getEntity();
Player master = (Player) wolf.getOwner(); Player master = (Player) wolf.getOwner();
int skillLevel = Users.getProfile(master).getSkillLevel(SkillType.TAMING); int skillLevel = Users.getProfile(master).getSkillLevel(SkillType.TAMING);
switch(cause) switch (cause) {
{
//Environmentally Aware /* Environmentally Aware */
case CONTACT: case CONTACT:
case LAVA: case LAVA:
case FIRE: case FIRE:
if(skillLevel >= 100) if (skillLevel >= ENVIRONMENTALLY_AWARE_LEVEL) {
{ if (event.getDamage() >= wolf.getHealth()) {
if(event.getDamage() >= wolf.getHealth()) return;
return; }
wolf.teleport(master.getLocation()); wolf.teleport(master.getLocation());
master.sendMessage(mcLocale.getString("mcEntityListener.WolfComesBack")); //$NON-NLS-1$ master.sendMessage(mcLocale.getString("mcEntityListener.WolfComesBack"));
} }
break; break;
case FALL:
if(skillLevel >= 100) case FALL:
event.setCancelled(true); if (skillLevel >= ENVIRONMENTALLY_AWARE_LEVEL) {
break; event.setCancelled(true);
}
//Thick Fur break;
case FIRE_TICK:
if(skillLevel >= 250) /* Thick Fur */
wolf.setFireTicks(0); case FIRE_TICK:
break; if(skillLevel >= THICK_FUR_LEVEL) {
case ENTITY_ATTACK: wolf.setFireTicks(0);
case PROJECTILE: }
if(skillLevel >= 250) break;
event.setDamage(event.getDamage() / 2);
break; case ENTITY_ATTACK:
case PROJECTILE:
//Shock Proof if (skillLevel >= THICK_FUR_LEVEL) {
case ENTITY_EXPLOSION: event.setDamage(event.getDamage() / THICK_FUR_MODIFIER);
case BLOCK_EXPLOSION: }
if(skillLevel >= 500) break;
event.setDamage(event.getDamage() / 6);
break; /* Shock Proof */
} case ENTITY_EXPLOSION:
} case BLOCK_EXPLOSION:
if (skillLevel >= SHOCK_PROOF_LEVEL) {
public static void animalSummon(EntityType type, Player player) event.setDamage(event.getDamage() / SHOCK_PROOF_MODIFIER);
{ }
ItemStack item = player.getItemInHand(); break;
Material summonItem = null;
int summonAmount = 0; default:
break;
switch(type) }
{ }
case WOLF:
summonItem = Material.BONE; /**
summonAmount = LoadProperties.bonesConsumedByCOTW; * Summon an animal.
break; *
case OCELOT: * @param type Type of animal to summon
summonItem = Material.RAW_FISH; * @param player Player summoning the animal
summonAmount = LoadProperties.fishConsumedByCOTW; */
break; public static void animalSummon(EntityType type, Player player, mcMMO plugin) {
} ItemStack item = player.getItemInHand();
Material summonItem = null;
if(item.getType().equals(summonItem) && item.getAmount() >= summonAmount) int summonAmount = 0;
{
for(Entity x : player.getNearbyEntities(40, 40, 40)) switch (type) {
{ case WOLF:
if(x.getType().equals(type)) summonItem = Material.BONE;
{ summonAmount = LoadProperties.bonesConsumedByCOTW;
player.sendMessage(mcLocale.getString("m.TamingSummonFailed")); break;
return;
} case OCELOT:
} summonItem = Material.RAW_FISH;
summonAmount = LoadProperties.fishConsumedByCOTW;
World world = player.getWorld(); break;
world.spawnCreature(player.getLocation(), type);
default:
int amount = item.getAmount(); break;
amount = amount - summonAmount; }
player.setItemInHand(new ItemStack(summonItem, amount));
player.sendMessage(mcLocale.getString("m.TamingSummon")); if (item.getType().equals(summonItem) && item.getAmount() >= summonAmount) {
} for (Entity x : player.getNearbyEntities(40, 40, 40)) {
} if (x.getType().equals(type)) {
player.sendMessage(mcLocale.getString("m.TamingSummonFailed"));
return;
}
}
LivingEntity entity = player.getWorld().spawnCreature(player.getLocation(), type);
entity.setMetadata("summoned", new FixedMetadataValue(plugin, true));
((Tameable) entity).setOwner(player);
player.setItemInHand(new ItemStack(summonItem, item.getAmount() - summonAmount));
player.sendMessage(mcLocale.getString("m.TamingSummon"));
}
}
} }