Revert "Protect placeStore. It's ugly and still needs work."

This reverts commit 1fe182babe.
This commit is contained in:
NuclearW 2013-02-17 10:05:35 -05:00
parent f2b03896e2
commit 57e6e5400b
14 changed files with 46 additions and 89 deletions

View File

@ -65,17 +65,17 @@ public class BlockListener implements Listener {
Block futureEmptyBlock = event.getBlock().getRelative(direction); // Block that would be air after piston is finished
for (Block b : blocks) {
if (mcMMO.p.isPlaced(b)) {
if (mcMMO.placeStore.isTrue(b)) {
b.getRelative(direction).setMetadata("pistonTrack", new FixedMetadataValue(plugin, true));
if (b.equals(futureEmptyBlock)) {
mcMMO.p.setNotPlaced(b);
mcMMO.placeStore.setFalse(b);
}
}
}
for (Block b : blocks) {
if (b.getRelative(direction).hasMetadata("pistonTrack")) {
mcMMO.p.setIsPlaced(b.getRelative(direction));
mcMMO.placeStore.setTrue(b.getRelative(direction));
b.getRelative(direction).removeMetadata("pistonTrack", plugin);
}
}
@ -111,7 +111,7 @@ public class BlockListener implements Listener {
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
if (BlockChecks.shouldBeWatched(block)) {
mcMMO.p.setIsPlaced(block);
mcMMO.placeStore.setTrue(block);
}
if (Repair.anvilMessagesEnabled) {
@ -169,7 +169,7 @@ public class BlockListener implements Listener {
}
/* MINING */
else if (BlockChecks.canBeSuperBroken(block) && ItemChecks.isPickaxe(heldItem) && player.hasPermission("mcmmo.skills.mining") && !mcMMO.p.isPlaced(block)) {
else if (BlockChecks.canBeSuperBroken(block) && ItemChecks.isPickaxe(heldItem) && player.hasPermission("mcmmo.skills.mining") && !mcMMO.placeStore.isTrue(block)) {
MiningManager miningManager = new MiningManager(mcMMOPlayer);
miningManager.miningBlockCheck(block);
@ -179,7 +179,7 @@ public class BlockListener implements Listener {
}
/* WOOD CUTTING */
else if (BlockChecks.isLog(block) && player.hasPermission("mcmmo.skills.woodcutting") && !mcMMO.p.isPlaced(block)) {
else if (BlockChecks.isLog(block) && player.hasPermission("mcmmo.skills.woodcutting") && !mcMMO.placeStore.isTrue(block)) {
if (profile.getAbilityMode(AbilityType.TREE_FELLER) && player.hasPermission("mcmmo.ability.woodcutting.treefeller") && ItemChecks.isAxe(heldItem)) {
Woodcutting.beginTreeFeller(mcMMOPlayer, block);
}
@ -196,7 +196,7 @@ public class BlockListener implements Listener {
}
/* EXCAVATION */
else if (BlockChecks.canBeGigaDrillBroken(block) && ItemChecks.isShovel(heldItem) && player.hasPermission("mcmmo.skills.excavation") && !mcMMO.p.isPlaced(block)) {
else if (BlockChecks.canBeGigaDrillBroken(block) && ItemChecks.isShovel(heldItem) && player.hasPermission("mcmmo.skills.excavation") && !mcMMO.placeStore.isTrue(block)) {
Excavation.excavationProcCheck(block, mcMMOPlayer);
if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) {
@ -205,8 +205,8 @@ public class BlockListener implements Listener {
}
/* Remove metadata from placed watched blocks */
if (BlockChecks.shouldBeWatched(block) && mcMMO.p.isPlaced(block)) {
mcMMO.p.setNotPlaced(block);
if (BlockChecks.shouldBeWatched(block) && mcMMO.placeStore.isTrue(block)) {
mcMMO.placeStore.setFalse(block);
}
}
@ -233,7 +233,7 @@ public class BlockListener implements Listener {
if (player.hasPermission("mcmmo.ability.herbalism.hylianluck") && ItemChecks.isSword(heldItem)) {
Herbalism.hylianLuck(block, player, event);
}
else if (BlockChecks.canBeFluxMined(block) && ItemChecks.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH) && player.hasPermission("mcmmo.ability.smelting.fluxmining") && !mcMMO.p.isPlaced(block)) {
else if (BlockChecks.canBeFluxMined(block) && ItemChecks.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH) && player.hasPermission("mcmmo.ability.smelting.fluxmining") && !mcMMO.placeStore.isTrue(block)) {
SmeltingManager smeltingManager = new SmeltingManager(Users.getPlayer(player));
smeltingManager.fluxMining(event);
}

View File

@ -65,13 +65,13 @@ public class EntityListener implements Listener {
if (entity instanceof FallingBlock) {
Block block = event.getBlock();
if (mcMMO.p.isPlaced(block) && !mcMMO.p.isSpawned(entity)) {
mcMMO.p.setNotPlaced(block);
mcMMO.p.setIsSpawned(entity);
if (mcMMO.placeStore.isTrue(block) && !mcMMO.placeStore.isSpawnedMob(entity)) {
mcMMO.placeStore.setFalse(block);
mcMMO.placeStore.addSpawnedMob(entity);
}
else if (mcMMO.p.isSpawned(entity)) {
mcMMO.p.setIsPlaced(block);
mcMMO.p.setNotSpawned(entity);
else if (mcMMO.placeStore.isSpawnedMob(entity)) {
mcMMO.placeStore.setTrue(block);
mcMMO.placeStore.removeSpawnedMob(entity);
}
}
}
@ -208,7 +208,7 @@ public class EntityListener implements Listener {
entity.setFireTicks(0);
BleedTimer.remove(entity);
Archery.arrowRetrievalCheck(entity);
mcMMO.p.setNotSpawned(entity);
mcMMO.placeStore.removeSpawnedMob(entity);
}
/**
@ -225,7 +225,7 @@ public class EntityListener implements Listener {
SpawnReason reason = event.getSpawnReason();
if (reason == SpawnReason.SPAWNER || reason == SpawnReason.SPAWNER_EGG) {
mcMMO.p.setIsSpawned(event.getEntity());
mcMMO.placeStore.addSpawnedMob(event.getEntity());
}
}

View File

@ -38,9 +38,9 @@ public class WorldListener implements Listener {
return;
}
if (mcMMO.p.isPlaced(event.getLocation().getBlock())) {
if (mcMMO.placeStore.isTrue(event.getLocation().getBlock())) {
for (BlockState block : event.getBlocks()) {
mcMMO.p.setNotPlaced(block.getBlock());
mcMMO.placeStore.setFalse(block.getBlock());
}
}
}
@ -73,7 +73,7 @@ public class WorldListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onWorldUnload(WorldUnloadEvent event) {
mcMMO.p.setUnloaded(event.getWorld());
mcMMO.placeStore.unloadWorld(event.getWorld());
}
/**
@ -83,7 +83,9 @@ public class WorldListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onChunkUnload(ChunkUnloadEvent event) {
mcMMO.p.setUnloaded(event.getChunk(), event.getWorld());
Chunk chunk = event.getChunk();
mcMMO.placeStore.chunkUnloaded(chunk.getX(), chunk.getZ(), event.getWorld());
}
/**
@ -98,7 +100,7 @@ public class WorldListener implements Listener {
for (Entity entity : entities) {
if (entity instanceof LivingEntity || entity instanceof FallingBlock) {
mcMMO.p.setLoaded(chunk, event.getWorld(), entities);
mcMMO.placeStore.loadChunk(chunk.getX(), chunk.getZ(), event.getWorld(), entities);
return;
}
}

View File

@ -8,11 +8,8 @@ import java.util.List;
import net.shatteredlands.shatt.backup.ZipLibrary;
import org.bukkit.Chunk;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
@ -66,7 +63,7 @@ public class mcMMO extends JavaPlugin {
public static mcMMO p;
private ChunkManager placeStore;
public static ChunkManager placeStore;
public static RepairManager repairManager;
// Jar Stuff
@ -422,48 +419,4 @@ public class mcMMO extends JavaPlugin {
public void toggleXpEventEnabled() {
xpEventEnabled = !xpEventEnabled;
}
public boolean isPlaced(Block block) {
return placeStore.isTrue(block);
}
public void setNotPlaced(Block block) {
placeStore.setFalse(block);
}
public void setIsPlaced(Block block) {
placeStore.setTrue(block);
}
public boolean isSpawned(Entity entity) {
return placeStore.isSpawnedMob(entity);
}
public void setIsSpawned(Entity entity) {
placeStore.addSpawnedMob(entity);
}
public void setNotSpawned(Entity entity) {
placeStore.removeSpawnedMob(entity);
}
public void setUnloaded(World world) {
placeStore.unloadWorld(world);
}
public void setUnloaded(Chunk chunk, World world) {
placeStore.chunkUnloaded(chunk.getX(), chunk.getZ(), world);
}
public void setLoaded(Chunk chunk, World world, Entity[] entities) {
placeStore.loadChunk(chunk.getX(), chunk.getZ(), world, entities);
}
public void cleanMobLists() {
placeStore.cleanMobLists();
}
public ChunkManager getChunkStore() {
return placeStore;
}
}

View File

@ -33,6 +33,6 @@ public class MobStoreCleaner implements Runnable {
@Override
public void run() {
mcMMO.p.cleanMobLists();
mcMMO.placeStore.cleanMobLists();
}
}

View File

@ -22,11 +22,11 @@ public class StickyPistonTracker implements Runnable {
return;
}
if (!mcMMO.p.isPlaced(originalBlock)) {
if (!mcMMO.placeStore.isTrue(originalBlock)) {
return;
}
mcMMO.p.setNotPlaced(originalBlock);
mcMMO.p.setIsPlaced(newBlock);
mcMMO.placeStore.setFalse(originalBlock);
mcMMO.placeStore.setTrue(newBlock);
}
}

View File

@ -130,7 +130,7 @@ public class Herbalism {
for (int y = 0; y <= 2; y++) {
Block relativeBlock = block.getRelative(BlockFace.UP, y);
if (relativeBlock.getType() == blockType && !mcMMO.p.isPlaced(relativeBlock)) {
if (relativeBlock.getType() == blockType && !mcMMO.placeStore.isTrue(relativeBlock)) {
dropAmount++;
}
}
@ -177,7 +177,7 @@ public class Herbalism {
greenThumbWheat(block, player, plugin);
}
else {
if (!mcMMO.p.isPlaced(block)) {
if (!mcMMO.placeStore.isTrue(block)) {
dropItem = herbalismBlock.getDropItem();
xp = herbalismBlock.getXpGain();
}
@ -332,8 +332,8 @@ public class Herbalism {
case RED_ROSE:
case YELLOW_FLOWER:
if (mcMMO.p.isPlaced(block)) {
mcMMO.p.setNotPlaced(block);
if (mcMMO.placeStore.isTrue(block)) {
mcMMO.placeStore.setFalse(block);
return;
}

View File

@ -51,7 +51,7 @@ public class BlastMiningDropEventHandler {
McMMOPlayer mcMMOPlayer = manager.getMcMMOPlayer();
for (Block block : droppedOres) {
if (!mcMMO.p.isPlaced(block)) {
if (!mcMMO.placeStore.isTrue(block)) {
Mining.miningXP(mcMMOPlayer, block, block.getType());
}
}
@ -66,7 +66,7 @@ public class BlastMiningDropEventHandler {
droppedOres.add(block);
Mining.miningDrops(block, location, type);
if (!mcMMO.p.isPlaced(block)) {
if (!mcMMO.placeStore.isTrue(block)) {
for (int i = 1 ; i < dropMultiplier ; i++) {
droppedOres.add(block);
Mining.miningDrops(block, location, type);

View File

@ -67,7 +67,7 @@ public class CallOfTheWildEventHandler {
return;
LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(player.getLocation(), type);
mcMMO.p.setIsSpawned(entity);
mcMMO.placeStore.addSpawnedPet(entity);
((Tameable) entity).setOwner(player);

View File

@ -27,7 +27,7 @@ public class TamingManager extends SkillManager {
* @param event The event to award XP for
*/
public void awardTamingXP(EntityTameEvent event) {
if (mcMMO.p.isSpawned(event.getEntity())) {
if (mcMMO.placeStore.isSpawnedMob(event.getEntity())) {
return;
}

View File

@ -459,8 +459,8 @@ public final class CombatTools {
baseXP = 20 * configInstance.getPlayerVersusPlayerXP();
}
}
else if (!mcMMO.p.isSpawned(target)) {
if (target instanceof Animals) {
else if (!mcMMO.placeStore.isSpawnedMob(target)) {
if (target instanceof Animals && !mcMMO.placeStore.isSpawnedPet(target)) {
if (ModChecks.isCustomEntity(target)) {
baseXP = ModChecks.getCustomEntity(target).getXpMultiplier();
}

View File

@ -112,7 +112,7 @@ public final class TreeFeller {
* @param treeFellerBlocks List of blocks to be removed
*/
private static void handleBlock(Block block, List<Block> futureCenterBlocks, List<Block> treeFellerBlocks) {
if (!BlockChecks.treeFellerCompatible(block) || mcMMO.p.isPlaced(block) || treeFellerBlocks.contains(block)) {
if (!BlockChecks.treeFellerCompatible(block) || mcMMO.placeStore.isTrue(block) || treeFellerBlocks.contains(block)) {
return;
}

View File

@ -619,9 +619,11 @@ public class HashChunkManager implements ChunkManager {
List<Entity> tempSpawnedMobs = new ArrayList<Entity>(spawnedMobs);
for (Entity entity : tempSpawnedMobs) {
if (entity.isDead() || !entity.isValid()) {
if (entity.isDead())
mobsToRemove.add(entity);
if (!entity.isValid())
mobsToRemove.add(entity);
}
}
spawnedMobs.removeAll(mobsToRemove);

View File

@ -34,7 +34,7 @@ public class BlockStoreConversionZDirectory implements Runnable {
this.world = world;
this.scheduler = mcMMO.p.getServer().getScheduler();
this.manager = new HashChunkletManager();
this.newManager = (HashChunkManager) mcMMO.p.getChunkStore();
this.newManager = (HashChunkManager) mcMMO.placeStore;
this.dataDir = dataDir;
this.xDir = xDir;