Mortar class now handles mortar block directional metadata
This commit is contained in:
parent
d7c15f6e4c
commit
4c1725a7d2
@ -4,7 +4,11 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Nameable;
|
import org.bukkit.Nameable;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
import xyz.soper.arty.Artillery;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -196,6 +200,17 @@ public class Mortar {
|
|||||||
&& isStringMortar(((Nameable) block.getState()).getCustomName());
|
&& isStringMortar(((Nameable) block.getState()).getCustomName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setMortarDirection(Block block, Vector direction){
|
||||||
|
if(isMortar(block)){
|
||||||
|
if(direction.getY() == 0){
|
||||||
|
block.setMetadata("direction_x", new FixedMetadataValue(Artillery.getPlugin(Artillery.class), direction.getX()));
|
||||||
|
block.setMetadata("direction_z", new FixedMetadataValue(Artillery.getPlugin(Artillery.class), direction.getZ()));
|
||||||
|
}
|
||||||
|
else block.setMetadata("direction_y", new FixedMetadataValue(Artillery.getPlugin(Artillery.class), direction.getY()));
|
||||||
|
}
|
||||||
|
else throw new IllegalArgumentException("Cannot set non-mortar block's directional MetaData");
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean isStringMortar(String string){
|
private static boolean isStringMortar(String string){
|
||||||
if(string == null){
|
if(string == null){
|
||||||
return false;
|
return false;
|
||||||
@ -205,4 +220,5 @@ public class Mortar {
|
|||||||
|| string.equals(REINFORCED_MORTAR_NAME)
|
|| string.equals(REINFORCED_MORTAR_NAME)
|
||||||
|| string.equals(INCENDIARY_CAPABLE_MORTAR_NAME));
|
|| string.equals(INCENDIARY_CAPABLE_MORTAR_NAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user