#1182: Consolidate Preconditions use and minor cleanup
By: Doc <nachito94@msn.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit.metadata;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.util.List;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -42,11 +43,8 @@ public class BlockMetadataStore extends MetadataStoreBase<Block> implements Meta
|
||||
*/
|
||||
@Override
|
||||
public List<MetadataValue> getMetadata(Block block, String metadataKey) {
|
||||
if (block.getWorld() == owningWorld) {
|
||||
return super.getMetadata(block, metadataKey);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Block does not belong to world " + owningWorld.getName());
|
||||
}
|
||||
Preconditions.checkArgument(block.getWorld() == this.owningWorld, "Block does not belong to world %s", owningWorld.getName());
|
||||
return super.getMetadata(block, metadataKey);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,11 +54,8 @@ public class BlockMetadataStore extends MetadataStoreBase<Block> implements Meta
|
||||
*/
|
||||
@Override
|
||||
public boolean hasMetadata(Block block, String metadataKey) {
|
||||
if (block.getWorld() == owningWorld) {
|
||||
return super.hasMetadata(block, metadataKey);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Block does not belong to world " + owningWorld.getName());
|
||||
}
|
||||
Preconditions.checkArgument(block.getWorld() == this.owningWorld, "Block does not belong to world %s", owningWorld.getName());
|
||||
return super.hasMetadata(block, metadataKey);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,11 +65,8 @@ public class BlockMetadataStore extends MetadataStoreBase<Block> implements Meta
|
||||
*/
|
||||
@Override
|
||||
public void removeMetadata(Block block, String metadataKey, Plugin owningPlugin) {
|
||||
if (block.getWorld() == owningWorld) {
|
||||
super.removeMetadata(block, metadataKey, owningPlugin);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Block does not belong to world " + owningWorld.getName());
|
||||
}
|
||||
Preconditions.checkArgument(block.getWorld() == this.owningWorld, "Block does not belong to world %s", owningWorld.getName());
|
||||
super.removeMetadata(block, metadataKey, owningPlugin);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,10 +76,7 @@ public class BlockMetadataStore extends MetadataStoreBase<Block> implements Meta
|
||||
*/
|
||||
@Override
|
||||
public void setMetadata(Block block, String metadataKey, MetadataValue newMetadataValue) {
|
||||
if (block.getWorld() == owningWorld) {
|
||||
super.setMetadata(block, metadataKey, newMetadataValue);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Block does not belong to world " + owningWorld.getName());
|
||||
}
|
||||
Preconditions.checkArgument(block.getWorld() == this.owningWorld, "Block does not belong to world %s", owningWorld.getName());
|
||||
super.setMetadata(block, metadataKey, newMetadataValue);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user