Skip to content

Instantly share code, notes, and snippets.

@applenick
Created August 23, 2015 02:20
Show Gist options
  • Select an option

  • Save applenick/6b0384f716c98d64cf18 to your computer and use it in GitHub Desktop.

Select an option

Save applenick/6b0384f716c98d64cf18 to your computer and use it in GitHub Desktop.
MiniBlocks API for use in the future
package me._ug.main;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.libs.jline.internal.Log;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
public class MiniBlock {
/*
*
* CREATED BY: _Ug
*
* Anyone can use this code without any form of thanks. It is 100% free for the public. Enjoy!
*
*/
//TODO replace main.pl with your plug-in. You do not need to have a time. To remove set removeTime to 0.
public static void removeStand(final ArmorStand as, int removeTime){
if(removeTime!=0){
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(main.pl, new Runnable(){
@Override
public void run() {
as.remove();
}
}, removeTime);
}
}
public static void spawnGroundItem(Location location, ItemStack item, boolean isBlock, int size, int removeTime){
if(!isBlock){
if(size == 2){
Location l = new Location(location.getWorld(), location.getX()+.7,location.getBlockY() - .8,location.getZ()-.1);
ArmorStand stand = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
stand.setVisible(false);
stand.setArms(true);
stand.setRightArmPose(new EulerAngle(0,1,0));
stand.setItemInHand(item);
stand.setGravity(false);
stand.setCanPickupItems(false);
stand.setSmall(false);
removeStand(stand, removeTime);
}else if(size == 1){
Location l = new Location(location.getWorld(), location.getX()+.2,location.getBlockY() - .5,location.getZ()-.1);
ArmorStand stand = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
stand.setVisible(false);
stand.setArms(true);
stand.setRightArmPose(new EulerAngle(-.35, 0, 0));
stand.setItemInHand(item);
stand.setGravity(false);
stand.setCanPickupItems(false);
stand.setSmall(true);
removeStand(stand, removeTime);
}
}else{
if(size == 2){
Location l = new Location(location.getWorld(), location.getX()+.6,location.getBlockY() - .65,location.getZ());
l.setYaw(45);
ArmorStand stand = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
stand.setVisible(false);
stand.setArms(true);
stand.setRightArmPose(new EulerAngle(-.25,0,0));
stand.setItemInHand(item);
stand.setGravity(false);
stand.setCanPickupItems(false);
stand.setSmall(false);
removeStand(stand, removeTime);
}else if(size == 1){
Location l = new Location(location.getWorld(), location.getX()+.2,location.getBlockY() - .445,location.getZ());
l.setYaw(45);
ArmorStand stand = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
stand.setVisible(false);
stand.setArms(true);
stand.setRightArmPose(new EulerAngle(-.6,0,0));
stand.setItemInHand(item);
stand.setGravity(false);
stand.setCanPickupItems(false);
stand.setSmall(true);
removeStand(stand, removeTime);
}else if(size == 3){
Location l = new Location(location.getWorld(), location.getX(),location.getBlockY() - .7,location.getZ());
ArmorStand stand = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
stand.setVisible(false);
stand.setGravity(false);
stand.setCanPickupItems(false);
stand.setSmall(true);
stand.setHelmet(item);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment