mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-24 01:27:41 +01:00
Changed placed block tracking to use metadata!
This commit is contained in:
parent
43ff0fa41a
commit
058cc3aac9
@ -36,6 +36,7 @@ Version 2.0.00-dev
|
||||
! Changed parties so that a player will leave their existing party if they enter a world where they don't have party permissions.
|
||||
! Changed Call of the Wild to summon animals already tamed.
|
||||
! Changed mob spawner tracking to use new Metadata API
|
||||
! Changed block watch list to use new Metadata API
|
||||
|
||||
Version 1.3.02
|
||||
+ Added in game guides for Mining, Excavation, and Acrobatics. Simply type /skillname ? to access them
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.gmail.nossr50;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
|
||||
@ -117,45 +116,4 @@ public class BlockChecks {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the block the the appropriate watchlist.
|
||||
*
|
||||
* @param material the type of Block to watch
|
||||
* @param block the Block to watch
|
||||
* @param plugin mcMMO plugin instance
|
||||
*/
|
||||
public static void watchBlock(Material material, Block block, mcMMO plugin) {
|
||||
|
||||
boolean addToChangeQueue = true;
|
||||
|
||||
switch (material) {
|
||||
case CACTUS:
|
||||
case GLOWING_REDSTONE_ORE:
|
||||
case JACK_O_LANTERN:
|
||||
case LOG:
|
||||
case PUMPKIN:
|
||||
case REDSTONE_ORE:
|
||||
case SUGAR_CANE_BLOCK:
|
||||
case VINE:
|
||||
addToChangeQueue = false; //We don't want these added to changeQueue - these use their data
|
||||
plugin.misc.blockWatchList.add(block);
|
||||
break;
|
||||
|
||||
case BROWN_MUSHROOM:
|
||||
case RED_MUSHROOM:
|
||||
case RED_ROSE:
|
||||
case YELLOW_FLOWER:
|
||||
case WATER_LILY:
|
||||
addToChangeQueue = false; //We don't want these added to changeQueue - they're already being added to the fast queue
|
||||
plugin.fastChangeQueue.push(block);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(addToChangeQueue)
|
||||
plugin.changeQueue.push(block);
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,7 @@ package com.gmail.nossr50.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -15,7 +13,6 @@ public class Misc
|
||||
{
|
||||
String location = "mcmmo.properties";
|
||||
|
||||
public HashSet<Block> blockWatchList = new HashSet<Block>();
|
||||
public HashMap<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>();
|
||||
public ArrayList<LivingEntity> bleedTracker = new ArrayList<LivingEntity>();
|
||||
public HashMap<Integer, Player> tntTracker = new HashMap<Integer, Player>();
|
||||
|
@ -30,6 +30,7 @@ import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
@ -74,7 +75,7 @@ public class mcBlockListener implements Listener {
|
||||
}
|
||||
else {
|
||||
Block newLocation = block.getRelative(0, y+1, 0);
|
||||
newLocation.setData((byte) 0x5);
|
||||
newLocation.setMetadata("placedBlock", new FixedMetadataValue(plugin, true));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -82,7 +83,7 @@ public class mcBlockListener implements Listener {
|
||||
|
||||
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
|
||||
if (BlockChecks.shouldBeWatched(mat)) {
|
||||
BlockChecks.watchBlock(mat, block, plugin);
|
||||
block.setMetadata("placedBlock", new FixedMetadataValue(plugin, true));
|
||||
}
|
||||
|
||||
if (id == LoadProperties.anvilID && LoadProperties.anvilmessages) {
|
||||
@ -137,7 +138,7 @@ public class mcBlockListener implements Listener {
|
||||
Herbalism.herbalismProcCheck(block, player, event, plugin); //Called twice for triple drop functionality
|
||||
}
|
||||
|
||||
if (mcPermissions.getInstance().herbalism(player) && block.getData() != (byte) 0x5 && Herbalism.canBeGreenTerra(mat)) {
|
||||
if (mcPermissions.getInstance().herbalism(player) && Herbalism.canBeGreenTerra(mat)) {
|
||||
Herbalism.herbalismProcCheck(block, player, event, plugin);
|
||||
}
|
||||
|
||||
@ -175,7 +176,7 @@ public class mcBlockListener implements Listener {
|
||||
* EXCAVATION
|
||||
*/
|
||||
|
||||
if (Excavation.canBeGigaDrillBroken(mat) && mcPermissions.getInstance().excavation(player) && block.getData() != (byte) 0x5) {
|
||||
if (Excavation.canBeGigaDrillBroken(mat) && mcPermissions.getInstance().excavation(player) && !block.hasMetadata("placedBlock")) {
|
||||
if (LoadProperties.excavationRequiresShovel && ItemChecks.isShovel(inhand)) {
|
||||
Excavation.excavationProcCheck(block, player);
|
||||
}
|
||||
@ -184,12 +185,9 @@ public class mcBlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
//Change the byte back when broken
|
||||
if (block.getData() == (byte) 0x5 && BlockChecks.shouldBeWatched(mat)) {
|
||||
block.setData((byte) 0x0);
|
||||
}
|
||||
else if(plugin.misc.blockWatchList.contains(block)) {
|
||||
plugin.misc.blockWatchList.remove(block);
|
||||
//Remove metadata when broken
|
||||
if (block.hasMetadata("placedBlock") && BlockChecks.shouldBeWatched(mat)) {
|
||||
block.removeMetadata("placedBlock", plugin);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,8 +59,6 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
private Runnable mcMMO_Timer = new mcTimer(this); //BLEED AND REGENERATION
|
||||
private Runnable mcMMO_SaveTimer = new mcSaveTimer(this); //Periodic saving of Player Data
|
||||
private Runnable ChangeDataValueTimer = new ChangeDataValueTimer(changeQueue); //R2 block place workaround
|
||||
private Runnable FastChangeDataValueTimer = new ChangeDataValueTimer(fastChangeQueue); //R2 block place workaround for instant-break stuff
|
||||
|
||||
//Alias - Command
|
||||
public HashMap<String, String> aliasMap = new HashMap<String, String>();
|
||||
@ -152,10 +150,6 @@ public class mcMMO extends JavaPlugin {
|
||||
//Bleed & Regen timer (Runs every 20 seconds)
|
||||
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, mcMMO_Timer, 0, 20);
|
||||
|
||||
//R2+ block place fix
|
||||
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, ChangeDataValueTimer, 0, 10);
|
||||
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, FastChangeDataValueTimer, 0, 1);
|
||||
|
||||
registerCommands();
|
||||
|
||||
//Spout Stuff
|
||||
|
@ -1,31 +0,0 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
/*
|
||||
* This file was created for a breakage introduced in 1.1-R2
|
||||
* It should be removed afterwards if the breakage is removed.
|
||||
*/
|
||||
public class ChangeDataValueTimer implements Runnable {
|
||||
private ArrayDeque<Block> queue;
|
||||
|
||||
public ChangeDataValueTimer(ArrayDeque<Block> queue) {
|
||||
this.queue = queue;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
int size = queue.size();
|
||||
if(size == 0) return;
|
||||
if(size > 25) {
|
||||
size = (int) Math.floor(size / 10);
|
||||
}
|
||||
|
||||
for(int i = 0; i < size; i++) {
|
||||
Block change = queue.poll();
|
||||
if(change == null) continue;
|
||||
change.setData((byte) 5);
|
||||
}
|
||||
}
|
||||
}
|
@ -48,7 +48,7 @@ public class BlastMining {
|
||||
blocksDropped.add(temp);
|
||||
Mining.miningDrops(temp);
|
||||
|
||||
if (temp.getData() != (byte) 0x5 && !plugin.misc.blockWatchList.contains(temp)) {
|
||||
if (!temp.hasMetadata("placedBlock")) {
|
||||
if (extraDrops == 2) {
|
||||
blocksDropped.add(temp);
|
||||
Mining.miningDrops(temp);
|
||||
@ -160,7 +160,7 @@ public class BlastMining {
|
||||
}
|
||||
|
||||
for (Block block : xp) {
|
||||
if (block.getData() != (byte)5 && !plugin.misc.blockWatchList.contains(block)) {
|
||||
if (!block.hasMetadata("placedBlock")) {
|
||||
Mining.miningXP(player, block);
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ public class Excavation {
|
||||
public static void gigaDrillBreaker(Player player, Block block) {
|
||||
Skills.abilityDurabilityLoss(player.getItemInHand(), LoadProperties.abilityDurabilityLoss);
|
||||
|
||||
if (block.getData() != (byte) 0x5) {
|
||||
if (!block.hasMetadata("placedBlock")) {
|
||||
PlayerAnimationEvent armswing = new PlayerAnimationEvent(player);
|
||||
Bukkit.getPluginManager().callEvent(armswing);
|
||||
|
||||
|
@ -135,7 +135,7 @@ public class Herbalism {
|
||||
Block b = block.getRelative(0, y, 0);
|
||||
if (b.getType().equals(Material.CACTUS)) {
|
||||
mat = Material.CACTUS;
|
||||
if (!plugin.misc.blockWatchList.contains(b)) {
|
||||
if (!b.hasMetadata("placedBlock")) {
|
||||
if(herbLevel > MAX_BONUS_LEVEL || (Math.random() * 1000 <= herbLevel)) {
|
||||
catciDrops++;
|
||||
}
|
||||
@ -154,7 +154,7 @@ public class Herbalism {
|
||||
break;
|
||||
|
||||
case MELON_BLOCK:
|
||||
if (data != (byte) 0x5) {
|
||||
if (!block.hasMetadata("placedBlock")) {
|
||||
mat = Material.MELON;
|
||||
xp = LoadProperties.mmelon;
|
||||
}
|
||||
@ -169,7 +169,7 @@ public class Herbalism {
|
||||
|
||||
case PUMPKIN:
|
||||
case JACK_O_LANTERN:
|
||||
if (!plugin.misc.blockWatchList.contains(block)) {
|
||||
if (!block.hasMetadata("placedBlock")) {
|
||||
mat = Material.getMaterial(id);
|
||||
xp = LoadProperties.mpumpkin;
|
||||
}
|
||||
@ -177,7 +177,7 @@ public class Herbalism {
|
||||
|
||||
case RED_ROSE:
|
||||
case YELLOW_FLOWER:
|
||||
if (!plugin.misc.blockWatchList.contains(block)) {
|
||||
if (!block.hasMetadata("placedBlock")) {
|
||||
mat = Material.getMaterial(id);
|
||||
xp = LoadProperties.mflower;
|
||||
}
|
||||
@ -188,7 +188,7 @@ public class Herbalism {
|
||||
Block b = block.getRelative(0, y, 0);
|
||||
if (b.getType().equals(Material.SUGAR_CANE_BLOCK)) {
|
||||
mat = Material.SUGAR_CANE;
|
||||
if (!plugin.misc.blockWatchList.contains(b)) {
|
||||
if (!b.hasMetadata("placedBlock")) {
|
||||
if(herbLevel > MAX_BONUS_LEVEL || (Math.random() * 1000 <= herbLevel)) {
|
||||
caneDrops++;
|
||||
}
|
||||
@ -199,14 +199,14 @@ public class Herbalism {
|
||||
break;
|
||||
|
||||
case VINE:
|
||||
if (!plugin.misc.blockWatchList.contains(block)) {
|
||||
if (!block.hasMetadata("placedBlock")) {
|
||||
mat = type;
|
||||
xp = LoadProperties.mvines;
|
||||
}
|
||||
break;
|
||||
|
||||
case WATER_LILY:
|
||||
if (data != (byte) 0x5) {
|
||||
if (!block.hasMetadata("placedBlock")) {
|
||||
mat = type;
|
||||
xp = LoadProperties.mlilypad;
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ public class Mining
|
||||
* @param plugin mcMMO plugin instance
|
||||
*/
|
||||
public static void miningBlockCheck(Player player, Block block, mcMMO plugin) {
|
||||
if (plugin.misc.blockWatchList.contains(block) || block.getData() == (byte) 5) {
|
||||
if (block.hasMetadata("placedBlock")) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -251,7 +251,7 @@ public class Mining
|
||||
case NETHERRACK:
|
||||
case SANDSTONE:
|
||||
case STONE:
|
||||
if ((block.getData() == (byte) 5) || plugin.misc.blockWatchList.contains(block)) {
|
||||
if (!block.hasMetadata("placedBlock")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -97,9 +97,7 @@ public class WoodCutting
|
||||
break;
|
||||
}
|
||||
|
||||
//ItemStack item = new ItemStack(x.getType(), 1, (byte)0, type);
|
||||
|
||||
if(!plugin.misc.blockWatchList.contains(x))
|
||||
if(!x.hasMetadata("placedBlock"))
|
||||
{
|
||||
WoodCutting.woodCuttingProcCheck(player, x);
|
||||
|
||||
@ -166,16 +164,16 @@ public class WoodCutting
|
||||
Block zPositive = world.getBlockAt(x, y, z+1);
|
||||
Block zNegative = world.getBlockAt(x, y, z-1);
|
||||
|
||||
if(!plugin.misc.blockWatchList.contains(currentBlock) &&
|
||||
if(!currentBlock.hasMetadata("placedBlock") &&
|
||||
!isTooAgressive(isAirOrLeaves, xPositive) && treeFellerCompatible(xPositive) && !toBeFelled.contains(xPositive))
|
||||
processTreeFelling(xPositive, world, toBeFelled, plugin);
|
||||
if(!plugin.misc.blockWatchList.contains(currentBlock) &&
|
||||
if(!currentBlock.hasMetadata("placedBlock") &&
|
||||
!isTooAgressive(isAirOrLeaves, xNegative) && treeFellerCompatible(xNegative) && !toBeFelled.contains(xNegative))
|
||||
processTreeFelling(xNegative, world, toBeFelled, plugin);
|
||||
if(!plugin.misc.blockWatchList.contains(currentBlock) &&
|
||||
if(!currentBlock.hasMetadata("placedBlock") &&
|
||||
!isTooAgressive(isAirOrLeaves, zPositive) && treeFellerCompatible(zPositive) && !toBeFelled.contains(zPositive))
|
||||
processTreeFelling(zPositive, world, toBeFelled, plugin);
|
||||
if(!plugin.misc.blockWatchList.contains(currentBlock) &&
|
||||
if(!currentBlock.hasMetadata("placedBlock") &&
|
||||
!isTooAgressive(isAirOrLeaves, zNegative) && treeFellerCompatible(zNegative) && !toBeFelled.contains(zNegative))
|
||||
processTreeFelling(zNegative, world, toBeFelled, plugin);
|
||||
|
||||
@ -184,7 +182,7 @@ public class WoodCutting
|
||||
|
||||
if(treeFellerCompatible(yPositive))
|
||||
{
|
||||
if(!plugin.misc.blockWatchList.contains(currentBlock) && !toBeFelled.contains(yPositive))
|
||||
if(!currentBlock.hasMetadata("placedBlock") && !toBeFelled.contains(yPositive))
|
||||
{
|
||||
processTreeFelling(yPositive, world, toBeFelled, plugin);
|
||||
}
|
||||
@ -217,7 +215,7 @@ public class WoodCutting
|
||||
int xp = 0;
|
||||
byte data = block.getData();
|
||||
|
||||
if(plugin.misc.blockWatchList.contains(block))
|
||||
if(block.hasMetadata("placedBlock"))
|
||||
return;
|
||||
|
||||
switch(data)
|
||||
|
Loading…
Reference in New Issue
Block a user