From eb31822b22aa86d81250449fc938a4c9801469ad Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 11 Feb 2011 17:56:15 -0800 Subject: [PATCH] Do a barrel roll. --- .../nossr50/mcMMO/mcEntityListener.java | 369 +++++++++++++++++- mcMMO/com/bukkit/nossr50/mcMMO/mcMMO.java | 3 + .../nossr50/mcMMO/mcPlayerListener.java | 40 +- mcMMO/com/bukkit/nossr50/mcMMO/mcUsers.java | 136 ++++++- mcMMO/com/bukkit/nossr50/mcMMO/mcm.java | 20 +- mcMMO/plugin.yml | 2 +- 6 files changed, 536 insertions(+), 34 deletions(-) diff --git a/mcMMO/com/bukkit/nossr50/mcMMO/mcEntityListener.java b/mcMMO/com/bukkit/nossr50/mcMMO/mcEntityListener.java index 2574e702c..9b7118a6e 100644 --- a/mcMMO/com/bukkit/nossr50/mcMMO/mcEntityListener.java +++ b/mcMMO/com/bukkit/nossr50/mcMMO/mcEntityListener.java @@ -3,6 +3,7 @@ package com.bukkit.nossr50.mcMMO; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.block.Block; import org.bukkit.entity.Animals; import org.bukkit.entity.Creature; import org.bukkit.entity.Creeper; @@ -13,8 +14,11 @@ import org.bukkit.entity.Skeleton; import org.bukkit.entity.Spider; import org.bukkit.entity.Squid; import org.bukkit.entity.Zombie; +import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageByProjectileEvent; import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityListener; import org.bukkit.inventory.ItemStack; @@ -25,16 +29,135 @@ public class mcEntityListener extends EntityListener { public mcEntityListener(final mcMMO plugin) { this.plugin = plugin; } + public void onEntityDamageByBlock(EntityDamageByBlockEvent event) { + Block block = event.getDamager(); + Entity x = event.getEntity(); + if(x instanceof Player){ + Player player = (Player)x; + if(block != null && block.getTypeId() == 81){ + if(mcUsers.getProfile(player).isDead()) + return; + if(player.getHealth() - event.getDamage() >= 0){ + mcUsers.getProfile(player).setDead(true); + for(Player bidoof : plugin.getServer().getOnlinePlayers()){ + bidoof.sendMessage(ChatColor.GRAY+player.getName()+" has been"+ChatColor.DARK_GREEN+" cactus tickled "+ChatColor.GRAY+"to death."); + } + } + } + } + } public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { Entity x = event.getEntity(); //Defender Entity y = event.getDamager(); //Attacker //If attacker is player... + if(x instanceof Player){ + Player defender = (Player)x; + /* + * PARRYING + */ + if(isSwords(defender.getItemInHand())){ + if(mcUsers.getProfile(defender).getSwordsInt() >= 50 && mcUsers.getProfile(defender).getSwordsInt() < 250){ + if(Math.random() * 10 > 8){ + event.setCancelled(true); + defender.sendMessage(ChatColor.YELLOW+"*CLANG* SUCCESSFUL PARRY *CLANG*"); + defender.getItemInHand().setDurability((short) (defender.getItemInHand().getDurability() + 1)); + mcUsers.getProfile(defender).skillUpSwords(1); + defender.sendMessage(ChatColor.YELLOW+"Swords skill increased by 1. Total ("+mcUsers.getProfile(defender).getSwords()+")"); + if(y instanceof Player){ + Player attacker = (Player)y; + attacker.sendMessage(ChatColor.DARK_RED+"**TARGET HAS PARRIED THAT ATTACK**"); + } + } + } + if(mcUsers.getProfile(defender).getSwordsInt() >= 250 && mcUsers.getProfile(defender).getSwordsInt() < 450){ + if(Math.random() * 10 > 6){ + event.setCancelled(true); + defender.sendMessage(ChatColor.YELLOW+"*CLANG* SUCCESSFUL PARRY *CLANG*"); + defender.getItemInHand().setDurability((short) (defender.getItemInHand().getDurability() + 1)); + mcUsers.getProfile(defender).skillUpSwords(1); + defender.sendMessage(ChatColor.YELLOW+"Swords skill increased by 1. Total ("+mcUsers.getProfile(defender).getSwords()+")"); + if(y instanceof Player){ + Player attacker = (Player)y; + attacker.sendMessage(ChatColor.DARK_RED+"**TARGET HAS PARRIED THAT ATTACK**"); + } + } + } + if(mcUsers.getProfile(defender).getSwordsInt() >= 450 && mcUsers.getProfile(defender).getSwordsInt() < 775){ + if(Math.random() * 10 > 4){ + event.setCancelled(true); + defender.sendMessage(ChatColor.YELLOW+"*CLANG* SUCCESSFUL PARRY *CLANG*"); + defender.getItemInHand().setDurability((short) (defender.getItemInHand().getDurability() + 1)); + mcUsers.getProfile(defender).skillUpSwords(1); + defender.sendMessage(ChatColor.YELLOW+"Swords skill increased by 1. Total ("+mcUsers.getProfile(defender).getSwords()+")"); + if(y instanceof Player){ + Player attacker = (Player)y; + attacker.sendMessage(ChatColor.DARK_RED+"**TARGET HAS PARRIED THAT ATTACK**"); + } + } + } + if(mcUsers.getProfile(defender).getSwordsInt() >= 775){ + if(Math.random() * 10 > 6){ + event.setCancelled(true); + defender.sendMessage(ChatColor.YELLOW+"*CLANG* SUCCESSFUL PARRY *CLANG*"); + defender.getItemInHand().setDurability((short) (defender.getItemInHand().getDurability() + 1)); + if(y instanceof Player){ + Player attacker = (Player)y; + attacker.sendMessage(ChatColor.DARK_RED+"**TARGET HAS PARRIED THAT ATTACK**"); + } + } + } + } + /* + * DEATH MESSAGES + */ + if(y instanceof Monster){ + if(mcUsers.getProfile(defender).isDead()) + return; + if(defender.getHealth() - event.getDamage() <= 0){ + defender.setHealth(0); + mcm.getInstance().simulateNaturalDrops(defender); + if(y instanceof Creeper){ + mcUsers.getProfile(defender).setDead(true); + for(Player derp : plugin.getServer().getOnlinePlayers()){ + derp.sendMessage(ChatColor.GRAY + "A "+ChatColor.DARK_GREEN+"Creeper"+ChatColor.GRAY+" has killed "+ChatColor.DARK_RED+defender.getName()); + } + } + if(y instanceof Skeleton){ + mcUsers.getProfile(defender).setDead(true); + for(Player derp : plugin.getServer().getOnlinePlayers()){ + derp.sendMessage(ChatColor.GRAY + "A "+ChatColor.WHITE+"Skeleton"+ChatColor.GRAY+" has killed "+ChatColor.DARK_RED+defender.getName()); + } + } + if(y instanceof Spider){ + mcUsers.getProfile(defender).setDead(true); + for(Player derp : plugin.getServer().getOnlinePlayers()){ + derp.sendMessage(ChatColor.GRAY + "A "+ChatColor.DARK_PURPLE+"Spider"+ChatColor.GRAY+" has killed "+ChatColor.DARK_RED+defender.getName()); + } + } + if(y instanceof Zombie){ + mcUsers.getProfile(defender).setDead(true); + for(Player derp : plugin.getServer().getOnlinePlayers()){ + derp.sendMessage(ChatColor.GRAY + "A "+ChatColor.DARK_BLUE+"Zombie"+ChatColor.GRAY+" has killed "+ChatColor.DARK_RED+defender.getName()); + } + } + } + } + } if(y instanceof Player){ int type = ((Player) y).getItemInHand().getTypeId(); Player attacker = (Player)y; if(x instanceof Squid){ + Squid defender = (Squid)event.getEntity(); + if(isSwords(attacker.getItemInHand()) && defender.getHealth() > 0){ + if(Math.random() * 10 > 9){ + mcUsers.getProfile(attacker).skillUpSwords(1); + attacker.sendMessage(ChatColor.YELLOW+"Swords skill increased by 1. Total ("+mcUsers.getProfile(attacker).getSwords()+")"); + } + } + /* + * UNARMED VS SQUID + */ if(type == 0){ - Squid defender = (Squid)event.getEntity(); if(defender.getHealth() <= 0) return; if(mcUsers.getProfile(attacker).getUnarmedInt() >= 50 && mcUsers.getProfile(attacker).getUnarmedInt() < 100){ @@ -68,6 +191,12 @@ public class mcEntityListener extends EntityListener { if(x instanceof Monster){ if(type == 0){ Monster defender = (Monster)event.getEntity(); + if(isSwords(attacker.getItemInHand()) && defender.getHealth() > 0){ + if(Math.random() * 10 > 9){ + mcUsers.getProfile(attacker).skillUpSwords(1); + attacker.sendMessage(ChatColor.YELLOW+"Swords skill increased by 1. Total ("+mcUsers.getProfile(attacker).getSwords()+")"); + } + } if(defender.getHealth() <= 0) return; if(mcUsers.getProfile(attacker).getUnarmedInt() >= 50 && mcUsers.getProfile(attacker).getUnarmedInt() < 100){ @@ -215,6 +344,20 @@ public class mcEntityListener extends EntityListener { } } } + public boolean isSwords(ItemStack is){ + if(is.getTypeId() == 268 || is.getTypeId() == 267 || is.getTypeId() == 271 || is.getTypeId() == 283 || is.getTypeId() == 276){ + return true; + } else { + return false; + } + } + public boolean isBow(ItemStack is){ + if (is.getTypeId() == 261){ + return true; + } else { + return false; + } + } public boolean simulateUnarmedProc(Player player){ if(mcUsers.getProfile(player).getUnarmedInt() >= 750){ if(Math.random() * 10 > 4){ @@ -263,33 +406,219 @@ public class mcEntityListener extends EntityListener { return health; } } + public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) { + Entity y = event.getDamager(); + Entity x = event.getEntity(); + /* + * Defender is player + */ + if(y instanceof Player){ + Player attacker = (Player)y; + /* + * Defender is Monster + */ + if(x instanceof Monster){ + Monster defender = (Monster)x; + if(mcUsers.getProfile(attacker).getArcheryInt() >= 50 && mcUsers.getProfile(attacker).getArcheryInt() < 150) + defender.setHealth(defender.getHealth() - 1); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 150 && mcUsers.getProfile(attacker).getArcheryInt() < 375) + defender.setHealth(defender.getHealth() - 2); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 375 && mcUsers.getProfile(attacker).getArcheryInt() < 525) + defender.setHealth(defender.getHealth() - 3); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 525 && mcUsers.getProfile(attacker).getArcheryInt() < 800) + defender.setHealth(defender.getHealth() - 4); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 800 && mcUsers.getProfile(attacker).getArcheryInt() < 1000) + defender.setHealth(defender.getHealth() - 6); + if(defender.getHealth() <= 0) + mcm.getInstance().simulateNaturalDrops(defender); + //XP + if(Math.random() * 10 > 7){ + mcUsers.getProfile(attacker).skillUpArchery(1); + attacker.sendMessage(ChatColor.YELLOW+"Archery skill increased by 1. Total ("+mcUsers.getProfile(attacker).getArchery()+")"); + } + } + /* + * Defender is Animals + */ + if(x instanceof Animals){ + Monster defender = (Monster)x; + if(mcUsers.getProfile(attacker).getArcheryInt() >= 50 && mcUsers.getProfile(attacker).getArcheryInt() < 150) + defender.setHealth(defender.getHealth() - 1); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 150 && mcUsers.getProfile(attacker).getArcheryInt() < 375) + defender.setHealth(defender.getHealth() - 2); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 375 && mcUsers.getProfile(attacker).getArcheryInt() < 525) + defender.setHealth(defender.getHealth() - 3); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 525 && mcUsers.getProfile(attacker).getArcheryInt() < 800) + defender.setHealth(defender.getHealth() - 4); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 800 && mcUsers.getProfile(attacker).getArcheryInt() < 1000) + defender.setHealth(defender.getHealth() - 6); + if(defender.getHealth() <= 0) + mcm.getInstance().simulateNaturalDrops(defender); + } + /* + * Defender is Squid + */ + if(x instanceof Squid){ + Monster defender = (Monster)x; + if(mcUsers.getProfile(attacker).getArcheryInt() >= 50 && mcUsers.getProfile(attacker).getArcheryInt() < 150) + defender.setHealth(defender.getHealth() - 1); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 150 && mcUsers.getProfile(attacker).getArcheryInt() < 375) + defender.setHealth(defender.getHealth() - 2); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 375 && mcUsers.getProfile(attacker).getArcheryInt() < 525) + defender.setHealth(defender.getHealth() - 3); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 525 && mcUsers.getProfile(attacker).getArcheryInt() < 800) + defender.setHealth(defender.getHealth() - 4); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 800 && mcUsers.getProfile(attacker).getArcheryInt() < 1000) + defender.setHealth(defender.getHealth() - 6); + if(defender.getHealth() <= 0) + mcm.getInstance().simulateNaturalDrops(defender); + } + /* + * Attacker is Player + */ + if(x instanceof Player){ + Player defender = (Player)x; + Location loc = defender.getLocation(); + loc.setPitch(90); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 200 && mcUsers.getProfile(attacker).getArcheryInt() < 400){ + if(Math.random() * 10 > 7){ + defender.teleportTo(loc); + defender.sendMessage(ChatColor.DARK_RED+"Touched Fuzzy. Felt Dizzy."); + attacker.sendMessage("Target was "+ChatColor.DARK_RED+"Dazed"); + } + } + if(mcUsers.getProfile(attacker).getArcheryInt() >= 400){ + if(Math.random() * 10 > 4){ + defender.teleportTo(loc); + defender.sendMessage(ChatColor.DARK_RED+"Touched Fuzzy. Felt Dizzy."); + attacker.sendMessage("Target was "+ChatColor.DARK_RED+"Dazed"); + } + } + if(mcUsers.getProfile(attacker).getArcheryInt() >= 50 && mcUsers.getProfile(attacker).getArcheryInt() < 150) + defender.setHealth(defender.getHealth() - 1); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 150 && mcUsers.getProfile(attacker).getArcheryInt() < 375) + defender.setHealth(defender.getHealth() - 2); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 375 && mcUsers.getProfile(attacker).getArcheryInt() < 525) + defender.setHealth(defender.getHealth() - 3); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 525 && mcUsers.getProfile(attacker).getArcheryInt() < 800) + defender.setHealth(defender.getHealth() - 4); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 800 && mcUsers.getProfile(attacker).getArcheryInt() < 1000) + defender.setHealth(defender.getHealth() - 6); + if(defender.getHealth() >= 0){ + if(mcUsers.getProfile(defender).isDead()) + return; + if(defender.getHealth() <= 0){ + for(ItemStack i : defender.getInventory().getContents()){ + if(i != null && i.getTypeId() != 0) + defender.getLocation().getWorld().dropItemNaturally(defender.getLocation(), i); + } + for(Player derp : plugin.getServer().getOnlinePlayers()){ + derp.sendMessage(ChatColor.GRAY+attacker.getName() + " has " +ChatColor.DARK_RED+"slain "+ChatColor.GRAY+defender.getName() + " with an arrow."); + mcUsers.getProfile(defender).setDead(true); + } + } + } + + if(mcUsers.getProfile(defender).isDead()) + return; + if(defender.getHealth() - event.getDamage() <= 0){ + for(Player derp : plugin.getServer().getOnlinePlayers()){ + derp.sendMessage(ChatColor.GRAY+attacker.getName() + " has " +ChatColor.DARK_RED+"slain "+ChatColor.GRAY+defender.getName() + " with an arrow."); + mcUsers.getProfile(defender).setDead(true); + } + } + } + } + + } public void onEntityDamage(EntityDamageEvent event) { - //Thanks to TimberJaw for sharing his source code! Entity x = event.getEntity(); if(x instanceof Player){ - Player player = (Player)x; - if((player.getHealth() - event.getDamage()) <= 0){ - Location deathLoc = player.getLocation(); - ItemStack[] items = player.getInventory().getContents(); - for(int i = 0; i < items.length; i++) - { - ItemStack is = items[i]; - if(is != null && is.getAmount() > 0) - { - player.getWorld().dropItemNaturally(deathLoc, is); - } + Player player = (Player)x; + DamageCause type = event.getCause(); + Location loc = player.getLocation(); + int xx = loc.getBlockX(); + int y = loc.getBlockY(); + int z = loc.getBlockZ(); + if(type == DamageCause.FALL){ + if(mcUsers.getProfile(player).getAcrobaticsInt() >= 50 && mcUsers.getProfile(player).getAcrobaticsInt() < 150 ){ + if(Math.random() * 10 > 8){ + event.setCancelled(true); + player.sendMessage("**ROLLED**"); + return; + } } - player.setHealth(20); - player.teleportTo(mcUsers.getProfile(player).getMySpawn(player)); - if(mcUsers.getProfile(player).isDead()){ - mcUsers.getProfile(player).setDead(false); + if(mcUsers.getProfile(player).getAcrobaticsInt() >= 150 && mcUsers.getProfile(player).getAcrobaticsInt() < 250 ){ + if(Math.random() * 10 > 6){ + event.setCancelled(true); + player.sendMessage("**ROLLED**"); + return; + } + } + if(mcUsers.getProfile(player).getAcrobaticsInt() >= 250 && mcUsers.getProfile(player).getAcrobaticsInt() < 350 ){ + if(Math.random() * 10 > 4){ + event.setCancelled(true); + player.sendMessage("**ROLLED**"); + return; + } + } + if(mcUsers.getProfile(player).getAcrobaticsInt() >= 350 && mcUsers.getProfile(player).getAcrobaticsInt() < 450 ){ + if(Math.random() * 10 > 2){ + event.setCancelled(true); + player.sendMessage("**BARREL ROLLED**"); + return; + } + } + if(mcUsers.getProfile(player).getAcrobaticsInt() >= 450){ + event.setCancelled(true); + player.sendMessage("**ROLLED... LIKE A BOSS**"); + return; + } + if(!mcConfig.getInstance().isBlockWatched(loc.getWorld().getBlockAt(xx, y, z))){ + if(event.getDamage() >= 2 && event.getDamage() < 6){ + mcUsers.getProfile(player).skillUpAcrobatics(1); + player.sendMessage(ChatColor.YELLOW+"Acrobatics skill increased by 1. Total ("+mcUsers.getProfile(player).getAcrobatics()+")"); + } + if(event.getDamage() >= 6 && event.getDamage() < 19){ + mcUsers.getProfile(player).skillUpAcrobatics(2); + player.sendMessage(ChatColor.YELLOW+"Acrobatics skill increased by 2. Total ("+mcUsers.getProfile(player).getAcrobatics()+")"); + } + if(event.getDamage() >= 19){ + mcUsers.getProfile(player).skillUpAcrobatics(6); + player.sendMessage(ChatColor.YELLOW+"Acrobatics skill increased by 6. Total ("+mcUsers.getProfile(player).getAcrobatics()+")"); + } + } + if(player.getHealth() - event.getDamage() <= 0){ + if(mcUsers.getProfile(player).isDead()) + return; + mcUsers.getProfile(player).setDead(true); + for(Player bidoof : plugin.getServer().getOnlinePlayers()){ + bidoof.sendMessage(ChatColor.GRAY+player.getName()+" has "+ChatColor.DARK_RED+"fallen "+ChatColor.GRAY+"to death."); + } + } + mcConfig.getInstance().addBlockWatch(loc.getWorld().getBlockAt(xx, y, z)); + } + if(type == DamageCause.DROWNING){ + if(mcUsers.getProfile(player).isDead()) return; + if(player.getHealth() - event.getDamage() <= 0){ + mcUsers.getProfile(player).setDead(true); + for(Player slipslap : plugin.getServer().getOnlinePlayers()){ + slipslap.sendMessage(ChatColor.GRAY+player.getName()+" has "+ChatColor.AQUA+"drowned."); + } } - for(Player derp : plugin.getServer().getOnlinePlayers()){ - derp.sendMessage(ChatColor.GRAY+player.getName() + " has died."); - } + } + if(type == DamageCause.FIRE || type == DamageCause.FIRE_TICK){ + if(mcUsers.getProfile(player).isDead()) + return; + if(player.getHealth() - event.getDamage() <= 0){ + mcUsers.getProfile(player).setDead(true); + for(Player slipslap : plugin.getServer().getOnlinePlayers()){ + slipslap.sendMessage(ChatColor.GRAY+player.getName()+" has "+ChatColor.RED+"burned "+ChatColor.GRAY+"to death."); + } } } + } } public void onEntityDeath(EntityDeathEvent event) { Entity x = event.getEntity(); diff --git a/mcMMO/com/bukkit/nossr50/mcMMO/mcMMO.java b/mcMMO/com/bukkit/nossr50/mcMMO/mcMMO.java index 4ce123a11..2f01ae020 100644 --- a/mcMMO/com/bukkit/nossr50/mcMMO/mcMMO.java +++ b/mcMMO/com/bukkit/nossr50/mcMMO/mcMMO.java @@ -51,6 +51,9 @@ public class mcMMO extends JavaPlugin { pm.registerEvent(Event.Type.PLAYER_ITEM, playerListener, Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_RESPAWN, playerListener, Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_ITEM_HELD, playerListener, Priority.Normal, this); + pm.registerEvent(Event.Type.ENTITY_DAMAGEDBY_PROJECTILE, entityListener, Priority.Normal, this); + pm.registerEvent(Event.Type.ENTITY_DAMAGEDBY_BLOCK, entityListener, Priority.Normal, this); + pm.registerEvent(Event.Type.ENTITY_DAMAGED, entityListener, Priority.Normal, this); //Displays a message when plugin is loaded PluginDescriptionFile pdfFile = this.getDescription(); mcPermissions.initialize(getServer()); diff --git a/mcMMO/com/bukkit/nossr50/mcMMO/mcPlayerListener.java b/mcMMO/com/bukkit/nossr50/mcMMO/mcPlayerListener.java index ff5bbebac..4415ddda4 100644 --- a/mcMMO/com/bukkit/nossr50/mcMMO/mcPlayerListener.java +++ b/mcMMO/com/bukkit/nossr50/mcMMO/mcPlayerListener.java @@ -24,7 +24,7 @@ public class mcPlayerListener extends PlayerListener { public void onPlayerRespawn(PlayerRespawnEvent event) { Player player = event.getPlayer(); if(mcPermissions.getInstance().mySpawn(player)){ - if(mcUsers.getProfile(player).getMySpawn(player) != null); + if(mcUsers.getProfile(player).getMySpawn(player) != null) event.setRespawnLocation(mcUsers.getProfile(player).getMySpawn(player)); } } @@ -89,13 +89,19 @@ public class mcPlayerListener extends PlayerListener { //BREAD if(is.getTypeId() == 297){ if(mcUsers.getProfile(player).getHerbalismInt() >= 50 && mcUsers.getProfile(player).getHerbalismInt() < 150){ + player.setHealth(player.getHealth() + 1); + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 150 && mcUsers.getProfile(player).getHerbalismInt() < 250){ player.setHealth(player.getHealth() + 2); - } else if (mcUsers.getProfile(player).getHerbalismInt() <= 250){ + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 250 && mcUsers.getProfile(player).getHerbalismInt() < 350){ + player.setHealth(player.getHealth() + 3); + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 350 && mcUsers.getProfile(player).getHerbalismInt() < 450){ player.setHealth(player.getHealth() + 4); - } else if (mcUsers.getProfile(player).getHerbalismInt() <= 400){ + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 450 && mcUsers.getProfile(player).getHerbalismInt() < 550){ player.setHealth(player.getHealth() + 5); - } else if (mcUsers.getProfile(player).getHerbalismInt() < 750){ + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 550 && mcUsers.getProfile(player).getHerbalismInt() < 650){ player.setHealth(player.getHealth() + 6); + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 650 && mcUsers.getProfile(player).getHerbalismInt() < 750){ + player.setHealth(player.getHealth() + 7); } else if (mcUsers.getProfile(player).getHerbalismInt() >= 750){ player.setHealth(player.getHealth() + 8); } @@ -104,14 +110,20 @@ public class mcPlayerListener extends PlayerListener { if(is.getTypeId() == 282){ if(mcUsers.getProfile(player).getHerbalismInt() >= 50 && mcUsers.getProfile(player).getHerbalismInt() < 150){ player.setHealth(player.getHealth() + 1); - } else if (mcUsers.getProfile(player).getHerbalismInt() <= 250){ + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 150 && mcUsers.getProfile(player).getHerbalismInt() < 250){ player.setHealth(player.getHealth() + 2); - } else if (mcUsers.getProfile(player).getHerbalismInt() <= 400){ + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 250 && mcUsers.getProfile(player).getHerbalismInt() < 350){ player.setHealth(player.getHealth() + 3); - } else if (mcUsers.getProfile(player).getHerbalismInt() < 750){ + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 350 && mcUsers.getProfile(player).getHerbalismInt() < 450){ player.setHealth(player.getHealth() + 4); - } else if (mcUsers.getProfile(player).getHerbalismInt() >= 750){ + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 450 && mcUsers.getProfile(player).getHerbalismInt() < 550){ + player.setHealth(player.getHealth() + 5); + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 550 && mcUsers.getProfile(player).getHerbalismInt() < 650){ player.setHealth(player.getHealth() + 6); + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 650 && mcUsers.getProfile(player).getHerbalismInt() < 750){ + player.setHealth(player.getHealth() + 7); + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 750){ + player.setHealth(player.getHealth() + 8); } } if(block != null && block.getTypeId() == 42){ @@ -160,7 +172,7 @@ public class mcPlayerListener extends PlayerListener { } //end if block is iron block bracket } //end onPlayerItem bracket public void needMoreVespeneGas(ItemStack is, Player player){ - if (mcm.getInstance().isDiamondTools(is) && mcUsers.getProfile(player).getRepairInt() < 50){ + if ((mcm.getInstance().isDiamondTools(is) || mcm.getInstance().isDiamondArmor(is) ) && mcUsers.getProfile(player).getRepairInt() < 50){ player.sendMessage(ChatColor.DARK_RED +"You're not adept enough to repair Diamond"); } else if (mcm.getInstance().isDiamondTools(is) && !mcm.getInstance().hasDiamond(player) || mcm.getInstance().isIronTools(is) && !mcm.getInstance().hasIron(player)){ if(mcm.getInstance().isDiamondTools(is) && !mcm.getInstance().hasDiamond(player)) @@ -312,7 +324,11 @@ public class mcPlayerListener extends PlayerListener { player.sendMessage("Woodcutting Skill: "+mcUsers.getProfile(target).getWoodCutting()); player.sendMessage("Unarmed Skill: "+mcUsers.getProfile(target).getUnarmed()); player.sendMessage("Herbalism Skill: "+mcUsers.getProfile(target).getHerbalism()); - player.sendMessage("Excavation Skill: "+mcUsers.getProfile(target).getWoodCutting()); + player.sendMessage("Excavation Skill: "+mcUsers.getProfile(target).getExcavation()); + player.sendMessage("Archery Skill: "+mcUsers.getProfile(target).getArchery()); + player.sendMessage("Swords Skill: "+mcUsers.getProfile(target).getSwords()); + player.sendMessage("Axes Skill: "+mcUsers.getProfile(target).getAxes()); + player.sendMessage("Acrobatics Skill: "+mcUsers.getProfile(target).getAcrobatics()); player.sendMessage(ChatColor.GREEN+"~~COORDINATES~~"); player.sendMessage("X: "+x); player.sendMessage("Y: "+y); @@ -340,6 +356,10 @@ public class mcPlayerListener extends PlayerListener { player.sendMessage(ChatColor.DARK_GREEN + "Unarmed Skill: " + mcUsers.getProfile(player).getUnarmed()); player.sendMessage(ChatColor.DARK_GREEN + "Herbalism Skill: " + mcUsers.getProfile(player).getHerbalism()); player.sendMessage(ChatColor.DARK_GREEN + "Excavation Skill: " + mcUsers.getProfile(player).getExcavation()); + player.sendMessage(ChatColor.DARK_GREEN + "Archery Skill: " + mcUsers.getProfile(player).getArchery()); + player.sendMessage(ChatColor.DARK_GREEN + "Swords Skill: " + mcUsers.getProfile(player).getSwords()); + player.sendMessage(ChatColor.DARK_GREEN + "Axes Skill: " + mcUsers.getProfile(player).getAxes()); + player.sendMessage(ChatColor.DARK_GREEN + "Acrobatics Skill: " + mcUsers.getProfile(player).getAcrobatics()); } //Party command if(split[0].equalsIgnoreCase("/party")){ diff --git a/mcMMO/com/bukkit/nossr50/mcMMO/mcUsers.java b/mcMMO/com/bukkit/nossr50/mcMMO/mcUsers.java index 1fb02ad45..00e97a488 100644 --- a/mcMMO/com/bukkit/nossr50/mcMMO/mcUsers.java +++ b/mcMMO/com/bukkit/nossr50/mcMMO/mcUsers.java @@ -153,7 +153,8 @@ class PlayerList class PlayerProfile { protected final Logger log = Logger.getLogger("Minecraft"); - private String playerName, gather, wgather, woodcutting, repair, mining, party, myspawn, unarmed, herbalism, excavation; + private String playerName, gather, wgather, woodcutting, repair, mining, party, myspawn, unarmed, herbalism, excavation, + archery, swords, axes, acrobatics; private boolean dead; char defaultColor; @@ -178,6 +179,10 @@ class PlayerList unarmed = new String(); herbalism = new String(); excavation = new String(); + archery = new String(); + swords = new String(); + axes = new String(); + acrobatics = new String(); //mining = "0"; wgather = new String(); //wgather = "0"; @@ -230,6 +235,14 @@ class PlayerList herbalism = character[9]; if(character.length > 10) excavation = character[10]; + if(character.length > 11) + archery = character[11]; + if(character.length > 12) + swords = character[12]; + if(character.length > 13) + axes = character[13]; + if(character.length > 14) + acrobatics = character[14]; in.close(); return true; } @@ -279,6 +292,10 @@ class PlayerList writer.append(unarmed+":"); writer.append(herbalism+":"); writer.append(excavation+":"); + writer.append(archery+":"); + writer.append(swords+":"); + writer.append(axes+":"); + writer.append(acrobatics+":"); writer.append("\r\n"); } } @@ -310,6 +327,10 @@ class PlayerList out.append(0+":"); //unarmed out.append(0+":"); //herbalism out.append(0+":"); //excavation + out.append(0+":"); //archery + out.append(0+":"); //swords + out.append(0+":"); //axes + out.append(0+":"); //acrobatics //Add more in the same format as the line above out.newLine(); @@ -329,6 +350,62 @@ class PlayerList { return player.getName().equals(playerName); } + public void skillUpAxes(int newskill){ + int x = 0; + if(axes != null){ + if(isInt(axes)){ + x = Integer.parseInt(axes); + }else { + axes = "0"; + x = Integer.parseInt(axes); + } + } + x += newskill; + axes = Integer.toString(x); + save(); + } + public void skillUpAcrobatics(int newskill){ + int x = 0; + if(acrobatics != null){ + if(isInt(acrobatics)){ + x = Integer.parseInt(acrobatics); + }else { + acrobatics = "0"; + x = Integer.parseInt(acrobatics); + } + } + x += newskill; + acrobatics = Integer.toString(x); + save(); + } + public void skillUpSwords(int newskill){ + int x = 0; + if(swords != null){ + if(isInt(swords)){ + x = Integer.parseInt(swords); + }else { + swords = "0"; + x = Integer.parseInt(swords); + } + } + x += newskill; + swords = Integer.toString(x); + save(); + } + public void skillUpArchery(int newskill){ + int x = 0; + if(archery != null){ + if(isInt(archery)){ + x = Integer.parseInt(archery); + }else { + archery = "0"; + x = Integer.parseInt(archery); + } + } + x += newskill; + archery = Integer.toString(x); + save(); + } public void skillUpRepair(int newskill){ int x = 0; if(repair != null){ @@ -428,6 +505,18 @@ class PlayerList public String getExcavation(){ return excavation; } + public String getArchery(){ + return archery; + } + public String getSwords(){ + return swords; + } + public String getAxes(){ + return axes; + } + public String getAcrobatics(){ + return acrobatics; + } public int getMiningInt(){ if(isInt(mining)){ int x = Integer.parseInt(mining); @@ -444,6 +533,38 @@ class PlayerList return 0; } } + public int getArcheryInt(){ + if(isInt(archery)){ + int x = Integer.parseInt(archery); + return x; + } else{ + return 0; + } + } + public int getSwordsInt(){ + if(isInt(swords)){ + int x = Integer.parseInt(swords); + return x; + } else{ + return 0; + } + } + public int getAxesInt(){ + if(isInt(axes)){ + int x = Integer.parseInt(axes); + return x; + } else{ + return 0; + } + } + public int getAcrobaticsInt(){ + if(isInt(acrobatics)){ + int x = Integer.parseInt(acrobatics); + return x; + } else{ + return 0; + } + } public int getHerbalismInt(){ if(isInt(herbalism)){ int x = Integer.parseInt(herbalism); @@ -530,6 +651,15 @@ class PlayerList } return true; } + public boolean isDouble(String string){ + try { + Double x = Double.valueOf(string); + } + catch(NumberFormatException nFE) { + return false; + } + return true; + } //Returns player gather public String getgather() { return gather; } public String getwgather() { return wgather; } @@ -603,9 +733,13 @@ class PlayerList } public Location getMySpawn(Player player){ Location loc = player.getLocation(); + if(isDouble(getX()) && isDouble(getY()) && isDouble(getX())){ loc.setX(Double.parseDouble(mcUsers.getProfile(player).getX())); loc.setY(Double.parseDouble(mcUsers.getProfile(player).getY())); loc.setZ(Double.parseDouble(mcUsers.getProfile(player).getZ())); + } else { + return null; + } loc.setYaw(0); loc.setPitch(0); return loc; diff --git a/mcMMO/com/bukkit/nossr50/mcMMO/mcm.java b/mcMMO/com/bukkit/nossr50/mcMMO/mcm.java index 5c981c89b..0708de4e7 100644 --- a/mcMMO/com/bukkit/nossr50/mcMMO/mcm.java +++ b/mcMMO/com/bukkit/nossr50/mcMMO/mcm.java @@ -29,6 +29,22 @@ public class mcm { return false; } } + public boolean hasArrows(Player player){ + for(ItemStack x : player.getInventory().getContents()){ + if (x.getTypeId() == 262){ + return true; + } + } + return false; + } + public void addArrows(Player player){ + for(ItemStack x : player.getInventory().getContents()){ + if (x.getTypeId() == 262){ + x.setAmount(x.getAmount() + 1); + return; + } + } + } public void simulateNaturalDrops(Entity entity){ Location loc = entity.getLocation(); if(entity instanceof Pig){ @@ -332,11 +348,11 @@ public class mcm { if(Math.random() * 10 > 6) loc.getWorld().dropItemNaturally(loc, is); } - if(mcUsers.getProfile(player).getHerbalismInt() >= 150 && mcUsers.getProfile(player).getHerbalismInt() < 500 ){ + if(mcUsers.getProfile(player).getHerbalismInt() >= 350 && mcUsers.getProfile(player).getHerbalismInt() < 500 ){ if(Math.random() * 10 > 4) loc.getWorld().dropItemNaturally(loc, is); } - if(mcUsers.getProfile(player).getHerbalismInt() >= 150 && mcUsers.getProfile(player).getHerbalismInt() < 750 ){ + if(mcUsers.getProfile(player).getHerbalismInt() >= 500 && mcUsers.getProfile(player).getHerbalismInt() < 750 ){ if(Math.random() * 10 > 2) loc.getWorld().dropItemNaturally(loc, is); } diff --git a/mcMMO/plugin.yml b/mcMMO/plugin.yml index 757b09777..1e0bc36a3 100644 --- a/mcMMO/plugin.yml +++ b/mcMMO/plugin.yml @@ -1,3 +1,3 @@ name: mcMMO main: com.bukkit.nossr50.mcMMO.mcMMO -version: 0.4.4 \ No newline at end of file +version: 0.5 \ No newline at end of file