From d1a7e5b661c1f1f585cde9a35adcc7bb14e375b2 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 22 Apr 2011 17:28:15 -0700 Subject: [PATCH] Another WIP --- mcMMO/com/gmail/nossr50/Combat.java | 486 +++++------------- mcMMO/com/gmail/nossr50/Database.java | 42 +- .../nossr50/datatypes/PlayerProfile.java | 14 +- .../gmail/nossr50/datatypes/PlayerStat.java | 2 +- mcMMO/com/gmail/nossr50/m.java | 32 +- mcMMO/com/gmail/nossr50/mcEntityListener.java | 2 +- mcMMO/com/gmail/nossr50/mcMMO.java | 3 +- mcMMO/com/gmail/nossr50/mcPlayerListener.java | 12 +- mcMMO/com/gmail/nossr50/skills/Axes.java | 36 ++ mcMMO/com/gmail/nossr50/skills/Swords.java | 3 + mcMMO/com/gmail/nossr50/skills/Taming.java | 10 +- mcMMO/com/gmail/nossr50/skills/Unarmed.java | 57 +- 12 files changed, 328 insertions(+), 371 deletions(-) diff --git a/mcMMO/com/gmail/nossr50/Combat.java b/mcMMO/com/gmail/nossr50/Combat.java index a29aa04f2..a4e186ce5 100644 --- a/mcMMO/com/gmail/nossr50/Combat.java +++ b/mcMMO/com/gmail/nossr50/Combat.java @@ -16,7 +16,9 @@ import org.bukkit.entity.Zombie; 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.inventory.ItemStack; +import org.bukkit.plugin.Plugin; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.LoadProperties; @@ -26,17 +28,19 @@ import com.gmail.nossr50.skills.Acrobatics; import com.gmail.nossr50.skills.Axes; import com.gmail.nossr50.skills.Skills; import com.gmail.nossr50.skills.Swords; +import com.gmail.nossr50.skills.Taming; +import com.gmail.nossr50.skills.Unarmed; public class Combat { private static mcMMO plugin; public Combat(mcMMO instance) { plugin = instance; } - public static void combatChecks(EntityDamageEvent event){ + public static void combatChecks(EntityDamageEvent event, Plugin pluginx){ if(event.isCancelled() || event.getDamage() == 0) return; /* - * OFFENSIVE CHECKS + * OFFENSIVE CHECKS FOR PLAYERS VERSUS ENTITIES */ if(event instanceof EntityDamageByEntityEvent && ((EntityDamageByEntityEvent) event).getDamager() instanceof Player) { @@ -45,27 +49,114 @@ public class Combat { Player attacker = (Player)((EntityDamageByEntityEvent) event).getDamager(); PlayerProfile PPa = Users.getProfile(attacker); + //Damage modifiers + if(mcPermissions.getInstance().unarmed(attacker) && attacker.getItemInHand().getTypeId() == 0) //Unarmed + Unarmed.unarmedBonus(attacker, eventb); + if(m.isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker) && PPa.getAxesInt() >= 500) + event.setDamage(event.getDamage()+4); + //If there are any abilities to activate combatAbilityChecks(attacker, PPa); + //Check for offensive procs + Axes.axeCriticalCheck(attacker, eventb); //Axe Criticals + if(!Config.getInstance().isBleedTracked(event.getEntity())) //Swords Bleed + Swords.bleedCheck(attacker, event.getEntity()); + //Modify the event damage if Attacker is Berserk if(PPa.getBerserkMode()) event.setDamage(event.getDamage() + (event.getDamage() / 2)); - //Handle the combat interactions between the Player and the defending entity - if(event.getEntity() instanceof Player) - playerVersusPlayerChecks(eventb, attacker); - if(event.getEntity() instanceof Animals) - playerVersusAnimalsChecks(eventb, attacker); - if(event.getEntity() instanceof Monster) - playerVersusMonsterChecks(eventb, attacker); - if(event.getEntity() instanceof Squid) - playerVersusSquidChecks(eventb, attacker); //Handle Ability Interactions if(PPa.getSkullSplitterMode() && m.isAxes(attacker.getItemInHand())) Axes.applyAoeDamage(attacker, eventb); if(PPa.getSerratedStrikesMode() && m.isSwords(attacker.getItemInHand())) Swords.applySerratedStrikes(attacker, eventb); + + //Experience + if(event.getEntity() instanceof Player) + { + Player defender = (Player)event.getEntity(); + PlayerProfile PPd = Users.getProfile(defender); + if(attacker != null && defender != null && LoadProperties.pvpxp) + { + if(System.currentTimeMillis() >= PPd.getRespawnATS() + 5000 && defender.getHealth() >= 1) + { + if(m.isAxes(attacker.getItemInHand())) + PPa.addAxesXP((event.getDamage() * 3) * LoadProperties.pvpxprewardmodifier); + if(m.isSwords(attacker.getItemInHand())) + PPa.addSwordsXP((event.getDamage() * 3) * LoadProperties.pvpxprewardmodifier); + if(attacker.getItemInHand().getTypeId() == 0) + PPa.addUnarmedXP((event.getDamage() * 3) * LoadProperties.pvpxprewardmodifier); + } + } + } + + if(event.getEntity() instanceof Monster) + { + int xp = 0; + if(event.getEntity() instanceof Creeper) + xp = (event.getDamage() * 4) * LoadProperties.xpGainMultiplier; + if(event.getEntity() instanceof Spider) + xp = (event.getDamage() * 3) * LoadProperties.xpGainMultiplier; + if(event.getEntity() instanceof Skeleton) + xp = (event.getDamage() * 2) * LoadProperties.xpGainMultiplier; + if(event.getEntity() instanceof Zombie) + xp = (event.getDamage() * 2) * LoadProperties.xpGainMultiplier; + if(event.getEntity() instanceof PigZombie) + xp = (event.getDamage() * 3) * LoadProperties.xpGainMultiplier; + + if(m.isSwords(attacker.getItemInHand()) && mcPermissions.getInstance().swords(attacker)) + PPa.addSwordsXP(xp); + if(m.isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)) + PPa.addAxesXP(xp); + if(attacker.getItemInHand().getTypeId() == 0 && mcPermissions.getInstance().unarmed(attacker)) + PPa.addUnarmedXP(xp); + } + Skills.XpCheck(attacker); + + //Taming Debug Stuff + if(event.getEntity() instanceof Wolf) + { + attacker.sendMessage("mcMMO Debug: Wolf Owner Name "+Taming.getOwnerName(event.getEntity())); + event.setCancelled(true); + } + } + /* + * OFFENSIVE CHECKS FOR WOLVES VERSUS ENTITIES + */ + if(event instanceof EntityDamageByEntityEvent && ((EntityDamageByEntityEvent) event).getDamager() instanceof Wolf){ + EntityDamageByEntityEvent eventb = (EntityDamageByEntityEvent) event; + if(Taming.hasOwner(eventb.getDamager(), pluginx)){ + Player master = Taming.getOwner(eventb.getDamager(), pluginx); + PlayerProfile PPo = Users.getProfile(master); + + //Sharpened Claws + if(PPo.getTamingInt() >= 750) + { + event.setDamage(event.getDamage() + 2); + } + + //Gore + if(Math.random() * 1000 <= PPo.getTamingInt()) + { + event.setDamage(event.getDamage() * 2); + + if(event.getEntity() instanceof Player) + { + Player target = (Player)event.getEntity(); + target.sendMessage(ChatColor.RED+"**STRUCK BY GORE**"); + Users.getProfile(target).setBleedTicks(2); + } + else + Config.getInstance().addToBleedQue(event.getEntity()); + + master.sendMessage(ChatColor.GREEN+"**GORE**"); + } + PPo.addTamingXP(event.getDamage() * 4); + master.sendMessage("mcMMO Debug: Event Damage "+event.getDamage()); + Skills.XpCheck(master); + } } //Another offensive check for Archery if(event instanceof EntityDamageByProjectileEvent) @@ -81,6 +172,27 @@ public class Combat { Swords.counterAttackChecks(event); Acrobatics.dodgeChecks((EntityDamageByEntityEvent)event); } + /* + * DEFENSIVE CHECKS FOR WOLVES + */ + if(event.getEntity() instanceof Wolf){ + if(Taming.hasOwner(event.getEntity(), pluginx)) + { + Player master = Taming.getOwner(event.getEntity(), pluginx); + PlayerProfile PPo = Users.getProfile(master); + + //Shock-Proof + if((event.getCause() == DamageCause.ENTITY_EXPLOSION || event.getCause() == DamageCause.BLOCK_EXPLOSION) && PPo.getTamingInt() >= 500) + { + event.setDamage(event.getDamage() / 6); + } + + //Thick Fur + if(PPo.getTamingInt() >= 250) + event.setDamage(event.getDamage() / 2); + master.sendMessage("mcMMO Debug: Wolf Damage Taken "+event.getDamage()); + } + } } public static void combatAbilityChecks(Player attacker, PlayerProfile PPa){ @@ -92,239 +204,6 @@ public class Combat { if(PPa.getFistsPreparationMode()) Skills.berserkActivationCheck(attacker, plugin); } - public static void playerVersusPlayerChecks(EntityDamageByEntityEvent event, Player attacker){ - Entity x = event.getEntity(); - if(x instanceof Player){ - if(LoadProperties.pvp == false){ - event.setCancelled(true); - return; - } - PlayerProfile PPa = Users.getProfile(attacker); - Player defender = (Player)x; - PlayerProfile PPd = Users.getProfile(defender); - - /* - * COMPATABILITY CHECKS (Stuff that wouldn't happen normally in basically...) - */ - if(Users.getProfile(defender) == null) - Users.addUser(defender); - if(attacker != null && defender != null && Users.getProfile(attacker).inParty() && Users.getProfile(defender).inParty()){ - if(Party.getInstance().inSameParty(defender, attacker)){ - event.setCancelled(true); - return; - } - } - /* - * AXE CRITICAL CHECK - */ - axeCriticalCheck(attacker, event, x); - if(!Config.getInstance().isBleedTracked(x)){ - Swords.bleedCheck(attacker, x); - } - if(defender != null && mcPermissions.getInstance().unarmed(attacker) && attacker.getItemInHand().getTypeId() == 0){ - - //Bonus just for having unarmed - int bonus = 2; - if (PPa.getUnarmedInt() >= 250) - bonus++; - if (PPa.getUnarmedInt() >= 500) - bonus++; - event.setDamage(calculateDamage(event, bonus)); - - //PROC - if(simulateUnarmedProc(attacker)){ - Location loc = defender.getLocation(); - if(defender.getItemInHand() != null && defender.getItemInHand().getTypeId() != 0){ - attacker.sendMessage(ChatColor.DARK_RED+"You have hit with great force."); - defender.sendMessage(ChatColor.DARK_RED+"You have been disarmed!"); - ItemStack item = defender.getItemInHand(); - if(item != null){ - loc.getWorld().dropItemNaturally(loc, item); - ItemStack itemx = null; - defender.setItemInHand(itemx); - } - } - } - } - /* - * PVP XP - */ - if(attacker != null && defender != null && LoadProperties.pvpxp){ - if(PPd.inParty() && PPa.inParty() && Party.getInstance().inSameParty(attacker, defender)) - return; - if(System.currentTimeMillis() >= PPd.getRespawnATS() + 5000 && defender.getHealth() >= 1){ - if(m.isAxes(attacker.getItemInHand())) - PPa.addAxesXP((event.getDamage() * 3) * LoadProperties.pvpxprewardmodifier); - if(m.isSwords(attacker.getItemInHand())) - PPa.addSwordsXP((event.getDamage() * 3) * LoadProperties.pvpxprewardmodifier); - if(attacker.getItemInHand().getTypeId() == 0) - PPa.addUnarmedXP((event.getDamage() * 3) * LoadProperties.pvpxprewardmodifier); - } - } - /* - * CHECK FOR LEVEL UPS - */ - Skills.XpCheck(attacker); - } - } - public static void playerVersusSquidChecks(EntityDamageByEntityEvent event, Player attacker){ - Entity x = event.getEntity(); - PlayerProfile PPa = Users.getProfile(attacker); - int type = attacker.getItemInHand().getTypeId(); - if(x instanceof Squid){ - if(!Config.getInstance().isBleedTracked(x)){ - Swords.bleedCheck(attacker, x); - } - Squid defender = (Squid)event.getEntity(); - if(m.isSwords(attacker.getItemInHand()) && defender.getHealth() > 0 && mcPermissions.getInstance().swords(attacker)){ - PPa.addSwordsXP(10 * LoadProperties.xpGainMultiplier); - } - Skills.XpCheck(attacker); - if(m.isAxes(attacker.getItemInHand()) - && defender.getHealth() > 0 - && mcPermissions.getInstance().axes(attacker)){ - PPa.addAxesXP(10 * LoadProperties.xpGainMultiplier); - Skills.XpCheck(attacker); - } - if(m.isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ - if(PPa.getAxesInt() >= 500){ - event.setDamage(calculateDamage(event, 4)); - } - } - /* - * UNARMED VS SQUID - */ - if(type == 0 && mcPermissions.getInstance().unarmed(attacker)){ - if(defender.getHealth() <= 0) - return; - - //Bonus just for having unarmed - int bonus = 2; - if (PPa.getUnarmedInt() >= 250) - bonus++; - if (PPa.getUnarmedInt() >= 500) - bonus++; - event.setDamage(calculateDamage(event, bonus)); - - //XP - if(defender.getHealth() != 0){ - PPa.addUnarmedXP(10 * LoadProperties.xpGainMultiplier); - Skills.XpCheck(attacker); - } - } - } - } - public static void playerVersusAnimalsChecks(EntityDamageByEntityEvent event, Player attacker){ - int type = attacker.getItemInHand().getTypeId(); - Entity x = event.getEntity(); - PlayerProfile PPa = Users.getProfile(attacker); - if(x instanceof Animals){ - if(!Config.getInstance().isBleedTracked(x)){ - Swords.bleedCheck(attacker, x); - } - Animals defender = (Animals)event.getEntity(); - if(m.isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ - if(defender.getHealth() <= 0) - return; - if(PPa.getAxesInt() >= 500){ - event.setDamage(calculateDamage(event, 4)); - } - } - if(type == 0 && mcPermissions.getInstance().unarmed(attacker)){ - //Bonus just for having unarmed - int bonus = 2; - if (PPa.getUnarmedInt() >= 250) - bonus++; - if (PPa.getUnarmedInt() >= 500) - bonus++; - event.setDamage(calculateDamage(event, bonus)); - } - } - } - public static void playerVersusMonsterChecks(EntityDamageByEntityEvent event, Player attacker){ - Entity x = event.getEntity(); - int type = attacker.getItemInHand().getTypeId(); - PlayerProfile PPa = Users.getProfile(attacker); - if(x instanceof Monster){ - /* - * AXE PROC CHECKS - */ - axeCriticalCheck(attacker, event, x); - if(!Config.getInstance().isBleedTracked(x)){ - Swords.bleedCheck(attacker, x); - } - Monster defender = (Monster)event.getEntity(); - if(m.isSwords(attacker.getItemInHand()) - && defender.getHealth() > 0 - && mcPermissions.getInstance().swords(attacker)){ - if(!Config.getInstance().isMobSpawnTracked(x)){ - if(x instanceof Creeper) - PPa.addSwordsXP((event.getDamage() * 4) * LoadProperties.xpGainMultiplier); - if(x instanceof Spider) - PPa.addSwordsXP((event.getDamage() * 3) * LoadProperties.xpGainMultiplier); - if(x instanceof Skeleton) - PPa.addSwordsXP((event.getDamage() * 2) * LoadProperties.xpGainMultiplier); - if(x instanceof Zombie) - PPa.addSwordsXP((event.getDamage() * 2) * LoadProperties.xpGainMultiplier); - if(x instanceof PigZombie) - PPa.addSwordsXP((event.getDamage() * 3) * LoadProperties.xpGainMultiplier); - } - Skills.XpCheck(attacker); - } - if(m.isAxes(attacker.getItemInHand()) - && defender.getHealth() > 0 - && mcPermissions.getInstance().axes(attacker)){ - if(!Config.getInstance().isMobSpawnTracked(x)){ - if(x instanceof Creeper) - PPa.addAxesXP((event.getDamage() * 4) * LoadProperties.xpGainMultiplier); - if(x instanceof Spider) - PPa.addAxesXP((event.getDamage() * 3) * LoadProperties.xpGainMultiplier); - if(x instanceof Skeleton) - PPa.addAxesXP((event.getDamage() * 2) * LoadProperties.xpGainMultiplier); - if(x instanceof Zombie) - PPa.addAxesXP((event.getDamage() * 2) * LoadProperties.xpGainMultiplier); - if(x instanceof PigZombie) - PPa.addAxesXP((event.getDamage() * 3) * LoadProperties.xpGainMultiplier); - } - Skills.XpCheck(attacker); - } - /* - * AXE DAMAGE SCALING && LOOT CHECKS - */ - if(m.isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ - if(PPa.getAxesInt() >= 500){ - event.setDamage(calculateDamage(event, 4)); - } - } - if(type == 0 && mcPermissions.getInstance().unarmed(attacker)){ - if(defender.getHealth() <= 0) - return; - - //Bonus just for having unarmed - int bonus = 2; - if (PPa.getUnarmedInt() >= 250) - bonus++; - if (PPa.getUnarmedInt() >= 500) - bonus++; - event.setDamage(calculateDamage(event, bonus)); - - //XP - if(!Config.getInstance().isMobSpawnTracked(x)){ - if(x instanceof Creeper) - PPa.addUnarmedXP((event.getDamage() * 4) * LoadProperties.xpGainMultiplier); - if(x instanceof Spider) - PPa.addUnarmedXP((event.getDamage() * 3) * LoadProperties.xpGainMultiplier); - if(x instanceof Skeleton) - PPa.addUnarmedXP((event.getDamage() * 2) * LoadProperties.xpGainMultiplier); - if(x instanceof Zombie) - PPa.addUnarmedXP((event.getDamage() * 2) * LoadProperties.xpGainMultiplier); - if(x instanceof PigZombie) - PPa.addUnarmedXP((event.getDamage() * 3) * LoadProperties.xpGainMultiplier); - } - Skills.XpCheck(attacker); - } - } - } public static void archeryCheck(EntityDamageByProjectileEvent event){ Entity y = event.getDamager(); Entity x = event.getEntity(); @@ -370,6 +249,20 @@ public class Combat { } } } + /* + * DAMAGE MODIFIER + */ + if(PPa.getArcheryInt() >= 50 && PPa.getArcheryInt() < 250) + event.setDamage(event.getDamage()+1); + if(PPa.getArcheryInt() >= 250 && PPa.getArcheryInt() < 575) + event.setDamage(event.getDamage()+2); + if(PPa.getArcheryInt() >= 575 && PPa.getArcheryInt() < 725) + event.setDamage(event.getDamage()+3); + if(PPa.getArcheryInt() >= 725 && PPa.getArcheryInt() < 1000) + event.setDamage(event.getDamage()+4); + if(PPa.getArcheryInt() >= 1000) + event.setDamage(event.getDamage()+5); + /* * IGNITION */ @@ -403,19 +296,6 @@ public class Combat { * Defender is Monster */ if(x instanceof Monster){ - /* - * TRACK ARROWS USED AGAINST THE ENTITY - */ - if(PPa.getArcheryInt() >= 50 && PPa.getArcheryInt() < 250) - event.setDamage(calculateDamage(event, 1)); - if(PPa.getArcheryInt() >= 250 && PPa.getArcheryInt() < 575) - event.setDamage(calculateDamage(event, 2)); - if(PPa.getArcheryInt() >= 575 && PPa.getArcheryInt() < 725) - event.setDamage(calculateDamage(event, 3)); - if(PPa.getArcheryInt() >= 725 && PPa.getArcheryInt() < 1000) - event.setDamage(calculateDamage(event, 4)); - if(PPa.getArcheryInt() >= 1000) - event.setDamage(calculateDamage(event, 5)); //XP if(!Config.getInstance().isMobSpawnTracked(x)){ if(x instanceof Creeper) @@ -430,36 +310,6 @@ public class Combat { PPa.addArcheryXP((event.getDamage() * 3) * LoadProperties.xpGainMultiplier); } } - /* - * Defender is Animals - */ - if(x instanceof Animals){ - if(PPa.getArcheryInt() >= 50 && PPa.getArcheryInt() < 250) - event.setDamage(calculateDamage(event, 1)); - if(PPa.getArcheryInt() >= 250 && PPa.getArcheryInt() < 575) - event.setDamage(calculateDamage(event, 2)); - if(PPa.getArcheryInt() >= 575 && PPa.getArcheryInt() < 725) - event.setDamage(calculateDamage(event, 3)); - if(PPa.getArcheryInt() >= 725 && PPa.getArcheryInt() < 1000) - event.setDamage(calculateDamage(event, 4)); - if(PPa.getArcheryInt() >= 1000) - event.setDamage(calculateDamage(event, 5)); - } - /* - * Defender is Squid - */ - if(x instanceof Squid){ - if(PPa.getArcheryInt() >= 50 && PPa.getArcheryInt() < 250) - event.setDamage(calculateDamage(event, 1)); - if(PPa.getArcheryInt() >= 250 && PPa.getArcheryInt() < 575) - event.setDamage(calculateDamage(event, 2)); - if(PPa.getArcheryInt() >= 575 && PPa.getArcheryInt() < 725) - event.setDamage(calculateDamage(event, 3)); - if(PPa.getArcheryInt() >= 725 && PPa.getArcheryInt() < 1000) - event.setDamage(calculateDamage(event, 4)); - if(PPa.getArcheryInt() >= 1000) - event.setDamage(calculateDamage(event, 5)); - } /* * Attacker is Player */ @@ -505,38 +355,10 @@ public class Combat { defender.sendMessage(ChatColor.DARK_RED+"Touched Fuzzy. Felt Dizzy."); attacker.sendMessage("Target was "+ChatColor.DARK_RED+"Dazed"); } - - if(PPa.getArcheryInt() >= 50 && PPa.getArcheryInt() < 250) - event.setDamage(calculateDamage(event, 1)); - if(PPa.getArcheryInt() >= 250 && PPa.getArcheryInt() < 575) - event.setDamage(calculateDamage(event, 2)); - if(PPa.getArcheryInt() >= 575 && PPa.getArcheryInt() < 725) - event.setDamage(calculateDamage(event, 3)); - if(PPa.getArcheryInt() >= 725 && PPa.getArcheryInt() < 1000) - event.setDamage(calculateDamage(event, 4)); - if(PPa.getArcheryInt() >= 1000) - event.setDamage(calculateDamage(event, 5)); } } Skills.XpCheck(attacker); } - } - public static boolean simulateUnarmedProc(Player player){ - PlayerProfile PP = Users.getProfile(player); - if(PP.getUnarmedInt() >= 1000){ - if(Math.random() * 4000 <= 1000){ - return true; - } - } else { - if(Math.random() * 4000 <= PP.getUnarmedInt()){ - return true; - } - } - return false; - } - - public static int calculateDamage(EntityDamageEvent event, int dmg){ - return event.getDamage() + dmg; } public static void dealDamage(Entity target, int dmg){ if(target instanceof Player){ @@ -549,38 +371,4 @@ public class Combat { ((Monster) target).damage(dmg); } } - public static void axeCriticalCheck(Player attacker, EntityDamageByEntityEvent event, Entity x){ - PlayerProfile PPa = Users.getProfile(attacker); - if(m.isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ - if(PPa.getAxesInt() >= 750){ - if(Math.random() * 1000 <= 750){ - if(x instanceof Player){ - Player player = (Player)x; - player.sendMessage(ChatColor.DARK_RED + "You were CRITICALLY hit!"); - } - if(x instanceof Player){ - event.setDamage(event.getDamage() * 2 - event.getDamage() / 2); - } else { - event.setDamage(event.getDamage() * 2); - } - attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); - } - } else if(Math.random() * 1000 <= PPa.getAxesInt()){ - if(x instanceof Player){ - Player player = (Player)x; - player.sendMessage(ChatColor.DARK_RED + "You were CRITICALLY hit!"); - } - if(x instanceof Player){ - event.setDamage(event.getDamage() * 2 - event.getDamage() / 2); - } else { - event.setDamage(event.getDamage() * 2); - } - attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); - } - } - } - - - - } diff --git a/mcMMO/com/gmail/nossr50/Database.java b/mcMMO/com/gmail/nossr50/Database.java index c94f61ccc..edf72db99 100644 --- a/mcMMO/com/gmail/nossr50/Database.java +++ b/mcMMO/com/gmail/nossr50/Database.java @@ -38,7 +38,47 @@ public class Database { System.out.println("VendorError: " + ex.getErrorCode()); } } - + //Create the DB structure + public void createStructure(){ + Write("CREATE TABLE IF NOT EXISTS `users` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT," + + "`user` varchar(30) NOT NULL," + + "`lastlogin` int(10) unsigned NOT NULL," + + "`party` varchar(100) NOT NULL DEFAULT ''," + + "PRIMARY KEY (`id`)," + + "UNIQUE KEY `user` (`user`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;"); + Write("CREATE TABLE IF NOT EXISTS `skills` (`user_id` int(10) unsigned NOT NULL," + + "`taming` int(10) unsigned NOT NULL DEFAULT '0'," + + "`mining` int(10) unsigned NOT NULL DEFAULT '0'," + + "`woodcutting` int(10) unsigned NOT NULL DEFAULT '0'," + + "`repair` int(10) unsigned NOT NULL DEFAULT '0'," + + "`unarmed` int(10) unsigned NOT NULL DEFAULT '0'," + + "`herbalism` int(10) unsigned NOT NULL DEFAULT '0'," + + "`excavation` int(10) unsigned NOT NULL DEFAULT '0'," + + "`archery` int(10) unsigned NOT NULL DEFAULT '0'," + + "`swords` int(10) unsigned NOT NULL DEFAULT '0'," + + "`axes` int(10) unsigned NOT NULL DEFAULT '0'," + + "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0'," + + "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); + Write("CREATE TABLE IF NOT EXISTS `experience` (`user_id` int(10) unsigned NOT NULL," + + "`taming` int(10) unsigned NOT NULL DEFAULT '0'," + + "`mining` int(10) unsigned NOT NULL DEFAULT '0'," + + "`woodcutting` int(10) unsigned NOT NULL DEFAULT '0'," + + "`repair` int(10) unsigned NOT NULL DEFAULT '0'," + + "`unarmed` int(10) unsigned NOT NULL DEFAULT '0'," + + "`herbalism` int(10) unsigned NOT NULL DEFAULT '0'," + + "`excavation` int(10) unsigned NOT NULL DEFAULT '0'," + + "`archery` int(10) unsigned NOT NULL DEFAULT '0'," + + "`swords` int(10) unsigned NOT NULL DEFAULT '0'," + + "`axes` int(10) unsigned NOT NULL DEFAULT '0'," + + "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0'," + + "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); + Write("CREATE TABLE IF NOT EXISTS `spawn` (`user_id` int(10) NOT NULL," + + "`x` int(11) NOT NULL DEFAULT '0'," + + "`y` int(11) NOT NULL DEFAULT '0'," + + "`z` int(11) NOT NULL DEFAULT '0'," + + "`world` varchar(50) NOT NULL DEFAULT ''," + + "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); + } // write query public boolean Write(String sql) { try { diff --git a/mcMMO/com/gmail/nossr50/datatypes/PlayerProfile.java b/mcMMO/com/gmail/nossr50/datatypes/PlayerProfile.java index 1e263f2c9..06d8ae5c4 100644 --- a/mcMMO/com/gmail/nossr50/datatypes/PlayerProfile.java +++ b/mcMMO/com/gmail/nossr50/datatypes/PlayerProfile.java @@ -700,12 +700,12 @@ public class PlayerProfile public void skillUpTaming(int newskill){ int x = 0; if(taming != null){ - if(isInt(taming)){ - x = Integer.parseInt(taming); - }else { - taming = "0"; - x = Integer.parseInt(taming); - } + if(isInt(taming)){ + x = Integer.parseInt(taming); + }else { + taming = "0"; + x = Integer.parseInt(taming); + } } x += newskill; taming = Integer.toString(x); @@ -1053,7 +1053,7 @@ public class PlayerProfile x = Integer.parseInt(tamingXP); } x += newXP; - acrobaticsXP = String.valueOf(x); + tamingXP = String.valueOf(x); save(); } public void addAcrobaticsXP(int newXP) diff --git a/mcMMO/com/gmail/nossr50/datatypes/PlayerStat.java b/mcMMO/com/gmail/nossr50/datatypes/PlayerStat.java index 0a78d48b5..a560555c5 100644 --- a/mcMMO/com/gmail/nossr50/datatypes/PlayerStat.java +++ b/mcMMO/com/gmail/nossr50/datatypes/PlayerStat.java @@ -3,4 +3,4 @@ package com.gmail.nossr50.datatypes; public class PlayerStat { public String name; public int statVal = 0; -} +} \ No newline at end of file diff --git a/mcMMO/com/gmail/nossr50/m.java b/mcMMO/com/gmail/nossr50/m.java index 8d173d1d8..4e423ea4d 100644 --- a/mcMMO/com/gmail/nossr50/m.java +++ b/mcMMO/com/gmail/nossr50/m.java @@ -26,7 +26,6 @@ public class m { * I'm storing my functions/methods in here in an unorganized manner. Spheal with it. */ private static mcMMO plugin; - private static mcMMO pluginx; public m(mcMMO instance) { plugin = instance; } @@ -172,7 +171,6 @@ public class m { for (int cy = -radius; cy <= radius; cy++) { for (int cz = -radius; cz <= radius; cz++) { Block block = loc.getWorld().getBlockAt(ox + cx, oy + cy, oz + cz); - //If block is block if (block.getTypeId() == typeid) { return true; } @@ -181,6 +179,7 @@ public class m { } return false; } + public static boolean isPvpEnabled(){ String propertyName = "pvp"; FileReader fr = null; @@ -304,6 +303,35 @@ public class m { } public static void mmoHelpCheck(String[] split, Player player, PlayerChatEvent event){ PlayerProfile PP = Users.getProfile(player); + if(split[0].equalsIgnoreCase("/taming")){ + event.setCancelled(true); + float skillvalue = (float)PP.getTamingInt(); + + String percentage = String.valueOf((skillvalue / 1000) * 100); + player.sendMessage(ChatColor.RED+"-----[]"+ChatColor.GREEN+"TAMING"+ChatColor.RED+"[]-----"); + player.sendMessage(ChatColor.DARK_GRAY+"XP GAIN: "+ChatColor.WHITE+"Fighting with your wolves"); + player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"EFFECTS"+ChatColor.RED+"[]---"); + //player.sendMessage(ChatColor.DARK_AQUA+"Tree Feller (ABILITY): "+ChatColor.GREEN+"Make trees explode"); + player.sendMessage(ChatColor.DARK_AQUA+"Gore: "+ChatColor.YELLOW+ChatColor.GREEN+"Critical Strike that applies Bleed"); + player.sendMessage(ChatColor.DARK_AQUA+"Sharpened Claws: "+ChatColor.YELLOW+ChatColor.GREEN+"Damage Bonus"); + player.sendMessage(ChatColor.DARK_AQUA+"Thick Fur: "+ChatColor.YELLOW+ChatColor.GREEN+"Damage Reduction"); + player.sendMessage(ChatColor.DARK_AQUA+"Shock Proof: "+ChatColor.YELLOW+ChatColor.GREEN+"Explosive Damage Reduction"); + player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"YOUR STATS"+ChatColor.RED+"[]---"); + if(PP.getTamingInt() < 250) + player.sendMessage(ChatColor.GRAY+"LOCKED UNTIL 250+ SKILL (THICK FUR)"); + else + player.sendMessage(ChatColor.RED+"Thick Fur: "+ChatColor.YELLOW+"Halved Damage"); + if(PP.getTamingInt() < 500) + player.sendMessage(ChatColor.GRAY+"LOCKED UNTIL 500+ SKILL (SHOCK PROOF)"); + else + player.sendMessage(ChatColor.RED+"Shock Proof: "+ChatColor.YELLOW+"Explosives do 1/6 normal damage"); + if(PP.getTamingInt() < 750) + player.sendMessage(ChatColor.GRAY+"LOCKED UNTIL 750+ SKILL (SHARPENED CLAWS)"); + else + player.sendMessage(ChatColor.RED+"Sharpened Claws: "+ChatColor.YELLOW+"+2 Damage"); + player.sendMessage(ChatColor.RED+"Gore Chance: "+ChatColor.YELLOW+percentage+"%"); + //player.sendMessage(ChatColor.RED+"Tree Feller Length: "+ChatColor.YELLOW+ticks+"s"); + } if(split[0].equalsIgnoreCase("/woodcutting")){ event.setCancelled(true); float skillvalue = (float)PP.getWoodCuttingInt(); diff --git a/mcMMO/com/gmail/nossr50/mcEntityListener.java b/mcMMO/com/gmail/nossr50/mcEntityListener.java index df53c3612..c402bcd36 100644 --- a/mcMMO/com/gmail/nossr50/mcEntityListener.java +++ b/mcMMO/com/gmail/nossr50/mcEntityListener.java @@ -99,7 +99,7 @@ public class mcEntityListener extends EntityListener { if(Party.getInstance().inSameParty(defender, attacker)) event.setCancelled(true); } - Combat.combatChecks(event); + Combat.combatChecks(event, plugin); } /* * Check to see if the defender took damage so we can apply recently hurt diff --git a/mcMMO/com/gmail/nossr50/mcMMO.java b/mcMMO/com/gmail/nossr50/mcMMO.java index 94729c94c..836ae9290 100644 --- a/mcMMO/com/gmail/nossr50/mcMMO.java +++ b/mcMMO/com/gmail/nossr50/mcMMO.java @@ -100,7 +100,8 @@ public class mcMMO extends JavaPlugin { PluginDescriptionFile pdfFile = this.getDescription(); mcPermissions.initialize(getServer()); - mcLoadMySQL(); + mcLoadMySQL(); + database.createStructure(); //Make Structure Leaderboard.makeLeaderboards(); //Make the leaderboards System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" ); diff --git a/mcMMO/com/gmail/nossr50/mcPlayerListener.java b/mcMMO/com/gmail/nossr50/mcPlayerListener.java index 4a235fc7b..a0fc45e96 100644 --- a/mcMMO/com/gmail/nossr50/mcPlayerListener.java +++ b/mcMMO/com/gmail/nossr50/mcPlayerListener.java @@ -7,7 +7,9 @@ import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import org.bukkit.entity.Wolf; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; @@ -26,6 +28,7 @@ import com.gmail.nossr50.party.Party; import com.gmail.nossr50.skills.Herbalism; import com.gmail.nossr50.skills.Repair; import com.gmail.nossr50.skills.Skills; +import com.gmail.nossr50.skills.Taming; public class mcPlayerListener extends PlayerListener { @@ -82,7 +85,6 @@ public class mcPlayerListener extends PlayerListener { if(mcPermissions.getInstance().motd(player)){ player.sendMessage(ChatColor.BLUE +"This server is running MMO "+plugin.getDescription().getVersion()+" type /"+ChatColor.YELLOW+LoadProperties.mcmmo+ChatColor.BLUE+ " for help."); player.sendMessage(ChatColor.GREEN+"http://mmo.wikia.com"+ChatColor.BLUE+" - MMO Wiki"); - player.sendMessage(ChatColor.DARK_RED+"ATTN: YOUR STATS WILL BE BACK TO NORMAL SHORTLY, WE ARE USING MySQL NOW AND I HAVE TO WRITE A MYSQL QUERY TO UPDATE YOUR STATS!"); } } public void onPlayerInteract(PlayerInteractEvent event) { @@ -91,6 +93,14 @@ public class mcPlayerListener extends PlayerListener { Action action = event.getAction(); Block block = event.getClickedBlock(); //Archery Nerf + if(action == Action.LEFT_CLICK_AIR) + { + if(player.getItemInHand().getTypeId() == 352) + { + Block targetBlock = player.getTargetBlock(null, 20); + player.sendMessage("Target Block TypeID = "+targetBlock.getTypeId()); + } + } if(player.getItemInHand().getTypeId() == 261 && LoadProperties.archeryFireRateLimit){ if(System.currentTimeMillis() < PP.getArcheryShotATS() + 1000){ /* diff --git a/mcMMO/com/gmail/nossr50/skills/Axes.java b/mcMMO/com/gmail/nossr50/skills/Axes.java index b7b406ab9..485c4f4eb 100644 --- a/mcMMO/com/gmail/nossr50/skills/Axes.java +++ b/mcMMO/com/gmail/nossr50/skills/Axes.java @@ -8,10 +8,46 @@ import org.bukkit.entity.Player; import org.bukkit.entity.Wolf; import org.bukkit.event.entity.EntityDamageByEntityEvent; +import com.gmail.nossr50.Users; import com.gmail.nossr50.m; +import com.gmail.nossr50.mcPermissions; +import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.party.Party; public class Axes { + + public static void axeCriticalCheck(Player attacker, EntityDamageByEntityEvent event){ + Entity x = event.getEntity(); + PlayerProfile PPa = Users.getProfile(attacker); + if(m.isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ + if(PPa.getAxesInt() >= 750){ + if(Math.random() * 1000 <= 750){ + if(x instanceof Player){ + Player player = (Player)x; + player.sendMessage(ChatColor.DARK_RED + "You were CRITICALLY hit!"); + } + if(x instanceof Player){ + event.setDamage(event.getDamage() * 2 - event.getDamage() / 2); + } else { + event.setDamage(event.getDamage() * 2); + } + attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); + } + } else if(Math.random() * 1000 <= PPa.getAxesInt()){ + if(x instanceof Player){ + Player player = (Player)x; + player.sendMessage(ChatColor.DARK_RED + "You were CRITICALLY hit!"); + } + if(x instanceof Player){ + event.setDamage(event.getDamage() * 2 - event.getDamage() / 2); + } else { + event.setDamage(event.getDamage() * 2); + } + attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); + } + } + } + public static void applyAoeDamage(Player attacker, EntityDamageByEntityEvent event){ int targets = 0; Entity x = event.getEntity(); diff --git a/mcMMO/com/gmail/nossr50/skills/Swords.java b/mcMMO/com/gmail/nossr50/skills/Swords.java index 664fa4eb9..229111895 100644 --- a/mcMMO/com/gmail/nossr50/skills/Swords.java +++ b/mcMMO/com/gmail/nossr50/skills/Swords.java @@ -121,6 +121,8 @@ public class Swords { { Player defender = (Player)event.getEntity(); PlayerProfile PPd = Users.getProfile(defender); + if(m.isSwords(defender.getItemInHand())&& mcPermissions.getInstance().swords(defender)) + { if(PPd.getSwordsInt() >= 600) { if(Math.random() * 2000 <= 600) @@ -138,6 +140,7 @@ public class Swords { if(f instanceof Player) ((Player) f).sendMessage(ChatColor.DARK_RED+"Hit with counterattack!"); } + } } } } diff --git a/mcMMO/com/gmail/nossr50/skills/Taming.java b/mcMMO/com/gmail/nossr50/skills/Taming.java index 6800f3f80..fa0208909 100644 --- a/mcMMO/com/gmail/nossr50/skills/Taming.java +++ b/mcMMO/com/gmail/nossr50/skills/Taming.java @@ -11,8 +11,8 @@ public class Taming { public static String getOwnerName(Entity theWolf){ CraftWolf cWolf = (CraftWolf)theWolf; EntityWolf eWolf = (EntityWolf)cWolf.getHandle(); - - String playerName = eWolf.v(); + + String playerName = eWolf.x(); return playerName; } public static boolean hasOwner(Entity theWolf, Plugin pluginx){ @@ -23,7 +23,7 @@ public class Taming { } return false; } - public Player getOwner(Entity theWolf, Plugin pluginx){ + public static Player getOwner(Entity theWolf, Plugin pluginx){ for(Player x : pluginx.getServer().getOnlinePlayers()){ if(x != null && x.getName().equals(getOwnerName(theWolf))){ return x; @@ -31,8 +31,4 @@ public class Taming { } return null; } - public static Taming getInstance() { - // TODO Auto-generated method stub - return null; - } } diff --git a/mcMMO/com/gmail/nossr50/skills/Unarmed.java b/mcMMO/com/gmail/nossr50/skills/Unarmed.java index d61da661b..9ee2e772a 100644 --- a/mcMMO/com/gmail/nossr50/skills/Unarmed.java +++ b/mcMMO/com/gmail/nossr50/skills/Unarmed.java @@ -1,5 +1,60 @@ package com.gmail.nossr50.skills; -public class Unarmed { +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.inventory.ItemStack; +import com.gmail.nossr50.Users; +import com.gmail.nossr50.datatypes.PlayerProfile; + +public class Unarmed { + public static void unarmedBonus(Player attacker, EntityDamageByEntityEvent event) + { + PlayerProfile PPa = Users.getProfile(attacker); + int bonus = 2; + if (PPa.getUnarmedInt() >= 250) + bonus++; + if (PPa.getUnarmedInt() >= 500) + bonus++; + event.setDamage(event.getDamage()+bonus); + } + public static void disarmProcCheck(Player attacker, Player defender) + { + PlayerProfile PP = Users.getProfile(attacker); + if(PP.getUnarmedInt() >= 1000){ + if(Math.random() * 4000 <= 1000){ + Location loc = defender.getLocation(); + if(defender.getItemInHand() != null && defender.getItemInHand().getTypeId() != 0) + { + attacker.sendMessage(ChatColor.DARK_RED+"You have hit with great force."); + defender.sendMessage(ChatColor.DARK_RED+"You have been disarmed!"); + ItemStack item = defender.getItemInHand(); + if(item != null) + { + loc.getWorld().dropItemNaturally(loc, item); + ItemStack itemx = null; + defender.setItemInHand(itemx); + } + } + } + } else { + if(Math.random() * 4000 <= PP.getUnarmedInt()){ + Location loc = defender.getLocation(); + if(defender.getItemInHand() != null && defender.getItemInHand().getTypeId() != 0) + { + attacker.sendMessage(ChatColor.DARK_RED+"You have hit with great force."); + defender.sendMessage(ChatColor.DARK_RED+"You have been disarmed!"); + ItemStack item = defender.getItemInHand(); + if(item != null) + { + loc.getWorld().dropItemNaturally(loc, item); + ItemStack itemx = null; + defender.setItemInHand(itemx); + } + } + } + } + } }