From 7114d04464bea5dd7196dd6a51cb593cb687ce4d Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 12 Sep 2011 00:19:15 -0700 Subject: [PATCH] Another WIP --- src/Changelog.txt | 7 ++ src/com/gmail/nossr50/Combat.java | 15 --- src/com/gmail/nossr50/command/Commands.java | 46 +------ src/com/gmail/nossr50/datatypes/Mob.java | 76 ------------ .../nossr50/listeners/mcEntityListener.java | 28 ----- .../nossr50/listeners/mcPlayerListener.java | 16 --- src/com/gmail/nossr50/mcMMO.java | 6 +- src/com/gmail/nossr50/mcTimer.java | 91 -------------- src/com/gmail/nossr50/party/Party.java | 2 +- src/com/gmail/nossr50/runnables/mcTimer.java | 64 ++++++++++ src/com/gmail/nossr50/skills/Axes.java | 3 +- src/com/gmail/nossr50/skills/Herbalism.java | 82 ------------- src/com/gmail/nossr50/skills/Swords.java | 35 ------ src/com/gmail/nossr50/spout/mmoHelper.java | 1 + .../spout/{ => util}/ArrayListString.java | 2 +- .../nossr50/spout/{ => util}/GenericFace.java | 2 +- .../spout/{ => util}/GenericLivingEntity.java | 4 +- src/org/blockface/bukkitstats/CallHome.java | 113 ++++++++++++++++++ 18 files changed, 199 insertions(+), 394 deletions(-) delete mode 100644 src/com/gmail/nossr50/datatypes/Mob.java delete mode 100644 src/com/gmail/nossr50/mcTimer.java create mode 100644 src/com/gmail/nossr50/runnables/mcTimer.java rename src/com/gmail/nossr50/spout/{ => util}/ArrayListString.java (98%) rename src/com/gmail/nossr50/spout/{ => util}/GenericFace.java (97%) rename src/com/gmail/nossr50/spout/{ => util}/GenericLivingEntity.java (98%) create mode 100644 src/org/blockface/bukkitstats/CallHome.java diff --git a/src/Changelog.txt b/src/Changelog.txt index 0a39d60e2..30b316ba1 100644 --- a/src/Changelog.txt +++ b/src/Changelog.txt @@ -1,6 +1,12 @@ Changelog: #Versions without changelogs probably had very small misc fixes, like tweaks to the source code Version 1.1.14 +Improvements have been made with MySQL thanks to krinsdeath +Added some experimental usage tracking, you can opt out of this in /plugins/stats/config.yml (Once its generated, may require 2 restarts) +[1.8] Removed the bonus damage from Archery (I'll rework this skill soon) +[1.8] Removed the food bonuses to healing Herbalism provided due to the change of eating in game mechanics +[1.8] Swords no longer parry, no need to compete with in game mechanics +[1.8] mcMMO no longer has an HP Regen system, no need to compete with in game mechanics mcMMO now transfers files between MC Server -> Client rather than Webserver -> Client (By default, you can change this..) Fixed a few problems with readying abilities for Woodcutting/Axes Changed the listener priority for OnEntityDamage from High to Monitor (Should make mcMMO compatible with Worldguards pvp regions among other things) @@ -8,6 +14,7 @@ Added addXpOverride for modders, this will ignore skill modifiers Added an option for Excavation to require use of a shovel, on by default The option to change the weburl of mcMMO Images/Sounds has been removed, if you want to customize mcMMO images/sounds you can open mcMMO.jar and replace them there Made party/admin chat modes more compatible with chat plugins (vChat) +Portuguese Brazil locale added (Code: pt_br) Version 1.1.13 Pets are removed from party bars diff --git a/src/com/gmail/nossr50/Combat.java b/src/com/gmail/nossr50/Combat.java index c2c10a102..9212bf093 100644 --- a/src/com/gmail/nossr50/Combat.java +++ b/src/com/gmail/nossr50/Combat.java @@ -227,8 +227,6 @@ public class Combat */ if(event instanceof EntityDamageByEntityEvent && event.getEntity() instanceof Player) { - Player defender = (Player)event.getEntity(); - Swords.parryCheck((EntityDamageByEntityEvent) event, defender); Swords.counterAttackChecks((EntityDamageByEntityEvent)event); Acrobatics.dodgeChecks((EntityDamageByEntityEvent)event); } @@ -312,19 +310,6 @@ public class Combat if(mcPermissions.getInstance().archery(attacker)) { Archery.trackArrows(pluginx, x, event, attacker); - /* - * DAMAGE MODIFIER - */ - if(PPa.getSkillLevel(SkillType.ARCHERY) >= 50 && PPa.getSkillLevel(SkillType.ARCHERY) < 250) - event.setDamage(event.getDamage()+1); - if(PPa.getSkillLevel(SkillType.ARCHERY) >= 250 && PPa.getSkillLevel(SkillType.ARCHERY) < 575) - event.setDamage(event.getDamage()+2); - if(PPa.getSkillLevel(SkillType.ARCHERY) >= 575 && PPa.getSkillLevel(SkillType.ARCHERY) < 725) - event.setDamage(event.getDamage()+3); - if(PPa.getSkillLevel(SkillType.ARCHERY) >= 725 && PPa.getSkillLevel(SkillType.ARCHERY) < 1000) - event.setDamage(event.getDamage()+4); - if(PPa.getSkillLevel(SkillType.ARCHERY) >= 1000) - event.setDamage(event.getDamage()+5); /* * IGNITION diff --git a/src/com/gmail/nossr50/command/Commands.java b/src/com/gmail/nossr50/command/Commands.java index 6ad90ebf0..3d8dab41d 100644 --- a/src/com/gmail/nossr50/command/Commands.java +++ b/src/com/gmail/nossr50/command/Commands.java @@ -132,17 +132,6 @@ public class Commands player.sendMessage(mcLocale.getString("m.WoodCuttingTreeFellerLength", new Object[] {ticks})); } else if(label.equalsIgnoreCase("archery") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillArchery").toLowerCase())){ - Integer rank = 0; - if(PP.getSkillLevel(SkillType.ARCHERY) >= 50) - rank++; - if(PP.getSkillLevel(SkillType.ARCHERY) >= 250) - rank++; - if(PP.getSkillLevel(SkillType.ARCHERY) >= 575) - rank++; - if(PP.getSkillLevel(SkillType.ARCHERY) >= 725) - rank++; - if(PP.getSkillLevel(SkillType.ARCHERY) >= 1000) - rank++; float skillvalue = (float)PP.getSkillLevel(SkillType.ARCHERY); String percentage = String.valueOf((skillvalue / 1000) * 100); @@ -171,13 +160,11 @@ public class Commands player.sendMessage(mcLocale.getString("m.SkillHeader", new Object[] {mcLocale.getString("m.Effects")})); player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] {mcLocale.getString("m.EffectsArchery1_0"), mcLocale.getString("m.EffectsArchery1_1")})); player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] {mcLocale.getString("m.EffectsArchery2_0"), mcLocale.getString("m.EffectsArchery2_1")})); - player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] {mcLocale.getString("m.EffectsArchery3_0"), mcLocale.getString("m.EffectsArchery3_1")})); player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] {mcLocale.getString("m.EffectsArchery4_0"), mcLocale.getString("m.EffectsArchery4_1")})); player.sendMessage(mcLocale.getString("m.SkillHeader", new Object[] {mcLocale.getString("m.YourStats")})); player.sendMessage(mcLocale.getString("m.ArcheryDazeChance", new Object[] {percentagedaze})); player.sendMessage(mcLocale.getString("m.ArcheryRetrieveChance", new Object[] {percentage})); - player.sendMessage(mcLocale.getString("m.ArcheryIgnitionLength", new Object[] {(ignition / 20)})); - player.sendMessage(mcLocale.getString("m.ArcheryDamagePlus", new Object[] {rank})); + player.sendMessage(mcLocale.getString("m.ArcheryIgnitionLength", new Object[] {(ignition / 20)})); } else if(label.equalsIgnoreCase("axes") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillAxes"))){ String percentage; @@ -213,7 +200,7 @@ public class Commands } else if(label.equalsIgnoreCase("swords") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillSwords").toLowerCase())){ int bleedrank = 2; - String percentage, parrypercentage = null, counterattackpercentage; + String percentage, counterattackpercentage; float skillvalue = (float)PP.getSkillLevel(SkillType.SWORDS); if(PP.getSkillLevel(SkillType.SWORDS) < 750){ percentage = String.valueOf((skillvalue / 1000) * 100); @@ -223,12 +210,6 @@ public class Commands if(skillvalue >= 750) bleedrank+=1; - if(PP.getSkillLevel(SkillType.SWORDS) <= 900){ - parrypercentage = String.valueOf((skillvalue / 3000) * 100); - } else { - parrypercentage = "30"; - } - if(PP.getSkillLevel(SkillType.SWORDS) <= 600){ counterattackpercentage = String.valueOf((skillvalue / 2000) * 100); } else { @@ -250,14 +231,12 @@ public class Commands player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] {mcLocale.getString("m.EffectsSwords1_0"), mcLocale.getString("m.EffectsSwords1_1")})); player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] {mcLocale.getString("m.EffectsSwords2_0"), mcLocale.getString("m.EffectsSwords2_1")})); player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] {mcLocale.getString("m.EffectsSwords3_0"), mcLocale.getString("m.EffectsSwords3_1")})); - player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] {mcLocale.getString("m.EffectsSwords4_0"), mcLocale.getString("m.EffectsSwords4_1")})); player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] {mcLocale.getString("m.EffectsSwords5_0"), mcLocale.getString("m.EffectsSwords5_1")})); player.sendMessage(mcLocale.getString("m.SkillHeader", new Object[] {mcLocale.getString("m.YourStats")})); player.sendMessage(mcLocale.getString("m.SwordsCounterAttChance", new Object[] {counterattackpercentage})); player.sendMessage(mcLocale.getString("m.SwordsBleedLength", new Object[] {bleedrank})); player.sendMessage(mcLocale.getString("m.SwordsTickNote")); player.sendMessage(mcLocale.getString("m.SwordsBleedLength", new Object[] {percentage})); - player.sendMessage(mcLocale.getString("m.SwordsParryChance", new Object[] {parrypercentage})); player.sendMessage(mcLocale.getString("m.SwordsSSLength", new Object[] {ticks})); } @@ -369,23 +348,6 @@ public class Commands player.sendMessage(mcLocale.getString("m.UnarmedBerserkLength", new Object[] {ticks})); } else if(label.equalsIgnoreCase("herbalism") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillHerbalism").toLowerCase())){ - int rank = 0; - if(PP.getSkillLevel(SkillType.HERBALISM) >= 50) - rank++; - if (PP.getSkillLevel(SkillType.HERBALISM) >= 150) - rank++; - if (PP.getSkillLevel(SkillType.HERBALISM) >= 250) - rank++; - if (PP.getSkillLevel(SkillType.HERBALISM) >= 350) - rank++; - if (PP.getSkillLevel(SkillType.HERBALISM) >= 450) - rank++; - if (PP.getSkillLevel(SkillType.HERBALISM) >= 550) - rank++; - if (PP.getSkillLevel(SkillType.HERBALISM) >= 650) - rank++; - if (PP.getSkillLevel(SkillType.HERBALISM) >= 750) - rank++; int bonus = 0; if(PP.getSkillLevel(SkillType.HERBALISM) >= 200) bonus++; @@ -412,14 +374,12 @@ public class Commands player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] {mcLocale.getString("m.EffectsHerbalism1_0"), mcLocale.getString("m.EffectsHerbalism1_1")})); player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] {mcLocale.getString("m.EffectsHerbalism2_0"), mcLocale.getString("m.EffectsHerbalism2_1")})); player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] {mcLocale.getString("m.EffectsHerbalism3_0"), mcLocale.getString("m.EffectsHerbalism3_1")})); - player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] {mcLocale.getString("m.EffectsHerbalism4_0"), mcLocale.getString("m.EffectsHerbalism4_1")})); player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] {mcLocale.getString("m.EffectsHerbalism5_0"), mcLocale.getString("m.EffectsHerbalism5_1")})); player.sendMessage(mcLocale.getString("m.SkillHeader", new Object[] {mcLocale.getString("m.YourStats")})); player.sendMessage(mcLocale.getString("m.HerbalismGreenTerraLength", new Object[] {ticks})); player.sendMessage(mcLocale.getString("m.HerbalismGreenThumbChance", new Object[] {gpercentage})); player.sendMessage(mcLocale.getString("m.HerbalismGreenThumbStage", new Object[] {bonus})); - player.sendMessage(mcLocale.getString("m.HerbalismDoubleDropChance", new Object[] {percentage})); - player.sendMessage(mcLocale.getString("m.HerbalismFoodPlus", new Object[] {rank})); + player.sendMessage(mcLocale.getString("m.HerbalismDoubleDropChance", new Object[] {percentage})); } else if(label.equalsIgnoreCase("excavation") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillExcavation").toLowerCase())) diff --git a/src/com/gmail/nossr50/datatypes/Mob.java b/src/com/gmail/nossr50/datatypes/Mob.java deleted file mode 100644 index 6332f3017..000000000 --- a/src/com/gmail/nossr50/datatypes/Mob.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.gmail.nossr50.datatypes; - -import java.util.HashMap; - -import org.bukkit.entity.*; - -public class Mob -{ - public HashMap mobDiff = new HashMap(); - public HashMap isAggressive = new HashMap(); - - public void assignDifficulty(Entity entity) - { - short x = 0; - - if(entity.getLocation().getY() >= 45) - { - //LEVEL 2 - if(Math.random() * 100 > 50) - { - x = 0; - } - //LEVEL 3 - else - { - x = 1; - } - } - else - { - double y = Math.random() * 100; - //HIGH CHANCE FOR 5's - if(entity.getLocation().getY() < 20) - { - //ASSIGN INTO THE 5 RANKS - if(y >= 0 && y < 50) - x = 0; - if(y >= 50 && y < 80) - x = 1; - if(y >= 80 && y < 95) - x = 2; - if(y >= 95 && y < 98) - x = 3; - if(y >= 98 && y <= 100) - x = 4; - } - //HIGH CHANCE FOR 4's - else - { - //ASSIGN INTO THE 5 RANKS - if(y >= 0 && y < 50) - x = 0; - if(y >= 50 && y < 74) - x = 1; - if(y >= 74 && y < 89) - x = 2; - if(y >= 89 && y < 99) - x = 3; - if(y >= 99 && y <= 100) - x = 4; - } - if(x > 1) - { - isAggressive.put(entity.getEntityId(), false); - } - - } - - if(!mobDiff.containsKey(entity.getEntityId())) - { - mobDiff.put(entity.getEntityId(), x); - //System.out.println("Mob "+entity.getEntityId()+" (DIFFICULTY) "+ - //(x +1)+"(DEPTH) "+entity.getLocation().getY()); - } - } -} diff --git a/src/com/gmail/nossr50/listeners/mcEntityListener.java b/src/com/gmail/nossr50/listeners/mcEntityListener.java index 426692d9a..c7b7dd60c 100644 --- a/src/com/gmail/nossr50/listeners/mcEntityListener.java +++ b/src/com/gmail/nossr50/listeners/mcEntityListener.java @@ -2,7 +2,6 @@ package com.gmail.nossr50.listeners; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Monster; import org.bukkit.entity.Player; import org.bukkit.entity.Wolf; import org.bukkit.event.entity.CreatureSpawnEvent; @@ -12,7 +11,6 @@ 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.event.entity.EntityTargetEvent; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.Combat; @@ -149,15 +147,9 @@ public class mcEntityListener extends EntityListener public void onEntityDeath(EntityDeathEvent event) { - Entity x = event.getEntity(); x.setFireTicks(0); - //cleanup mob diff - if(plugin.mob.mobDiff.containsKey(event.getEntity().getEntityId())) - plugin.mob.mobDiff.remove(event.getEntity().getEntityId()); - - //Remove bleed track if(plugin.misc.bleedTracker.contains((LivingEntity)x)) plugin.misc.addToBleedRemovalQue((LivingEntity)x); @@ -183,29 +175,9 @@ public class mcEntityListener extends EntityListener if(reason == SpawnReason.SPAWNER && !LoadProperties.xpGainsMobSpawners) { plugin.misc.mobSpawnerList.add(event.getEntity()); - } else - { - if(event.getEntity() instanceof Monster && !plugin.mob.mobDiff.containsKey(event.getEntity().getEntityId())) - plugin.mob.assignDifficulty(event.getEntity()); } } - public void onEntityTarget(EntityTargetEvent event) - { - - int type = event.getEntity().getEntityId(); - //Make 3+ non-aggressive - if(event.getEntity() instanceof Monster - && plugin.mob.mobDiff.containsKey(type) - && plugin.mob.isAggressive.containsKey(type)) - { - if(plugin.mob.mobDiff.get(type) >= 2 && plugin.mob.isAggressive.get(type) == false) - { - event.setCancelled(true); - event.setTarget(null); - } - } - } public boolean isBow(ItemStack is){ if (is.getTypeId() == 261){ return true; diff --git a/src/com/gmail/nossr50/listeners/mcPlayerListener.java b/src/com/gmail/nossr50/listeners/mcPlayerListener.java index d1e7233b3..792ec577c 100644 --- a/src/com/gmail/nossr50/listeners/mcPlayerListener.java +++ b/src/com/gmail/nossr50/listeners/mcPlayerListener.java @@ -201,22 +201,6 @@ public class mcPlayerListener extends PlayerListener Skills.hoeReadinessCheck(player); Skills.abilityActivationCheck(player); } - if(action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK) - { - /* - * HERBALISM MODIFIERS - */ - if(action == Action.RIGHT_CLICK_BLOCK && !m.abilityBlockCheck(event.getClickedBlock())) - { - return; - } - - if(mcPermissions.getInstance().herbalism(player)) - { - Herbalism.breadCheck(player, player.getItemInHand()); - Herbalism.stewCheck(player, player.getItemInHand()); - } - } /* * ITEM CHECKS diff --git a/src/com/gmail/nossr50/mcMMO.java b/src/com/gmail/nossr50/mcMMO.java index 645ba53dd..0f6969182 100644 --- a/src/com/gmail/nossr50/mcMMO.java +++ b/src/com/gmail/nossr50/mcMMO.java @@ -1,10 +1,10 @@ package com.gmail.nossr50; -import com.gmail.nossr50.datatypes.Mob; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.command.Commands; import com.gmail.nossr50.config.*; +import com.gmail.nossr50.runnables.mcTimer; import com.gmail.nossr50.spout.SpoutStuff; import com.gmail.nossr50.spout.mmoHelper; import com.gmail.nossr50.listeners.mcBlockListener; @@ -14,6 +14,7 @@ import com.gmail.nossr50.party.Party; import com.gmail.nossr50.skills.*; import com.nijikokun.bukkit.Permissions.Permissions; +import org.blockface.bukkitstats.CallHome; import org.bukkit.Bukkit; import java.io.BufferedInputStream; import java.io.BufferedReader; @@ -70,7 +71,6 @@ public class mcMMO extends JavaPlugin //private Timer mcMMO_SpellTimer = new Timer(true); public static Database database = null; - public Mob mob = new Mob(); public Misc misc = new Misc(this); //Config file stuff @@ -135,7 +135,6 @@ public class mcMMO extends JavaPlugin pm.registerEvent(Event.Type.BLOCK_PLACE, blockListener, Priority.Normal, this); //Entity Stuff - pm.registerEvent(Event.Type.ENTITY_TARGET, entityListener, Priority.Normal, this); pm.registerEvent(Event.Type.ENTITY_DEATH, entityListener, Priority.Normal, this); pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Priority.Monitor, this); pm.registerEvent(Event.Type.CREATURE_SPAWN, entityListener, Priority.Normal, this); @@ -174,6 +173,7 @@ public class mcMMO extends JavaPlugin System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" ); Bukkit.getServer().getScheduler().scheduleAsyncRepeatingTask(this, mcMMO_Timer, 0, 20); + CallHome.load(this); //Swearword's blockface usage statistics, only dials home once } public PlayerProfile getPlayerProfile(Player player) diff --git a/src/com/gmail/nossr50/mcTimer.java b/src/com/gmail/nossr50/mcTimer.java deleted file mode 100644 index 1c90bb586..000000000 --- a/src/com/gmail/nossr50/mcTimer.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.gmail.nossr50; -import org.bukkit.entity.*; - -import com.gmail.nossr50.config.LoadProperties; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.skills.Skills; -import com.gmail.nossr50.skills.Swords; - - -public class mcTimer implements Runnable -{ - private final mcMMO plugin; - int thecount = 1; - - public mcTimer(final mcMMO plugin) - { - this.plugin = plugin; - } - - public void run() - { - for(Player player : plugin.getServer().getOnlinePlayers()) - { - if(player == null) - continue; - PlayerProfile PP = Users.getProfile(player); - - if(PP == null) - continue; - - /* - * MONITOR SKILLS - */ - Skills.monitorSkills(player); - - /* - * COOLDOWN MONITORING - */ - Skills.watchCooldowns(player); - - /* - * PLAYER BLEED MONITORING - */ - if(thecount % 2 == 0 && PP.getBleedTicks() >= 1) - { - player.damage(2); - PP.decreaseBleedTicks(); - } - - if(LoadProperties.enableRegen && mcPermissions.getInstance().regeneration(player) && System.currentTimeMillis() >= PP.getRecentlyHurt() + 60000) - { - if(thecount == 20 || thecount == 40 || thecount == 60 || thecount == 80){ - if(player != null && - player.getHealth() > 0 && player.getHealth() < 20 - && m.getPowerLevel(player) >= 1000){ - player.setHealth(m.calculateHealth(player.getHealth(), 1)); - } - } - if(thecount == 40 || thecount == 80){ - if(player != null && - player.getHealth() > 0 && player.getHealth() < 20 - && m.getPowerLevel(player) >= 500 - && m.getPowerLevel(player) < 1000){ - player.setHealth(m.calculateHealth(player.getHealth(), 1)); - } - } - if(thecount == 80) - { - if(player != null && - player.getHealth() > 0 && player.getHealth() < 20 - && m.getPowerLevel(player) < 500){ - player.setHealth(m.calculateHealth(player.getHealth(), 1)); - } - } - } - } - - - /* - * NON-PLAYER BLEED MONITORING - */ - - if(thecount % 2 == 0) - Swords.bleedSimulate(plugin); - - //SETUP FOR HP REGEN/BLEED - thecount++; - if(thecount >= 81) - thecount = 1; - } -} diff --git a/src/com/gmail/nossr50/party/Party.java b/src/com/gmail/nossr50/party/Party.java index 36575d880..84defd31a 100644 --- a/src/com/gmail/nossr50/party/Party.java +++ b/src/com/gmail/nossr50/party/Party.java @@ -19,7 +19,7 @@ import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.locale.mcLocale; -import com.gmail.nossr50.spout.ArrayListString; +import com.gmail.nossr50.spout.util.ArrayListString; public class Party diff --git a/src/com/gmail/nossr50/runnables/mcTimer.java b/src/com/gmail/nossr50/runnables/mcTimer.java new file mode 100644 index 000000000..5ef6bda52 --- /dev/null +++ b/src/com/gmail/nossr50/runnables/mcTimer.java @@ -0,0 +1,64 @@ +package com.gmail.nossr50.runnables; +import org.bukkit.entity.*; + +import com.gmail.nossr50.Users; +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.datatypes.PlayerProfile; +import com.gmail.nossr50.skills.Skills; +import com.gmail.nossr50.skills.Swords; + + +public class mcTimer implements Runnable +{ + private final mcMMO plugin; + int thecount = 1; + + public mcTimer(final mcMMO plugin) + { + this.plugin = plugin; + } + + public void run() + { + for(Player player : plugin.getServer().getOnlinePlayers()) + { + if(player == null) + continue; + PlayerProfile PP = Users.getProfile(player); + + if(PP == null) + continue; + + /* + * MONITOR SKILLS + */ + Skills.monitorSkills(player); + + /* + * COOLDOWN MONITORING + */ + Skills.watchCooldowns(player); + + /* + * PLAYER BLEED MONITORING + */ + if(thecount % 2 == 0 && PP.getBleedTicks() >= 1) + { + player.damage(2); + PP.decreaseBleedTicks(); + } + + /* + * NON-PLAYER BLEED MONITORING + */ + + if(thecount % 2 == 0) + Swords.bleedSimulate(plugin); + + //SETUP FOR HP REGEN/BLEED + thecount++; + if(thecount >= 81) + thecount = 1; + } + } +} diff --git a/src/com/gmail/nossr50/skills/Axes.java b/src/com/gmail/nossr50/skills/Axes.java index edd89eea4..661a925da 100644 --- a/src/com/gmail/nossr50/skills/Axes.java +++ b/src/com/gmail/nossr50/skills/Axes.java @@ -52,7 +52,8 @@ public class Axes { } } } - public static void axeCriticalCheck(Player attacker, EntityDamageByEntityEvent event, Plugin pluginx){ + public static void axeCriticalCheck(Player attacker, EntityDamageByEntityEvent event, Plugin pluginx) + { Entity x = event.getEntity(); if(x instanceof Wolf){ Wolf wolf = (Wolf)x; diff --git a/src/com/gmail/nossr50/skills/Herbalism.java b/src/com/gmail/nossr50/skills/Herbalism.java index b9bc19b48..047d4fa0a 100644 --- a/src/com/gmail/nossr50/skills/Herbalism.java +++ b/src/com/gmail/nossr50/skills/Herbalism.java @@ -305,86 +305,4 @@ public class Herbalism } Skills.XpCheckSkill(SkillType.HERBALISM, player); } - public static void breadCheck(Player player, ItemStack is) - { - PlayerProfile PP = Users.getProfile(player); - int herbalism = PP.getSkillLevel(SkillType.HERBALISM); - int heal = 0; - if(is.getTypeId() == 297) - { - if(herbalism >= 50 && herbalism < 150) - { - heal = 1; - } else if (herbalism >= 150 && herbalism < 250) - { - heal = 2; - } else if (herbalism >= 250 && herbalism < 350) - { - heal = 3; - } else if (herbalism >= 350 && herbalism < 450) - { - heal = 4; - } else if (herbalism >= 450 && herbalism < 550) - { - heal = 5; - } else if (herbalism >= 550 && herbalism < 650) - { - heal = 6; - } else if (herbalism >= 650 && herbalism < 750) - { - heal = 7; - } else if (herbalism >= 750) - { - heal = 8; - } - - if(player.getHealth()+heal > 20) - { - player.setHealth(20); - } - else - player.setHealth(player.getHealth()+heal); - } - } - public static void stewCheck(Player player, ItemStack is) - { - PlayerProfile PP = Users.getProfile(player); - int herbalism = PP.getSkillLevel(SkillType.HERBALISM); - int heal = 0; - if(is.getTypeId() == 282) - { - if(herbalism >= 50 && herbalism < 150) - { - heal = 1; - } else if (herbalism >= 150 && herbalism < 250) - { - heal = 2; - } else if (herbalism >= 250 && herbalism < 350) - { - heal = 3; - } else if (herbalism >= 350 && herbalism < 450) - { - heal = 4; - } else if (herbalism >= 450 && herbalism < 550) - { - heal = 5; - } else if (herbalism >= 550 && herbalism < 650) - { - heal = 6; - } else if (herbalism >= 650 && herbalism < 750) - { - heal = 7; - } else if (herbalism >= 750) - { - heal = 8; - } - - if(player.getHealth()+heal > 20) - { - player.setHealth(20); - } - else - player.setHealth(player.getHealth()+heal); - } - } } diff --git a/src/com/gmail/nossr50/skills/Swords.java b/src/com/gmail/nossr50/skills/Swords.java index 68b235bcb..de3e3ad91 100644 --- a/src/com/gmail/nossr50/skills/Swords.java +++ b/src/com/gmail/nossr50/skills/Swords.java @@ -157,41 +157,6 @@ public class Swords } } - public static void parryCheck(EntityDamageByEntityEvent event, Player defender) - { - Entity y = event.getDamager(); - PlayerProfile PPd = Users.getProfile(defender); - if(defender != null && m.isSwords(defender.getItemInHand()) - && mcPermissions.getInstance().swords(defender)){ - if(PPd.getSkillLevel(SkillType.SWORDS) >= 900) - { - if(Math.random() * 3000 <= 900) - { - event.setCancelled(true); - defender.sendMessage(ChatColor.GREEN+"**PARRIED**"); - defender.getItemInHand().setDurability((short) (defender.getItemInHand().getDurability() + 1)); - if(y instanceof Player) - { - Player attacker = (Player)y; - attacker.sendMessage(ChatColor.GREEN+"**PARRIED**"); - } - } - } else - { - if(Math.random() * 3000 <= PPd.getSkillLevel(SkillType.SWORDS)) - { - 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**"); - } - } - } - } - } public static void counterAttackChecks(EntityDamageByEntityEvent event) { //Don't want to counter attack arrows diff --git a/src/com/gmail/nossr50/spout/mmoHelper.java b/src/com/gmail/nossr50/spout/mmoHelper.java index ebbf34beb..7ead8290a 100644 --- a/src/com/gmail/nossr50/spout/mmoHelper.java +++ b/src/com/gmail/nossr50/spout/mmoHelper.java @@ -38,6 +38,7 @@ import org.getspout.spoutapi.player.SpoutPlayer; import com.gmail.nossr50.Users; import com.gmail.nossr50.party.Party; +import com.gmail.nossr50.spout.util.GenericLivingEntity; public class mmoHelper { diff --git a/src/com/gmail/nossr50/spout/ArrayListString.java b/src/com/gmail/nossr50/spout/util/ArrayListString.java similarity index 98% rename from src/com/gmail/nossr50/spout/ArrayListString.java rename to src/com/gmail/nossr50/spout/util/ArrayListString.java index ad68b6892..1b6d0c0ae 100644 --- a/src/com/gmail/nossr50/spout/ArrayListString.java +++ b/src/com/gmail/nossr50/spout/util/ArrayListString.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.gmail.nossr50.spout; +package com.gmail.nossr50.spout.util; import java.util.ArrayList; diff --git a/src/com/gmail/nossr50/spout/GenericFace.java b/src/com/gmail/nossr50/spout/util/GenericFace.java similarity index 97% rename from src/com/gmail/nossr50/spout/GenericFace.java rename to src/com/gmail/nossr50/spout/util/GenericFace.java index ffa70395d..432c8a96a 100644 --- a/src/com/gmail/nossr50/spout/GenericFace.java +++ b/src/com/gmail/nossr50/spout/util/GenericFace.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.gmail.nossr50.spout; +package com.gmail.nossr50.spout.util; import org.getspout.spoutapi.gui.GenericTexture; diff --git a/src/com/gmail/nossr50/spout/GenericLivingEntity.java b/src/com/gmail/nossr50/spout/util/GenericLivingEntity.java similarity index 98% rename from src/com/gmail/nossr50/spout/GenericLivingEntity.java rename to src/com/gmail/nossr50/spout/util/GenericLivingEntity.java index 6d3d923a2..143c738d1 100644 --- a/src/com/gmail/nossr50/spout/GenericLivingEntity.java +++ b/src/com/gmail/nossr50/spout/util/GenericLivingEntity.java @@ -14,13 +14,15 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package com.gmail.nossr50.spout; +package com.gmail.nossr50.spout.util; import org.bukkit.Bukkit; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.getspout.spoutapi.gui.*; +import com.gmail.nossr50.spout.mmoHelper; + public class GenericLivingEntity extends GenericContainer { private Container _bars; diff --git a/src/org/blockface/bukkitstats/CallHome.java b/src/org/blockface/bukkitstats/CallHome.java new file mode 100644 index 000000000..ac8e69d6e --- /dev/null +++ b/src/org/blockface/bukkitstats/CallHome.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2011. SwearWord + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this + * software and associated documentation files (the "Software"), to deal in the Software + * without restriction, including without limitation the rights to use the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following + * conditions: + * + * No modifications may be made to the Software. User must use the code as is. + * + * Users of any software implementing this Software must be made aware of this Software's + * implementation. This Software may not be executed on uninformed clients. + * + * The above copyright notice and this permission notice shall be included in all copies + * or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package org.blockface.bukkitstats; + +import org.bukkit.plugin.Plugin; +import org.bukkit.util.config.Configuration; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; +/* +@ + */ + +public class CallHome{ + + private static Configuration cfg=null; + + public static void load(Plugin plugin) { + if(cfg==null) { + if(!verifyConfig()) return; + } + if(cfg.getBoolean("opt-out",false)) return; + plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin,new CallTask(plugin,cfg.getBoolean("list-server",true)),0L,20L*60L*10); + System.out.println(plugin.getDescription().getName() + " is keeping usage stats an. To opt-out for whatever bizarre reason, check plugins/stats."); + + } + + private static Boolean verifyConfig() { + Boolean ret = true; + File config = new File("plugins/stats/config.yml"); + if(!config.getParentFile().exists()) config.getParentFile().mkdir(); + if(!config.exists()) try { + config.createNewFile(); + ret = false; + System.out.println("BukkitStats has initialized for the first time. To opt-out check plugins/stats"); + } catch (IOException e) { + return false; + } + cfg=new Configuration(config); + cfg.load(); + cfg.getBoolean("opt-out",false); + cfg.getBoolean("list-server", true); + cfg.save(); + return ret; + } + + +} + +class CallTask implements Runnable { + private Plugin plugin; + private int pub=1; + + public CallTask(Plugin plugin,Boolean pub) { + this.plugin = plugin; + if(!pub) this.pub = 0; + } + + + + public void run() { + try { + if(postUrl().contains("Success")) return; + } catch (Exception ignored) { + } + System.out.println("Could not call home."); + } + + private String postUrl() throws Exception { + String url = String.format("http://usage.blockface.org/update.php?name=%s&build=%s&plugin=%s&port=%s&public=%s", + plugin.getServer().getName(), + plugin.getDescription().getVersion(), + plugin.getDescription().getName(), + plugin.getServer().getPort(), + pub); + URL oracle = new URL(url); + URLConnection yc = oracle.openConnection(); + BufferedReader in = new BufferedReader( + new InputStreamReader( + yc.getInputStream())); + String inputLine; + while ((inputLine = in.readLine()) != null) + inputLine += ""; + return inputLine; + } +}