mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Changed Tree Feller to not rely on external ArrayList
Given Bukkit's behavior of events, it would have never been possible for more than one player's data to occupy the shared arraylist... Still looked ugly, though. Also helps toward concurrent events, should they ever come. Also moved from a static boolean flag to a per-use flag Also removed unused static variable "w"
This commit is contained in:
parent
cca04468de
commit
b08aead536
@ -8,8 +8,9 @@ Version 1.3.00-dev
|
|||||||
- Added configuration option to control mcMMO reporting damage events
|
- Added configuration option to control mcMMO reporting damage events
|
||||||
- Added hunger regain bonuses to Herbalism skill
|
- Added hunger regain bonuses to Herbalism skill
|
||||||
- Changed chat logging for /p & /a
|
- Changed chat logging for /p & /a
|
||||||
- Fixed Tree Feller not playing nice with NoCheat
|
- Fixed Tree Feller not playing nice with NoCheat (?)
|
||||||
- Added framework for new Blast Mining skill
|
- Added framework for new Blast Mining skill
|
||||||
|
- Changed Tree Feller to use per-use ArrayList
|
||||||
|
|
||||||
Version 1.2.12
|
Version 1.2.12
|
||||||
- Fixed issue that caused terrible MySQL performance and negative XP on levelup (Issue #134)
|
- Fixed issue that caused terrible MySQL performance and negative XP on levelup (Issue #134)
|
||||||
|
@ -33,7 +33,6 @@ public class Misc
|
|||||||
|
|
||||||
public ArrayList<Entity> mobSpawnerList = new ArrayList<Entity>();
|
public ArrayList<Entity> mobSpawnerList = new ArrayList<Entity>();
|
||||||
public HashSet<Block> blockWatchList = new HashSet<Block>();
|
public HashSet<Block> blockWatchList = new HashSet<Block>();
|
||||||
public ArrayList<Block> treeFeller = new ArrayList<Block>();
|
|
||||||
public HashMap<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>();
|
public HashMap<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>();
|
||||||
public ArrayList<LivingEntity> bleedTracker = new ArrayList<LivingEntity>();
|
public ArrayList<LivingEntity> bleedTracker = new ArrayList<LivingEntity>();
|
||||||
public HashMap<Block, Integer> tntTracker = new HashMap<Block, Integer>();
|
public HashMap<Block, Integer> tntTracker = new HashMap<Block, Integer>();
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.gmail.nossr50.listeners;
|
package com.gmail.nossr50.listeners;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import com.gmail.nossr50.Users;
|
import com.gmail.nossr50.Users;
|
||||||
import com.gmail.nossr50.m;
|
import com.gmail.nossr50.m;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
@ -223,8 +225,8 @@ public class mcBlockListener implements Listener
|
|||||||
PlayerAnimationEvent armswing = new PlayerAnimationEvent(player);
|
PlayerAnimationEvent armswing = new PlayerAnimationEvent(player);
|
||||||
Bukkit.getPluginManager().callEvent(armswing);
|
Bukkit.getPluginManager().callEvent(armswing);
|
||||||
|
|
||||||
WoodCutting.treeFeller(block, player, plugin);
|
ArrayList<Block> fell = WoodCutting.treeFeller(block, player);
|
||||||
for(Block blockx : plugin.misc.treeFeller)
|
for(Block blockx : fell)
|
||||||
{
|
{
|
||||||
if(blockx != null)
|
if(blockx != null)
|
||||||
{
|
{
|
||||||
@ -262,7 +264,6 @@ public class mcBlockListener implements Listener
|
|||||||
if(!player.getItemInHand().containsEnchantment(Enchantment.DURABILITY))
|
if(!player.getItemInHand().containsEnchantment(Enchantment.DURABILITY))
|
||||||
m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss);
|
m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss);
|
||||||
}
|
}
|
||||||
plugin.misc.treeFeller.clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -40,8 +40,6 @@ import org.getspout.spoutapi.sound.SoundEffect;
|
|||||||
|
|
||||||
public class WoodCutting
|
public class WoodCutting
|
||||||
{
|
{
|
||||||
static int w = 0;
|
|
||||||
private static boolean isdone = false;
|
|
||||||
|
|
||||||
public static void woodCuttingProcCheck(Player player, Block block)
|
public static void woodCuttingProcCheck(Player player, Block block)
|
||||||
{
|
{
|
||||||
@ -99,34 +97,29 @@ public class WoodCutting
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void treeFeller(Block block, Player player, mcMMO plugin){
|
public static ArrayList<Block> treeFeller(Block block, Player player) {
|
||||||
PlayerProfile PP = Users.getProfile(player);
|
PlayerProfile PP = Users.getProfile(player);
|
||||||
|
|
||||||
int radius = 1;
|
int radius = 1;
|
||||||
if(PP.getSkillLevel(SkillType.WOODCUTTING) >= 500)
|
if(PP.getSkillLevel(SkillType.WOODCUTTING) >= 500)
|
||||||
radius++;
|
radius++;
|
||||||
if(PP.getSkillLevel(SkillType.WOODCUTTING) >= 950)
|
if(PP.getSkillLevel(SkillType.WOODCUTTING) >= 950)
|
||||||
radius++;
|
radius++;
|
||||||
ArrayList<Block> blocklist = new ArrayList<Block>();
|
|
||||||
ArrayList<Block> toAdd = new ArrayList<Block>();
|
ArrayList<Block> blockList = new ArrayList<Block>();
|
||||||
|
ArrayList<Block> returnList = new ArrayList<Block>();
|
||||||
|
|
||||||
if(block != null)
|
if(block != null)
|
||||||
blocklist.add(block);
|
blockList.add(block);
|
||||||
while(isdone == false){
|
|
||||||
addBlocksToTreeFelling(blocklist, toAdd, radius);
|
boolean isDone = false;
|
||||||
|
while(isDone == false){
|
||||||
|
isDone = addBlocksToTreeFelling(blockList, returnList, radius);
|
||||||
}
|
}
|
||||||
//This needs to be a hashmap too!
|
|
||||||
isdone = false;
|
return returnList;
|
||||||
/*
|
|
||||||
* Add blocks from the temporary 'toAdd' array list into the 'treeFeller' array list
|
|
||||||
* We use this temporary list to prevent concurrent modification exceptions
|
|
||||||
*/
|
|
||||||
for(Block x : toAdd)
|
|
||||||
{
|
|
||||||
if(!plugin.misc.treeFeller.contains(x))
|
|
||||||
plugin.misc.treeFeller.add(x);
|
|
||||||
}
|
}
|
||||||
toAdd.clear();
|
public static boolean addBlocksToTreeFelling(ArrayList<Block> blocklist, ArrayList<Block> toAdd, Integer radius)
|
||||||
}
|
|
||||||
public static void addBlocksToTreeFelling(ArrayList<Block> blocklist, ArrayList<Block> toAdd, Integer radius)
|
|
||||||
{
|
{
|
||||||
int u = 0;
|
int u = 0;
|
||||||
for (Block x : blocklist)
|
for (Block x : blocklist)
|
||||||
@ -134,7 +127,6 @@ public class WoodCutting
|
|||||||
u++;
|
u++;
|
||||||
if(toAdd.contains(x))
|
if(toAdd.contains(x))
|
||||||
continue;
|
continue;
|
||||||
w = 0;
|
|
||||||
Location loc = x.getLocation();
|
Location loc = x.getLocation();
|
||||||
int vx = x.getX();
|
int vx = x.getX();
|
||||||
int vy = x.getY();
|
int vy = x.getY();
|
||||||
@ -149,7 +141,6 @@ public class WoodCutting
|
|||||||
Block blocktarget = loc.getWorld().getBlockAt(vx + cx, vy + cy, vz + cz);
|
Block blocktarget = loc.getWorld().getBlockAt(vx + cx, vy + cy, vz + cz);
|
||||||
if (!blocklist.contains(blocktarget) && !toAdd.contains(blocktarget) && (blocktarget.getTypeId() == 17 || blocktarget.getTypeId() == 18)) {
|
if (!blocklist.contains(blocktarget) && !toAdd.contains(blocktarget) && (blocktarget.getTypeId() == 17 || blocktarget.getTypeId() == 18)) {
|
||||||
toAdd.add(blocktarget);
|
toAdd.add(blocktarget);
|
||||||
w++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,9 +156,9 @@ public class WoodCutting
|
|||||||
}
|
}
|
||||||
if(u >= blocklist.size())
|
if(u >= blocklist.size())
|
||||||
{
|
{
|
||||||
isdone = true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
isdone = false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user