diff --git a/mcMMO/com/gmail/nossr50/mcBlockListener.java b/mcMMO/com/gmail/nossr50/mcBlockListener.java index 7bd92bb7a..d5139522b 100644 --- a/mcMMO/com/gmail/nossr50/mcBlockListener.java +++ b/mcMMO/com/gmail/nossr50/mcBlockListener.java @@ -1,5 +1,7 @@ package com.gmail.nossr50; +import java.util.ArrayList; + import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; @@ -69,29 +71,34 @@ public class mcBlockListener extends BlockListener { /* * IF PLAYER IS USING TREEFELLER */ - /* - if(mcPermissions.getInstance().woodcuttingability(player)){ - player.sendMessage(ChatColor.RED+"TIIIIIIIIIIIMBER"); - mcWoodCutting.getInstance().treeFeller(block); + if(mcPermissions.getInstance().woodcuttingability(player) && mcUsers.getProfile(player).getTreeFellerMode() && block.getTypeId() == 17){ + mcWoodCutting.getInstance().treeFeller(block, player); for(Block blockx : mcConfig.getInstance().getTreeFeller()){ if(blockx != null){ Material mat = Material.getMaterial(blockx.getTypeId()); byte damage = 0; ItemStack item = new ItemStack(mat, 1, (byte)0, damage); blockx.setTypeId(0); - if(item.getTypeId() == 17) + if(item.getTypeId() == 17){ blockx.getLocation().getWorld().dropItemNaturally(blockx.getLocation(), item); + mcWoodCutting.getInstance().woodCuttingProcCheck(player, blockx, blockx.getLocation()); + mcUsers.getProfile(player).addWoodcuttingGather(7); + } if(item.getTypeId() == 18){ mat = Material.getMaterial(6); item = new ItemStack(mat, 1, (byte)0, damage); - if(Math.random() * 10 > 6) + if(Math.random() * 10 > 8) blockx.getLocation().getWorld().dropItemNaturally(blockx.getLocation(), item); } } - //mcConfig.getInstance().removeTreeFeller(blockx); } + /* + * NOTE TO SELF + * I NEED TO REMOVE TREE FELL BLOCKS FROM BEING WATCHED AFTER THIS CODE IS EXECUTED + * OR ELSE IT COULD BE A MEMORY LEAK SITUATION + */ + mcConfig.getInstance().clearTreeFeller(); } - */ } /* * EXCAVATION diff --git a/mcMMO/com/gmail/nossr50/mcConfig.java b/mcMMO/com/gmail/nossr50/mcConfig.java index 9b385cb18..64e61053c 100644 --- a/mcMMO/com/gmail/nossr50/mcConfig.java +++ b/mcMMO/com/gmail/nossr50/mcConfig.java @@ -32,6 +32,9 @@ public class mcConfig { public void removeBleedTrack(Entity entity){ bleedTracker.remove(entity); } + public void clearTreeFeller(){ + treeFeller.clear(); + } public void setBleedCount(Entity entity, Integer newvalue){ bleedTracker.add(entity); } diff --git a/mcMMO/com/gmail/nossr50/mcPlayerListener.java b/mcMMO/com/gmail/nossr50/mcPlayerListener.java index d645f080f..b588904ef 100644 --- a/mcMMO/com/gmail/nossr50/mcPlayerListener.java +++ b/mcMMO/com/gmail/nossr50/mcPlayerListener.java @@ -69,6 +69,20 @@ public class mcPlayerListener extends PlayerListener { Block block = event.getBlockClicked(); Player player = event.getPlayer(); ItemStack is = player.getItemInHand(); + if(mcPermissions.getInstance().woodcuttingability(player) && mcm.getInstance().isAxes(is)){ + if(block != null){ + if(!mcm.getInstance().abilityBlockCheck(block)) + return; + } + if(!mcUsers.getProfile(player).getTreeFellerMode() && mcUsers.getProfile(player).getTreeFellerCooldown() == 0){ + player.sendMessage(ChatColor.GRAY+"You feel great strength enter you"); + mcUsers.getProfile(player).setTreeFellerTicks(8); + mcUsers.getProfile(player).setTreeFellerMode(true); + } + if(!mcUsers.getProfile(player).getTreeFellerMode() && mcUsers.getProfile(player).getTreeFellerCooldown() >= 1){ + player.sendMessage(ChatColor.RED+"You are too tired to use that ability again."); + } + } if(mcPermissions.getInstance().herbalism(player)){ //BREADCHECK, CHECKS HERBALISM SKILL FOR BREAD HP MODIFIERS mcHerbalism.getInstance().breadCheck(player, is); diff --git a/mcMMO/com/gmail/nossr50/mcTimer.java b/mcMMO/com/gmail/nossr50/mcTimer.java index 5e9b1e331..abe41b282 100644 --- a/mcMMO/com/gmail/nossr50/mcTimer.java +++ b/mcMMO/com/gmail/nossr50/mcTimer.java @@ -1,6 +1,8 @@ package com.gmail.nossr50; +import java.awt.Color; import java.util.TimerTask; +import org.bukkit.ChatColor; import org.bukkit.entity.*; public class mcTimer extends TimerTask{ @@ -13,6 +15,7 @@ public class mcTimer extends TimerTask{ public void run() { Player[] playerlist = plugin.getServer().getOnlinePlayers(); + /* if(thecount == 5 || thecount == 10 || thecount == 15 || thecount == 20){ for(Player player : playerlist){ if(player != null && @@ -58,5 +61,29 @@ public class mcTimer extends TimerTask{ thecount = 1; } mcCombat.getInstance().bleedSimulate(); + */ + /* + * TREE FELLER INTERACTIONS + */ + for(Player player : playerlist){ + if(mcPermissions.getInstance().woodcuttingability(player)){ + //Monitor the length of TreeFeller mode + if(mcUsers.getProfile(player).getTreeFellerMode()){ + mcUsers.getProfile(player).decreaseTreeFellerTicks(); + if(mcUsers.getProfile(player).getTreeFellerTicks() <= 0){ + mcUsers.getProfile(player).setTreeFellerMode(false); + mcUsers.getProfile(player).setTreeFellerCooldown(120); + player.sendMessage(ChatColor.GRAY+"**You feel strength leaving you**"); + } + } + //Monitor the cooldown + if(!mcUsers.getProfile(player).getTreeFellerMode() && mcUsers.getProfile(player).getTreeFellerCooldown() >= 1){ + mcUsers.getProfile(player).decreaseTreeFellerCooldown(); + if(mcUsers.getProfile(player).getTreeFellerCooldown() == 0){ + player.sendMessage(ChatColor.GREEN+"Your Tree Felling ability is refreshed!"); + } + } + } + } } } diff --git a/mcMMO/com/gmail/nossr50/mcUsers.java b/mcMMO/com/gmail/nossr50/mcUsers.java index e21104f80..6d4344e5f 100644 --- a/mcMMO/com/gmail/nossr50/mcUsers.java +++ b/mcMMO/com/gmail/nossr50/mcUsers.java @@ -156,8 +156,8 @@ class PlayerList protected final Logger log = Logger.getLogger("Minecraft"); 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, bleedticks = 0; + private boolean dead, treefellermode; + private int recentlyhurt = 0, bleedticks = 0, treefellerticks = 0, treefellercooldown = 0; Player thisplayer; char defaultColor; @@ -206,7 +206,7 @@ class PlayerList //gather = "0"; party = null; dead = false; - + treefellermode = false; //Try to load the player and if they aren't found, append them if(!load()) addPlayer(); @@ -433,6 +433,34 @@ class PlayerList public void setBleedTicks(Integer newvalue){ bleedticks = newvalue; } + public boolean getTreeFellerMode(){ + return treefellermode; + } + public void setTreeFellerMode(Boolean bool){ + treefellermode = bool; + } + public Integer getTreeFellerTicks(){ + return treefellerticks; + } + public void setTreeFellerTicks(Integer newvalue){ + treefellerticks = newvalue; + } + public void decreaseTreeFellerTicks(){ + if(treefellerticks >= 1){ + treefellerticks--; + } + } + public void setTreeFellerCooldown(Integer newvalue){ + treefellercooldown = newvalue; + } + public int getTreeFellerCooldown(){ + return treefellercooldown; + } + public void decreaseTreeFellerCooldown(){ + if(treefellercooldown >= 1){ + treefellercooldown--; + } + } public Integer getRecentlyHurt(){ return recentlyhurt; } diff --git a/mcMMO/com/gmail/nossr50/mcWoodCutting.java b/mcMMO/com/gmail/nossr50/mcWoodCutting.java index e8223f50c..8a52c3969 100644 --- a/mcMMO/com/gmail/nossr50/mcWoodCutting.java +++ b/mcMMO/com/gmail/nossr50/mcWoodCutting.java @@ -34,8 +34,12 @@ public class mcWoodCutting { } } } - public void treeFeller(Block block){ + public void treeFeller(Block block, Player player){ int radius = 1; + if(mcUsers.getProfile(player).getWoodCuttingGatherInt() >= 500) + radius++; + if(mcUsers.getProfile(player).getWoodCuttingGatherInt() >= 950) + radius++; ArrayList blocklist = new ArrayList(); ArrayList toAdd = new ArrayList(); if(block != null) diff --git a/mcMMO/com/gmail/nossr50/mcm.java b/mcMMO/com/gmail/nossr50/mcm.java index dc1816b41..c69c0db51 100644 --- a/mcMMO/com/gmail/nossr50/mcm.java +++ b/mcMMO/com/gmail/nossr50/mcm.java @@ -35,6 +35,14 @@ public class mcm { return Math.sqrt(Math.pow(loca.getX() - locb.getX(), 2) + Math.pow(loca.getY() - locb.getY(), 2) + Math.pow(loca.getZ() - locb.getZ(), 2)); } + public boolean abilityBlockCheck(Block block){ + int i = block.getTypeId(); + if(i == 58 || i == 61 || i == 42 || i == 71 || i == 64 || i == 84 || i == 324 || i == 330){ + return false; + } else { + return true; + } + } public boolean isBlockAround(Location loc, Integer radius, Integer typeid){ Block blockx = loc.getBlock(); int ox = blockx.getX(); diff --git a/mcMMO/plugin.yml b/mcMMO/plugin.yml index a241e7687..cfbee228a 100644 --- a/mcMMO/plugin.yml +++ b/mcMMO/plugin.yml @@ -1,3 +1,3 @@ name: mcMMO main: com.gmail.nossr50.mcMMO -version: 0.8.16 \ No newline at end of file +version: 0.9 WIP \ No newline at end of file