From ab7fe5320aca9f603018d2d32636008a3d528a28 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 25 Feb 2011 16:33:00 -0800 Subject: [PATCH] Changes up to 0.8.1 --- mcMMO/com/gmail/nossr50/mcMMO.java | 2 +- mcMMO/com/gmail/nossr50/mcTimer.java | 53 +++++++++++++--------------- mcMMO/com/gmail/nossr50/mcUsers.java | 13 ++++++- mcMMO/com/gmail/nossr50/mcm.java | 16 +++++++++ mcMMO/plugin.yml | 2 +- 5 files changed, 55 insertions(+), 31 deletions(-) diff --git a/mcMMO/com/gmail/nossr50/mcMMO.java b/mcMMO/com/gmail/nossr50/mcMMO.java index 8eff5afcd..794c2c91f 100644 --- a/mcMMO/com/gmail/nossr50/mcMMO.java +++ b/mcMMO/com/gmail/nossr50/mcMMO.java @@ -43,7 +43,7 @@ public class mcMMO extends JavaPlugin { */ //herp public void onEnable() { - mcMMO_Timer.schedule(new mcTimer(this), 0, (long)(1000)); + mcMMO_Timer.schedule(new mcTimer(this), 0, (long)(2000)); //Make the directory if it does not exist new File(maindirectory).mkdir(); //Make the file if it does not exist diff --git a/mcMMO/com/gmail/nossr50/mcTimer.java b/mcMMO/com/gmail/nossr50/mcTimer.java index 0d7d8c0c5..7dff23964 100644 --- a/mcMMO/com/gmail/nossr50/mcTimer.java +++ b/mcMMO/com/gmail/nossr50/mcTimer.java @@ -45,24 +45,15 @@ public class mcTimer extends TimerTask{ public void run() { for(World world : plugin.getServer().getWorlds()){ for(Entity entity : world.getEntities()){ - if(entity == null || getHealth(entity) <= 0) + if(entity == null) return; - if(mcConfig.getInstance().getBleedCount(entity) < 1) + /* + if(!mcConfig.getInstance().isBleedTracked(entity)) return; - if(mcConfig.getInstance().isBleedTracked(entity)){ - if(entity instanceof Player){ - Player player = (Player)entity; - if(player.getHealth() >= 1){ - player.setHealth(calculateMinusHealth(player.getHealth(), 1)); - player.sendMessage(ChatColor.RED+"**BLEED**"); - if(player.getHealth() <= 0){ - for(ItemStack items : player.getInventory().getContents()){ - if(items.getTypeId() != 0) - player.getLocation().getWorld().dropItemNaturally(player.getLocation(), items); - } - } - } - } + */ + if(getHealth(entity) <= 0) + return; + /* if(entity instanceof Animals){ Animals animals = (Animals)entity; if(animals.getHealth() >= 1){ @@ -77,22 +68,28 @@ public class mcTimer extends TimerTask{ if(monster.getHealth() >= 1){ monster.setHealth(calculateMinusHealth(monster.getHealth(), 1)); if(monster.getHealth() <= 0){ - mcm.getInstance().simulateNaturalDrops(entity); + mcm.getInstance().simulateNaturalDrops(entity); } } } - } - } - } - for(World world : plugin.getServer().getWorlds()){ - for(Entity entity : world.getEntities()){ - if(mcConfig.getInstance().isBleedTracked(entity)){ - if(mcConfig.getInstance().getBleedCount(entity) >= 2){ - mcConfig.getInstance().removeBleedCount(entity, 1); - } else if(mcConfig.getInstance().getBleedCount(entity) == 1){ - mcConfig.getInstance().removeBleedTrack(entity); + */ + if(entity instanceof Player){ + Player player = (Player)entity; + if(player.getHealth() >= 1 && mcUsers.getProfile(player).getBleedTicks() >= 1){ + player.setHealth(calculateMinusHealth(player.getHealth(), 1)); + player.sendMessage(ChatColor.RED+"**BLEED**"); + if(player.getHealth() <= 0){ + mcUsers.getProfile(player).setBleedTicks(0); + for(ItemStack items : player.getInventory().getContents()){ + if(items.getTypeId() != 0) + player.getLocation().getWorld().dropItemNaturally(player.getLocation(), items); + } + } + if(mcUsers.getProfile(player).getBleedTicks() >= 1){ + mcUsers.getProfile(player).setBleedTicks(mcUsers.getProfile(player).getBleedTicks() - 1); + } + } } - } } } if(thecount == 10 || thecount == 20 || thecount == 30 || thecount == 40){ diff --git a/mcMMO/com/gmail/nossr50/mcUsers.java b/mcMMO/com/gmail/nossr50/mcUsers.java index ded24bcf5..dcb249422 100644 --- a/mcMMO/com/gmail/nossr50/mcUsers.java +++ b/mcMMO/com/gmail/nossr50/mcUsers.java @@ -156,7 +156,7 @@ class PlayerList private String playerName, gather, wgather, woodcutting, repair, mining, party, myspawn, myspawnworld, unarmed, herbalism, excavation, archery, swords, axes, invite, acrobatics, repairgather, unarmedgather, herbalismgather, excavationgather, archerygather, swordsgather, axesgather, acrobaticsgather; private boolean dead; - private int recentlyhurt = 0; + private int recentlyhurt = 0, bleedticks = 0; Player thisplayer; char defaultColor; @@ -421,6 +421,17 @@ class PlayerList recentlyhurt--; } } + public void decreaseBleedTicks(){ + if(bleedticks >= 1){ + bleedticks--; + } + } + public Integer getBleedTicks(){ + return bleedticks; + } + public void setBleedTicks(Integer newvalue){ + bleedticks = newvalue; + } public Integer getRecentlyHurt(){ return recentlyhurt; } diff --git a/mcMMO/com/gmail/nossr50/mcm.java b/mcMMO/com/gmail/nossr50/mcm.java index dca6ffbaa..0ff4654d1 100644 --- a/mcMMO/com/gmail/nossr50/mcm.java +++ b/mcMMO/com/gmail/nossr50/mcm.java @@ -753,21 +753,37 @@ public class mcm { if(mcUsers.getProfile(attacker).getSwordsInt() >= 50 && mcUsers.getProfile(attacker).getSwordsInt() < 200){ if(Math.random() * 10 > 8){ mcConfig.getInstance().addBleedTrack(x, 4); + if(x instanceof Player){ + Player target = (Player)x; + mcUsers.getProfile(target).setBleedTicks(4); + } attacker.sendMessage(ChatColor.RED+"**Your target is bleeding**"); } } else if(mcUsers.getProfile(attacker).getSwordsInt() >= 200 && mcUsers.getProfile(attacker).getSwordsInt() < 600){ if(Math.random() * 10 > 6){ mcConfig.getInstance().addBleedTrack(x, 4); + if(x instanceof Player){ + Player target = (Player)x; + mcUsers.getProfile(target).setBleedTicks(4); + } attacker.sendMessage(ChatColor.RED+"**Your target is bleeding**"); } } else if(mcUsers.getProfile(attacker).getSwordsInt() >= 600 && mcUsers.getProfile(attacker).getSwordsInt() < 900){ if(Math.random() * 10 > 4){ mcConfig.getInstance().addBleedTrack(x, 6); + if(x instanceof Player){ + Player target = (Player)x; + mcUsers.getProfile(target).setBleedTicks(6); + } attacker.sendMessage(ChatColor.RED+"**Your target is bleeding**"); } } else if(mcUsers.getProfile(attacker).getSwordsInt() >= 900){ if(Math.random() * 100 > 75){ mcConfig.getInstance().addBleedTrack(x, 6); + if(x instanceof Player){ + Player target = (Player)x; + mcUsers.getProfile(target).setBleedTicks(6); + } attacker.sendMessage(ChatColor.RED+"**Your target is bleeding**"); } } diff --git a/mcMMO/plugin.yml b/mcMMO/plugin.yml index 654d67224..99683dd12 100644 --- a/mcMMO/plugin.yml +++ b/mcMMO/plugin.yml @@ -1,3 +1,3 @@ name: mcMMO main: com.gmail.nossr50.mcMMO -version: 0.8 \ No newline at end of file +version: 0.8.1 \ No newline at end of file